[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 */
+ break;
+ }
+
+ /* Create a new integer */
+
+ ReturnDesc = AcpiUtCreateIntegerObject (Result);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (Result)));
+
+ /* Save the Result */
+
+ AcpiExTruncateFor32bitTable (ReturnDesc);
+ *ResultDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToBuffer
+ *
+ * PARAMETERS: ObjDesc - Object to be converted. Must be an
+ * Integer, Buffer, or String
+ * ResultDesc - Where the new buffer object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an ACPI Object to a Buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToBuffer (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc)
+{
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ UINT8 *NewBuf;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
+
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+
+ /* No conversion necessary */
+
+ *ResultDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+
+
+ case ACPI_TYPE_INTEGER:
+
+ /*
+ * Create a new Buffer object.
+ * Need enough space for one integer
+ */
+ ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the integer to the buffer, LSB first */
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+ ACPI_MEMCPY (NewBuf,
+ &ObjDesc->Integer.Value,
+ AcpiGbl_IntegerByteWidth);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Create a new Buffer object
+ * Size will be the string length
+ *
+ * NOTE: Add one to the string length to include the null terminator.
+ * The ACPI spec is unclear on this subject, but there is existing
+ * ASL/AML code that depends on the null being transferred to the new
+ * buffer.
+ */
+ ReturnDesc = AcpiUtCreateBufferObject (
+ (ACPI_SIZE) ObjDesc->String.Length + 1);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the string to the buffer */
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+ ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
+ ObjDesc->String.Length);
+ break;
+
+
+ default:
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /* Mark buffer initialized */
+
+ ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
+ *ResultDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToAscii
+ *
+ * PARAMETERS: Integer - Value to be converted
+ * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
+ * String - Where the string is returned
+ * DataWidth - Size of data item to be converted, in bytes
+ *
+ * RETURN: Actual string length
+ *
+ * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExConvertToAscii (
+ UINT64 Integer,
+ UINT16 Base,
+ UINT8 *String,
+ UINT8 DataWidth)
+{
+ UINT64 Digit;
+ UINT32 i;
+ UINT32 j;
+ UINT32 k = 0;
+ UINT32 HexLength;
+ UINT32 DecimalLength;
+ UINT32 Remainder;
+ BOOLEAN SupressZeros;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (Base)
+ {
+ case 10:
+
+ /* Setup max length for the decimal number */
+
+ switch (DataWidth)
+ {
+ case 1:
+ DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
+ break;
+
+ case 4:
+ DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
+ break;
+
+ case 8:
+ default:
+ DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
+ break;
+ }
+
+ SupressZeros = TRUE; /* No leading zeros */
+ Remainder = 0;
+
+ for (i = DecimalLength; i > 0; i--)
+ {
+ /* Divide by nth factor of 10 */
+
+ Digit = Integer;
+ for (j = 0; j < i; j++)
+ {
+ (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
+ }
+
+ /* Handle leading zeros */
+
+ if (Remainder != 0)
+ {
+ SupressZeros = FALSE;
+ }
+
+ if (!SupressZeros)
+ {
+ String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
+ k++;
+ }
+ }
+ break;
+
+ case 16:
+
+ /* HexLength: 2 ascii hex chars per data byte */
+
+ HexLength = ACPI_MUL_2 (DataWidth);
+ for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
+ {
+ /* Get one hex digit, most significant digits first */
+
+ String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
+ k++;
+ }
+ break;
+
+ default:
+ return (0);
+ }
+
+ /*
+ * Since leading zeros are suppressed, we must check for the case where
+ * the integer equals 0
+ *
+ * Finally, null terminate the string and return the length
+ */
+ if (!k)
+ {
+ String [0] = ACPI_ASCII_ZERO;
+ k = 1;
+ }
+
+ String [k] = 0;
+ return ((UINT32) k);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToString
+ *
+ * PARAMETERS: ObjDesc - Object to be converted. Must be an
+ * Integer, Buffer, or String
+ * ResultDesc - Where the string object is returned
+ * Type - String flags (base and conversion type)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an ACPI Object to a string
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToString (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc,
+ UINT32 Type)
+{
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ UINT8 *NewBuf;
+ UINT32 i;
+ UINT32 StringLength = 0;
+ UINT16 Base = 16;
+ UINT8 Separator = ',';
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
+
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ /* No conversion necessary */
+
+ *ResultDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+
+
+ case ACPI_TYPE_INTEGER:
+
+ switch (Type)
+ {
+ case ACPI_EXPLICIT_CONVERT_DECIMAL:
+
+ /* Make room for maximum decimal number */
+
+ StringLength = ACPI_MAX_DECIMAL_DIGITS;
+ Base = 10;
+ break;
+
+ default:
+
+ /* Two hex string characters for each integer byte */
+
+ StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
+ break;
+ }
+
+ /*
+ * Create a new String
+ * Need enough space for one ASCII integer (plus null terminator)
+ */
+ ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+
+ /* Convert integer to string */
+
+ StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base,
+ NewBuf, AcpiGbl_IntegerByteWidth);
+
+ /* Null terminate at the correct place */
+
+ ReturnDesc->String.Length = StringLength;
+ NewBuf [StringLength] = 0;
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Setup string length, base, and separator */
+
+ switch (Type)
+ {
+ case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
+ /*
+ * From ACPI: "If Data is a buffer, it is converted to a string of
+ * decimal values separated by commas."
+ */
+ Base = 10;
+
+ /*
+ * Calculate the final string length. Individual string values
+ * are variable length (include separator for each)
+ */
+ for (i = 0; i < ObjDesc->Buffer.Length; i++)
+ {
+ if (ObjDesc->Buffer.Pointer[i] >= 100)
+ {
+ StringLength += 4;
+ }
+ else if (ObjDesc->Buffer.Pointer[i] >= 10)
+ {
+ StringLength += 3;
+ }
+ else
+ {
+ StringLength += 2;
+ }
+ }
+ break;
+
+ case ACPI_IMPLICIT_CONVERT_HEX:
+ /*
+ * From the ACPI spec:
+ *"The entire contents of the buffer are converted to a string of
+ * two-character hexadecimal numbers, each separated by a space."
+ */
+ Separator = ' ';
+ StringLength = (ObjDesc->Buffer.Length * 3);
+ break;
+
+ case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */
+ /*
+ * From ACPI: "If Data is a buffer, it is converted to a string of
+ * hexadecimal values separated by commas."
+ */
+ StringLength = (ObjDesc->Buffer.Length * 3);
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Create a new string object and string buffer
+ * (-1 because of extra separator included in StringLength from above)
+ * Allow creation of zero-length strings from zero-length buffers.
+ */
+ if (StringLength)
+ {
+ StringLength--;
+ }
+
+ ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ NewBuf = ReturnDesc->Buffer.Pointer;
+
+ /*
+ * Convert buffer bytes to hex or decimal values
+ * (separated by commas or spaces)
+ */
+ for (i = 0; i < ObjDesc->Buffer.Length; i++)
+ {
+ NewBuf += AcpiExConvertToAscii (
+ (UINT64) ObjDesc->Buffer.Pointer[i], Base,
+ NewBuf, 1);
+ *NewBuf++ = Separator; /* each separated by a comma or space */
+ }
+
+ /*
+ * Null terminate the string
+ * (overwrites final comma/space from above)
+ */
+ if (ObjDesc->Buffer.Length)
+ {
+ NewBuf--;
+ }
+ *NewBuf = 0;
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ *ResultDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConvertToTargetType
+ *
+ * PARAMETERS: DestinationType - Current type of the destination
+ * SourceDesc - Source object to be converted.
+ * ResultDesc - Where the converted object is returned
+ * WalkState - Current method state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToTargetType (
+ ACPI_OBJECT_TYPE DestinationType,
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExConvertToTargetType);
+
+
+ /* Default behavior */
+
+ *ResultDesc = SourceDesc;
+
+ /*
+ * If required by the target,
+ * perform implicit conversion on the source before we store it.
+ */
+ switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
+ {
+ case ARGI_SIMPLE_TARGET:
+ case ARGI_FIXED_TARGET:
+ case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
+
+ switch (DestinationType)
+ {
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ /*
+ * Named field can always handle conversions
+ */
+ break;
+
+ default:
+ /* No conversion allowed for these types */
+
+ if (DestinationType != SourceDesc->Common.Type)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Explicit operator, will store (%s) over existing type (%s)\n",
+ AcpiUtGetObjectTypeName (SourceDesc),
+ AcpiUtGetTypeName (DestinationType)));
+ Status = AE_TYPE;
+ }
+ }
+ break;
+
+
+ case ARGI_TARGETREF:
+
+ switch (DestinationType)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ /*
+ * These types require an Integer operand. We can convert
+ * a Buffer or a String to an Integer if necessary.
+ */
+ Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
+ 16);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+ /*
+ * The operand must be a String. We can convert an
+ * Integer or Buffer if necessary
+ */
+ Status = AcpiExConvertToString (SourceDesc, ResultDesc,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+ /*
+ * The operand must be a Buffer. We can convert an
+ * Integer or String if necessary
+ */
+ Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: 0x%X",
+ DestinationType));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ break;
+
+
+ case ARGI_REFERENCE:
+ /*
+ * CreateXxxxField cases - we are storing the field object into the name
+ */
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
+ GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
+ WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
+ Status = AE_AML_INTERNAL;
+ }
+
+ /*
+ * Source-to-Target conversion semantics:
+ *
+ * If conversion to the target type cannot be performed, then simply
+ * overwrite the target with the new object and type.
+ */
+ if (Status == AE_TYPE)
+ {
+ Status = AE_OK;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/excreate.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/excreate.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,574 @@
+/******************************************************************************
+ *
+ * Module Name: excreate - Named object creation
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXCREATE_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>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("excreate")
+
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateAlias
+ *
+ * PARAMETERS: WalkState - Current state, contains operands
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new named alias
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateAlias (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_NAMESPACE_NODE *TargetNode;
+ ACPI_NAMESPACE_NODE *AliasNode;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExCreateAlias);
+
+
+ /* Get the source/alias operands (both namespace nodes) */
+
+ AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
+ TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
+
+ if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
+ (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
+ {
+ /*
+ * Dereference an existing alias so that we don't create a chain
+ * of aliases. With this code, we guarantee that an alias is
+ * always exactly one level of indirection away from the
+ * actual aliased name.
+ */
+ TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
+ }
+
+ /*
+ * For objects that can never change (i.e., the NS node will
+ * permanently point to the same object), we can simply attach
+ * the object to the new NS node. For other objects (such as
+ * Integers, buffers, etc.), we have to point the Alias node
+ * to the original Node.
+ */
+ switch (TargetNode->Type)
+ {
+
+ /* For these types, the sub-object can change dynamically via a Store */
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ /*
+ * These types open a new scope, so we need the NS node in order to access
+ * any children.
+ */
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_POWER:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_THERMAL:
+ case ACPI_TYPE_LOCAL_SCOPE:
+
+ /*
+ * The new alias has the type ALIAS and points to the original
+ * NS node, not the object itself.
+ */
+ AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
+ AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
+ break;
+
+ case ACPI_TYPE_METHOD:
+
+ /*
+ * Control method aliases need to be differentiated
+ */
+ AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
+ AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
+ break;
+
+ default:
+
+ /* Attach the original source object to the new Alias Node */
+
+ /*
+ * The new alias assumes the type of the target, and it points
+ * to the same object. The reference count of the object has an
+ * additional reference to prevent deletion out from under either the
+ * target node or the alias Node
+ */
+ Status = AcpiNsAttachObject (AliasNode,
+ AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
+ break;
+ }
+
+ /* Since both operands are Nodes, we don't need to delete them */
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateEvent
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new event object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateEvent (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE (ExCreateEvent);
+
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Create the actual OS semaphore, with zero initial units -- meaning
+ * that the event is created in an unsignalled state
+ */
+ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
+ &ObjDesc->Event.OsSemaphore);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Attach object to the Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
+ ObjDesc, ACPI_TYPE_EVENT);
+
+Cleanup:
+ /*
+ * Remove local reference to the object (on error, will cause deletion
+ * of both object and semaphore if present.)
+ */
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateMutex
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new mutex object
+ *
+ * Mutex (Name[0], SyncLevel[1])
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateMutex (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
+
+
+ /* Create the new mutex object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Create the actual OS Mutex */
+
+ Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Init object and attach to NS node */
+
+ ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
+ ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
+
+ Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
+
+
+Cleanup:
+ /*
+ * Remove local reference to the object (on error, will cause deletion
+ * of both object and semaphore if present.)
+ */
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateRegion
+ *
+ * PARAMETERS: AmlStart - Pointer to the region declaration AML
+ * AmlLength - Max length of the declaration AML
+ * SpaceId - Address space ID for the region
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new operation region object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateRegion (
+ UINT8 *AmlStart,
+ UINT32 AmlLength,
+ UINT8 SpaceId,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OPERAND_OBJECT *RegionObj2;
+
+
+ ACPI_FUNCTION_TRACE (ExCreateRegion);
+
+
+ /* Get the Namespace Node */
+
+ Node = WalkState->Op->Common.Node;
+
+ /*
+ * If the region object is already attached to this node,
+ * just return
+ */
+ if (AcpiNsGetAttachedObject (Node))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Space ID must be one of the predefined IDs, or in the user-defined
+ * range
+ */
+ if (!AcpiIsValidSpaceId (SpaceId))
+ {
+ /*
+ * Print an error message, but continue. We don't want to abort
+ * a table load for this exception. Instead, if the region is
+ * actually used at runtime, abort the executing method.
+ */
+ ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
+ AcpiUtGetRegionName (SpaceId), SpaceId));
+
+ /* Create the region descriptor */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Remember location in AML stream of address & length
+ * operands since they need to be evaluated at run time.
+ */
+ RegionObj2 = ObjDesc->Common.NextObject;
+ RegionObj2->Extra.AmlStart = AmlStart;
+ RegionObj2->Extra.AmlLength = AmlLength;
+ if (WalkState->ScopeInfo)
+ {
+ RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
+ }
+ else
+ {
+ RegionObj2->Extra.ScopeNode = Node;
+ }
+
+ /* Init the region from the operands */
+
+ ObjDesc->Region.SpaceId = SpaceId;
+ ObjDesc->Region.Address = 0;
+ ObjDesc->Region.Length = 0;
+ ObjDesc->Region.Node = Node;
+
+ /* Install the new region object in the parent Node */
+
+ Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
+
+
+Cleanup:
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateProcessor
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new processor object and populate the fields
+ *
+ * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateProcessor (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
+
+
+ /* Create the processor object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize the processor object from the operands */
+
+ ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
+ ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
+ ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
+
+ /* Install the processor object in the parent Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
+ ObjDesc, ACPI_TYPE_PROCESSOR);
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreatePowerResource
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new PowerResource object and populate the fields
+ *
+ * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreatePowerResource (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
+
+
+ /* Create the power resource object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize the power object from the operands */
+
+ ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
+ ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
+
+ /* Install the power resource object in the parent Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
+ ObjDesc, ACPI_TYPE_POWER);
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCreateMethod
+ *
+ * PARAMETERS: AmlStart - First byte of the method's AML
+ * AmlLength - AML byte count for this method
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new method object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCreateMethod (
+ UINT8 *AmlStart,
+ UINT32 AmlLength,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+ UINT8 MethodFlags;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
+
+
+ /* Create a new method object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Exit;
+ }
+
+ /* Save the method's AML pointer and length */
+
+ ObjDesc->Method.AmlStart = AmlStart;
+ ObjDesc->Method.AmlLength = AmlLength;
+
+ /*
+ * Disassemble the method flags. Split off the ArgCount, Serialized
+ * flag, and SyncLevel for efficiency.
+ */
+ MethodFlags = (UINT8) Operand[1]->Integer.Value;
+ ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
+
+ /*
+ * Get the SyncLevel. If method is serialized, a mutex will be
+ * created for this method when it is parsed.
+ */
+ if (MethodFlags & AML_METHOD_SERIALIZED)
+ {
+ ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
+
+ /*
+ * ACPI 1.0: SyncLevel = 0
+ * ACPI 2.0: SyncLevel = SyncLevel in method declaration
+ */
+ ObjDesc->Method.SyncLevel = (UINT8)
+ ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
+ }
+
+ /* Attach the new object to the method Node */
+
+ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
+ ObjDesc, ACPI_TYPE_METHOD);
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+
+Exit:
+ /* Remove a reference to the operand */
+
+ AcpiUtRemoveReference (Operand[1]);
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exdebug.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exdebug.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,278 @@
+/******************************************************************************
+ *
+ * Module Name: exdebug - Support for stores to the AML Debug Object
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXDEBUG_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exdebug")
+
+
+#ifndef ACPI_NO_ERROR_MESSAGES
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoDebugObject
+ *
+ * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
+ * Level - Indentation level (used for packages)
+ * Index - Current package element, zero if not pkg
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Handles stores to the AML Debug Object. For example:
+ * Store(INT1, Debug)
+ *
+ * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
+ *
+ * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or
+ * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
+ * operational case, stores to the debug object are ignored but can be easily
+ * enabled if necessary.
+ *
+ ******************************************************************************/
+
+void
+AcpiExDoDebugObject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ UINT32 Level,
+ UINT32 Index)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
+
+
+ /* Output must be enabled via the DebugObject global or the DbgLevel */
+
+ if (!AcpiGbl_EnableAmlDebugObject &&
+ !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
+ {
+ return_VOID;
+ }
+
+ /*
+ * Print line header as long as we are not in the middle of an
+ * object display
+ */
+ if (!((Level > 0) && Index == 0))
+ {
+ AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
+ }
+
+ /* Display the index for package output only */
+
+ if (Index > 0)
+ {
+ AcpiOsPrintf ("(%.2u) ", Index-1);
+ }
+
+ if (!SourceDesc)
+ {
+ AcpiOsPrintf ("[Null Object]\n");
+ return_VOID;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
+ {
+ AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
+
+ if (!AcpiUtValidInternalObject (SourceDesc))
+ {
+ AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
+ return_VOID;
+ }
+ }
+ else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiOsPrintf ("%s: %p\n",
+ AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
+ SourceDesc);
+ return_VOID;
+ }
+ else
+ {
+ return_VOID;
+ }
+
+ /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
+
+ switch (SourceDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Output correct integer width */
+
+ if (AcpiGbl_IntegerByteWidth == 4)
+ {
+ AcpiOsPrintf ("0x%8.8X\n",
+ (UINT32) SourceDesc->Integer.Value);
+ }
+ else
+ {
+ AcpiOsPrintf ("0x%8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
+ AcpiUtDumpBuffer2 (SourceDesc->Buffer.Pointer,
+ (SourceDesc->Buffer.Length < 256) ?
+ SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
+ SourceDesc->String.Length, SourceDesc->String.Pointer);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
+ SourceDesc->Package.Count);
+
+ /* Output the entire contents of the package */
+
+ for (i = 0; i < SourceDesc->Package.Count; i++)
+ {
+ AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
+ Level+4, i+1);
+ }
+ break;
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
+
+ /* Decode the reference */
+
+ switch (SourceDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_INDEX:
+
+ AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
+ break;
+
+ case ACPI_REFCLASS_TABLE:
+
+ /* Case for DdbHandle */
+
+ AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
+ return;
+
+ default:
+ break;
+ }
+
+ AcpiOsPrintf (" ");
+
+ /* Check for valid node first, then valid object */
+
+ if (SourceDesc->Reference.Node)
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
+ ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiOsPrintf (" %p - Not a valid namespace node\n",
+ SourceDesc->Reference.Node);
+ }
+ else
+ {
+ AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
+ (SourceDesc->Reference.Node)->Name.Ascii);
+
+ switch ((SourceDesc->Reference.Node)->Type)
+ {
+ /* These types have no attached object */
+
+ case ACPI_TYPE_DEVICE:
+ AcpiOsPrintf ("Device\n");
+ break;
+
+ case ACPI_TYPE_THERMAL:
+ AcpiOsPrintf ("Thermal Zone\n");
+ break;
+
+ default:
+ AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
+ Level+4, 0);
+ break;
+ }
+ }
+ }
+ else if (SourceDesc->Reference.Object)
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
+ ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
+ SourceDesc->Reference.Object)->Object,
+ Level+4, 0);
+ }
+ else
+ {
+ AcpiExDoDebugObject (SourceDesc->Reference.Object,
+ Level+4, 0);
+ }
+ }
+ break;
+
+ default:
+
+ AcpiOsPrintf ("%p\n", SourceDesc);
+ break;
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
+ return_VOID;
+}
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exdump.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exdump.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1124 @@
+/******************************************************************************
+ *
+ * Module Name: exdump - Interpreter debug 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.
+ */
+
+#define __EXDUMP_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>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exdump")
+
+/*
+ * The following routines are used for debug output only
+ */
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/* Local prototypes */
+
+static void
+AcpiExOutString (
+ char *Title,
+ char *Value);
+
+static void
+AcpiExOutPointer (
+ char *Title,
+ void *Value);
+
+static void
+AcpiExDumpObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_EXDUMP_INFO *Info);
+
+static void
+AcpiExDumpReferenceObj (
+ ACPI_OPERAND_OBJECT *ObjDesc);
+
+static void
+AcpiExDumpPackageObj (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Level,
+ UINT32 Index);
+
+
+/*******************************************************************************
+ *
+ * Object Descriptor info tables
+ *
+ * Note: The first table entry must be an INIT opcode and must contain
+ * the table length (number of table entries)
+ *
+ ******************************************************************************/
+
+static ACPI_EXDUMP_INFO AcpiExDumpInteger[2] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger), NULL},
+ {ACPI_EXD_UINT64, ACPI_EXD_OFFSET (Integer.Value), "Value"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpString[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpString), NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (String.Length), "Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (String.Pointer), "Pointer"},
+ {ACPI_EXD_STRING, 0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"},
+ {ACPI_EXD_BUFFER, 0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Elements"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"},
+ {ACPI_EXD_PACKAGE, 0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.Handler), "Handler"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.DeviceNotify), "Device Notify"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.InfoFlags), "Info Flags"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"},
+ {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"},
+ {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Handler), "Handler"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpPower[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.DeviceNotify), "Device Notify"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"},
+ {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"},
+ {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.DeviceNotify), "Device Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.Handler), "Handler"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpThermal[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.SystemNotify), "System Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.DeviceNotify), "Device Notify"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.Handler), "Handler"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpBufferField[3] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BufferField.BufferObj), "Buffer Object"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpRegionField[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Field.AccessLength), "AccessLength"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.RegionObj), "Region Object"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.ResourceBuffer), "ResourceBuffer"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpBankField[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (BankField.Value), "Value"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.RegionObj), "Region Object"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.BankObj), "Bank Object"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL},
+ {ACPI_EXD_FIELD, 0, NULL},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (IndexField.Value), "Value"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.IndexObj), "Index Object"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpReference[8] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"},
+ {ACPI_EXD_REFERENCE,0, NULL}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Next), "Next"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpNotify[3] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Node), "Node"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"}
+};
+
+
+/* Miscellaneous tables */
+
+static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL},
+ {ACPI_EXD_TYPE , 0, NULL},
+ {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.FieldFlags), "Field Flags"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.AccessByteWidth), "Access Byte Width"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"},
+ {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"},
+ {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"},
+ {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"}
+};
+
+static ACPI_EXDUMP_INFO AcpiExDumpNode[5] =
+{
+ {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL},
+ {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"},
+ {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"},
+ {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"},
+ {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"}
+};
+
+
+/* Dispatch table, indexed by object type */
+
+static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] =
+{
+ NULL,
+ AcpiExDumpInteger,
+ AcpiExDumpString,
+ AcpiExDumpBuffer,
+ AcpiExDumpPackage,
+ NULL,
+ AcpiExDumpDevice,
+ AcpiExDumpEvent,
+ AcpiExDumpMethod,
+ AcpiExDumpMutex,
+ AcpiExDumpRegion,
+ AcpiExDumpPower,
+ AcpiExDumpProcessor,
+ AcpiExDumpThermal,
+ AcpiExDumpBufferField,
+ NULL,
+ NULL,
+ AcpiExDumpRegionField,
+ AcpiExDumpBankField,
+ AcpiExDumpIndexField,
+ AcpiExDumpReference,
+ NULL,
+ NULL,
+ AcpiExDumpNotify,
+ AcpiExDumpAddressHandler,
+ NULL,
+ NULL,
+ NULL
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpObject
+ *
+ * PARAMETERS: ObjDesc - Descriptor to dump
+ * Info - Info table corresponding to this object
+ * type
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Walk the info table for this object
+ *
+ ******************************************************************************/
+
+static void
+AcpiExDumpObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_EXDUMP_INFO *Info)
+{
+ UINT8 *Target;
+ char *Name;
+ UINT8 Count;
+
+
+ if (!Info)
+ {
+ AcpiOsPrintf (
+ "ExDumpObject: Display not implemented for object type %s\n",
+ AcpiUtGetObjectTypeName (ObjDesc));
+ return;
+ }
+
+ /* First table entry must contain the table length (# of table entries) */
+
+ Count = Info->Offset;
+
+ while (Count)
+ {
+ Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset);
+ Name = Info->Name;
+
+ switch (Info->Opcode)
+ {
+ case ACPI_EXD_INIT:
+ break;
+
+ case ACPI_EXD_TYPE:
+
+ AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc));
+ break;
+
+ case ACPI_EXD_UINT8:
+
+ AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target);
+ break;
+
+ case ACPI_EXD_UINT16:
+
+ AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target));
+ break;
+
+ case ACPI_EXD_UINT32:
+
+ AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target));
+ break;
+
+ case ACPI_EXD_UINT64:
+
+ AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value",
+ ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
+ break;
+
+ case ACPI_EXD_POINTER:
+ case ACPI_EXD_ADDRESS:
+
+ AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target));
+ break;
+
+ case ACPI_EXD_STRING:
+
+ AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
+ AcpiOsPrintf ("\n");
+ break;
+
+ case ACPI_EXD_BUFFER:
+
+ ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
+ break;
+
+ case ACPI_EXD_PACKAGE:
+
+ /* Dump the package contents */
+
+ AcpiOsPrintf ("\nPackage Contents:\n");
+ AcpiExDumpPackageObj (ObjDesc, 0, 0);
+ break;
+
+ case ACPI_EXD_FIELD:
+
+ AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon);
+ break;
+
+ case ACPI_EXD_REFERENCE:
+
+ AcpiExOutString ("Class Name",
+ ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc)));
+ AcpiExDumpReferenceObj (ObjDesc);
+ break;
+
+ default:
+
+ AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
+ Info->Opcode);
+ return;
+ }
+
+ Info++;
+ Count--;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpOperand
+ *
+ * PARAMETERS: *ObjDesc - Pointer to entry to be dumped
+ * Depth - Current nesting depth
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump an operand object
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpOperand (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Depth)
+{
+ UINT32 Length;
+ UINT32 Index;
+
+
+ ACPI_FUNCTION_NAME (ExDumpOperand)
+
+
+ if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return;
+ }
+
+ if (!ObjDesc)
+ {
+ /* This could be a null element of a package */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
+ return;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc));
+ ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC);
+ return;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "%p is not a node or operand object: [%s]\n",
+ ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
+ ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT));
+ return;
+ }
+
+ /* ObjDesc is a valid object */
+
+ if (Depth > 0)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ",
+ Depth, " ", Depth, ObjDesc));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc));
+ }
+
+ /* Decode object type */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc));
+
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_DEBUG:
+
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object);
+ break;
+
+
+ case ACPI_REFCLASS_TABLE:
+
+ AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value);
+ break;
+
+
+ case ACPI_REFCLASS_REFOF:
+
+ AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object,
+ AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
+ ObjDesc->Reference.Object)->Common.Type));
+ break;
+
+
+ case ACPI_REFCLASS_NAME:
+
+ AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii);
+ break;
+
+
+ case ACPI_REFCLASS_ARG:
+ case ACPI_REFCLASS_LOCAL:
+
+ AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value);
+ break;
+
+
+ default: /* Unknown reference class */
+
+ AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
+ break;
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("Buffer length %.2X @ %p\n",
+ ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer);
+
+ /* Debug only -- dump the buffer contents */
+
+ if (ObjDesc->Buffer.Pointer)
+ {
+ Length = ObjDesc->Buffer.Length;
+ if (Length > 128)
+ {
+ Length = 128;
+ }
+
+ AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n",
+ Length);
+ ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length);
+ }
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+
+ AcpiOsPrintf ("Integer %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("Package [Len %X] ElementArray %p\n",
+ ObjDesc->Package.Count, ObjDesc->Package.Elements);
+
+ /*
+ * If elements exist, package element pointer is valid,
+ * and debug_level exceeds 1, dump package's elements.
+ */
+ if (ObjDesc->Package.Count &&
+ ObjDesc->Package.Elements &&
+ AcpiDbgLevel > 1)
+ {
+ for (Index = 0; Index < ObjDesc->Package.Count; Index++)
+ {
+ AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1);
+ }
+ }
+ break;
+
+
+ case ACPI_TYPE_REGION:
+
+ AcpiOsPrintf ("Region %s (%X)",
+ AcpiUtGetRegionName (ObjDesc->Region.SpaceId),
+ ObjDesc->Region.SpaceId);
+
+ /*
+ * If the address and length have not been evaluated,
+ * don't print them.
+ */
+ if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID))
+ {
+ AcpiOsPrintf ("\n");
+ }
+ else
+ {
+ AcpiOsPrintf (" base %8.8X%8.8X Length %X\n",
+ ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
+ ObjDesc->Region.Length);
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("String length %X @ %p ",
+ ObjDesc->String.Length,
+ ObjDesc->String.Pointer);
+
+ AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ AcpiOsPrintf ("BankField\n");
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
+ "byte=%X bit=%X of below:\n",
+ ObjDesc->Field.BitLength,
+ ObjDesc->Field.AccessByteWidth,
+ ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK,
+ ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK,
+ ObjDesc->Field.BaseByteOffset,
+ ObjDesc->Field.StartFieldBitOffset);
+
+ AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ AcpiOsPrintf ("IndexField\n");
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n",
+ ObjDesc->BufferField.BitLength,
+ ObjDesc->BufferField.BaseByteOffset,
+ ObjDesc->BufferField.StartFieldBitOffset);
+
+ if (!ObjDesc->BufferField.BufferObj)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n"));
+ }
+ else if ((ObjDesc->BufferField.BufferObj)->Common.Type !=
+ ACPI_TYPE_BUFFER)
+ {
+ AcpiOsPrintf ("*not a Buffer*\n");
+ }
+ else
+ {
+ AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1);
+ }
+ break;
+
+
+ case ACPI_TYPE_EVENT:
+
+ AcpiOsPrintf ("Event\n");
+ break;
+
+
+ case ACPI_TYPE_METHOD:
+
+ AcpiOsPrintf ("Method(%X) @ %p:%X\n",
+ ObjDesc->Method.ParamCount,
+ ObjDesc->Method.AmlStart,
+ ObjDesc->Method.AmlLength);
+ break;
+
+
+ case ACPI_TYPE_MUTEX:
+
+ AcpiOsPrintf ("Mutex\n");
+ break;
+
+
+ case ACPI_TYPE_DEVICE:
+
+ AcpiOsPrintf ("Device\n");
+ break;
+
+
+ case ACPI_TYPE_POWER:
+
+ AcpiOsPrintf ("Power\n");
+ break;
+
+
+ case ACPI_TYPE_PROCESSOR:
+
+ AcpiOsPrintf ("Processor\n");
+ break;
+
+
+ case ACPI_TYPE_THERMAL:
+
+ AcpiOsPrintf ("Thermal\n");
+ break;
+
+
+ default:
+ /* Unknown Type */
+
+ AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type);
+ break;
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpOperands
+ *
+ * PARAMETERS: Operands - A list of Operand objects
+ * OpcodeName - AML opcode name
+ * NumOperands - Operand count for this opcode
+ *
+ * DESCRIPTION: Dump the operands associated with the opcode
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpOperands (
+ ACPI_OPERAND_OBJECT **Operands,
+ const char *OpcodeName,
+ UINT32 NumOperands)
+{
+ ACPI_FUNCTION_NAME (ExDumpOperands);
+
+
+ if (!OpcodeName)
+ {
+ OpcodeName = "UNKNOWN";
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "**** Start operand dump for opcode [%s], %u operands\n",
+ OpcodeName, NumOperands));
+
+ if (NumOperands == 0)
+ {
+ NumOperands = 1;
+ }
+
+ /* Dump the individual operands */
+
+ while (NumOperands)
+ {
+ AcpiExDumpOperand (*Operands, 0);
+ Operands++;
+ NumOperands--;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "**** End operand dump for [%s]\n", OpcodeName));
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOut* functions
+ *
+ * PARAMETERS: Title - Descriptive text
+ * Value - Value to be displayed
+ *
+ * DESCRIPTION: Object dump output formatting functions. These functions
+ * reduce the number of format strings required and keeps them
+ * all in one place for easy modification.
+ *
+ ******************************************************************************/
+
+static void
+AcpiExOutString (
+ char *Title,
+ char *Value)
+{
+ AcpiOsPrintf ("%20s : %s\n", Title, Value);
+}
+
+static void
+AcpiExOutPointer (
+ char *Title,
+ void *Value)
+{
+ AcpiOsPrintf ("%20s : %p\n", Title, Value);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpNamespaceNode
+ *
+ * PARAMETERS: Node - Descriptor to dump
+ * Flags - Force display if TRUE
+ *
+ * DESCRIPTION: Dumps the members of the given.Node
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpNamespaceNode (
+ ACPI_NAMESPACE_NODE *Node,
+ UINT32 Flags)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Flags)
+ {
+ if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return;
+ }
+ }
+
+ AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node));
+ AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type));
+ AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node));
+ AcpiExOutPointer ("Parent", Node->Parent);
+
+ AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node),
+ AcpiExDumpNode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpReferenceObj
+ *
+ * PARAMETERS: Object - Descriptor to dump
+ *
+ * DESCRIPTION: Dumps a reference object
+ *
+ ******************************************************************************/
+
+static void
+AcpiExDumpReferenceObj (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_BUFFER RetBuf;
+ ACPI_STATUS Status;
+
+
+ RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+ if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME)
+ {
+ AcpiOsPrintf (" %p ", ObjDesc->Reference.Node);
+
+ Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf (" Could not convert name to pathname\n");
+ }
+ else
+ {
+ AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer);
+ ACPI_FREE (RetBuf.Pointer);
+ }
+ }
+ else if (ObjDesc->Reference.Object)
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
+ {
+ AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object);
+ if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE)
+ {
+ AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value);
+ }
+ else
+ {
+ AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object,
+ AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
+ ObjDesc->Reference.Object)->Common.Type));
+ }
+ }
+ else
+ {
+ AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpPackageObj
+ *
+ * PARAMETERS: ObjDesc - Descriptor to dump
+ * Level - Indentation Level
+ * Index - Package index for this object
+ *
+ * DESCRIPTION: Dumps the elements of the package
+ *
+ ******************************************************************************/
+
+static void
+AcpiExDumpPackageObj (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Level,
+ UINT32 Index)
+{
+ UINT32 i;
+
+
+ /* Indentation and index output */
+
+ if (Level > 0)
+ {
+ for (i = 0; i < Level; i++)
+ {
+ AcpiOsPrintf (" ");
+ }
+
+ AcpiOsPrintf ("[%.2d] ", Index);
+ }
+
+ AcpiOsPrintf ("%p ", ObjDesc);
+
+ /* Null package elements are allowed */
+
+ if (!ObjDesc)
+ {
+ AcpiOsPrintf ("[Null Object]\n");
+ return;
+ }
+
+ /* Packages may only contain a few object types */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("[String] Value: ");
+ for (i = 0; i < ObjDesc->String.Length; i++)
+ {
+ AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
+ }
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
+ if (ObjDesc->Buffer.Length)
+ {
+ AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
+ ObjDesc->Buffer.Length, DB_DWORD_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++)
+ {
+ AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i);
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X",
+ AcpiUtGetReferenceName (ObjDesc),
+ ObjDesc->Reference.Class);
+ AcpiExDumpReferenceObj (ObjDesc);
+ break;
+
+
+ default:
+
+ AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type);
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDumpObjectDescriptor
+ *
+ * PARAMETERS: ObjDesc - Descriptor to dump
+ * Flags - Force display if TRUE
+ *
+ * DESCRIPTION: Dumps the members of the object descriptor given.
+ *
+ ******************************************************************************/
+
+void
+AcpiExDumpObjectDescriptor (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 Flags)
+{
+ ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor);
+
+
+ if (!ObjDesc)
+ {
+ return_VOID;
+ }
+
+ if (!Flags)
+ {
+ if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
+ {
+ return_VOID;
+ }
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags);
+
+ AcpiOsPrintf ("\nAttached Object (%p):\n",
+ ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object);
+
+ AcpiExDumpObjectDescriptor (
+ ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags);
+ return_VOID;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
+ {
+ AcpiOsPrintf (
+ "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
+ ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
+ return_VOID;
+ }
+
+ if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX)
+ {
+ return_VOID;
+ }
+
+ /* Common Fields */
+
+ AcpiExDumpObject (ObjDesc, AcpiExDumpCommon);
+
+ /* Object-specific fields */
+
+ AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]);
+ return_VOID;
+}
+
+#endif
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exfield.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exfield.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,406 @@
+/******************************************************************************
+ *
+ * Module Name: exfield - ACPI AML (p-code) execution - field 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 __EXFIELD_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>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exfield")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReadDataFromField
+ *
+ * PARAMETERS: WalkState - Current execution state
+ * ObjDesc - The named field
+ * RetBufferDesc - Where the return data object is stored
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read from a named field. Returns either an Integer or a
+ * Buffer, depending on the size of the field.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExReadDataFromField (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **RetBufferDesc)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *BufferDesc;
+ ACPI_SIZE Length;
+ void *Buffer;
+ UINT32 Function;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc);
+
+
+ /* Parameter validation */
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+ if (!RetBufferDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * If the BufferField arguments have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+ else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
+ (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
+ {
+ /*
+ * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold
+ * the data and then directly access the region handler.
+ *
+ * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function
+ */
+ if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
+ {
+ Length = ACPI_SMBUS_BUFFER_SIZE;
+ Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
+ }
+ else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
+ {
+ Length = ACPI_GSBUS_BUFFER_SIZE;
+ Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
+ }
+ else /* IPMI */
+ {
+ Length = ACPI_IPMI_BUFFER_SIZE;
+ Function = ACPI_READ;
+ }
+
+ BufferDesc = AcpiUtCreateBufferObject (Length);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /* Call the region handler for the read */
+
+ Status = AcpiExAccessRegion (ObjDesc, 0,
+ ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer),
+ Function);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+ goto Exit;
+ }
+
+ /*
+ * Allocate a buffer for the contents of the field.
+ *
+ * If the field is larger than the current integer width, create
+ * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
+ * the use of arithmetic operators on the returned value if the
+ * field size is equal or smaller than an Integer.
+ *
+ * Note: Field.length is in bits.
+ */
+ Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
+ if (Length > AcpiGbl_IntegerByteWidth)
+ {
+ /* Field is too large for an Integer, create a Buffer instead */
+
+ BufferDesc = AcpiUtCreateBufferObject (Length);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ Buffer = BufferDesc->Buffer.Pointer;
+ }
+ else
+ {
+ /* Field will fit within an Integer (normal case) */
+
+ BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Length = AcpiGbl_IntegerByteWidth;
+ Buffer = &BufferDesc->Integer.Value;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
+ ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length));
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
+ ObjDesc->CommonField.BitLength,
+ ObjDesc->CommonField.StartFieldBitOffset,
+ ObjDesc->CommonField.BaseByteOffset));
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /* Read from the field */
+
+ Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+
+Exit:
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (BufferDesc);
+ }
+ else
+ {
+ *RetBufferDesc = BufferDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExWriteDataToField
+ *
+ * PARAMETERS: SourceDesc - Contains data to write
+ * ObjDesc - The named field
+ * ResultDesc - Where the return value is returned, if any
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write to a named field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExWriteDataToField (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ResultDesc)
+{
+ ACPI_STATUS Status;
+ UINT32 Length;
+ void *Buffer;
+ ACPI_OPERAND_OBJECT *BufferDesc;
+ UINT32 Function;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc);
+
+
+ /* Parameter validation */
+
+ if (!SourceDesc || !ObjDesc)
+ {
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * If the BufferField arguments have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+ else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
+ (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
+ ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
+ {
+ /*
+ * This is an SMBus, GSBus or IPMI write. We will bypass the entire field
+ * mechanism and handoff the buffer directly to the handler. For
+ * these address spaces, the buffer is bi-directional; on a write,
+ * return data is returned in the same buffer.
+ *
+ * Source must be a buffer of sufficient size:
+ * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE.
+ *
+ * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function
+ */
+ if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
+ {
+ Length = ACPI_SMBUS_BUFFER_SIZE;
+ Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
+ }
+ else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
+ {
+ Length = ACPI_GSBUS_BUFFER_SIZE;
+ Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
+ }
+ else /* IPMI */
+ {
+ Length = ACPI_IPMI_BUFFER_SIZE;
+ Function = ACPI_WRITE;
+ }
+
+ if (SourceDesc->Buffer.Length < Length)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u",
+ Length, SourceDesc->Buffer.Length));
+
+ return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
+ }
+
+ /* Create the bi-directional buffer */
+
+ BufferDesc = AcpiUtCreateBufferObject (Length);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Buffer = BufferDesc->Buffer.Pointer;
+ ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length);
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /*
+ * Perform the write (returns status and perhaps data in the
+ * same buffer)
+ */
+ Status = AcpiExAccessRegion (ObjDesc, 0,
+ (UINT64 *) Buffer, Function);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ *ResultDesc = BufferDesc;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get a pointer to the data to be written */
+
+ switch (SourceDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Buffer = &SourceDesc->Integer.Value;
+ Length = sizeof (SourceDesc->Integer.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Buffer = SourceDesc->Buffer.Pointer;
+ Length = SourceDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Buffer = SourceDesc->String.Pointer;
+ Length = SourceDesc->String.Length;
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
+ SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type),
+ SourceDesc->Common.Type, Buffer, Length));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
+ ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type),
+ ObjDesc->Common.Type,
+ ObjDesc->CommonField.BitLength,
+ ObjDesc->CommonField.StartFieldBitOffset,
+ ObjDesc->CommonField.BaseByteOffset));
+
+ /* Lock entire transaction if requested */
+
+ AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ /* Write to the field */
+
+ Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length);
+ AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exfldio.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exfldio.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1055 @@
+/******************************************************************************
+ *
+ * Module Name: exfldio - Aml Field I/O
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXFLDIO_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>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exfldio")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExFieldDatumIo (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ UINT64 *Value,
+ UINT32 ReadWrite);
+
+static BOOLEAN
+AcpiExRegisterOverflow (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT64 Value);
+
+static ACPI_STATUS
+AcpiExSetupRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSetupRegion
+ *
+ * PARAMETERS: ObjDesc - Field to be read or written
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Common processing for AcpiExExtractFromField and
+ * AcpiExInsertIntoField. Initialize the Region if necessary and
+ * validate the request.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExSetupRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *RgnDesc;
+ UINT8 SpaceId;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset);
+
+
+ RgnDesc = ObjDesc->CommonField.RegionObj;
+
+ /* We must have a valid region */
+
+ if (RgnDesc->Common.Type != ACPI_TYPE_REGION)
+ {
+ ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
+ RgnDesc->Common.Type,
+ AcpiUtGetObjectTypeName (RgnDesc)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ SpaceId = RgnDesc->Region.SpaceId;
+
+ /* Validate the Space ID */
+
+ if (!AcpiIsValidSpaceId (SpaceId))
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
+ return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
+ }
+
+ /*
+ * If the Region Address and Length have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetRegionArguments (RgnDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Exit now for SMBus, GSBus or IPMI address space, it has a non-linear
+ * address space and the request cannot be directly validated
+ */
+ if (SpaceId == ACPI_ADR_SPACE_SMBUS ||
+ SpaceId == ACPI_ADR_SPACE_GSBUS ||
+ SpaceId == ACPI_ADR_SPACE_IPMI)
+ {
+ /* SMBus or IPMI has a non-linear address space */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+#ifdef ACPI_UNDER_DEVELOPMENT
+ /*
+ * If the Field access is AnyAcc, we can now compute the optimal
+ * access (because we know know the length of the parent region)
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+#endif
+
+ /*
+ * Validate the request. The entire request from the byte offset for a
+ * length of one field datum (access width) must fit within the region.
+ * (Region length is specified in bytes)
+ */
+ if (RgnDesc->Region.Length <
+ (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset +
+ ObjDesc->CommonField.AccessByteWidth))
+ {
+ if (AcpiGbl_EnableInterpreterSlack)
+ {
+ /*
+ * Slack mode only: We will go ahead and allow access to this
+ * field if it is within the region length rounded up to the next
+ * access width boundary. ACPI_SIZE cast for 64-bit compile.
+ */
+ if (ACPI_ROUND_UP (RgnDesc->Region.Length,
+ ObjDesc->CommonField.AccessByteWidth) >=
+ ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset +
+ ObjDesc->CommonField.AccessByteWidth +
+ FieldDatumByteOffset))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth)
+ {
+ /*
+ * This is the case where the AccessType (AccWord, etc.) is wider
+ * than the region itself. For example, a region of length one
+ * byte, and a field with Dword access specified.
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Field [%4.4s] access width (%u bytes) too large for region [%4.4s] (length %u)",
+ AcpiUtGetNodeName (ObjDesc->CommonField.Node),
+ ObjDesc->CommonField.AccessByteWidth,
+ AcpiUtGetNodeName (RgnDesc->Region.Node),
+ RgnDesc->Region.Length));
+ }
+
+ /*
+ * Offset rounded up to next multiple of field width
+ * exceeds region length, indicate an error
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Field [%4.4s] Base+Offset+Width %u+%u+%u is beyond end of region [%4.4s] (length %u)",
+ AcpiUtGetNodeName (ObjDesc->CommonField.Node),
+ ObjDesc->CommonField.BaseByteOffset,
+ FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth,
+ AcpiUtGetNodeName (RgnDesc->Region.Node),
+ RgnDesc->Region.Length));
+
+ return_ACPI_STATUS (AE_AML_REGION_LIMIT);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAccessRegion
+ *
+ * PARAMETERS: ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * Value - Where to store value (must at least
+ * 64 bits)
+ * Function - Read or Write flag plus other region-
+ * dependent flags
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or Write a single field datum to an Operation Region.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExAccessRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ UINT64 *Value,
+ UINT32 Function)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *RgnDesc;
+ UINT32 RegionOffset;
+
+
+ ACPI_FUNCTION_TRACE (ExAccessRegion);
+
+
+ /*
+ * Ensure that the region operands are fully evaluated and verify
+ * the validity of the request
+ */
+ Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The physical address of this field datum is:
+ *
+ * 1) The base of the region, plus
+ * 2) The base offset of the field, plus
+ * 3) The current offset into the field
+ */
+ RgnDesc = ObjDesc->CommonField.RegionObj;
+ RegionOffset =
+ ObjDesc->CommonField.BaseByteOffset +
+ FieldDatumByteOffset;
+
+ if ((Function & ACPI_IO_MASK) == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
+ " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId,
+ ObjDesc->CommonField.AccessByteWidth,
+ ObjDesc->CommonField.BaseByteOffset,
+ FieldDatumByteOffset,
+ ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset))));
+
+ /* Invoke the appropriate AddressSpace/OpRegion handler */
+
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc,
+ Function, RegionOffset,
+ ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value);
+
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_IMPLEMENTED)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Region %s (ID=%u) not implemented",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+ else if (Status == AE_NOT_EXIST)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Region %s (ID=%u) has no handler",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExRegisterOverflow
+ *
+ * PARAMETERS: ObjDesc - Register(Field) to be written
+ * Value - Value to be stored
+ *
+ * RETURN: TRUE if value overflows the field, FALSE otherwise
+ *
+ * DESCRIPTION: Check if a value is out of range of the field being written.
+ * Used to check if the values written to Index and Bank registers
+ * are out of range. Normally, the value is simply truncated
+ * to fit the field, but this case is most likely a serious
+ * coding error in the ASL.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiExRegisterOverflow (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT64 Value)
+{
+
+ if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE)
+ {
+ /*
+ * The field is large enough to hold the maximum integer, so we can
+ * never overflow it.
+ */
+ return (FALSE);
+ }
+
+ if (Value >= ((UINT64) 1 << ObjDesc->CommonField.BitLength))
+ {
+ /*
+ * The Value is larger than the maximum value that can fit into
+ * the register.
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Index value 0x%8.8X%8.8X overflows field width 0x%X",
+ ACPI_FORMAT_UINT64 (Value),
+ ObjDesc->CommonField.BitLength));
+
+ return (TRUE);
+ }
+
+ /* The Value will fit into the field with no truncation */
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExFieldDatumIo
+ *
+ * PARAMETERS: ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * Value - Where to store value (must be 64 bits)
+ * ReadWrite - Read or Write flag
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or Write a single datum of a field. The FieldType is
+ * demultiplexed here to handle the different types of fields
+ * (BufferField, RegionField, IndexField, BankField)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExFieldDatumIo (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ UINT64 *Value,
+ UINT32 ReadWrite)
+{
+ ACPI_STATUS Status;
+ UINT64 LocalValue;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset);
+
+
+ if (ReadWrite == ACPI_READ)
+ {
+ if (!Value)
+ {
+ LocalValue = 0;
+
+ /* To support reads without saving return value */
+ Value = &LocalValue;
+ }
+
+ /* Clear the entire return buffer first, [Very Important!] */
+
+ *Value = 0;
+ }
+
+ /*
+ * The four types of fields are:
+ *
+ * BufferField - Read/write from/to a Buffer
+ * RegionField - Read/write from/to a Operation Region.
+ * BankField - Write to a Bank Register, then read/write from/to an
+ * OperationRegion
+ * IndexField - Write to an Index Register, then read/write from/to a
+ * Data Register
+ */
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+ /*
+ * If the BufferField arguments have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /*
+ * Copy the data from the source buffer.
+ * Length is the field width in bytes.
+ */
+ ACPI_MEMCPY (Value,
+ (ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
+ ObjDesc->BufferField.BaseByteOffset +
+ FieldDatumByteOffset,
+ ObjDesc->CommonField.AccessByteWidth);
+ }
+ else
+ {
+ /*
+ * Copy the data to the target buffer.
+ * Length is the field width in bytes.
+ */
+ ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
+ ObjDesc->BufferField.BaseByteOffset +
+ FieldDatumByteOffset,
+ Value, ObjDesc->CommonField.AccessByteWidth);
+ }
+
+ Status = AE_OK;
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ /*
+ * Ensure that the BankValue is not beyond the capacity of
+ * the register
+ */
+ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj,
+ (UINT64) ObjDesc->BankField.Value))
+ {
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
+ /*
+ * For BankFields, we must write the BankValue to the BankRegister
+ * (itself a RegionField) before we can access the data.
+ */
+ Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj,
+ &ObjDesc->BankField.Value,
+ sizeof (ObjDesc->BankField.Value));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now that the Bank has been selected, fall through to the
+ * RegionField case and write the datum to the Operation Region
+ */
+
+ /*lint -fallthrough */
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ /*
+ * For simple RegionFields, we just directly access the owning
+ * Operation Region.
+ */
+ Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value,
+ ReadWrite);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+
+ /*
+ * Ensure that the IndexValue is not beyond the capacity of
+ * the register
+ */
+ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj,
+ (UINT64) ObjDesc->IndexField.Value))
+ {
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
+ /* Write the index value to the IndexRegister (itself a RegionField) */
+
+ FieldDatumByteOffset += ObjDesc->IndexField.Value;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Write to Index Register: Value %8.8X\n",
+ FieldDatumByteOffset));
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj,
+ &FieldDatumByteOffset,
+ sizeof (FieldDatumByteOffset));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /* Read the datum from the DataRegister */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Read from Data Register\n"));
+
+ Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj,
+ Value, sizeof (UINT64));
+ }
+ else
+ {
+ /* Write the datum to the DataRegister */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Write to Data Register: Value %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (*Value)));
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj,
+ Value, sizeof (UINT64));
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %u",
+ ObjDesc->Common.Type));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ if (ReadWrite == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Value Read %8.8X%8.8X, Width %u\n",
+ ACPI_FORMAT_UINT64 (*Value),
+ ObjDesc->CommonField.AccessByteWidth));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Value Written %8.8X%8.8X, Width %u\n",
+ ACPI_FORMAT_UINT64 (*Value),
+ ObjDesc->CommonField.AccessByteWidth));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExWriteWithUpdateRule
+ *
+ * PARAMETERS: ObjDesc - Field to be written
+ * Mask - bitmask within field datum
+ * FieldValue - Value to write
+ * FieldDatumByteOffset - Offset of datum within field
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Apply the field update rule to a field write
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExWriteWithUpdateRule (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT64 Mask,
+ UINT64 FieldValue,
+ UINT32 FieldDatumByteOffset)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT64 MergedValue;
+ UINT64 CurrentValue;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask);
+
+
+ /* Start with the new bits */
+
+ MergedValue = FieldValue;
+
+ /* If the mask is all ones, we don't need to worry about the update rule */
+
+ if (Mask != ACPI_UINT64_MAX)
+ {
+ /* Decode the update rule */
+
+ switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
+ {
+ case AML_FIELD_UPDATE_PRESERVE:
+ /*
+ * Check if update rule needs to be applied (not if mask is all
+ * ones) The left shift drops the bits we want to ignore.
+ */
+ if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) -
+ ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0)
+ {
+ /*
+ * Read the current contents of the byte/word/dword containing
+ * the field, and merge with the new field value.
+ */
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &CurrentValue, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ MergedValue |= (CurrentValue & ~Mask);
+ }
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ONES:
+
+ /* Set positions outside the field to all ones */
+
+ MergedValue |= ~Mask;
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
+
+ /* Set positions outside the field to all zeros */
+
+ MergedValue &= Mask;
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown UpdateRule value: 0x%X",
+ (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (Mask),
+ FieldDatumByteOffset,
+ ObjDesc->CommonField.AccessByteWidth,
+ ACPI_FORMAT_UINT64 (FieldValue),
+ ACPI_FORMAT_UINT64 (MergedValue)));
+
+ /* Write the merged value */
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &MergedValue, ACPI_WRITE);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExExtractFromField
+ *
+ * PARAMETERS: ObjDesc - Field to be read
+ * Buffer - Where to store the field data
+ * BufferLength - Length of Buffer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the current value of the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExExtractFromField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength)
+{
+ ACPI_STATUS Status;
+ UINT64 RawDatum;
+ UINT64 MergedDatum;
+ UINT32 FieldOffset = 0;
+ UINT32 BufferOffset = 0;
+ UINT32 BufferTailBits;
+ UINT32 DatumCount;
+ UINT32 FieldDatumCount;
+ UINT32 AccessBitWidth;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (ExExtractFromField);
+
+
+ /* Validate target buffer and clear it */
+
+ if (BufferLength <
+ ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Field size %u (bits) is too large for buffer (%u)",
+ ObjDesc->CommonField.BitLength, BufferLength));
+
+ return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ }
+
+ ACPI_MEMSET (Buffer, 0, BufferLength);
+ AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
+
+ /* Handle the simple case here */
+
+ if ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
+ (ObjDesc->CommonField.BitLength == AccessBitWidth))
+ {
+ Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ);
+ return_ACPI_STATUS (Status);
+ }
+
+/* TBD: Move to common setup code */
+
+ /* Field algorithm is limited to sizeof(UINT64), truncate if needed */
+
+ if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
+ {
+ ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
+ AccessBitWidth = sizeof (UINT64) * 8;
+ }
+
+ /* Compute the number of datums (access width data items) */
+
+ DatumCount = ACPI_ROUND_UP_TO (
+ ObjDesc->CommonField.BitLength, AccessBitWidth);
+
+ FieldDatumCount = ACPI_ROUND_UP_TO (
+ ObjDesc->CommonField.BitLength +
+ ObjDesc->CommonField.StartFieldBitOffset, AccessBitWidth);
+
+ /* Priming read from the field */
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
+
+ /* Read the rest of the field */
+
+ for (i = 1; i < FieldDatumCount; i++)
+ {
+ /* Get next input datum from the field */
+
+ FieldOffset += ObjDesc->CommonField.AccessByteWidth;
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset,
+ &RawDatum, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Merge with previous datum if necessary.
+ *
+ * Note: Before the shift, check if the shift value will be larger than
+ * the integer size. If so, there is no need to perform the operation.
+ * This avoids the differences in behavior between different compilers
+ * concerning shift values larger than the target data width.
+ */
+ if (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset <
+ ACPI_INTEGER_BIT_SIZE)
+ {
+ MergedDatum |= RawDatum <<
+ (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
+ }
+
+ if (i == DatumCount)
+ {
+ break;
+ }
+
+ /* Write merged datum to target buffer */
+
+ ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ BufferOffset += ObjDesc->CommonField.AccessByteWidth;
+ MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
+ }
+
+ /* Mask off any extra bits in the last datum */
+
+ BufferTailBits = ObjDesc->CommonField.BitLength % AccessBitWidth;
+ if (BufferTailBits)
+ {
+ MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
+ }
+
+ /* Write the last datum to the buffer */
+
+ ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExInsertIntoField
+ *
+ * PARAMETERS: ObjDesc - Field to be written
+ * Buffer - Data to be written
+ * BufferLength - Length of Buffer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the Buffer contents into the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExInsertIntoField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength)
+{
+ void *NewBuffer;
+ ACPI_STATUS Status;
+ UINT64 Mask;
+ UINT64 WidthMask;
+ UINT64 MergedDatum;
+ UINT64 RawDatum = 0;
+ UINT32 FieldOffset = 0;
+ UINT32 BufferOffset = 0;
+ UINT32 BufferTailBits;
+ UINT32 DatumCount;
+ UINT32 FieldDatumCount;
+ UINT32 AccessBitWidth;
+ UINT32 RequiredLength;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (ExInsertIntoField);
+
+
+ /* Validate input buffer */
+
+ NewBuffer = NULL;
+ RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (
+ ObjDesc->CommonField.BitLength);
+ /*
+ * We must have a buffer that is at least as long as the field
+ * we are writing to. This is because individual fields are
+ * indivisible and partial writes are not supported -- as per
+ * the ACPI specification.
+ */
+ if (BufferLength < RequiredLength)
+ {
+ /* We need to create a new buffer */
+
+ NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength);
+ if (!NewBuffer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Copy the original data to the new buffer, starting
+ * at Byte zero. All unused (upper) bytes of the
+ * buffer will be 0.
+ */
+ ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength);
+ Buffer = NewBuffer;
+ BufferLength = RequiredLength;
+ }
+
+/* TBD: Move to common setup code */
+
+ /* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */
+ if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
+ {
+ ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
+ }
+
+ AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
+
+ /*
+ * Create the bitmasks used for bit insertion.
+ * Note: This if/else is used to bypass compiler differences with the
+ * shift operator
+ */
+ if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
+ {
+ WidthMask = ACPI_UINT64_MAX;
+ }
+ else
+ {
+ WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
+ }
+
+ Mask = WidthMask &
+ ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
+
+ /* Compute the number of datums (access width data items) */
+
+ DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength,
+ AccessBitWidth);
+
+ FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength +
+ ObjDesc->CommonField.StartFieldBitOffset,
+ AccessBitWidth);
+
+ /* Get initial Datum from the input buffer */
+
+ ACPI_MEMCPY (&RawDatum, Buffer,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
+
+ /* Write the entire field */
+
+ for (i = 1; i < FieldDatumCount; i++)
+ {
+ /* Write merged datum to the target field */
+
+ MergedDatum &= Mask;
+ Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask,
+ MergedDatum, FieldOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+
+ FieldOffset += ObjDesc->CommonField.AccessByteWidth;
+
+ /*
+ * Start new output datum by merging with previous input datum
+ * if necessary.
+ *
+ * Note: Before the shift, check if the shift value will be larger than
+ * the integer size. If so, there is no need to perform the operation.
+ * This avoids the differences in behavior between different compilers
+ * concerning shift values larger than the target data width.
+ */
+ if ((AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset) <
+ ACPI_INTEGER_BIT_SIZE)
+ {
+ MergedDatum = RawDatum >>
+ (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
+ }
+ else
+ {
+ MergedDatum = 0;
+ }
+
+ Mask = WidthMask;
+
+ if (i == DatumCount)
+ {
+ break;
+ }
+
+ /* Get the next input datum from the buffer */
+
+ BufferOffset += ObjDesc->CommonField.AccessByteWidth;
+ ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset,
+ ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
+ BufferLength - BufferOffset));
+
+ MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
+ }
+
+ /* Mask off any extra bits in the last datum */
+
+ BufferTailBits = (ObjDesc->CommonField.BitLength +
+ ObjDesc->CommonField.StartFieldBitOffset) % AccessBitWidth;
+ if (BufferTailBits)
+ {
+ Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
+ }
+
+ /* Write the last datum to the field */
+
+ MergedDatum &= Mask;
+ Status = AcpiExWriteWithUpdateRule (ObjDesc,
+ Mask, MergedDatum, FieldOffset);
+
+Exit:
+ /* Free temporary buffer if we used one */
+
+ if (NewBuffer)
+ {
+ ACPI_FREE (NewBuffer);
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exmisc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exmisc.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,800 @@
+
+/******************************************************************************
+ *
+ * Module Name: exmisc - ACPI AML (p-code) execution - specific 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 __EXMISC_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>
+#include <contrib/dev/acpica/include/amlresrc.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exmisc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGetObjectReference
+ *
+ * PARAMETERS: ObjDesc - Create a reference to this object
+ * ReturnDesc - Where to store the reference
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Obtain and return a "reference" to the target object
+ * Common code for the RefOfOp and the CondRefOfOp.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExGetObjectReference (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **ReturnDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ReferenceObj;
+ ACPI_OPERAND_OBJECT *ReferencedObj;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
+
+
+ *ReturnDesc = NULL;
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+
+ if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * Must be a reference to a Local or Arg
+ */
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+ case ACPI_REFCLASS_DEBUG:
+
+ /* The referenced object is the pseudo-node for the local/arg */
+
+ ReferencedObj = ObjDesc->Reference.Object;
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
+ ObjDesc->Reference.Class));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+ break;
+
+
+ case ACPI_DESC_TYPE_NAMED:
+
+ /*
+ * A named reference that has already been resolved to a Node
+ */
+ ReferencedObj = ObjDesc;
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X",
+ ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+
+ /* Create a new reference object */
+
+ ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
+ if (!ReferenceObj)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF;
+ ReferenceObj->Reference.Object = ReferencedObj;
+ *ReturnDesc = ReferenceObj;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Object %p Type [%s], returning Reference %p\n",
+ ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExConcatTemplate
+ *
+ * PARAMETERS: Operand0 - First source object
+ * Operand1 - Second source object
+ * ActualReturnDesc - Where to place the return object
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Concatenate two resource templates
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConcatTemplate (
+ ACPI_OPERAND_OBJECT *Operand0,
+ ACPI_OPERAND_OBJECT *Operand1,
+ ACPI_OPERAND_OBJECT **ActualReturnDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ UINT8 *NewBuf;
+ UINT8 *EndTag;
+ ACPI_SIZE Length0;
+ ACPI_SIZE Length1;
+ ACPI_SIZE NewLength;
+
+
+ ACPI_FUNCTION_TRACE (ExConcatTemplate);
+
+
+ /*
+ * Find the EndTag descriptor in each resource template.
+ * Note1: returned pointers point TO the EndTag, not past it.
+ * Note2: zero-length buffers are allowed; treated like one EndTag
+ */
+
+ /* Get the length of the first resource template */
+
+ Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
+
+ /* Get the length of the second resource template */
+
+ Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
+
+ /* Combine both lengths, minimum size will be 2 for EndTag */
+
+ NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
+
+ /* Create a new buffer object for the result (with one EndTag) */
+
+ ReturnDesc = AcpiUtCreateBufferObject (NewLength);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Copy the templates to the new buffer, 0 first, then 1 follows. One
+ * EndTag descriptor is copied from Operand1.
+ */
+ NewBuf = ReturnDesc->Buffer.Pointer;
+ ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0);
+ ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
+
+ /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
+
+ NewBuf[NewLength - 1] = 0;
+ NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
+
+ /* Return the completed resource template */
+
+ *ActualReturnDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoConcatenate
+ *
+ * PARAMETERS: Operand0 - First source object
+ * Operand1 - Second source object
+ * ActualReturnDesc - Where to place the return object
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDoConcatenate (
+ ACPI_OPERAND_OBJECT *Operand0,
+ ACPI_OPERAND_OBJECT *Operand1,
+ ACPI_OPERAND_OBJECT **ActualReturnDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ char *NewBuf;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExDoConcatenate);
+
+
+ /*
+ * Convert the second operand if necessary. The first operand
+ * determines the type of the second operand, (See the Data Types
+ * section of the ACPI specification.) Both object types are
+ * guaranteed to be either Integer/String/Buffer by the operand
+ * resolution mechanism.
+ */
+ switch (Operand0->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
+ break;
+
+ case ACPI_TYPE_STRING:
+ Status = AcpiExConvertToString (Operand1, &LocalOperand1,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
+ Operand0->Common.Type));
+ Status = AE_AML_INTERNAL;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Both operands are now known to be the same object type
+ * (Both are Integer, String, or Buffer), and we can now perform the
+ * concatenation.
+ */
+
+ /*
+ * There are three cases to handle:
+ *
+ * 1) Two Integers concatenated to produce a new Buffer
+ * 2) Two Strings concatenated to produce a new String
+ * 3) Two Buffers concatenated to produce a new Buffer
+ */
+ switch (Operand0->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Result of two Integers is a Buffer */
+ /* Need enough buffer space for two integers */
+
+ ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
+ ACPI_MUL_2 (AcpiGbl_IntegerByteWidth));
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ NewBuf = (char *) ReturnDesc->Buffer.Pointer;
+
+ /* Copy the first integer, LSB first */
+
+ ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value,
+ AcpiGbl_IntegerByteWidth);
+
+ /* Copy the second integer (LSB first) after the first */
+
+ ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
+ &LocalOperand1->Integer.Value,
+ AcpiGbl_IntegerByteWidth);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ /* Result of two Strings is a String */
+
+ ReturnDesc = AcpiUtCreateStringObject (
+ ((ACPI_SIZE) Operand0->String.Length +
+ LocalOperand1->String.Length));
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ NewBuf = ReturnDesc->String.Pointer;
+
+ /* Concatenate the strings */
+
+ ACPI_STRCPY (NewBuf, Operand0->String.Pointer);
+ ACPI_STRCPY (NewBuf + Operand0->String.Length,
+ LocalOperand1->String.Pointer);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Result of two Buffers is a Buffer */
+
+ ReturnDesc = AcpiUtCreateBufferObject (
+ ((ACPI_SIZE) Operand0->Buffer.Length +
+ LocalOperand1->Buffer.Length));
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ NewBuf = (char *) ReturnDesc->Buffer.Pointer;
+
+ /* Concatenate the buffers */
+
+ ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer,
+ Operand0->Buffer.Length);
+ ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
+ LocalOperand1->Buffer.Pointer,
+ LocalOperand1->Buffer.Length);
+ break;
+
+ default:
+
+ /* Invalid object type, should not happen here */
+
+ ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
+ Operand0->Common.Type));
+ Status =AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ *ActualReturnDesc = ReturnDesc;
+
+Cleanup:
+ if (LocalOperand1 != Operand1)
+ {
+ AcpiUtRemoveReference (LocalOperand1);
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoMathOp
+ *
+ * PARAMETERS: Opcode - AML opcode
+ * Integer0 - Integer operand #0
+ * Integer1 - Integer operand #1
+ *
+ * RETURN: Integer result of the operation
+ *
+ * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
+ * math functions here is to prevent a lot of pointer dereferencing
+ * to obtain the operands.
+ *
+ ******************************************************************************/
+
+UINT64
+AcpiExDoMathOp (
+ UINT16 Opcode,
+ UINT64 Integer0,
+ UINT64 Integer1)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (Opcode)
+ {
+ case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
+
+ return (Integer0 + Integer1);
+
+
+ case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
+
+ return (Integer0 & Integer1);
+
+
+ case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
+
+ return (~(Integer0 & Integer1));
+
+
+ case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
+
+ return (Integer0 | Integer1);
+
+
+ case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
+
+ return (~(Integer0 | Integer1));
+
+
+ case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
+
+ return (Integer0 ^ Integer1);
+
+
+ case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
+
+ return (Integer0 * Integer1);
+
+
+ case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
+
+ /*
+ * We need to check if the shiftcount is larger than the integer bit
+ * width since the behavior of this is not well-defined in the C language.
+ */
+ if (Integer1 >= AcpiGbl_IntegerBitWidth)
+ {
+ return (0);
+ }
+ return (Integer0 << Integer1);
+
+
+ case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
+
+ /*
+ * We need to check if the shiftcount is larger than the integer bit
+ * width since the behavior of this is not well-defined in the C language.
+ */
+ if (Integer1 >= AcpiGbl_IntegerBitWidth)
+ {
+ return (0);
+ }
+ return (Integer0 >> Integer1);
+
+
+ case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
+
+ return (Integer0 - Integer1);
+
+ default:
+
+ return (0);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoLogicalNumericOp
+ *
+ * PARAMETERS: Opcode - AML opcode
+ * Integer0 - Integer operand #0
+ * Integer1 - Integer operand #1
+ * LogicalResult - TRUE/FALSE result of the operation
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
+ * operators (LAnd and LOr), both operands must be integers.
+ *
+ * Note: cleanest machine code seems to be produced by the code
+ * below, rather than using statements of the form:
+ * Result = (Integer0 && Integer1);
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDoLogicalNumericOp (
+ UINT16 Opcode,
+ UINT64 Integer0,
+ UINT64 Integer1,
+ BOOLEAN *LogicalResult)
+{
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN LocalResult = FALSE;
+
+
+ ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
+
+
+ switch (Opcode)
+ {
+ case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
+
+ if (Integer0 && Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LOR_OP: /* LOr (Integer0, Integer1) */
+
+ if (Integer0 || Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ /* Return the logical result and status */
+
+ *LogicalResult = LocalResult;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoLogicalOp
+ *
+ * PARAMETERS: Opcode - AML opcode
+ * Operand0 - operand #0
+ * Operand1 - operand #1
+ * LogicalResult - TRUE/FALSE result of the operation
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
+ * functions here is to prevent a lot of pointer dereferencing
+ * to obtain the operands and to simplify the generation of the
+ * logical value. For the Numeric operators (LAnd and LOr), both
+ * operands must be integers. For the other logical operators,
+ * operands can be any combination of Integer/String/Buffer. The
+ * first operand determines the type to which the second operand
+ * will be converted.
+ *
+ * Note: cleanest machine code seems to be produced by the code
+ * below, rather than using statements of the form:
+ * Result = (Operand0 == Operand1);
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDoLogicalOp (
+ UINT16 Opcode,
+ ACPI_OPERAND_OBJECT *Operand0,
+ ACPI_OPERAND_OBJECT *Operand1,
+ BOOLEAN *LogicalResult)
+{
+ ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
+ UINT64 Integer0;
+ UINT64 Integer1;
+ UINT32 Length0;
+ UINT32 Length1;
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN LocalResult = FALSE;
+ int Compare;
+
+
+ ACPI_FUNCTION_TRACE (ExDoLogicalOp);
+
+
+ /*
+ * Convert the second operand if necessary. The first operand
+ * determines the type of the second operand, (See the Data Types
+ * section of the ACPI 3.0+ specification.) Both object types are
+ * guaranteed to be either Integer/String/Buffer by the operand
+ * resolution mechanism.
+ */
+ switch (Operand0->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
+ break;
+
+ case ACPI_TYPE_STRING:
+ Status = AcpiExConvertToString (Operand1, &LocalOperand1,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Two cases: 1) Both Integers, 2) Both Strings or Buffers
+ */
+ if (Operand0->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ /*
+ * 1) Both operands are of type integer
+ * Note: LocalOperand1 may have changed above
+ */
+ Integer0 = Operand0->Integer.Value;
+ Integer1 = LocalOperand1->Integer.Value;
+
+ switch (Opcode)
+ {
+ case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
+
+ if (Integer0 == Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
+
+ if (Integer0 > Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
+
+ if (Integer0 < Integer1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ }
+ else
+ {
+ /*
+ * 2) Both operands are Strings or both are Buffers
+ * Note: Code below takes advantage of common Buffer/String
+ * object fields. LocalOperand1 may have changed above. Use
+ * memcmp to handle nulls in buffers.
+ */
+ Length0 = Operand0->Buffer.Length;
+ Length1 = LocalOperand1->Buffer.Length;
+
+ /* Lexicographic compare: compare the data bytes */
+
+ Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer,
+ LocalOperand1->Buffer.Pointer,
+ (Length0 > Length1) ? Length1 : Length0);
+
+ switch (Opcode)
+ {
+ case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
+
+ /* Length and all bytes must be equal */
+
+ if ((Length0 == Length1) &&
+ (Compare == 0))
+ {
+ /* Length and all bytes match ==> TRUE */
+
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
+
+ if (Compare > 0)
+ {
+ LocalResult = TRUE;
+ goto Cleanup; /* TRUE */
+ }
+ if (Compare < 0)
+ {
+ goto Cleanup; /* FALSE */
+ }
+
+ /* Bytes match (to shortest length), compare lengths */
+
+ if (Length0 > Length1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
+
+ if (Compare > 0)
+ {
+ goto Cleanup; /* FALSE */
+ }
+ if (Compare < 0)
+ {
+ LocalResult = TRUE;
+ goto Cleanup; /* TRUE */
+ }
+
+ /* Bytes match (to shortest length), compare lengths */
+
+ if (Length0 < Length1)
+ {
+ LocalResult = TRUE;
+ }
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ }
+
+Cleanup:
+
+ /* New object was created if implicit conversion performed - delete */
+
+ if (LocalOperand1 != Operand1)
+ {
+ AcpiUtRemoveReference (LocalOperand1);
+ }
+
+ /* Return the logical result and status */
+
+ *LogicalResult = LocalResult;
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exmutex.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exmutex.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,554 @@
+
+/******************************************************************************
+ *
+ * Module Name: exmutex - ASL Mutex Acquire/Release 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.
+ */
+
+#define __EXMUTEX_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/acevents.h>
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exmutex")
+
+/* Local prototypes */
+
+static void
+AcpiExLinkMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_THREAD_STATE *Thread);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExUnlinkMutex
+ *
+ * PARAMETERS: ObjDesc - The mutex to be unlinked
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list
+ *
+ ******************************************************************************/
+
+void
+AcpiExUnlinkMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread;
+
+
+ if (!Thread)
+ {
+ return;
+ }
+
+ /* Doubly linked list */
+
+ if (ObjDesc->Mutex.Next)
+ {
+ (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev;
+ }
+
+ if (ObjDesc->Mutex.Prev)
+ {
+ (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next;
+
+ /*
+ * Migrate the previous sync level associated with this mutex to
+ * the previous mutex on the list so that it may be preserved.
+ * This handles the case where several mutexes have been acquired
+ * at the same level, but are not released in opposite order.
+ */
+ (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel =
+ ObjDesc->Mutex.OriginalSyncLevel;
+ }
+ else
+ {
+ Thread->AcquiredMutexList = ObjDesc->Mutex.Next;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExLinkMutex
+ *
+ * PARAMETERS: ObjDesc - The mutex to be linked
+ * Thread - Current executing thread object
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk
+ *
+ ******************************************************************************/
+
+static void
+AcpiExLinkMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_THREAD_STATE *Thread)
+{
+ ACPI_OPERAND_OBJECT *ListHead;
+
+
+ ListHead = Thread->AcquiredMutexList;
+
+ /* This object will be the first object in the list */
+
+ ObjDesc->Mutex.Prev = NULL;
+ ObjDesc->Mutex.Next = ListHead;
+
+ /* Update old first object to point back to this object */
+
+ if (ListHead)
+ {
+ ListHead->Mutex.Prev = ObjDesc;
+ }
+
+ /* Update list head */
+
+ Thread->AcquiredMutexList = ObjDesc;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAcquireMutexObject
+ *
+ * PARAMETERS: Timeout - Timeout in milliseconds
+ * ObjDesc - Mutex object
+ * ThreadId - Current thread state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common
+ * path that supports multiple acquires by the same thread.
+ *
+ * MUTEX: Interpreter must be locked
+ *
+ * NOTE: This interface is called from three places:
+ * 1) From AcpiExAcquireMutex, via an AML Acquire() operator
+ * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the
+ * global lock
+ * 3) From the external interface, AcpiAcquireGlobalLock
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExAcquireMutexObject (
+ UINT16 Timeout,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_THREAD_ID ThreadId)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc);
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Support for multiple acquires by the owning thread */
+
+ if (ObjDesc->Mutex.ThreadId == ThreadId)
+ {
+ /*
+ * The mutex is already owned by this thread, just increment the
+ * acquisition depth
+ */
+ ObjDesc->Mutex.AcquisitionDepth++;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Acquire the mutex, wait if necessary. Special case for Global Lock */
+
+ if (ObjDesc == AcpiGbl_GlobalLockMutex)
+ {
+ Status = AcpiEvAcquireGlobalLock (Timeout);
+ }
+ else
+ {
+ Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex,
+ Timeout);
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Includes failure from a timeout on TimeDesc */
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Acquired the mutex: update mutex object */
+
+ ObjDesc->Mutex.ThreadId = ThreadId;
+ ObjDesc->Mutex.AcquisitionDepth = 1;
+ ObjDesc->Mutex.OriginalSyncLevel = 0;
+ ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAcquireMutex
+ *
+ * PARAMETERS: TimeDesc - Timeout integer
+ * ObjDesc - Mutex object
+ * WalkState - Current method execution state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Acquire an AML mutex
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExAcquireMutex (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc);
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Must have a valid thread state struct */
+
+ if (!WalkState->Thread)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot acquire Mutex [%4.4s], null thread info",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /*
+ * Current sync level must be less than or equal to the sync level of the
+ * mutex. This mechanism provides some deadlock prevention
+ */
+ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%u)",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node),
+ WalkState->Thread->CurrentSyncLevel));
+ return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
+ }
+
+ Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value,
+ ObjDesc, WalkState->Thread->ThreadId);
+ if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1)
+ {
+ /* Save Thread object, original/current sync levels */
+
+ ObjDesc->Mutex.OwnerThread = WalkState->Thread;
+ ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel;
+ WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel;
+
+ /* Link the mutex to the current thread for force-unlock at method exit */
+
+ AcpiExLinkMutex (ObjDesc, WalkState->Thread);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseMutexObject
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release a previously acquired Mutex, low level interface.
+ * Provides a common path that supports multiple releases (after
+ * previous multiple acquires) by the same thread.
+ *
+ * MUTEX: Interpreter must be locked
+ *
+ * NOTE: This interface is called from three places:
+ * 1) From AcpiExReleaseMutex, via an AML Acquire() operator
+ * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the
+ * global lock
+ * 3) From the external interface, AcpiReleaseGlobalLock
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExReleaseMutexObject (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExReleaseMutexObject);
+
+
+ if (ObjDesc->Mutex.AcquisitionDepth == 0)
+ {
+ return (AE_NOT_ACQUIRED);
+ }
+
+ /* Match multiple Acquires with multiple Releases */
+
+ ObjDesc->Mutex.AcquisitionDepth--;
+ if (ObjDesc->Mutex.AcquisitionDepth != 0)
+ {
+ /* Just decrement the depth and return */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ if (ObjDesc->Mutex.OwnerThread)
+ {
+ /* Unlink the mutex from the owner's list */
+
+ AcpiExUnlinkMutex (ObjDesc);
+ ObjDesc->Mutex.OwnerThread = NULL;
+ }
+
+ /* Release the mutex, special case for Global Lock */
+
+ if (ObjDesc == AcpiGbl_GlobalLockMutex)
+ {
+ Status = AcpiEvReleaseGlobalLock ();
+ }
+ else
+ {
+ AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
+ }
+
+ /* Clear mutex info */
+
+ ObjDesc->Mutex.ThreadId = 0;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseMutex
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ * WalkState - Current method execution state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release a previously acquired Mutex.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExReleaseMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 PreviousSyncLevel;
+ ACPI_THREAD_STATE *OwnerThread;
+
+
+ ACPI_FUNCTION_TRACE (ExReleaseMutex);
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ OwnerThread = ObjDesc->Mutex.OwnerThread;
+
+ /* The mutex must have been previously acquired in order to release it */
+
+ if (!OwnerThread)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot release Mutex [%4.4s], not acquired",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
+ return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
+ }
+
+ /* Must have a valid thread ID */
+
+ if (!WalkState->Thread)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot release Mutex [%4.4s], null thread info",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /*
+ * The Mutex is owned, but this thread must be the owner.
+ * Special case for Global Lock, any thread can release
+ */
+ if ((OwnerThread->ThreadId != WalkState->Thread->ThreadId) &&
+ (ObjDesc != AcpiGbl_GlobalLockMutex))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
+ (UINT32) WalkState->Thread->ThreadId,
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node),
+ (UINT32) OwnerThread->ThreadId));
+ return_ACPI_STATUS (AE_AML_NOT_OWNER);
+ }
+
+ /*
+ * The sync level of the mutex must be equal to the current sync level. In
+ * other words, the current level means that at least one mutex at that
+ * level is currently being held. Attempting to release a mutex of a
+ * different level can only mean that the mutex ordering rule is being
+ * violated. This behavior is clarified in ACPI 4.0 specification.
+ */
+ if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %u current %u",
+ AcpiUtGetNodeName (ObjDesc->Mutex.Node),
+ ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel));
+ return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
+ }
+
+ /*
+ * Get the previous SyncLevel from the head of the acquired mutex list.
+ * This handles the case where several mutexes at the same level have been
+ * acquired, but are not released in reverse order.
+ */
+ PreviousSyncLevel =
+ OwnerThread->AcquiredMutexList->Mutex.OriginalSyncLevel;
+
+ Status = AcpiExReleaseMutexObject (ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc->Mutex.AcquisitionDepth == 0)
+ {
+ /* Restore the previous SyncLevel */
+
+ OwnerThread->CurrentSyncLevel = PreviousSyncLevel;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseAllMutexes
+ *
+ * PARAMETERS: Thread - Current executing thread object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release all mutexes held by this thread
+ *
+ * NOTE: This function is called as the thread is exiting the interpreter.
+ * Mutexes are not released when an individual control method is exited, but
+ * only when the parent thread actually exits the interpreter. This allows one
+ * method to acquire a mutex, and a different method to release it, as long as
+ * this is performed underneath a single parent control method.
+ *
+ ******************************************************************************/
+
+void
+AcpiExReleaseAllMutexes (
+ ACPI_THREAD_STATE *Thread)
+{
+ ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Traverse the list of owned mutexes, releasing each one */
+
+ while (Next)
+ {
+ ObjDesc = Next;
+ Next = ObjDesc->Mutex.Next;
+
+ ObjDesc->Mutex.Prev = NULL;
+ ObjDesc->Mutex.Next = NULL;
+ ObjDesc->Mutex.AcquisitionDepth = 0;
+
+ /* Release the mutex, special case for Global Lock */
+
+ if (ObjDesc == AcpiGbl_GlobalLockMutex)
+ {
+ /* Ignore errors */
+
+ (void) AcpiEvReleaseGlobalLock ();
+ }
+ else
+ {
+ AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
+ }
+
+ /* Mark mutex unowned */
+
+ ObjDesc->Mutex.OwnerThread = NULL;
+ ObjDesc->Mutex.ThreadId = 0;
+
+ /* Update Thread SyncLevel (Last mutex is the important one) */
+
+ Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel;
+ }
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exnames.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exnames.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,488 @@
+
+/******************************************************************************
+ *
+ * Module Name: exnames - interpreter/scanner name load/execute
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXNAMES_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 ("exnames")
+
+/* Local prototypes */
+
+static char *
+AcpiExAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs);
+
+static ACPI_STATUS
+AcpiExNameSegment (
+ UINT8 **InAmlAddress,
+ char *NameString);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAllocateNameString
+ *
+ * PARAMETERS: PrefixCount - Count of parent levels. Special cases:
+ * (-1)==root, 0==none
+ * NumNameSegs - count of 4-character name segments
+ *
+ * RETURN: A pointer to the allocated string segment. This segment must
+ * be deleted by the caller.
+ *
+ * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name
+ * string is long enough, and set up prefix if any.
+ *
+ ******************************************************************************/
+
+static char *
+AcpiExAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs)
+{
+ char *TempPtr;
+ char *NameString;
+ UINT32 SizeNeeded;
+
+ ACPI_FUNCTION_TRACE (ExAllocateNameString);
+
+
+ /*
+ * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix.
+ * Also, one byte for the null terminator.
+ * This may actually be somewhat longer than needed.
+ */
+ if (PrefixCount == ACPI_UINT32_MAX)
+ {
+ /* Special case for root */
+
+ SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
+ }
+ else
+ {
+ SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
+ }
+
+ /*
+ * Allocate a buffer for the name.
+ * This buffer must be deleted by the caller!
+ */
+ NameString = ACPI_ALLOCATE (SizeNeeded);
+ if (!NameString)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not allocate size %u", SizeNeeded));
+ return_PTR (NULL);
+ }
+
+ TempPtr = NameString;
+
+ /* Set up Root or Parent prefixes if needed */
+
+ if (PrefixCount == ACPI_UINT32_MAX)
+ {
+ *TempPtr++ = AML_ROOT_PREFIX;
+ }
+ else
+ {
+ while (PrefixCount--)
+ {
+ *TempPtr++ = AML_PARENT_PREFIX;
+ }
+ }
+
+
+ /* Set up Dual or Multi prefixes if needed */
+
+ if (NumNameSegs > 2)
+ {
+ /* Set up multi prefixes */
+
+ *TempPtr++ = AML_MULTI_NAME_PREFIX_OP;
+ *TempPtr++ = (char) NumNameSegs;
+ }
+ else if (2 == NumNameSegs)
+ {
+ /* Set up dual prefixes */
+
+ *TempPtr++ = AML_DUAL_NAME_PREFIX;
+ }
+
+ /*
+ * Terminate string following prefixes. AcpiExNameSegment() will
+ * append the segment(s)
+ */
+ *TempPtr = 0;
+
+ return_PTR (NameString);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExNameSegment
+ *
+ * PARAMETERS: InAmlAddress - Pointer to the name in the AML code
+ * NameString - Where to return the name. The name is appended
+ * to any existing string to form a namepath
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExNameSegment (
+ UINT8 **InAmlAddress,
+ char *NameString)
+{
+ char *AmlAddress = (void *) *InAmlAddress;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Index;
+ char CharBuf[5];
+
+
+ ACPI_FUNCTION_TRACE (ExNameSegment);
+
+
+ /*
+ * If first character is a digit, then we know that we aren't looking at a
+ * valid name segment
+ */
+ CharBuf[0] = *AmlAddress;
+
+ if ('0' <= CharBuf[0] && CharBuf[0] <= '9')
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid leading digit: %c", CharBuf[0]));
+ return_ACPI_STATUS (AE_CTRL_PENDING);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n"));
+
+ for (Index = 0;
+ (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0));
+ Index++)
+ {
+ CharBuf[Index] = *AmlAddress++;
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[Index]));
+ }
+
+
+ /* Valid name segment */
+
+ if (Index == 4)
+ {
+ /* Found 4 valid characters */
+
+ CharBuf[4] = '\0';
+
+ if (NameString)
+ {
+ ACPI_STRCAT (NameString, CharBuf);
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Appended to - %s\n", NameString));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "No Name string - %s\n", CharBuf));
+ }
+ }
+ else if (Index == 0)
+ {
+ /*
+ * First character was not a valid name character,
+ * so we are looking at something other than a name.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Leading character is not alpha: %02Xh (not a name)\n",
+ CharBuf[0]));
+ Status = AE_CTRL_PENDING;
+ }
+ else
+ {
+ /*
+ * Segment started with one or more valid characters, but fewer than
+ * the required 4
+ */
+ Status = AE_AML_BAD_NAME;
+ ACPI_ERROR ((AE_INFO,
+ "Bad character 0x%02x in name, at %p",
+ *AmlAddress, AmlAddress));
+ }
+
+ *InAmlAddress = ACPI_CAST_PTR (UINT8, AmlAddress);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGetNameString
+ *
+ * PARAMETERS: DataType - Object type to be associated with this
+ * name
+ * InAmlAddress - Pointer to the namestring in the AML code
+ * OutNameString - Where the namestring is returned
+ * OutNameLength - Length of the returned string
+ *
+ * RETURN: Status, namestring and length
+ *
+ * DESCRIPTION: Extract a full namepath from the AML byte stream,
+ * including any prefixes.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExGetNameString (
+ ACPI_OBJECT_TYPE DataType,
+ UINT8 *InAmlAddress,
+ char **OutNameString,
+ UINT32 *OutNameLength)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 *AmlAddress = InAmlAddress;
+ char *NameString = NULL;
+ UINT32 NumSegments;
+ UINT32 PrefixCount = 0;
+ BOOLEAN HasPrefix = FALSE;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress);
+
+
+ if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType ||
+ ACPI_TYPE_LOCAL_BANK_FIELD == DataType ||
+ ACPI_TYPE_LOCAL_INDEX_FIELD == DataType)
+ {
+ /* Disallow prefixes for types associated with FieldUnit names */
+
+ NameString = AcpiExAllocateNameString (0, 1);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ }
+ else
+ {
+ Status = AcpiExNameSegment (&AmlAddress, NameString);
+ }
+ }
+ else
+ {
+ /*
+ * DataType is not a field name.
+ * Examine first character of name for root or parent prefix operators
+ */
+ switch (*AmlAddress)
+ {
+ case AML_ROOT_PREFIX:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n",
+ AmlAddress));
+
+ /*
+ * Remember that we have a RootPrefix --
+ * see comment in AcpiExAllocateNameString()
+ */
+ AmlAddress++;
+ PrefixCount = ACPI_UINT32_MAX;
+ HasPrefix = TRUE;
+ break;
+
+
+ case AML_PARENT_PREFIX:
+
+ /* Increment past possibly multiple parent prefixes */
+
+ do
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n",
+ AmlAddress));
+
+ AmlAddress++;
+ PrefixCount++;
+
+ } while (*AmlAddress == AML_PARENT_PREFIX);
+
+ HasPrefix = TRUE;
+ break;
+
+
+ default:
+
+ /* Not a prefix character */
+
+ break;
+ }
+
+ /* Examine first character of name for name segment prefix operator */
+
+ switch (*AmlAddress)
+ {
+ case AML_DUAL_NAME_PREFIX:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n",
+ AmlAddress));
+
+ AmlAddress++;
+ NameString = AcpiExAllocateNameString (PrefixCount, 2);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ /* Indicate that we processed a prefix */
+
+ HasPrefix = TRUE;
+
+ Status = AcpiExNameSegment (&AmlAddress, NameString);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiExNameSegment (&AmlAddress, NameString);
+ }
+ break;
+
+
+ case AML_MULTI_NAME_PREFIX_OP:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
+ AmlAddress));
+
+ /* Fetch count of segments remaining in name path */
+
+ AmlAddress++;
+ NumSegments = *AmlAddress;
+
+ NameString = AcpiExAllocateNameString (PrefixCount, NumSegments);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ /* Indicate that we processed a prefix */
+
+ AmlAddress++;
+ HasPrefix = TRUE;
+
+ while (NumSegments &&
+ (Status = AcpiExNameSegment (&AmlAddress, NameString)) ==
+ AE_OK)
+ {
+ NumSegments--;
+ }
+
+ break;
+
+
+ case 0:
+
+ /* NullName valid as of 8-12-98 ASL/AML Grammar Update */
+
+ if (PrefixCount == ACPI_UINT32_MAX)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "NameSeg is \"\\\" followed by NULL\n"));
+ }
+
+ /* Consume the NULL byte */
+
+ AmlAddress++;
+ NameString = AcpiExAllocateNameString (PrefixCount, 0);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ break;
+
+
+ default:
+
+ /* Name segment string */
+
+ NameString = AcpiExAllocateNameString (PrefixCount, 1);
+ if (!NameString)
+ {
+ Status = AE_NO_MEMORY;
+ break;
+ }
+
+ Status = AcpiExNameSegment (&AmlAddress, NameString);
+ break;
+ }
+ }
+
+ if (AE_CTRL_PENDING == Status && HasPrefix)
+ {
+ /* Ran out of segments after processing a prefix */
+
+ ACPI_ERROR ((AE_INFO,
+ "Malformed Name at %p", NameString));
+ Status = AE_AML_BAD_NAME;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ if (NameString)
+ {
+ ACPI_FREE (NameString);
+ }
+ return_ACPI_STATUS (Status);
+ }
+
+ *OutNameString = NameString;
+ *OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exoparg1.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exoparg1.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1111 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg1 - AML execution - opcodes with 1 argument
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXOPARG1_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/acinterp.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg1")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (0 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_0A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute operator with no operands, one return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_0A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_TIMER_OP: /* Timer () */
+
+ /* Create a return object of type Integer */
+
+ ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ WalkState->ResultObj = NULL;
+ }
+ else
+ {
+ /* Save the return value */
+
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_0T_0R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
+ * object stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_0T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_RELEASE_OP: /* Release (MutexObject) */
+
+ Status = AcpiExReleaseMutex (Operand[0], WalkState);
+ break;
+
+
+ case AML_RESET_OP: /* Reset (EventObject) */
+
+ Status = AcpiExSystemResetEvent (Operand[0]);
+ break;
+
+
+ case AML_SIGNAL_OP: /* Signal (EventObject) */
+
+ Status = AcpiExSystemSignalEvent (Operand[0]);
+ break;
+
+
+ case AML_SLEEP_OP: /* Sleep (MsecTime) */
+
+ Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
+ break;
+
+
+ case AML_STALL_OP: /* Stall (UsecTime) */
+
+ Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
+ break;
+
+
+ case AML_UNLOAD_OP: /* Unload (Handle) */
+
+ Status = AcpiExUnloadTable (Operand[0]);
+ break;
+
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_1T_0R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with one argument, one target, and no
+ * return value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_1T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_LOAD_OP:
+
+ Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
+ break;
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_1T_1R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with one argument, one target, and a
+ * return value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_1T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
+ UINT32 Temp32;
+ UINT32 i;
+ UINT64 PowerOfTen;
+ UINT64 Digit;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_BIT_NOT_OP:
+ case AML_FIND_SET_LEFT_BIT_OP:
+ case AML_FIND_SET_RIGHT_BIT_OP:
+ case AML_FROM_BCD_OP:
+ case AML_TO_BCD_OP:
+ case AML_COND_REF_OF_OP:
+
+ /* Create a return object of type Integer for these opcodes */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ switch (WalkState->Opcode)
+ {
+ case AML_BIT_NOT_OP: /* Not (Operand, Result) */
+
+ ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
+ break;
+
+
+ case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
+
+ ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
+
+ /*
+ * Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundary condition is valid.
+ */
+ for (Temp32 = 0; ReturnDesc->Integer.Value &&
+ Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
+ {
+ ReturnDesc->Integer.Value >>= 1;
+ }
+
+ ReturnDesc->Integer.Value = Temp32;
+ break;
+
+
+ case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
+
+ ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
+
+ /*
+ * The Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundary condition is valid.
+ */
+ for (Temp32 = 0; ReturnDesc->Integer.Value &&
+ Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
+ {
+ ReturnDesc->Integer.Value <<= 1;
+ }
+
+ /* Since the bit position is one-based, subtract from 33 (65) */
+
+ ReturnDesc->Integer.Value =
+ Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
+ break;
+
+
+ case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
+
+ /*
+ * The 64-bit ACPI integer can hold 16 4-bit BCD characters
+ * (if table is 32-bit, integer can hold 8 BCD characters)
+ * Convert each 4-bit BCD value
+ */
+ PowerOfTen = 1;
+ ReturnDesc->Integer.Value = 0;
+ Digit = Operand[0]->Integer.Value;
+
+ /* Convert each BCD digit (each is one nybble wide) */
+
+ for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
+ {
+ /* Get the least significant 4-bit BCD digit */
+
+ Temp32 = ((UINT32) Digit) & 0xF;
+
+ /* Check the range of the digit */
+
+ if (Temp32 > 9)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "BCD digit too large (not decimal): 0x%X",
+ Temp32));
+
+ Status = AE_AML_NUMERIC_OVERFLOW;
+ goto Cleanup;
+ }
+
+ /* Sum the digit into the result with the current power of 10 */
+
+ ReturnDesc->Integer.Value +=
+ (((UINT64) Temp32) * PowerOfTen);
+
+ /* Shift to next BCD digit */
+
+ Digit >>= 4;
+
+ /* Next power of 10 */
+
+ PowerOfTen *= 10;
+ }
+ break;
+
+
+ case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
+
+ ReturnDesc->Integer.Value = 0;
+ Digit = Operand[0]->Integer.Value;
+
+ /* Each BCD digit is one nybble wide */
+
+ for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
+ {
+ (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
+
+ /*
+ * Insert the BCD digit that resides in the
+ * remainder from above
+ */
+ ReturnDesc->Integer.Value |=
+ (((UINT64) Temp32) << ACPI_MUL_4 (i));
+ }
+
+ /* Overflow if there is any data left in Digit */
+
+ if (Digit > 0)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Integer too large to convert to BCD: 0x%8.8X%8.8X",
+ ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
+ Status = AE_AML_NUMERIC_OVERFLOW;
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
+
+ /*
+ * This op is a little strange because the internal return value is
+ * different than the return value stored in the result descriptor
+ * (There are really two return values)
+ */
+ if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
+ {
+ /*
+ * This means that the object does not exist in the namespace,
+ * return FALSE
+ */
+ ReturnDesc->Integer.Value = 0;
+ goto Cleanup;
+ }
+
+ /* Get the object reference, store it, and remove our reference */
+
+ Status = AcpiExGetObjectReference (Operand[0],
+ &ReturnDesc2, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
+ AcpiUtRemoveReference (ReturnDesc2);
+
+ /* The object exists in the namespace, return TRUE */
+
+ ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
+ goto Cleanup;
+
+
+ default:
+ /* No other opcodes get here */
+ break;
+ }
+ break;
+
+
+ case AML_STORE_OP: /* Store (Source, Target) */
+
+ /*
+ * A store operand is typically a number, string, buffer or lvalue
+ * Be careful about deleting the source object,
+ * since the object itself may have been stored.
+ */
+ Status = AcpiExStore (Operand[0], Operand[1], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* It is possible that the Store already produced a return object */
+
+ if (!WalkState->ResultObj)
+ {
+ /*
+ * Normally, we would remove a reference on the Operand[0]
+ * parameter; But since it is being used as the internal return
+ * object (meaning we would normally increment it), the two
+ * cancel out, and we simply don't do anything.
+ */
+ WalkState->ResultObj = Operand[0];
+ WalkState->Operands[0] = NULL; /* Prevent deletion */
+ }
+ return_ACPI_STATUS (Status);
+
+
+ /*
+ * ACPI 2.0 Opcodes
+ */
+ case AML_COPY_OP: /* Copy (Source, Target) */
+
+ Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
+ WalkState);
+ break;
+
+
+ case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
+
+ Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
+ ACPI_EXPLICIT_CONVERT_DECIMAL);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
+
+ Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
+ ACPI_EXPLICIT_CONVERT_HEX);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
+
+ Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
+
+ Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
+ ACPI_ANY_BASE);
+ if (ReturnDesc == Operand[0])
+ {
+ /* No conversion performed, add ref to handle return value */
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
+ case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
+
+ /* These are two obsolete opcodes */
+
+ ACPI_ERROR ((AE_INFO,
+ "%s is obsolete and not implemented",
+ AcpiPsGetOpcodeName (WalkState->Opcode)));
+ Status = AE_SUPPORT;
+ goto Cleanup;
+
+
+ default: /* Unknown opcode */
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Store the return value computed above into the target object */
+
+ Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else if (!WalkState->ResultObj)
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_1A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with one argument, no target, and a return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_1A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *TempDesc;
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Type;
+ UINT64 Value;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the AML opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_LNOT_OP: /* LNot (Operand) */
+
+ ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Set result to ONES (TRUE) if Value == 0. Note:
+ * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
+ */
+ if (!Operand[0]->Integer.Value)
+ {
+ ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
+ }
+ break;
+
+
+ case AML_DECREMENT_OP: /* Decrement (Operand) */
+ case AML_INCREMENT_OP: /* Increment (Operand) */
+
+ /*
+ * Create a new integer. Can't just get the base integer and
+ * increment it because it may be an Arg or Field.
+ */
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Since we are expecting a Reference operand, it can be either a
+ * NS Node or an internal object.
+ */
+ TempDesc = Operand[0];
+ if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
+ {
+ /* Internal reference object - prevent deletion */
+
+ AcpiUtAddReference (TempDesc);
+ }
+
+ /*
+ * Convert the Reference operand to an Integer (This removes a
+ * reference on the Operand[0] object)
+ *
+ * NOTE: We use LNOT_OP here in order to force resolution of the
+ * reference operand to an actual integer.
+ */
+ Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "While resolving operands for [%s]",
+ AcpiPsGetOpcodeName (WalkState->Opcode)));
+
+ goto Cleanup;
+ }
+
+ /*
+ * TempDesc is now guaranteed to be an Integer object --
+ * Perform the actual increment or decrement
+ */
+ if (WalkState->Opcode == AML_INCREMENT_OP)
+ {
+ ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
+ }
+ else
+ {
+ ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
+ }
+
+ /* Finished with this Integer object */
+
+ AcpiUtRemoveReference (TempDesc);
+
+ /*
+ * Store the result back (indirectly) through the original
+ * Reference object
+ */
+ Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
+ break;
+
+
+ case AML_TYPE_OP: /* ObjectType (SourceObject) */
+
+ /*
+ * Note: The operand is not resolved at this point because we want to
+ * get the associated object, not its value. For example, we don't
+ * want to resolve a FieldUnit to its value, we want the actual
+ * FieldUnit object.
+ */
+
+ /* Get the type of the base object */
+
+ Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Allocate a descriptor to hold the type. */
+
+ ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
+
+ /*
+ * Note: The operand is not resolved at this point because we want to
+ * get the associated object, not its value.
+ */
+
+ /* Get the base object */
+
+ Status = AcpiExResolveMultiple (WalkState,
+ Operand[0], &Type, &TempDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * The type of the base object must be integer, buffer, string, or
+ * package. All others are not supported.
+ *
+ * NOTE: Integer is not specifically supported by the ACPI spec,
+ * but is supported implicitly via implicit operand conversion.
+ * rather than bother with conversion, we just use the byte width
+ * global (4 or 8 bytes).
+ */
+ switch (Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Value = AcpiGbl_IntegerByteWidth;
+ break;
+
+ case ACPI_TYPE_STRING:
+ Value = TempDesc->String.Length;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Buffer arguments may not be evaluated at this point */
+
+ Status = AcpiDsGetBufferArguments (TempDesc);
+ Value = TempDesc->Buffer.Length;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ /* Package arguments may not be evaluated at this point */
+
+ Status = AcpiDsGetPackageArguments (TempDesc);
+ Value = TempDesc->Package.Count;
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Operand must be Buffer/Integer/String/Package - found type %s",
+ AcpiUtGetTypeName (Type)));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Now that we have the size of the object, create a result
+ * object to hold the value
+ */
+ ReturnDesc = AcpiUtCreateIntegerObject (Value);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_REF_OF_OP: /* RefOf (SourceObject) */
+
+ Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
+
+ /* Check for a method local or argument, or standalone String */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
+ {
+ TempDesc = AcpiNsGetAttachedObject (
+ (ACPI_NAMESPACE_NODE *) Operand[0]);
+ if (TempDesc &&
+ ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
+ (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
+ {
+ Operand[0] = TempDesc;
+ AcpiUtAddReference (TempDesc);
+ }
+ else
+ {
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ }
+ else
+ {
+ switch ((Operand[0])->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ /*
+ * This is a DerefOf (LocalX | ArgX)
+ *
+ * Must resolve/dereference the local/arg reference first
+ */
+ switch (Operand[0]->Reference.Class)
+ {
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ /* Set Operand[0] to the value of the local/arg */
+
+ Status = AcpiDsMethodDataGetValue (
+ Operand[0]->Reference.Class,
+ Operand[0]->Reference.Value,
+ WalkState, &TempDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Delete our reference to the input object and
+ * point to the object just retrieved
+ */
+ AcpiUtRemoveReference (Operand[0]);
+ Operand[0] = TempDesc;
+ break;
+
+ case ACPI_REFCLASS_REFOF:
+
+ /* Get the object to which the reference refers */
+
+ TempDesc = Operand[0]->Reference.Object;
+ AcpiUtRemoveReference (Operand[0]);
+ Operand[0] = TempDesc;
+ break;
+
+ default:
+
+ /* Must be an Index op - handled below */
+ break;
+ }
+ break;
+
+ case ACPI_TYPE_STRING:
+ break;
+
+ default:
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
+ {
+ if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
+ {
+ /*
+ * This is a DerefOf (String). The string is a reference
+ * to a named ACPI object.
+ *
+ * 1) Find the owning Node
+ * 2) Dereference the node to an actual object. Could be a
+ * Field, so we need to resolve the node to a value.
+ */
+ Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
+ Operand[0]->String.Pointer,
+ ACPI_NS_SEARCH_PARENT,
+ ACPI_CAST_INDIRECT_PTR (
+ ACPI_NAMESPACE_NODE, &ReturnDesc));
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiExResolveNodeToValue (
+ ACPI_CAST_INDIRECT_PTR (
+ ACPI_NAMESPACE_NODE, &ReturnDesc),
+ WalkState);
+ goto Cleanup;
+ }
+ }
+
+ /* Operand[0] may have changed from the code above */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
+ {
+ /*
+ * This is a DerefOf (ObjectReference)
+ * Get the actual object from the Node (This is the dereference).
+ * This case may only happen when a LocalX or ArgX is
+ * dereferenced above.
+ */
+ ReturnDesc = AcpiNsGetAttachedObject (
+ (ACPI_NAMESPACE_NODE *) Operand[0]);
+ AcpiUtAddReference (ReturnDesc);
+ }
+ else
+ {
+ /*
+ * This must be a reference object produced by either the
+ * Index() or RefOf() operator
+ */
+ switch (Operand[0]->Reference.Class)
+ {
+ case ACPI_REFCLASS_INDEX:
+
+ /*
+ * The target type for the Index operator must be
+ * either a Buffer or a Package
+ */
+ switch (Operand[0]->Reference.TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ TempDesc = Operand[0]->Reference.Object;
+
+ /*
+ * Create a new object that contains one element of the
+ * buffer -- the element pointed to by the index.
+ *
+ * NOTE: index into a buffer is NOT a pointer to a
+ * sub-buffer of the main buffer, it is only a pointer to a
+ * single element (byte) of the buffer!
+ *
+ * Since we are returning the value of the buffer at the
+ * indexed location, we don't need to add an additional
+ * reference to the buffer itself.
+ */
+ ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
+ TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ /*
+ * Return the referenced element of the package. We must
+ * add another reference to the referenced object, however.
+ */
+ ReturnDesc = *(Operand[0]->Reference.Where);
+ if (ReturnDesc)
+ {
+ AcpiUtAddReference (ReturnDesc);
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Index TargetType 0x%X in reference object %p",
+ Operand[0]->Reference.TargetType, Operand[0]));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+ break;
+
+
+ case ACPI_REFCLASS_REFOF:
+
+ ReturnDesc = Operand[0]->Reference.Object;
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
+ ACPI_DESC_TYPE_NAMED)
+ {
+ ReturnDesc = AcpiNsGetAttachedObject (
+ (ACPI_NAMESPACE_NODE *) ReturnDesc);
+ }
+
+ /* Add another reference to the object! */
+
+ AcpiUtAddReference (ReturnDesc);
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Unknown class in reference(%p) - 0x%2.2X",
+ Operand[0], Operand[0]->Reference.Class));
+
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exoparg2.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exoparg2.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,642 @@
+/******************************************************************************
+ *
+ * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXOPARG2_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/acinterp.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg2")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (1 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_0T_0R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with two arguments, no target, and no return
+ * value.
+ *
+ * ALLOCATION: Deletes both operands
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_0T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_NAMESPACE_NODE *Node;
+ UINT32 Value;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Examine the opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */
+
+ /* The first operand is a namespace node */
+
+ Node = (ACPI_NAMESPACE_NODE *) Operand[0];
+
+ /* Second value is the notify value */
+
+ Value = (UINT32) Operand[1]->Integer.Value;
+
+ /* Are notifies allowed on this object? */
+
+ if (!AcpiEvIsNotifyObject (Node))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Unexpected notify object type [%s]",
+ AcpiUtGetTypeName (Node->Type)));
+
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ /*
+ * Dispatch the notify to the appropriate handler
+ * NOTE: the request is queued for execution after this method
+ * completes. The notify handlers are NOT invoked synchronously
+ * from this thread -- because handlers may in turn run other
+ * control methods.
+ */
+ Status = AcpiEvQueueNotifyRequest (Node, Value);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_2T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
+ * and one implicit return value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_2T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL;
+ ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Execute the opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_DIVIDE_OP:
+
+ /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
+
+ ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc1)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc2)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
+
+ Status = AcpiUtDivide (Operand[0]->Integer.Value,
+ Operand[1]->Integer.Value,
+ &ReturnDesc1->Integer.Value,
+ &ReturnDesc2->Integer.Value);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+ /* Store the results to the target reference operands */
+
+ Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+Cleanup:
+ /*
+ * Since the remainder is not returned indirectly, remove a reference to
+ * it. Only the quotient is returned indirectly.
+ */
+ AcpiUtRemoveReference (ReturnDesc2);
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Delete the return object */
+
+ AcpiUtRemoveReference (ReturnDesc1);
+ }
+
+ /* Save return object (the remainder) on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc1;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_1T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with two arguments, one target, and a return
+ * value.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_1T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ UINT64 Index;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_SIZE Length;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Execute the opcode */
+
+ if (WalkState->OpInfo->Flags & AML_MATH)
+ {
+ /* All simple math opcodes (add, etc.) */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode,
+ Operand[0]->Integer.Value,
+ Operand[1]->Integer.Value);
+ goto StoreResultToTarget;
+ }
+
+ switch (WalkState->Opcode)
+ {
+ case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* ReturnDesc will contain the remainder */
+
+ Status = AcpiUtDivide (Operand[0]->Integer.Value,
+ Operand[1]->Integer.Value,
+ NULL,
+ &ReturnDesc->Integer.Value);
+ break;
+
+
+ case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
+
+ Status = AcpiExDoConcatenate (Operand[0], Operand[1],
+ &ReturnDesc, WalkState);
+ break;
+
+
+ case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
+
+ /*
+ * Input object is guaranteed to be a buffer at this point (it may have
+ * been converted.) Copy the raw buffer data to a new object of
+ * type String.
+ */
+
+ /*
+ * Get the length of the new string. It is the smallest of:
+ * 1) Length of the input buffer
+ * 2) Max length as specified in the ToString operator
+ * 3) Length of input buffer up to a zero byte (null terminator)
+ *
+ * NOTE: A length of zero is ok, and will create a zero-length, null
+ * terminated string.
+ */
+ Length = 0;
+ while ((Length < Operand[0]->Buffer.Length) &&
+ (Length < Operand[1]->Integer.Value) &&
+ (Operand[0]->Buffer.Pointer[Length]))
+ {
+ Length++;
+ }
+
+ /* Allocate a new string object */
+
+ ReturnDesc = AcpiUtCreateStringObject (Length);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Copy the raw buffer data with no transform.
+ * (NULL terminated already)
+ */
+ ACPI_MEMCPY (ReturnDesc->String.Pointer,
+ Operand[0]->Buffer.Pointer, Length);
+ break;
+
+
+ case AML_CONCAT_RES_OP:
+
+ /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
+
+ Status = AcpiExConcatTemplate (Operand[0], Operand[1],
+ &ReturnDesc, WalkState);
+ break;
+
+
+ case AML_INDEX_OP: /* Index (Source Index Result) */
+
+ /* Create the internal return object */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Initialize the Index reference object */
+
+ Index = Operand[1]->Integer.Value;
+ ReturnDesc->Reference.Value = (UINT32) Index;
+ ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX;
+
+ /*
+ * At this point, the Source operand is a String, Buffer, or Package.
+ * Verify that the index is within range.
+ */
+ switch ((Operand[0])->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ if (Index >= Operand[0]->String.Length)
+ {
+ Status = AE_AML_STRING_LIMIT;
+ }
+
+ ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ if (Index >= Operand[0]->Buffer.Length)
+ {
+ Status = AE_AML_BUFFER_LIMIT;
+ }
+
+ ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ if (Index >= Operand[0]->Package.Count)
+ {
+ Status = AE_AML_PACKAGE_LIMIT;
+ }
+
+ ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
+ ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index];
+ break;
+
+ default:
+
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ /* Failure means that the Index was beyond the end of the object */
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Index (0x%8.8X%8.8X) is beyond end of object",
+ ACPI_FORMAT_UINT64 (Index)));
+ goto Cleanup;
+ }
+
+ /*
+ * Save the target object and add a reference to it for the life
+ * of the index
+ */
+ ReturnDesc->Reference.Object = Operand[0];
+ AcpiUtAddReference (Operand[0]);
+
+ /* Store the reference to the Target */
+
+ Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
+
+ /* Return the reference */
+
+ WalkState->ResultObj = ReturnDesc;
+ goto Cleanup;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+
+StoreResultToTarget:
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * Store the result of the operation (which is now in ReturnDesc) into
+ * the Target descriptor.
+ */
+ Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (!WalkState->ResultObj)
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ WalkState->ResultObj = NULL;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_2A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_2A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN LogicalResult = FALSE;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /* Create the internal return object */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Execute the Opcode */
+
+ if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)
+ {
+ /* LogicalOp (Operand0, Operand1) */
+
+ Status = AcpiExDoLogicalNumericOp (WalkState->Opcode,
+ Operand[0]->Integer.Value, Operand[1]->Integer.Value,
+ &LogicalResult);
+ goto StoreLogicalResult;
+ }
+ else if (WalkState->OpInfo->Flags & AML_LOGICAL)
+ {
+ /* LogicalOp (Operand0, Operand1) */
+
+ Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],
+ Operand[1], &LogicalResult);
+ goto StoreLogicalResult;
+ }
+
+ switch (WalkState->Opcode)
+ {
+ case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */
+
+ Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
+ if (Status == AE_TIME)
+ {
+ LogicalResult = TRUE; /* TRUE = Acquire timed out */
+ Status = AE_OK;
+ }
+ break;
+
+
+ case AML_WAIT_OP: /* Wait (EventObject, Timeout) */
+
+ Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
+ if (Status == AE_TIME)
+ {
+ LogicalResult = TRUE; /* TRUE, Wait timed out */
+ Status = AE_OK;
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+StoreLogicalResult:
+ /*
+ * Set return value to according to LogicalResult. logical TRUE (all ones)
+ * Default is FALSE (zero)
+ */
+ if (LogicalResult)
+ {
+ ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
+ }
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exoparg3.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exoparg3.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,304 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXOPARG3_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/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg3")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (1 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_3A_0T_0R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Triadic operator (3 operands)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_3A_0T_0R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_SIGNAL_FATAL_INFO *Fatal;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
+ (UINT32) Operand[0]->Integer.Value,
+ (UINT32) Operand[1]->Integer.Value,
+ (UINT32) Operand[2]->Integer.Value));
+
+ Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO));
+ if (Fatal)
+ {
+ Fatal->Type = (UINT32) Operand[0]->Integer.Value;
+ Fatal->Code = (UINT32) Operand[1]->Integer.Value;
+ Fatal->Argument = (UINT32) Operand[2]->Integer.Value;
+ }
+
+ /* Always signal the OS! */
+
+ Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal);
+
+ /* Might return while OS is shutting down, just continue */
+
+ ACPI_FREE (Fatal);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_3A_1T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Triadic operator (3 operands)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_3A_1T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ char *Buffer = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT64 Index;
+ ACPI_SIZE Length;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
+
+ /*
+ * Create the return object. The Source operand is guaranteed to be
+ * either a String or a Buffer, so just use its type.
+ */
+ ReturnDesc = AcpiUtCreateInternalObject (
+ (Operand[0])->Common.Type);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Get the Integer values from the objects */
+
+ Index = Operand[1]->Integer.Value;
+ Length = (ACPI_SIZE) Operand[2]->Integer.Value;
+
+ /*
+ * If the index is beyond the length of the String/Buffer, or if the
+ * requested length is zero, return a zero-length String/Buffer
+ */
+ if (Index >= Operand[0]->String.Length)
+ {
+ Length = 0;
+ }
+
+ /* Truncate request if larger than the actual String/Buffer */
+
+ else if ((Index + Length) > Operand[0]->String.Length)
+ {
+ Length = (ACPI_SIZE) Operand[0]->String.Length -
+ (ACPI_SIZE) Index;
+ }
+
+ /* Strings always have a sub-pointer, not so for buffers */
+
+ switch ((Operand[0])->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ /* Always allocate a new buffer for the String */
+
+ Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
+ if (!Buffer)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ /* If the requested length is zero, don't allocate a buffer */
+
+ if (Length > 0)
+ {
+ /* Allocate a new buffer for the Buffer */
+
+ Buffer = ACPI_ALLOCATE_ZEROED (Length);
+ if (!Buffer)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+ }
+ break;
+
+ default: /* Should not happen */
+
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ if (Buffer)
+ {
+ /* We have a buffer, copy the portion requested */
+
+ ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index,
+ Length);
+ }
+
+ /* Set the length of the new String/Buffer */
+
+ ReturnDesc->String.Pointer = Buffer;
+ ReturnDesc->String.Length = (UINT32) Length;
+
+ /* Mark buffer initialized */
+
+ ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+ /* Store the result in the target */
+
+ Status = AcpiExStore (ReturnDesc, Operand[3], WalkState);
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) || WalkState->ResultObj)
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ WalkState->ResultObj = NULL;
+ }
+
+ /* Set the return object and exit */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exoparg6.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exoparg6.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,365 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXOPARG6_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/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg6")
+
+
+/*!
+ * Naming convention for AML interpreter execution routines.
+ *
+ * The routines that begin execution of AML opcodes are named with a common
+ * convention based upon the number of arguments, the number of target operands,
+ * and whether or not a value is returned:
+ *
+ * AcpiExOpcode_xA_yT_zR
+ *
+ * Where:
+ *
+ * xA - ARGUMENTS: The number of arguments (input operands) that are
+ * required for this opcode type (1 through 6 args).
+ * yT - TARGETS: The number of targets (output operands) that are required
+ * for this opcode type (0, 1, or 2 targets).
+ * zR - RETURN VALUE: Indicates whether this opcode type returns a value
+ * as the function return (0 or 1).
+ *
+ * The AcpiExOpcode* functions are called via the Dispatcher component with
+ * fully resolved operands.
+!*/
+
+/* Local prototypes */
+
+static BOOLEAN
+AcpiExDoMatch (
+ UINT32 MatchOp,
+ ACPI_OPERAND_OBJECT *PackageObj,
+ ACPI_OPERAND_OBJECT *MatchObj);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoMatch
+ *
+ * PARAMETERS: MatchOp - The AML match operand
+ * PackageObj - Object from the target package
+ * MatchObj - Object to be matched
+ *
+ * RETURN: TRUE if the match is successful, FALSE otherwise
+ *
+ * DESCRIPTION: Implements the low-level match for the ASL Match operator.
+ * Package elements will be implicitly converted to the type of
+ * the match object (Integer/Buffer/String).
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiExDoMatch (
+ UINT32 MatchOp,
+ ACPI_OPERAND_OBJECT *PackageObj,
+ ACPI_OPERAND_OBJECT *MatchObj)
+{
+ BOOLEAN LogicalResult = TRUE;
+ ACPI_STATUS Status;
+
+
+ /*
+ * Note: Since the PackageObj/MatchObj ordering is opposite to that of
+ * the standard logical operators, we have to reverse them when we call
+ * DoLogicalOp in order to make the implicit conversion rules work
+ * correctly. However, this means we have to flip the entire equation
+ * also. A bit ugly perhaps, but overall, better than fussing the
+ * parameters around at runtime, over and over again.
+ *
+ * Below, P[i] refers to the package element, M refers to the Match object.
+ */
+ switch (MatchOp)
+ {
+ case MATCH_MTR:
+
+ /* Always true */
+
+ break;
+
+ case MATCH_MEQ:
+
+ /*
+ * True if equal: (P[i] == M)
+ * Change to: (M == P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ break;
+
+ case MATCH_MLE:
+
+ /*
+ * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M)
+ * Change to: (M >= P[i]) (M NotLess than P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ LogicalResult = (BOOLEAN) !LogicalResult;
+ break;
+
+ case MATCH_MLT:
+
+ /*
+ * True if less than: (P[i] < M)
+ * Change to: (M > P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ break;
+
+ case MATCH_MGE:
+
+ /*
+ * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M)
+ * Change to: (M <= P[i]) (M NotGreater than P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ LogicalResult = (BOOLEAN)!LogicalResult;
+ break;
+
+ case MATCH_MGT:
+
+ /*
+ * True if greater than: (P[i] > M)
+ * Change to: (M < P[i])
+ */
+ Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
+ &LogicalResult);
+ if (ACPI_FAILURE (Status))
+ {
+ return (FALSE);
+ }
+ break;
+
+ default:
+
+ /* Undefined */
+
+ return (FALSE);
+ }
+
+ return LogicalResult;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_6A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_6A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT64 Index;
+ ACPI_OPERAND_OBJECT *ThisElement;
+
+
+ ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R,
+ AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_MATCH_OP:
+ /*
+ * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2],
+ * MatchOp2[3], MatchObj2[4], StartIndex[5])
+ */
+
+ /* Validate both Match Term Operators (MTR, MEQ, etc.) */
+
+ if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) ||
+ (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR))
+ {
+ ACPI_ERROR ((AE_INFO, "Match operator out of range"));
+ Status = AE_AML_OPERAND_VALUE;
+ goto Cleanup;
+ }
+
+ /* Get the package StartIndex, validate against the package length */
+
+ Index = Operand[5]->Integer.Value;
+ if (Index >= Operand[0]->Package.Count)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Index (0x%8.8X%8.8X) beyond package end (0x%X)",
+ ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count));
+ Status = AE_AML_PACKAGE_LIMIT;
+ goto Cleanup;
+ }
+
+ /* Create an integer for the return value */
+ /* Default return value is ACPI_UINT64_MAX if no match found */
+
+ ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+
+ }
+
+ /*
+ * Examine each element until a match is found. Both match conditions
+ * must be satisfied for a match to occur. Within the loop,
+ * "continue" signifies that the current element does not match
+ * and the next should be examined.
+ *
+ * Upon finding a match, the loop will terminate via "break" at
+ * the bottom. If it terminates "normally", MatchValue will be
+ * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
+ * match was found.
+ */
+ for ( ; Index < Operand[0]->Package.Count; Index++)
+ {
+ /* Get the current package element */
+
+ ThisElement = Operand[0]->Package.Elements[Index];
+
+ /* Treat any uninitialized (NULL) elements as non-matching */
+
+ if (!ThisElement)
+ {
+ continue;
+ }
+
+ /*
+ * Both match conditions must be satisfied. Execution of a continue
+ * (proceed to next iteration of enclosing for loop) signifies a
+ * non-match.
+ */
+ if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value,
+ ThisElement, Operand[2]))
+ {
+ continue;
+ }
+
+ if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value,
+ ThisElement, Operand[4]))
+ {
+ continue;
+ }
+
+ /* Match found: Index is the return value */
+
+ ReturnDesc->Integer.Value = Index;
+ break;
+ }
+ break;
+
+
+ case AML_LOAD_TABLE_OP:
+
+ Status = AcpiExLoadTableOp (WalkState, &ReturnDesc);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ReturnDesc);
+ }
+
+ /* Save return object on success */
+
+ else
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+
+ return_ACPI_STATUS (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exprep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exprep.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,648 @@
+
+/******************************************************************************
+ *
+ * Module Name: exprep - ACPI AML (p-code) execution - field prep 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 __EXPREP_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>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exprep")
+
+/* Local prototypes */
+
+static UINT32
+AcpiExDecodeFieldAccess (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 FieldFlags,
+ UINT32 *ReturnByteAlignment);
+
+
+#ifdef ACPI_UNDER_DEVELOPMENT
+
+static UINT32
+AcpiExGenerateAccess (
+ UINT32 FieldBitOffset,
+ UINT32 FieldBitLength,
+ UINT32 RegionLength);
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGenerateAccess
+ *
+ * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer
+ * FieldBitLength - Length of field in bits
+ * RegionLength - Length of parent in bytes
+ *
+ * RETURN: Field granularity (8, 16, 32 or 64) and
+ * ByteAlignment (1, 2, 3, or 4)
+ *
+ * DESCRIPTION: Generate an optimal access width for fields defined with the
+ * AnyAcc keyword.
+ *
+ * NOTE: Need to have the RegionLength in order to check for boundary
+ * conditions (end-of-region). However, the RegionLength is a deferred
+ * operation. Therefore, to complete this implementation, the generation
+ * of this access width must be deferred until the region length has
+ * been evaluated.
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExGenerateAccess (
+ UINT32 FieldBitOffset,
+ UINT32 FieldBitLength,
+ UINT32 RegionLength)
+{
+ UINT32 FieldByteLength;
+ UINT32 FieldByteOffset;
+ UINT32 FieldByteEndOffset;
+ UINT32 AccessByteWidth;
+ UINT32 FieldStartOffset;
+ UINT32 FieldEndOffset;
+ UINT32 MinimumAccessWidth = 0xFFFFFFFF;
+ UINT32 MinimumAccesses = 0xFFFFFFFF;
+ UINT32 Accesses;
+
+
+ ACPI_FUNCTION_TRACE (ExGenerateAccess);
+
+
+ /* Round Field start offset and length to "minimal" byte boundaries */
+
+ FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8));
+ FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength +
+ FieldBitOffset, 8));
+ FieldByteLength = FieldByteEndOffset - FieldByteOffset;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Bit length %u, Bit offset %u\n",
+ FieldBitLength, FieldBitOffset));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Byte Length %u, Byte Offset %u, End Offset %u\n",
+ FieldByteLength, FieldByteOffset, FieldByteEndOffset));
+
+ /*
+ * Iterative search for the maximum access width that is both aligned
+ * and does not go beyond the end of the region
+ *
+ * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes)
+ */
+ for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1)
+ {
+ /*
+ * 1) Round end offset up to next access boundary and make sure that
+ * this does not go beyond the end of the parent region.
+ * 2) When the Access width is greater than the FieldByteLength, we
+ * are done. (This does not optimize for the perfectly aligned
+ * case yet).
+ */
+ if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength)
+ {
+ FieldStartOffset =
+ ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) /
+ AccessByteWidth;
+
+ FieldEndOffset =
+ ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset),
+ AccessByteWidth) / AccessByteWidth;
+
+ Accesses = FieldEndOffset - FieldStartOffset;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "AccessWidth %u end is within region\n", AccessByteWidth));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Field Start %u, Field End %u -- requires %u accesses\n",
+ FieldStartOffset, FieldEndOffset, Accesses));
+
+ /* Single access is optimal */
+
+ if (Accesses <= 1)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Entire field can be accessed with one operation of size %u\n",
+ AccessByteWidth));
+ return_VALUE (AccessByteWidth);
+ }
+
+ /*
+ * Fits in the region, but requires more than one read/write.
+ * try the next wider access on next iteration
+ */
+ if (Accesses < MinimumAccesses)
+ {
+ MinimumAccesses = Accesses;
+ MinimumAccessWidth = AccessByteWidth;
+ }
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "AccessWidth %u end is NOT within region\n", AccessByteWidth));
+ if (AccessByteWidth == 1)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Field goes beyond end-of-region!\n"));
+
+ /* Field does not fit in the region at all */
+
+ return_VALUE (0);
+ }
+
+ /*
+ * This width goes beyond the end-of-region, back off to
+ * previous access
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Backing off to previous optimal access width of %u\n",
+ MinimumAccessWidth));
+ return_VALUE (MinimumAccessWidth);
+ }
+ }
+
+ /*
+ * Could not read/write field with one operation,
+ * just use max access width
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Cannot access field in one operation, using width 8\n"));
+ return_VALUE (8);
+}
+#endif /* ACPI_UNDER_DEVELOPMENT */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDecodeFieldAccess
+ *
+ * PARAMETERS: ObjDesc - Field object
+ * FieldFlags - Encoded fieldflags (contains access bits)
+ * ReturnByteAlignment - Where the byte alignment is returned
+ *
+ * RETURN: Field granularity (8, 16, 32 or 64) and
+ * ByteAlignment (1, 2, 3, or 4)
+ *
+ * DESCRIPTION: Decode the AccessType bits of a field definition.
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExDecodeFieldAccess (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 FieldFlags,
+ UINT32 *ReturnByteAlignment)
+{
+ UINT32 Access;
+ UINT32 ByteAlignment;
+ UINT32 BitLength;
+
+
+ ACPI_FUNCTION_TRACE (ExDecodeFieldAccess);
+
+
+ Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK);
+
+ switch (Access)
+ {
+ case AML_FIELD_ACCESS_ANY:
+
+#ifdef ACPI_UNDER_DEVELOPMENT
+ ByteAlignment =
+ AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset,
+ ObjDesc->CommonField.BitLength,
+ 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */);
+ BitLength = ByteAlignment * 8;
+#endif
+
+ ByteAlignment = 1;
+ BitLength = 8;
+ break;
+
+ case AML_FIELD_ACCESS_BYTE:
+ case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
+ ByteAlignment = 1;
+ BitLength = 8;
+ break;
+
+ case AML_FIELD_ACCESS_WORD:
+ ByteAlignment = 2;
+ BitLength = 16;
+ break;
+
+ case AML_FIELD_ACCESS_DWORD:
+ ByteAlignment = 4;
+ BitLength = 32;
+ break;
+
+ case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
+ ByteAlignment = 8;
+ BitLength = 64;
+ break;
+
+ default:
+ /* Invalid field access type */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown field access type 0x%X",
+ Access));
+ return_UINT32 (0);
+ }
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * BufferField access can be on any byte boundary, so the
+ * ByteAlignment is always 1 byte -- regardless of any ByteAlignment
+ * implied by the field access type.
+ */
+ ByteAlignment = 1;
+ }
+
+ *ReturnByteAlignment = ByteAlignment;
+ return_UINT32 (BitLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPrepCommonFieldObject
+ *
+ * PARAMETERS: ObjDesc - The field object
+ * FieldFlags - Access, LockRule, and UpdateRule.
+ * The format of a FieldFlag is described
+ * in the ACPI specification
+ * FieldAttribute - Special attributes (not used)
+ * FieldBitPosition - Field start position
+ * FieldBitLength - Field length in number of bits
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize the areas of the field object that are common
+ * to the various types of fields. Note: This is very "sensitive"
+ * code because we are solving the general case for field
+ * alignment.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPrepCommonFieldObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 FieldFlags,
+ UINT8 FieldAttribute,
+ UINT32 FieldBitPosition,
+ UINT32 FieldBitLength)
+{
+ UINT32 AccessBitWidth;
+ UINT32 ByteAlignment;
+ UINT32 NearestByteAddress;
+
+
+ ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject);
+
+
+ /*
+ * Note: the structure being initialized is the
+ * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common
+ * area are initialized by this procedure.
+ */
+ ObjDesc->CommonField.FieldFlags = FieldFlags;
+ ObjDesc->CommonField.Attribute = FieldAttribute;
+ ObjDesc->CommonField.BitLength = FieldBitLength;
+
+ /*
+ * Decode the access type so we can compute offsets. The access type gives
+ * two pieces of information - the width of each field access and the
+ * necessary ByteAlignment (address granularity) of the access.
+ *
+ * For AnyAcc, the AccessBitWidth is the largest width that is both
+ * necessary and possible in an attempt to access the whole field in one
+ * I/O operation. However, for AnyAcc, the ByteAlignment is always one
+ * byte.
+ *
+ * For all Buffer Fields, the ByteAlignment is always one byte.
+ *
+ * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
+ * the same (equivalent) as the ByteAlignment.
+ */
+ AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
+ &ByteAlignment);
+ if (!AccessBitWidth)
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+ /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */
+
+ ObjDesc->CommonField.AccessByteWidth = (UINT8)
+ ACPI_DIV_8 (AccessBitWidth);
+
+ /*
+ * BaseByteOffset is the address of the start of the field within the
+ * region. It is the byte address of the first *datum* (field-width data
+ * unit) of the field. (i.e., the first datum that contains at least the
+ * first *bit* of the field.)
+ *
+ * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
+ * (Byte access), and it defines the addressing granularity of the parent
+ * region or buffer.
+ */
+ NearestByteAddress =
+ ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
+ ObjDesc->CommonField.BaseByteOffset = (UINT32)
+ ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
+
+ /*
+ * StartFieldBitOffset is the offset of the first bit of the field within
+ * a field datum.
+ */
+ ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
+ (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPrepFieldValue
+ *
+ * PARAMETERS: Info - Contains all field creation info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
+ * connect it to the parent Node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPrepFieldValue (
+ ACPI_CREATE_FIELD_INFO *Info)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *SecondDesc = NULL;
+ ACPI_STATUS Status;
+ UINT32 AccessByteWidth;
+ UINT32 Type;
+
+
+ ACPI_FUNCTION_TRACE (ExPrepFieldValue);
+
+
+ /* Parameter validation */
+
+ if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
+ {
+ if (!Info->RegionNode)
+ {
+ ACPI_ERROR ((AE_INFO, "Null RegionNode"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ Type = AcpiNsGetType (Info->RegionNode);
+ if (Type != ACPI_TYPE_REGION)
+ {
+ ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
+ Type, AcpiUtGetTypeName (Type)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ }
+
+ /* Allocate a new field object */
+
+ ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize areas of the object that are common to all fields */
+
+ ObjDesc->CommonField.Node = Info->FieldNode;
+ Status = AcpiExPrepCommonFieldObject (ObjDesc,
+ Info->FieldFlags, Info->Attribute,
+ Info->FieldBitPosition, Info->FieldBitLength);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtDeleteObjectDesc (ObjDesc);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Initialize areas of the object that are specific to the field type */
+
+ switch (Info->FieldType)
+ {
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
+
+ /* Fields specific to GenericSerialBus fields */
+
+ ObjDesc->Field.AccessLength = Info->AccessLength;
+
+ if (Info->ConnectionNode)
+ {
+ SecondDesc = Info->ConnectionNode->Object;
+ if (!(SecondDesc->Common.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetBufferArguments (SecondDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtDeleteObjectDesc (ObjDesc);
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ ObjDesc->Field.ResourceBuffer = SecondDesc->Buffer.Pointer;
+ ObjDesc->Field.ResourceLength = (UINT16) SecondDesc->Buffer.Length;
+ }
+ else if (Info->ResourceBuffer)
+ {
+ ObjDesc->Field.ResourceBuffer = Info->ResourceBuffer;
+ ObjDesc->Field.ResourceLength = Info->ResourceLength;
+ }
+
+ /* Allow full data read from EC address space */
+
+ if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) &&
+ (ObjDesc->CommonField.BitLength > 8))
+ {
+ AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES (
+ ObjDesc->CommonField.BitLength);
+
+ /* Maximum byte width supported is 255 */
+
+ if (AccessByteWidth < 256)
+ {
+ ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth;
+ }
+ }
+
+ /* An additional reference for the container */
+
+ AcpiUtAddReference (ObjDesc->Field.RegionObj);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
+ ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
+ ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ ObjDesc->BankField.Value = Info->BankValue;
+ ObjDesc->BankField.RegionObj =
+ AcpiNsGetAttachedObject (Info->RegionNode);
+ ObjDesc->BankField.BankObj =
+ AcpiNsGetAttachedObject (Info->RegisterNode);
+
+ /* An additional reference for the attached objects */
+
+ AcpiUtAddReference (ObjDesc->BankField.RegionObj);
+ AcpiUtAddReference (ObjDesc->BankField.BankObj);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
+ ObjDesc->BankField.StartFieldBitOffset,
+ ObjDesc->BankField.BaseByteOffset,
+ ObjDesc->Field.AccessByteWidth,
+ ObjDesc->BankField.RegionObj,
+ ObjDesc->BankField.BankObj));
+
+ /*
+ * Remember location in AML stream of the field unit
+ * opcode and operands -- since the BankValue
+ * operands must be evaluated.
+ */
+ SecondDesc = ObjDesc->Common.NextObject;
+ SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
+ Info->DataRegisterNode)->Named.Data;
+ SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
+ Info->DataRegisterNode)->Named.Length;
+
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ /* Get the Index and Data registers */
+
+ ObjDesc->IndexField.IndexObj =
+ AcpiNsGetAttachedObject (Info->RegisterNode);
+ ObjDesc->IndexField.DataObj =
+ AcpiNsGetAttachedObject (Info->DataRegisterNode);
+
+ if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
+ {
+ ACPI_ERROR ((AE_INFO, "Null Index Object during field prep"));
+ AcpiUtDeleteObjectDesc (ObjDesc);
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* An additional reference for the attached objects */
+
+ AcpiUtAddReference (ObjDesc->IndexField.DataObj);
+ AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
+
+ /*
+ * April 2006: Changed to match MS behavior
+ *
+ * The value written to the Index register is the byte offset of the
+ * target field in units of the granularity of the IndexField
+ *
+ * Previously, the value was calculated as an index in terms of the
+ * width of the Data register, as below:
+ *
+ * ObjDesc->IndexField.Value = (UINT32)
+ * (Info->FieldBitPosition / ACPI_MUL_8 (
+ * ObjDesc->Field.AccessByteWidth));
+ *
+ * February 2006: Tried value as a byte offset:
+ * ObjDesc->IndexField.Value = (UINT32)
+ * ACPI_DIV_8 (Info->FieldBitPosition);
+ */
+ ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN (
+ ACPI_DIV_8 (Info->FieldBitPosition),
+ ObjDesc->IndexField.AccessByteWidth);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
+ ObjDesc->IndexField.StartFieldBitOffset,
+ ObjDesc->IndexField.BaseByteOffset,
+ ObjDesc->IndexField.Value,
+ ObjDesc->Field.AccessByteWidth,
+ ObjDesc->IndexField.IndexObj,
+ ObjDesc->IndexField.DataObj));
+ break;
+
+ default:
+ /* No other types should get here */
+ break;
+ }
+
+ /*
+ * Store the constructed descriptor (ObjDesc) into the parent Node,
+ * preserving the current type of that NamedObj.
+ */
+ Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
+ AcpiNsGetType (Info->FieldNode));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
+ Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exregion.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exregion.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,565 @@
+
+/******************************************************************************
+ *
+ * Module Name: exregion - ACPI default OpRegion (address space) handlers
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXREGION_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exregion")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemMemorySpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the System Memory address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemMemorySpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ void *LogicalAddrPtr = NULL;
+ ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
+ UINT32 Length;
+ ACPI_SIZE MapLength;
+ ACPI_SIZE PageBoundaryMapLength;
+#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
+ UINT32 Remainder;
+#endif
+
+
+ ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
+
+
+ /* Validate and translate the bit width */
+
+ switch (BitWidth)
+ {
+ case 8:
+ Length = 1;
+ break;
+
+ case 16:
+ Length = 2;
+ break;
+
+ case 32:
+ Length = 4;
+ break;
+
+ case 64:
+ Length = 8;
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
+ BitWidth));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
+ /*
+ * Hardware does not support non-aligned data transfers, we must verify
+ * the request.
+ */
+ (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder);
+ if (Remainder != 0)
+ {
+ return_ACPI_STATUS (AE_AML_ALIGNMENT);
+ }
+#endif
+
+ /*
+ * Does the request fit into the cached memory mapping?
+ * Is 1) Address below the current mapping? OR
+ * 2) Address beyond the current mapping?
+ */
+ if ((Address < MemInfo->MappedPhysicalAddress) ||
+ (((UINT64) Address + Length) >
+ ((UINT64)
+ MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
+ {
+ /*
+ * The request cannot be resolved by the current memory mapping;
+ * Delete the existing mapping and create a new one.
+ */
+ if (MemInfo->MappedLength)
+ {
+ /* Valid mapping, delete it */
+
+ AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress,
+ MemInfo->MappedLength);
+ }
+
+ /*
+ * October 2009: Attempt to map from the requested address to the
+ * end of the region. However, we will never map more than one
+ * page, nor will we cross a page boundary.
+ */
+ MapLength = (ACPI_SIZE)
+ ((MemInfo->Address + MemInfo->Length) - Address);
+
+ /*
+ * If mapping the entire remaining portion of the region will cross
+ * a page boundary, just map up to the page boundary, do not cross.
+ * On some systems, crossing a page boundary while mapping regions
+ * can cause warnings if the pages have different attributes
+ * due to resource management.
+ *
+ * This has the added benefit of constraining a single mapping to
+ * one page, which is similar to the original code that used a 4k
+ * maximum window.
+ */
+ PageBoundaryMapLength =
+ ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address;
+ if (PageBoundaryMapLength == 0)
+ {
+ PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE;
+ }
+
+ if (MapLength > PageBoundaryMapLength)
+ {
+ MapLength = PageBoundaryMapLength;
+ }
+
+ /* Create a new mapping starting at the address given */
+
+ MemInfo->MappedLogicalAddress = AcpiOsMapMemory (
+ (ACPI_PHYSICAL_ADDRESS) Address, MapLength);
+ if (!MemInfo->MappedLogicalAddress)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not map memory at 0x%8.8X%8.8X, size %u",
+ ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength));
+ MemInfo->MappedLength = 0;
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Save the physical address and mapping size */
+
+ MemInfo->MappedPhysicalAddress = Address;
+ MemInfo->MappedLength = MapLength;
+ }
+
+ /*
+ * Generate a logical pointer corresponding to the address we want to
+ * access
+ */
+ LogicalAddrPtr = MemInfo->MappedLogicalAddress +
+ ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
+ BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
+
+ /*
+ * Perform the memory read or write
+ *
+ * Note: For machines that do not support non-aligned transfers, the target
+ * address was checked for alignment above. We do not attempt to break the
+ * transfer up into smaller (byte-size) chunks because the AML specifically
+ * asked for a transfer width that the hardware may require.
+ */
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ switch (BitWidth)
+ {
+ case 8:
+ *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
+ break;
+
+ case 16:
+ *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
+ break;
+
+ case 32:
+ *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
+ break;
+
+ case 64:
+ *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
+ break;
+
+ default:
+ /* BitWidth was already validated */
+ break;
+ }
+ break;
+
+ case ACPI_WRITE:
+
+ switch (BitWidth)
+ {
+ case 8:
+ ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value;
+ break;
+
+ case 16:
+ ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value;
+ break;
+
+ case 32:
+ ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value;
+ break;
+
+ case 64:
+ ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value;
+ break;
+
+ default:
+ /* BitWidth was already validated */
+ break;
+ }
+ break;
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemIoSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the System IO address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemIoSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Value32;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
+ BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
+
+ /* Decode the function parameter */
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
+ &Value32, BitWidth);
+ *Value = Value32;
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
+ (UINT32) *Value, BitWidth);
+ break;
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPciConfigSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the PCI Config address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPciConfigSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PCI_ID *PciId;
+ UINT16 PciRegister;
+
+
+ ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler);
+
+
+ /*
+ * The arguments to AcpiOs(Read|Write)PciConfiguration are:
+ *
+ * PciSegment is the PCI bus segment range 0-31
+ * PciBus is the PCI bus number range 0-255
+ * PciDevice is the PCI device number range 0-31
+ * PciFunction is the PCI device function number
+ * PciRegister is the Config space register range 0-255 bytes
+ *
+ * Value - input value for write, output address for read
+ *
+ */
+ PciId = (ACPI_PCI_ID *) RegionContext;
+ PciRegister = (UINT16) (UINT32) Address;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
+ Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
+ PciId->Function, PciRegister));
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ Status = AcpiOsReadPciConfiguration (PciId, PciRegister,
+ Value, BitWidth);
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiOsWritePciConfiguration (PciId, PciRegister,
+ *Value, BitWidth);
+ break;
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCmosSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the CMOS address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCmosSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPciBarSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPciBarSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler);
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDataTableSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the Data Table address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDataTableSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ UINT64 *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler);
+
+
+ /*
+ * Perform the memory read or write. The BitWidth was already
+ * validated.
+ */
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
+ ACPI_DIV_8 (BitWidth));
+ break;
+
+ case ACPI_WRITE:
+
+ ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
+ ACPI_DIV_8 (BitWidth));
+ break;
+
+ default:
+
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exresnte.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exresnte.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,302 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresnte - AML Interpreter object resolution
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXRESNTE_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>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exresnte")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveNodeToValue
+ *
+ * PARAMETERS: ObjectPtr - Pointer to a location that contains
+ * a pointer to a NS node, and will receive a
+ * pointer to the resolved object.
+ * WalkState - Current state. Valid only if executing AML
+ * code. NULL if simply resolving an object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Resolve a Namespace node to a valued object
+ *
+ * Note: for some of the data types, the pointer attached to the Node
+ * can be either a pointer to an actual internal object or a pointer into the
+ * AML stream itself. These types are currently:
+ *
+ * ACPI_TYPE_INTEGER
+ * ACPI_TYPE_STRING
+ * ACPI_TYPE_BUFFER
+ * ACPI_TYPE_MUTEX
+ * ACPI_TYPE_PACKAGE
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveNodeToValue (
+ ACPI_NAMESPACE_NODE **ObjectPtr,
+ ACPI_WALK_STATE *WalkState)
+
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *SourceDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OBJECT_TYPE EntryType;
+
+
+ ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
+
+
+ /*
+ * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
+ * object that is attached to the Node.
+ */
+ Node = *ObjectPtr;
+ SourceDesc = AcpiNsGetAttachedObject (Node);
+ EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
+ Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
+
+ if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
+ (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
+ {
+ /* There is always exactly one level of indirection */
+
+ Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
+ SourceDesc = AcpiNsGetAttachedObject (Node);
+ EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
+ *ObjectPtr = Node;
+ }
+
+ /*
+ * Several object types require no further processing:
+ * 1) Device/Thermal objects don't have a "real" subobject, return the Node
+ * 2) Method locals and arguments have a pseudo-Node
+ * 3) 10/2007: Added method type to assist with Package construction.
+ */
+ if ((EntryType == ACPI_TYPE_DEVICE) ||
+ (EntryType == ACPI_TYPE_THERMAL) ||
+ (EntryType == ACPI_TYPE_METHOD) ||
+ (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ if (!SourceDesc)
+ {
+ ACPI_ERROR ((AE_INFO, "No object attached to node %p",
+ Node));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /*
+ * Action is based on the type of the Node, which indicates the type
+ * of the attached object or pointer
+ */
+ switch (EntryType)
+ {
+ case ACPI_TYPE_PACKAGE:
+
+ if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ Status = AcpiDsGetPackageArguments (SourceDesc);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ Status = AcpiDsGetBufferArguments (SourceDesc);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+
+ if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
+ {
+ ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "FieldRead Node=%p SourceDesc=%p Type=%X\n",
+ Node, SourceDesc, EntryType));
+
+ Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
+ break;
+
+ /* For these objects, just return the object attached to the Node */
+
+ case ACPI_TYPE_MUTEX:
+ case ACPI_TYPE_POWER:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_EVENT:
+ case ACPI_TYPE_REGION:
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+ /* TYPE_ANY is untyped, and thus there is no object associated with it */
+
+ case ACPI_TYPE_ANY:
+
+ ACPI_ERROR ((AE_INFO,
+ "Untyped entry %p, no attached object!", Node));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
+
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ switch (SourceDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_INDEX:
+
+ /* Return an additional reference to the object */
+
+ ObjDesc = SourceDesc;
+ AcpiUtAddReference (ObjDesc);
+ break;
+
+ default:
+ /* No named references are allowed here */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unsupported Reference type 0x%X",
+ SourceDesc->Reference.Class));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ break;
+
+
+ default:
+
+ /* Default case is for unknown types */
+
+ ACPI_ERROR ((AE_INFO,
+ "Node %p - Unknown object type 0x%X",
+ Node, EntryType));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+
+ } /* switch (EntryType) */
+
+
+ /* Return the object descriptor */
+
+ *ObjectPtr = (void *) ObjDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exresolv.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exresolv.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,580 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresolv - AML Interpreter object resolution
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXRESOLV_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>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exresolv")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExResolveObjectToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveToValue
+ *
+ * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can
+ * be either an (ACPI_OPERAND_OBJECT *)
+ * or an ACPI_HANDLE.
+ * WalkState - Current method state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert Reference objects to values
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr);
+
+
+ if (!StackPtr || !*StackPtr)
+ {
+ ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /*
+ * The entity pointed to by the StackPtr can be either
+ * 1) A valid ACPI_OPERAND_OBJECT, or
+ * 2) A ACPI_NAMESPACE_NODE (NamedObj)
+ */
+ if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND)
+ {
+ Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!*StackPtr)
+ {
+ ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+ }
+
+ /*
+ * Object on the stack may have changed if AcpiExResolveObjectToValue()
+ * was called (i.e., we can't use an _else_ here.)
+ */
+ if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED)
+ {
+ Status = AcpiExResolveNodeToValue (
+ ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr),
+ WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveObjectToValue
+ *
+ * PARAMETERS: StackPtr - Pointer to an internal object
+ * WalkState - Current method state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the value from an internal object. The Reference type
+ * uses the associated AML opcode to determine the value.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExResolveObjectToValue (
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *StackDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ UINT8 RefType;
+
+
+ ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
+
+
+ StackDesc = *StackPtr;
+
+ /* This is an ACPI_OPERAND_OBJECT */
+
+ switch (StackDesc->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ RefType = StackDesc->Reference.Class;
+
+ switch (RefType)
+ {
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ /*
+ * Get the local from the method's state info
+ * Note: this increments the local's object reference count
+ */
+ Status = AcpiDsMethodDataGetValue (RefType,
+ StackDesc->Reference.Value, WalkState, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
+ StackDesc->Reference.Value, ObjDesc));
+
+ /*
+ * Now we can delete the original Reference Object and
+ * replace it with the resolved value
+ */
+ AcpiUtRemoveReference (StackDesc);
+ *StackPtr = ObjDesc;
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ switch (StackDesc->Reference.TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ /* Just return - do not dereference */
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ /* If method call or CopyObject - do not dereference */
+
+ if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
+ (WalkState->Opcode == AML_COPY_OP))
+ {
+ break;
+ }
+
+ /* Otherwise, dereference the PackageIndex to a package element */
+
+ ObjDesc = *StackDesc->Reference.Where;
+ if (ObjDesc)
+ {
+ /*
+ * Valid object descriptor, copy pointer to return value
+ * (i.e., dereference the package index)
+ * Delete the ref object, increment the returned object
+ */
+ AcpiUtRemoveReference (StackDesc);
+ AcpiUtAddReference (ObjDesc);
+ *StackPtr = ObjDesc;
+ }
+ else
+ {
+ /*
+ * A NULL object descriptor means an uninitialized element of
+ * the package, can't dereference it
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Attempt to dereference an Index to NULL package element Idx=%p",
+ StackDesc));
+ Status = AE_AML_UNINITIALIZED_ELEMENT;
+ }
+ break;
+
+
+ default:
+
+ /* Invalid reference object */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown TargetType 0x%X in Index/Reference object %p",
+ StackDesc->Reference.TargetType, StackDesc));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ break;
+
+
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_DEBUG:
+ case ACPI_REFCLASS_TABLE:
+
+ /* Just leave the object as-is, do not dereference */
+
+ break;
+
+ case ACPI_REFCLASS_NAME: /* Reference to a named object */
+
+ /* Dereference the name */
+
+ if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
+ (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
+ {
+ /* These node types do not have 'real' subobjects */
+
+ *StackPtr = (void *) StackDesc->Reference.Node;
+ }
+ else
+ {
+ /* Get the object pointed to by the namespace node */
+
+ *StackPtr = (StackDesc->Reference.Node)->Object;
+ AcpiUtAddReference (*StackPtr);
+ }
+
+ AcpiUtRemoveReference (StackDesc);
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Reference type 0x%X in %p", RefType, StackDesc));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ Status = AcpiDsGetBufferArguments (StackDesc);
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ Status = AcpiDsGetPackageArguments (StackDesc);
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n",
+ StackDesc, StackDesc->Common.Type));
+
+ Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
+
+ /* Remove a reference to the original operand, then override */
+
+ AcpiUtRemoveReference (*StackPtr);
+ *StackPtr = (void *) ObjDesc;
+ break;
+
+ default:
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveMultiple
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ * Operand - Starting point for resolution
+ * ReturnType - Where the object type is returned
+ * ReturnDesc - Where the resolved object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Return the base object and type. Traverse a reference list if
+ * necessary to get to the base object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveMultiple (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_OPERAND_OBJECT *Operand,
+ ACPI_OBJECT_TYPE *ReturnType,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OBJECT_TYPE Type;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
+
+
+ /* Operand can be either a namespace node or an operand descriptor */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+ Type = ObjDesc->Common.Type;
+ break;
+
+ case ACPI_DESC_TYPE_NAMED:
+ Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
+
+ /* If we had an Alias node, use the attached object for type info */
+
+ if (Type == ACPI_TYPE_LOCAL_ALIAS)
+ {
+ Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
+ }
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* If type is anything other than a reference, we are done */
+
+ if (Type != ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ goto Exit;
+ }
+
+ /*
+ * For reference objects created via the RefOf, Index, or Load/LoadTable
+ * operators, we need to get to the base object (as per the ACPI
+ * specification of the ObjectType and SizeOf operators). This means
+ * traversing the list of possibly many nested references.
+ */
+ while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_NAME:
+
+ /* Dereference the reference pointer */
+
+ if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)
+ {
+ Node = ObjDesc->Reference.Object;
+ }
+ else /* AML_INT_NAMEPATH_OP */
+ {
+ Node = ObjDesc->Reference.Node;
+ }
+
+ /* All "References" point to a NS node */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Not a namespace node %p [%s]",
+ Node, AcpiUtGetDescriptorName (Node)));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* Get the attached object */
+
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (!ObjDesc)
+ {
+ /* No object, use the NS node type */
+
+ Type = AcpiNsGetType (Node);
+ goto Exit;
+ }
+
+ /* Check for circular references */
+
+ if (ObjDesc == Operand)
+ {
+ return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
+ }
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ /* Get the type of this reference (index into another object) */
+
+ Type = ObjDesc->Reference.TargetType;
+ if (Type != ACPI_TYPE_PACKAGE)
+ {
+ goto Exit;
+ }
+
+ /*
+ * The main object is a package, we want to get the type
+ * of the individual package element that is referenced by
+ * the index.
+ *
+ * This could of course in turn be another reference object.
+ */
+ ObjDesc = *(ObjDesc->Reference.Where);
+ if (!ObjDesc)
+ {
+ /* NULL package elements are allowed */
+
+ Type = 0; /* Uninitialized */
+ goto Exit;
+ }
+ break;
+
+
+ case ACPI_REFCLASS_TABLE:
+
+ Type = ACPI_TYPE_DDB_HANDLE;
+ goto Exit;
+
+
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ if (ReturnDesc)
+ {
+ Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
+ ObjDesc->Reference.Value, WalkState, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ else
+ {
+ Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
+ ObjDesc->Reference.Value, WalkState, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (!ObjDesc)
+ {
+ Type = ACPI_TYPE_ANY;
+ goto Exit;
+ }
+ }
+ break;
+
+
+ case ACPI_REFCLASS_DEBUG:
+
+ /* The Debug Object is of type "DebugObject" */
+
+ Type = ACPI_TYPE_DEBUG_OBJECT;
+ goto Exit;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+ }
+
+ /*
+ * Now we are guaranteed to have an object that has not been created
+ * via the RefOf or Index operators.
+ */
+ Type = ObjDesc->Common.Type;
+
+
+Exit:
+ /* Convert internal types to external types */
+
+ switch (Type)
+ {
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ Type = ACPI_TYPE_FIELD_UNIT;
+ break;
+
+ case ACPI_TYPE_LOCAL_SCOPE:
+
+ /* Per ACPI Specification, Scope is untyped */
+
+ Type = ACPI_TYPE_ANY;
+ break;
+
+ default:
+ /* No change to Type required */
+ break;
+ }
+
+ *ReturnType = Type;
+ if (ReturnDesc)
+ {
+ *ReturnDesc = ObjDesc;
+ }
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exresop.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exresop.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,738 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresop - AML Interpreter operand/object resolution
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXRESOP_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/acparser.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exresop")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExCheckObjectType (
+ ACPI_OBJECT_TYPE TypeNeeded,
+ ACPI_OBJECT_TYPE ThisType,
+ void *Object);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCheckObjectType
+ *
+ * PARAMETERS: TypeNeeded Object type needed
+ * ThisType Actual object type
+ * Object Object pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check required type against actual type
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExCheckObjectType (
+ ACPI_OBJECT_TYPE TypeNeeded,
+ ACPI_OBJECT_TYPE ThisType,
+ void *Object)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (TypeNeeded == ACPI_TYPE_ANY)
+ {
+ /* All types OK, so we don't perform any typechecks */
+
+ return (AE_OK);
+ }
+
+ if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ /*
+ * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
+ * objects and thus allow them to be targets. (As per the ACPI
+ * specification, a store to a constant is a noop.)
+ */
+ if ((ThisType == ACPI_TYPE_INTEGER) &&
+ (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
+ {
+ return (AE_OK);
+ }
+ }
+
+ if (TypeNeeded != ThisType)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed type [%s], found [%s] %p",
+ AcpiUtGetTypeName (TypeNeeded),
+ AcpiUtGetTypeName (ThisType), Object));
+
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveOperands
+ *
+ * PARAMETERS: Opcode - Opcode being interpreted
+ * StackPtr - Pointer to the operand stack to be
+ * resolved
+ * WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert multiple input operands to the types required by the
+ * target operator.
+ *
+ * Each 5-bit group in ArgTypes represents one required
+ * operand and indicates the required Type. The corresponding operand
+ * will be converted to the required type if possible, otherwise we
+ * abort with an exception.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveOperands (
+ UINT16 Opcode,
+ ACPI_OPERAND_OBJECT **StackPtr,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status = AE_OK;
+ UINT8 ObjectType;
+ UINT32 ArgTypes;
+ const ACPI_OPCODE_INFO *OpInfo;
+ UINT32 ThisArgType;
+ ACPI_OBJECT_TYPE TypeNeeded;
+ UINT16 TargetOp = 0;
+
+
+ ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode);
+
+
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+ if (OpInfo->Class == AML_CLASS_UNKNOWN)
+ {
+ return_ACPI_STATUS (AE_AML_BAD_OPCODE);
+ }
+
+ ArgTypes = OpInfo->RuntimeArgs;
+ if (ArgTypes == ARGI_INVALID_OPCODE)
+ {
+ ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
+ Opcode));
+
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Opcode %X [%s] RequiredOperandTypes=%8.8X\n",
+ Opcode, OpInfo->Name, ArgTypes));
+
+ /*
+ * Normal exit is with (ArgTypes == 0) at end of argument list.
+ * Function will return an exception from within the loop upon
+ * finding an entry which is not (or cannot be converted
+ * to) the required type; if stack underflows; or upon
+ * finding a NULL stack entry (which should not happen).
+ */
+ while (GET_CURRENT_ARG_TYPE (ArgTypes))
+ {
+ if (!StackPtr || !*StackPtr)
+ {
+ ACPI_ERROR ((AE_INFO, "Null stack entry at %p",
+ StackPtr));
+
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /* Extract useful items */
+
+ ObjDesc = *StackPtr;
+
+ /* Decode the descriptor type */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_NAMED:
+
+ /* Namespace Node */
+
+ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+
+ /*
+ * Resolve an alias object. The construction of these objects
+ * guarantees that there is only one level of alias indirection;
+ * thus, the attached object is always the aliased namespace node
+ */
+ if (ObjectType == ACPI_TYPE_LOCAL_ALIAS)
+ {
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
+ *StackPtr = ObjDesc;
+ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
+ }
+ break;
+
+
+ case ACPI_DESC_TYPE_OPERAND:
+
+ /* ACPI internal object */
+
+ ObjectType = ObjDesc->Common.Type;
+
+ /* Check for bad ACPI_OBJECT_TYPE */
+
+ if (!AcpiUtValidObjectType (ObjectType))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Bad operand object type [0x%X]", ObjectType));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ /* Validate the Reference */
+
+ switch (ObjDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_DEBUG:
+
+ TargetOp = AML_DEBUG_OP;
+
+ /*lint -fallthrough */
+
+ case ACPI_REFCLASS_ARG:
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_INDEX:
+ case ACPI_REFCLASS_REFOF:
+ case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
+ case ACPI_REFCLASS_NAME: /* Reference to a named object */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Operand is a Reference, Class [%s] %2.2X\n",
+ AcpiUtGetReferenceName (ObjDesc),
+ ObjDesc->Reference.Class));
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown Reference Class 0x%2.2X in %p",
+ ObjDesc->Reference.Class, ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ }
+ break;
+
+
+ default:
+
+ /* Invalid descriptor */
+
+ ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]",
+ ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Get one argument type, point to the next */
+
+ ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
+ INCREMENT_ARG_LIST (ArgTypes);
+
+ /*
+ * Handle cases where the object does not need to be
+ * resolved to a value
+ */
+ switch (ThisArgType)
+ {
+ case ARGI_REF_OR_STRING: /* Can be a String or Reference */
+
+ if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
+ (ObjDesc->Common.Type == ACPI_TYPE_STRING))
+ {
+ /*
+ * String found - the string references a named object and
+ * must be resolved to a node
+ */
+ goto NextOperand;
+ }
+
+ /*
+ * Else not a string - fall through to the normal Reference
+ * case below
+ */
+ /*lint -fallthrough */
+
+ case ARGI_REFERENCE: /* References: */
+ case ARGI_INTEGER_REF:
+ case ARGI_OBJECT_REF:
+ case ARGI_DEVICE_REF:
+ case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
+ case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
+ case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
+
+ /*
+ * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
+ * A Namespace Node is OK as-is
+ */
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ goto NextOperand;
+ }
+
+ Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE,
+ ObjectType, ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ goto NextOperand;
+
+
+ case ARGI_DATAREFOBJ: /* Store operator only */
+
+ /*
+ * We don't want to resolve IndexOp reference objects during
+ * a store because this would be an implicit DeRefOf operation.
+ * Instead, we just want to store the reference object.
+ * -- All others must be resolved below.
+ */
+ if ((Opcode == AML_STORE_OP) &&
+ ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+ ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX))
+ {
+ goto NextOperand;
+ }
+ break;
+
+ default:
+ /* All cases covered above */
+ break;
+ }
+
+ /*
+ * Resolve this object to a value
+ */
+ Status = AcpiExResolveToValue (StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the resolved object */
+
+ ObjDesc = *StackPtr;
+
+ /*
+ * Check the resulting object (value) type
+ */
+ switch (ThisArgType)
+ {
+ /*
+ * For the simple cases, only one type of resolved object
+ * is allowed
+ */
+ case ARGI_MUTEX:
+
+ /* Need an operand of type ACPI_TYPE_MUTEX */
+
+ TypeNeeded = ACPI_TYPE_MUTEX;
+ break;
+
+ case ARGI_EVENT:
+
+ /* Need an operand of type ACPI_TYPE_EVENT */
+
+ TypeNeeded = ACPI_TYPE_EVENT;
+ break;
+
+ case ARGI_PACKAGE: /* Package */
+
+ /* Need an operand of type ACPI_TYPE_PACKAGE */
+
+ TypeNeeded = ACPI_TYPE_PACKAGE;
+ break;
+
+ case ARGI_ANYTYPE:
+
+ /* Any operand type will do */
+
+ TypeNeeded = ACPI_TYPE_ANY;
+ break;
+
+ case ARGI_DDBHANDLE:
+
+ /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
+
+ TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
+ break;
+
+
+ /*
+ * The more complex cases allow multiple resolved object types
+ */
+ case ARGI_INTEGER:
+
+ /*
+ * Need an operand of type ACPI_TYPE_INTEGER,
+ * But we can implicitly convert from a STRING or BUFFER
+ * Aka - "Implicit Source Operand Conversion"
+ */
+ Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_TYPE)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ goto NextOperand;
+
+
+ case ARGI_BUFFER:
+
+ /*
+ * Need an operand of type ACPI_TYPE_BUFFER,
+ * But we can implicitly convert from a STRING or INTEGER
+ * Aka - "Implicit Source Operand Conversion"
+ */
+ Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_TYPE)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ goto NextOperand;
+
+
+ case ARGI_STRING:
+
+ /*
+ * Need an operand of type ACPI_TYPE_STRING,
+ * But we can implicitly convert from a BUFFER or INTEGER
+ * Aka - "Implicit Source Operand Conversion"
+ */
+ Status = AcpiExConvertToString (ObjDesc, StackPtr,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_TYPE)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ goto NextOperand;
+
+
+ case ARGI_COMPUTEDATA:
+
+ /* Need an operand of type INTEGER, STRING or BUFFER */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_BUFFER_OR_STRING:
+
+ /* Need an operand of type STRING or BUFFER */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ case ACPI_TYPE_INTEGER:
+
+ /* Highest priority conversion is to type Buffer */
+
+ Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ObjDesc != *StackPtr)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Integer/String/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_DATAOBJECT:
+ /*
+ * ARGI_DATAOBJECT is only used by the SizeOf operator.
+ * Need a buffer, string, package, or RefOf reference.
+ *
+ * The only reference allowed here is a direct reference to
+ * a namespace node.
+ */
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Buffer/String/Package/Reference], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_COMPLEXOBJ:
+
+ /* Need a buffer or package or (ACPI 2.0) String */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Buffer/String/Package], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_REGION_OR_BUFFER: /* Used by Load() only */
+
+ /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_REGION:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Needed [Region/Buffer], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_DATAREFOBJ:
+
+ /* Used by the Store() operator only */
+
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ case ACPI_TYPE_DDB_HANDLE:
+
+ /* Valid operand */
+ break;
+
+ default:
+
+ if (AcpiGbl_EnableInterpreterSlack)
+ {
+ /*
+ * Enable original behavior of Store(), allowing any and all
+ * objects as the source operand. The ACPI spec does not
+ * allow this, however.
+ */
+ break;
+ }
+
+ if (TargetOp == AML_DEBUG_OP)
+ {
+ /* Allow store of any object to the Debug object */
+
+ break;
+ }
+
+ ACPI_ERROR ((AE_INFO,
+ "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ default:
+
+ /* Unknown type */
+
+ ACPI_ERROR ((AE_INFO,
+ "Internal - Unknown ARGI (required operand) type 0x%X",
+ ThisArgType));
+
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Make sure that the original object was resolved to the
+ * required object type (Simple cases only).
+ */
+ Status = AcpiExCheckObjectType (TypeNeeded,
+ (*StackPtr)->Common.Type, *StackPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+NextOperand:
+ /*
+ * If more operands needed, decrement StackPtr to point
+ * to next operand on stack
+ */
+ if (GET_CURRENT_ARG_TYPE (ArgTypes))
+ {
+ StackPtr--;
+ }
+ }
+
+ ACPI_DUMP_OPERANDS (WalkState->Operands,
+ AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exstore.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exstore.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,531 @@
+/******************************************************************************
+ *
+ * Module Name: exstore - AML Interpreter object store 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.
+ */
+
+#define __EXSTORE_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/amlcode.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exstore")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExStoreObjectToIndex (
+ ACPI_OPERAND_OBJECT *ValDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_WALK_STATE *WalkState);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStore
+ *
+ * PARAMETERS: *SourceDesc - Value to be stored
+ * *DestDesc - Where to store it. Must be an NS node
+ * or an ACPI_OPERAND_OBJECT of type
+ * Reference;
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the value described by SourceDesc into the location
+ * described by DestDesc. Called by various interpreter
+ * functions to store the result of an operation into
+ * the destination operand -- not just simply the actual "Store"
+ * ASL operator.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStore (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *RefDesc = DestDesc;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc);
+
+
+ /* Validate parameters */
+
+ if (!SourceDesc || !DestDesc)
+ {
+ ACPI_ERROR ((AE_INFO, "Null parameter"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /* DestDesc can be either a namespace node or an ACPI object */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ /*
+ * Dest is a namespace node,
+ * Storing an object into a Named node.
+ */
+ Status = AcpiExStoreObjectToNode (SourceDesc,
+ (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
+ ACPI_IMPLICIT_CONVERSION);
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Destination object must be a Reference or a Constant object */
+
+ switch (DestDesc->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ break;
+
+ case ACPI_TYPE_INTEGER:
+
+ /* Allow stores to Constants -- a Noop as per ACPI spec */
+
+ if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*lint -fallthrough */
+
+ default:
+
+ /* Destination is not a Reference object */
+
+ ACPI_ERROR ((AE_INFO,
+ "Target is not a Reference or Constant object - %s [%p]",
+ AcpiUtGetObjectTypeName (DestDesc), DestDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * Examine the Reference class. These cases are handled:
+ *
+ * 1) Store to Name (Change the object associated with a name)
+ * 2) Store to an indexed area of a Buffer or Package
+ * 3) Store to a Method Local or Arg
+ * 4) Store to the debug object
+ */
+ switch (RefDesc->Reference.Class)
+ {
+ case ACPI_REFCLASS_REFOF:
+
+ /* Storing an object into a Name "container" */
+
+ Status = AcpiExStoreObjectToNode (SourceDesc,
+ RefDesc->Reference.Object,
+ WalkState, ACPI_IMPLICIT_CONVERSION);
+ break;
+
+
+ case ACPI_REFCLASS_INDEX:
+
+ /* Storing to an Index (pointer into a packager or buffer) */
+
+ Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
+ break;
+
+
+ case ACPI_REFCLASS_LOCAL:
+ case ACPI_REFCLASS_ARG:
+
+ /* Store to a method local/arg */
+
+ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class,
+ RefDesc->Reference.Value, SourceDesc, WalkState);
+ break;
+
+
+ case ACPI_REFCLASS_DEBUG:
+
+ /*
+ * Storing to the Debug object causes the value stored to be
+ * displayed and otherwise has no effect -- see ACPI Specification
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "**** Write to Debug Object: Object %p %s ****:\n\n",
+ SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));
+
+ ACPI_DEBUG_OBJECT (SourceDesc, 0, 0);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
+ RefDesc->Reference.Class));
+ ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO);
+
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreObjectToIndex
+ *
+ * PARAMETERS: *SourceDesc - Value to be stored
+ * *DestDesc - Named object to receive the value
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the object to indexed Buffer or Package element
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExStoreObjectToIndex (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *IndexDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *NewDesc;
+ UINT8 Value = 0;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);
+
+
+ /*
+ * Destination must be a reference pointer, and
+ * must point to either a buffer or a package
+ */
+ switch (IndexDesc->Reference.TargetType)
+ {
+ case ACPI_TYPE_PACKAGE:
+ /*
+ * Storing to a package element. Copy the object and replace
+ * any existing object with the new object. No implicit
+ * conversion is performed.
+ *
+ * The object at *(IndexDesc->Reference.Where) is the
+ * element within the package that is to be modified.
+ * The parent package object is at IndexDesc->Reference.Object
+ */
+ ObjDesc = *(IndexDesc->Reference.Where);
+
+ if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE &&
+ SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
+ {
+ /* This is a DDBHandle, just add a reference to it */
+
+ AcpiUtAddReference (SourceDesc);
+ NewDesc = SourceDesc;
+ }
+ else
+ {
+ /* Normal object, copy it */
+
+ Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (ObjDesc)
+ {
+ /* Decrement reference count by the ref count of the parent package */
+
+ for (i = 0;
+ i < ((ACPI_OPERAND_OBJECT *)
+ IndexDesc->Reference.Object)->Common.ReferenceCount;
+ i++)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ }
+
+ *(IndexDesc->Reference.Where) = NewDesc;
+
+ /* Increment ref count by the ref count of the parent package-1 */
+
+ for (i = 1;
+ i < ((ACPI_OPERAND_OBJECT *)
+ IndexDesc->Reference.Object)->Common.ReferenceCount;
+ i++)
+ {
+ AcpiUtAddReference (NewDesc);
+ }
+
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ /*
+ * Store into a Buffer or String (not actually a real BufferField)
+ * at a location defined by an Index.
+ *
+ * The first 8-bit element of the source object is written to the
+ * 8-bit Buffer location defined by the Index destination object,
+ * according to the ACPI 2.0 specification.
+ */
+
+ /*
+ * Make sure the target is a Buffer or String. An error should
+ * not happen here, since the ReferenceObject was constructed
+ * by the INDEX_OP code.
+ */
+ ObjDesc = IndexDesc->Reference.Object;
+ if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (ObjDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * The assignment of the individual elements will be slightly
+ * different for each source type.
+ */
+ switch (SourceDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Use the least-significant byte of the integer */
+
+ Value = (UINT8) (SourceDesc->Integer.Value);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_STRING:
+
+ /* Note: Takes advantage of common string/buffer fields */
+
+ Value = SourceDesc->Buffer.Pointer[0];
+ break;
+
+ default:
+
+ /* All other types are invalid */
+
+ ACPI_ERROR ((AE_INFO,
+ "Source must be Integer/Buffer/String type, not %s",
+ AcpiUtGetObjectTypeName (SourceDesc)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Store the source value into the target buffer byte */
+
+ ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value;
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO,
+ "Target is not a Package or BufferField"));
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreObjectToNode
+ *
+ * PARAMETERS: SourceDesc - Value to be stored
+ * Node - Named object to receive the value
+ * WalkState - Current walk state
+ * ImplicitConversion - Perform implicit conversion (yes/no)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the object to the named object.
+ *
+ * The Assignment of an object to a named object is handled here
+ * The value passed in will replace the current value (if any)
+ * with the input value.
+ *
+ * When storing into an object the data is converted to the
+ * target object type then stored in the object. This means
+ * that the target object type (for an initialized target) will
+ * not be changed by a store operation.
+ *
+ * Assumes parameters are already validated.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreObjectToNode (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_WALK_STATE *WalkState,
+ UINT8 ImplicitConversion)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *TargetDesc;
+ ACPI_OPERAND_OBJECT *NewDesc;
+ ACPI_OBJECT_TYPE TargetType;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);
+
+
+ /* Get current type of the node, and object attached to Node */
+
+ TargetType = AcpiNsGetType (Node);
+ TargetDesc = AcpiNsGetAttachedObject (Node);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
+ SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
+ Node, AcpiUtGetTypeName (TargetType)));
+
+ /*
+ * Resolve the source object to an actual value
+ * (If it is a reference object)
+ */
+ Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* If no implicit conversion, drop into the default case below */
+
+ if ((!ImplicitConversion) ||
+ ((WalkState->Opcode == AML_COPY_OP) &&
+ (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) &&
+ (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) &&
+ (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD)))
+ {
+ /*
+ * Force execution of default (no implicit conversion). Note:
+ * CopyObject does not perform an implicit conversion, as per the ACPI
+ * spec -- except in case of region/bank/index fields -- because these
+ * objects must retain their original type permanently.
+ */
+ TargetType = ACPI_TYPE_ANY;
+ }
+
+ /* Do the actual store operation */
+
+ switch (TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ /* For fields, copy the source data to the target field. */
+
+ Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,
+ &WalkState->ResultObj);
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * These target types are all of type Integer/String/Buffer, and
+ * therefore support implicit conversion before the store.
+ *
+ * Copy and/or convert the source object to a new target object
+ */
+ Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,
+ &NewDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (NewDesc != TargetDesc)
+ {
+ /*
+ * Store the new NewDesc as the new value of the Name, and set
+ * the Name's type to that of the value being stored in it.
+ * SourceDesc reference count is incremented by AttachObject.
+ *
+ * Note: This may change the type of the node if an explicit store
+ * has been performed such that the node/object type has been
+ * changed.
+ */
+ Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Store %s into %s via Convert/Attach\n",
+ AcpiUtGetObjectTypeName (SourceDesc),
+ AcpiUtGetObjectTypeName (NewDesc)));
+ }
+ break;
+
+
+ default:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
+ AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node));
+
+ /* No conversions for all other types. Just attach the source object */
+
+ Status = AcpiNsAttachObject (Node, SourceDesc,
+ SourceDesc->Common.Type);
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exstoren.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exstoren.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,314 @@
+
+/******************************************************************************
+ *
+ * Module Name: exstoren - AML Interpreter object store support,
+ * Store to Node (namespace object)
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXSTOREN_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 ("exstoren")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExResolveObject
+ *
+ * PARAMETERS: SourceDescPtr - Pointer to the source object
+ * TargetType - Current type of the target
+ * WalkState - Current walk state
+ *
+ * RETURN: Status, resolved object in SourceDescPtr.
+ *
+ * DESCRIPTION: Resolve an object. If the object is a reference, dereference
+ * it and return the actual object in the SourceDescPtr.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExResolveObject (
+ ACPI_OPERAND_OBJECT **SourceDescPtr,
+ ACPI_OBJECT_TYPE TargetType,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExResolveObject);
+
+
+ /* Ensure we have a Target that can be stored to */
+
+ switch (TargetType)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ /*
+ * These cases all require only Integers or values that
+ * can be converted to Integers (Strings or Buffers)
+ */
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /*
+ * Stores into a Field/Region or into a Integer/Buffer/String
+ * are all essentially the same. This case handles the
+ * "interchangeable" types Integer, String, and Buffer.
+ */
+ if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ /* Resolve a reference object first */
+
+ Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ break;
+ }
+ }
+
+ /* For CopyObject, no further validation necessary */
+
+ if (WalkState->Opcode == AML_COPY_OP)
+ {
+ break;
+ }
+
+ /* Must have a Integer, Buffer, or String */
+
+ if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
+ (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) &&
+ (SourceDesc->Common.Type != ACPI_TYPE_STRING) &&
+ !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+ (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE)))
+ {
+ /* Conversion successful but still not a valid type */
+
+ ACPI_ERROR ((AE_INFO,
+ "Cannot assign type %s to %s (must be type Int/Str/Buf)",
+ AcpiUtGetObjectTypeName (SourceDesc),
+ AcpiUtGetTypeName (TargetType)));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_ALIAS:
+ case ACPI_TYPE_LOCAL_METHOD_ALIAS:
+
+ /*
+ * All aliases should have been resolved earlier, during the
+ * operand resolution phase.
+ */
+ ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object"));
+ Status = AE_AML_INTERNAL;
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+ default:
+
+ /*
+ * All other types than Alias and the various Fields come here,
+ * including the untyped case - ACPI_TYPE_ANY.
+ */
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreObjectToObject
+ *
+ * PARAMETERS: SourceDesc - Object to store
+ * DestDesc - Object to receive a copy of the source
+ * NewDesc - New object if DestDesc is obsoleted
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: "Store" an object to another object. This may include
+ * converting the source type to the target type (implicit
+ * conversion), and a copy of the value of the source to
+ * the target.
+ *
+ * The Assignment of an object to another (not named) object
+ * is handled here.
+ * The Source passed in will replace the current value (if any)
+ * with the input value.
+ *
+ * When storing into an object the data is converted to the
+ * target object type then stored in the object. This means
+ * that the target object type (for an initialized target) will
+ * not be changed by a store operation.
+ *
+ * This module allows destination types of Number, String,
+ * Buffer, and Package.
+ *
+ * Assumes parameters are already validated. NOTE: SourceDesc
+ * resolution (from a reference object) must be performed by
+ * the caller if necessary.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreObjectToObject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *DestDesc,
+ ACPI_OPERAND_OBJECT **NewDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *ActualSrcDesc;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc);
+
+
+ ActualSrcDesc = SourceDesc;
+ if (!DestDesc)
+ {
+ /*
+ * There is no destination object (An uninitialized node or
+ * package element), so we can simply copy the source object
+ * creating a new destination object
+ */
+ Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState);
+ return_ACPI_STATUS (Status);
+ }
+
+ if (SourceDesc->Common.Type != DestDesc->Common.Type)
+ {
+ /*
+ * The source type does not match the type of the destination.
+ * Perform the "implicit conversion" of the source to the current type
+ * of the target as per the ACPI specification.
+ *
+ * If no conversion performed, ActualSrcDesc = SourceDesc.
+ * Otherwise, ActualSrcDesc is a temporary object to hold the
+ * converted object.
+ */
+ Status = AcpiExConvertToTargetType (DestDesc->Common.Type,
+ SourceDesc, &ActualSrcDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (SourceDesc == ActualSrcDesc)
+ {
+ /*
+ * No conversion was performed. Return the SourceDesc as the
+ * new object.
+ */
+ *NewDesc = SourceDesc;
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ /*
+ * We now have two objects of identical types, and we can perform a
+ * copy of the *value* of the source object.
+ */
+ switch (DestDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ DestDesc->Integer.Value = ActualSrcDesc->Integer.Value;
+
+ /* Truncate value if we are executing from a 32-bit ACPI table */
+
+ AcpiExTruncateFor32bitTable (DestDesc);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc,
+ WalkState);
+ break;
+
+ default:
+ /*
+ * All other types come here.
+ */
+ ACPI_WARNING ((AE_INFO, "Store into type %s not implemented",
+ AcpiUtGetObjectTypeName (DestDesc)));
+
+ Status = AE_NOT_IMPLEMENTED;
+ break;
+ }
+
+ if (ActualSrcDesc != SourceDesc)
+ {
+ /* Delete the intermediate (temporary) source object */
+
+ AcpiUtRemoveReference (ActualSrcDesc);
+ }
+
+ *NewDesc = DestDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exstorob.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exstorob.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,244 @@
+
+/******************************************************************************
+ *
+ * Module Name: exstorob - AML Interpreter object store support, store to object
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXSTOROB_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exstorob")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreBufferToBuffer
+ *
+ * PARAMETERS: SourceDesc - Source object to copy
+ * TargetDesc - Destination object of the copy
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy a buffer object to another buffer object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreBufferToBuffer (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *TargetDesc)
+{
+ UINT32 Length;
+ UINT8 *Buffer;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc);
+
+
+ /* If Source and Target are the same, just return */
+
+ if (SourceDesc == TargetDesc)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* We know that SourceDesc is a buffer by now */
+
+ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer);
+ Length = SourceDesc->Buffer.Length;
+
+ /*
+ * If target is a buffer of length zero or is a static buffer,
+ * allocate a new buffer of the proper length
+ */
+ if ((TargetDesc->Buffer.Length == 0) ||
+ (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))
+ {
+ TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length);
+ if (!TargetDesc->Buffer.Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ TargetDesc->Buffer.Length = Length;
+ }
+
+ /* Copy source buffer to target buffer */
+
+ if (Length <= TargetDesc->Buffer.Length)
+ {
+ /* Clear existing buffer and copy in the new one */
+
+ ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
+ ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length);
+
+#ifdef ACPI_OBSOLETE_BEHAVIOR
+ /*
+ * NOTE: ACPI versions up to 3.0 specified that the buffer must be
+ * truncated if the string is smaller than the buffer. However, "other"
+ * implementations of ACPI never did this and thus became the defacto
+ * standard. ACPI 3.0A changes this behavior such that the buffer
+ * is no longer truncated.
+ */
+
+ /*
+ * OBSOLETE BEHAVIOR:
+ * If the original source was a string, we must truncate the buffer,
+ * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
+ * copy must not truncate the original buffer.
+ */
+ if (OriginalSrcType == ACPI_TYPE_STRING)
+ {
+ /* Set the new length of the target */
+
+ TargetDesc->Buffer.Length = Length;
+ }
+#endif
+ }
+ else
+ {
+ /* Truncate the source, copy only what will fit */
+
+ ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer,
+ TargetDesc->Buffer.Length);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Truncating source buffer from %X to %X\n",
+ Length, TargetDesc->Buffer.Length));
+ }
+
+ /* Copy flags */
+
+ TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags;
+ TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExStoreStringToString
+ *
+ * PARAMETERS: SourceDesc - Source object to copy
+ * TargetDesc - Destination object of the copy
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy a String object to another String object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExStoreStringToString (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *TargetDesc)
+{
+ UINT32 Length;
+ UINT8 *Buffer;
+
+
+ ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc);
+
+
+ /* If Source and Target are the same, just return */
+
+ if (SourceDesc == TargetDesc)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* We know that SourceDesc is a string by now */
+
+ Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer);
+ Length = SourceDesc->String.Length;
+
+ /*
+ * Replace existing string value if it will fit and the string
+ * pointer is not a static pointer (part of an ACPI table)
+ */
+ if ((Length < TargetDesc->String.Length) &&
+ (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
+ {
+ /*
+ * String will fit in existing non-static buffer.
+ * Clear old string and copy in the new one
+ */
+ ACPI_MEMSET (TargetDesc->String.Pointer, 0,
+ (ACPI_SIZE) TargetDesc->String.Length + 1);
+ ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
+ }
+ else
+ {
+ /*
+ * Free the current buffer, then allocate a new buffer
+ * large enough to hold the value
+ */
+ if (TargetDesc->String.Pointer &&
+ (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
+ {
+ /* Only free if not a pointer into the DSDT */
+
+ ACPI_FREE (TargetDesc->String.Pointer);
+ }
+
+ TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED (
+ (ACPI_SIZE) Length + 1);
+ if (!TargetDesc->String.Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
+ ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
+ }
+
+ /* Set the new target length */
+
+ TargetDesc->String.Length = Length;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exsystem.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exsystem.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,355 @@
+
+/******************************************************************************
+ *
+ * Module Name: exsystem - Interface to OS services
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __EXSYSTEM_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exsystem")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitSemaphore
+ *
+ * PARAMETERS: Semaphore - Semaphore to wait on
+ * Timeout - Max time to wait
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implements a semaphore wait with a check to see if the
+ * semaphore is available immediately. If it is not, the
+ * interpreter is released before waiting.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemWaitSemaphore (
+ ACPI_SEMAPHORE Semaphore,
+ UINT16 Timeout)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore);
+
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Status == AE_TIME)
+ {
+ /* We must wait, so unlock the interpreter */
+
+ AcpiExRelinquishInterpreter ();
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "*** Thread awake after blocking, %s\n",
+ AcpiFormatException (Status)));
+
+ /* Reacquire the interpreter */
+
+ AcpiExReacquireInterpreter ();
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitMutex
+ *
+ * PARAMETERS: Mutex - Mutex to wait on
+ * Timeout - Max time to wait
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implements a mutex wait with a check to see if the
+ * mutex is available immediately. If it is not, the
+ * interpreter is released before waiting.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemWaitMutex (
+ ACPI_MUTEX Mutex,
+ UINT16 Timeout)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemWaitMutex);
+
+
+ Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Status == AE_TIME)
+ {
+ /* We must wait, so unlock the interpreter */
+
+ AcpiExRelinquishInterpreter ();
+
+ Status = AcpiOsAcquireMutex (Mutex, Timeout);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "*** Thread awake after blocking, %s\n",
+ AcpiFormatException (Status)));
+
+ /* Reacquire the interpreter */
+
+ AcpiExReacquireInterpreter ();
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemDoStall
+ *
+ * PARAMETERS: HowLong - The amount of time to stall,
+ * in microseconds
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Suspend running thread for specified amount of time.
+ * Note: ACPI specification requires that Stall() does not
+ * relinquish the processor, and delays longer than 100 usec
+ * should use Sleep() instead. We allow stalls up to 255 usec
+ * for compatibility with other interpreters and existing BIOSs.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemDoStall (
+ UINT32 HowLong)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (HowLong > 255) /* 255 microseconds */
+ {
+ /*
+ * Longer than 255 usec, this is an error
+ *
+ * (ACPI specifies 100 usec as max, but this gives some slack in
+ * order to support existing BIOSs)
+ */
+ ACPI_ERROR ((AE_INFO, "Time parameter is too large (%u)",
+ HowLong));
+ Status = AE_AML_OPERAND_VALUE;
+ }
+ else
+ {
+ AcpiOsStall (HowLong);
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemDoSleep
+ *
+ * PARAMETERS: HowLong - The amount of time to sleep,
+ * in milliseconds
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Sleep the running thread for specified amount of time.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemDoSleep (
+ UINT64 HowLong)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Since this thread will sleep, we must release the interpreter */
+
+ AcpiExRelinquishInterpreter ();
+
+ /*
+ * For compatibility with other ACPI implementations and to prevent
+ * accidental deep sleeps, limit the sleep time to something reasonable.
+ */
+ if (HowLong > ACPI_MAX_SLEEP)
+ {
+ HowLong = ACPI_MAX_SLEEP;
+ }
+
+ AcpiOsSleep (HowLong);
+
+ /* And now we must get the interpreter again */
+
+ AcpiExReacquireInterpreter ();
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemSignalEvent
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemSignalEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemSignalEvent);
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitEvent
+ *
+ * PARAMETERS: TimeDesc - The 'time to delay' object descriptor
+ * ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML. This operation is a request to wait for an
+ * event.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemWaitEvent (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (ExSystemWaitEvent);
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore,
+ (UINT16) TimeDesc->Integer.Value);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemResetEvent
+ *
+ * PARAMETERS: ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reset an event to a known state.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemResetEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_SEMAPHORE TempSemaphore;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * We are going to simply delete the existing semaphore and
+ * create a new one!
+ */
+ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore);
+ if (ACPI_SUCCESS (Status))
+ {
+ (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore);
+ ObjDesc->Event.OsSemaphore = TempSemaphore;
+ }
+
+ return (Status);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exutils.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exutils.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,532 @@
+
+/******************************************************************************
+ *
+ * Module Name: exutils - interpreter/scanner 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 __EXUTILS_C__
+
+/*
+ * DEFINE_AML_GLOBALS is tested in amlcode.h
+ * to determine whether certain global names should be "defined" or only
+ * "declared" in the current compilation. This enhances maintainability
+ * by enabling a single header file to embody all knowledge of the names
+ * in question.
+ *
+ * Exactly one module of any executable should #define DEFINE_GLOBALS
+ * before #including the header files which use this convention. The
+ * names in question will be defined and initialized in that module,
+ * and declared as extern in all other modules which #include those
+ * header files.
+ */
+
+#define DEFINE_AML_GLOBALS
+
+#include <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 ("exutils")
+
+/* Local prototypes */
+
+static UINT32
+AcpiExDigitsNeeded (
+ UINT64 Value,
+ UINT32 Base);
+
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExEnterInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Enter the interpreter execution region. Failure to enter
+ * the interpreter region is a fatal system error. Used in
+ * conjunction with ExitInterpreter.
+ *
+ ******************************************************************************/
+
+void
+AcpiExEnterInterpreter (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExEnterInterpreter);
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReacquireInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Reacquire the interpreter execution region from within the
+ * interpreter code. Failure to enter the interpreter region is a
+ * fatal system error. Used in conjuction with
+ * RelinquishInterpreter
+ *
+ ******************************************************************************/
+
+void
+AcpiExReacquireInterpreter (
+ void)
+{
+ ACPI_FUNCTION_TRACE (ExReacquireInterpreter);
+
+
+ /*
+ * If the global serialized flag is set, do not release the interpreter,
+ * since it was not actually released by AcpiExRelinquishInterpreter.
+ * This forces the interpreter to be single threaded.
+ */
+ if (!AcpiGbl_AllMethodsSerialized)
+ {
+ AcpiExEnterInterpreter ();
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExExitInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Exit the interpreter execution region. This is the top level
+ * routine used to exit the interpreter when all processing has
+ * been completed.
+ *
+ ******************************************************************************/
+
+void
+AcpiExExitInterpreter (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExExitInterpreter);
+
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExRelinquishInterpreter
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Exit the interpreter execution region, from within the
+ * interpreter - before attempting an operation that will possibly
+ * block the running thread.
+ *
+ * Cases where the interpreter is unlocked internally
+ * 1) Method to be blocked on a Sleep() AML opcode
+ * 2) Method to be blocked on an Acquire() AML opcode
+ * 3) Method to be blocked on a Wait() AML opcode
+ * 4) Method to be blocked to acquire the global lock
+ * 5) Method to be blocked waiting to execute a serialized control method
+ * that is currently executing
+ * 6) About to invoke a user-installed opregion handler
+ *
+ ******************************************************************************/
+
+void
+AcpiExRelinquishInterpreter (
+ void)
+{
+ ACPI_FUNCTION_TRACE (ExRelinquishInterpreter);
+
+
+ /*
+ * If the global serialized flag is set, do not release the interpreter.
+ * This forces the interpreter to be single threaded.
+ */
+ if (!AcpiGbl_AllMethodsSerialized)
+ {
+ AcpiExExitInterpreter ();
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExTruncateFor32bitTable
+ *
+ * PARAMETERS: ObjDesc - Object to be truncated
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
+ * 32-bit, as determined by the revision of the DSDT.
+ *
+ ******************************************************************************/
+
+void
+AcpiExTruncateFor32bitTable (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Object must be a valid number and we must be executing
+ * a control method. NS node could be there for AML_INT_NAMEPATH_OP.
+ */
+ if ((!ObjDesc) ||
+ (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) ||
+ (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
+ {
+ return;
+ }
+
+ if (AcpiGbl_IntegerByteWidth == 4)
+ {
+ /*
+ * We are running a method that exists in a 32-bit ACPI table.
+ * Truncate the value to 32 bits by zeroing out the upper 32-bit field
+ */
+ ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAcquireGlobalLock
+ *
+ * PARAMETERS: FieldFlags - Flags with Lock rule:
+ * AlwaysLock or NeverLock
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
+ * flags specifiy that it is to be obtained before field access.
+ *
+ ******************************************************************************/
+
+void
+AcpiExAcquireGlobalLock (
+ UINT32 FieldFlags)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExAcquireGlobalLock);
+
+
+ /* Only use the lock if the AlwaysLock bit is set */
+
+ if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
+ {
+ return_VOID;
+ }
+
+ /* Attempt to get the global lock, wait forever */
+
+ Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER,
+ AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not acquire Global Lock"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExReleaseGlobalLock
+ *
+ * PARAMETERS: FieldFlags - Flags with Lock rule:
+ * AlwaysLock or NeverLock
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Release the ACPI hardware Global Lock
+ *
+ ******************************************************************************/
+
+void
+AcpiExReleaseGlobalLock (
+ UINT32 FieldFlags)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (ExReleaseGlobalLock);
+
+
+ /* Only use the lock if the AlwaysLock bit is set */
+
+ if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
+ {
+ return_VOID;
+ }
+
+ /* Release the global lock */
+
+ Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Report the error, but there isn't much else we can do */
+
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not release Global Lock"));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDigitsNeeded
+ *
+ * PARAMETERS: Value - Value to be represented
+ * Base - Base of representation
+ *
+ * RETURN: The number of digits.
+ *
+ * DESCRIPTION: Calculate the number of digits needed to represent the Value
+ * in the given Base (Radix)
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiExDigitsNeeded (
+ UINT64 Value,
+ UINT32 Base)
+{
+ UINT32 NumDigits;
+ UINT64 CurrentValue;
+
+
+ ACPI_FUNCTION_TRACE (ExDigitsNeeded);
+
+
+ /* UINT64 is unsigned, so we don't worry about a '-' prefix */
+
+ if (Value == 0)
+ {
+ return_UINT32 (1);
+ }
+
+ CurrentValue = Value;
+ NumDigits = 0;
+
+ /* Count the digits in the requested base */
+
+ while (CurrentValue)
+ {
+ (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL);
+ NumDigits++;
+ }
+
+ return_UINT32 (NumDigits);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExEisaIdToString
+ *
+ * PARAMETERS: CompressedId - EISAID to be converted
+ * OutString - Where to put the converted string (8 bytes)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Convert a numeric EISAID to string representation. Return
+ * buffer must be large enough to hold the string. The string
+ * returned is always exactly of length ACPI_EISAID_STRING_SIZE
+ * (includes null terminator). The EISAID is always 32 bits.
+ *
+ ******************************************************************************/
+
+void
+AcpiExEisaIdToString (
+ char *OutString,
+ UINT64 CompressedId)
+{
+ UINT32 SwappedId;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* The EISAID should be a 32-bit integer */
+
+ if (CompressedId > ACPI_UINT32_MAX)
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating",
+ ACPI_FORMAT_UINT64 (CompressedId)));
+ }
+
+ /* Swap ID to big-endian to get contiguous bits */
+
+ SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId);
+
+ /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
+
+ OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F));
+ OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F));
+ OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F));
+ OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12);
+ OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8);
+ OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4);
+ OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0);
+ OutString[7] = 0;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExIntegerToString
+ *
+ * PARAMETERS: OutString - Where to put the converted string. At least
+ * 21 bytes are needed to hold the largest
+ * possible 64-bit integer.
+ * Value - Value to be converted
+ *
+ * RETURN: None, string
+ *
+ * DESCRIPTION: Convert a 64-bit integer to decimal string representation.
+ * Assumes string buffer is large enough to hold the string. The
+ * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1).
+ *
+ ******************************************************************************/
+
+void
+AcpiExIntegerToString (
+ char *OutString,
+ UINT64 Value)
+{
+ UINT32 Count;
+ UINT32 DigitsNeeded;
+ UINT32 Remainder;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
+ OutString[DigitsNeeded] = 0;
+
+ for (Count = DigitsNeeded; Count > 0; Count--)
+ {
+ (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder);
+ OutString[Count-1] = (char) ('0' + Remainder);\
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiIsValidSpaceId
+ *
+ * PARAMETERS: SpaceId - ID to be validated
+ *
+ * RETURN: TRUE if valid/supported ID.
+ *
+ * DESCRIPTION: Validate an operation region SpaceID.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiIsValidSpaceId (
+ UINT8 SpaceId)
+{
+
+ if ((SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) &&
+ (SpaceId < ACPI_USER_REGION_BEGIN) &&
+ (SpaceId != ACPI_ADR_SPACE_DATA_TABLE) &&
+ (SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE))
+ {
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
+
+#endif
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwacpi.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwacpi.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,209 @@
+
+/******************************************************************************
+ *
+ * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __HWACPI_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwacpi")
+
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwSetMode
+ *
+ * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Transitions the system into the requested mode.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwSetMode (
+ UINT32 Mode)
+{
+
+ ACPI_STATUS Status;
+ UINT32 Retry;
+
+
+ ACPI_FUNCTION_TRACE (HwSetMode);
+
+ /*
+ * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
+ * system does not support mode transition.
+ */
+ if (!AcpiGbl_FADT.SmiCommand)
+ {
+ ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed"));
+ return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+ }
+
+ /*
+ * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE
+ * in FADT: If it is zero, enabling or disabling is not supported.
+ * As old systems may have used zero for mode transition,
+ * we make sure both the numbers are zero to determine these
+ * transitions are not supported.
+ */
+ if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "No ACPI mode transition supported in this system "
+ "(enable/disable both zero)"));
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ switch (Mode)
+ {
+ case ACPI_SYS_MODE_ACPI:
+
+ /* BIOS should have disabled ALL fixed and GP events */
+
+ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
+ (UINT32) AcpiGbl_FADT.AcpiEnable, 8);
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
+ break;
+
+ case ACPI_SYS_MODE_LEGACY:
+
+ /*
+ * BIOS should clear all fixed status bits and restore fixed event
+ * enable bits to default
+ */
+ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
+ (UINT32) AcpiGbl_FADT.AcpiDisable, 8);
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Attempting to enable Legacy (non-ACPI) mode\n"));
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not write ACPI mode change"));
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Some hardware takes a LONG time to switch modes. Give them 3 sec to
+ * do so, but allow faster systems to proceed more quickly.
+ */
+ Retry = 3000;
+ while (Retry)
+ {
+ if (AcpiHwGetMode() == Mode)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n",
+ Mode));
+ return_ACPI_STATUS (AE_OK);
+ }
+ AcpiOsStall(1000);
+ Retry--;
+ }
+
+ ACPI_ERROR ((AE_INFO, "Hardware did not change modes"));
+ return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetMode
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY
+ *
+ * DESCRIPTION: Return current operating state of system. Determined by
+ * querying the SCI_EN bit.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiHwGetMode (
+ void)
+{
+ ACPI_STATUS Status;
+ UINT32 Value;
+
+
+ ACPI_FUNCTION_TRACE (HwGetMode);
+
+
+ /*
+ * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
+ * system does not support mode transition.
+ */
+ if (!AcpiGbl_FADT.SmiCommand)
+ {
+ return_UINT32 (ACPI_SYS_MODE_ACPI);
+ }
+
+ Status = AcpiReadBitRegister (ACPI_BITREG_SCI_ENABLE, &Value);
+ if (ACPI_FAILURE (Status))
+ {
+ return_UINT32 (ACPI_SYS_MODE_LEGACY);
+ }
+
+ if (Value)
+ {
+ return_UINT32 (ACPI_SYS_MODE_ACPI);
+ }
+ else
+ {
+ return_UINT32 (ACPI_SYS_MODE_LEGACY);
+ }
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwesleep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwesleep.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,263 @@
+/******************************************************************************
+ *
+ * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the
+ * extended FADT-V5 sleep registers.
+ *
+ *****************************************************************************/
+
+/*
+ * 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>
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwesleep")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwExecuteSleepMethod
+ *
+ * PARAMETERS: MethodName - Pathname of method to execute
+ * IntegerArgument - Argument to pass to the method
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Execute a sleep/wake related method with one integer argument
+ * and no return value.
+ *
+ ******************************************************************************/
+
+void
+AcpiHwExecuteSleepMethod (
+ char *MethodName,
+ UINT32 IntegerArgument)
+{
+ ACPI_OBJECT_LIST ArgList;
+ ACPI_OBJECT Arg;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwExecuteSleepMethod);
+
+
+ /* One argument, IntegerArgument; No return value expected */
+
+ ArgList.Count = 1;
+ ArgList.Pointer = &Arg;
+ Arg.Type = ACPI_TYPE_INTEGER;
+ Arg.Integer.Value = (UINT64) IntegerArgument;
+
+ Status = AcpiEvaluateObject (NULL, MethodName, &ArgList, NULL);
+ if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "While executing method %s",
+ MethodName));
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwExtendedSleep
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter a system sleep state via the extended FADT sleep
+ * registers (V5 FADT).
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwExtendedSleep (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+ UINT8 SleepTypeValue;
+ UINT64 SleepStatus;
+
+
+ ACPI_FUNCTION_TRACE (HwExtendedSleep);
+
+
+ /* Extended sleep registers must be valid */
+
+ if (!AcpiGbl_FADT.SleepControl.Address ||
+ !AcpiGbl_FADT.SleepStatus.Address)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /* Clear wake status (WAK_STS) */
+
+ Status = AcpiWrite (ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ AcpiGbl_SystemAwakeAndRunning = FALSE;
+
+ /* Execute the _GTS method (Going To Sleep) */
+
+ AcpiHwExecuteSleepMethod (METHOD_NAME__GTS, SleepState);
+
+ /* Flush caches, as per ACPI specification */
+
+ ACPI_FLUSH_CPU_CACHE ();
+
+ /*
+ * Set the SLP_TYP and SLP_EN bits.
+ *
+ * Note: We only use the first value returned by the \_Sx method
+ * (AcpiGbl_SleepTypeA) - As per ACPI specification.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+ "Entering sleep state [S%u]\n", SleepState));
+
+ SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) &
+ ACPI_X_SLEEP_TYPE_MASK);
+
+ Status = AcpiWrite ((SleepTypeValue | ACPI_X_SLEEP_ENABLE),
+ &AcpiGbl_FADT.SleepControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Wait for transition back to Working State */
+
+ do
+ {
+ Status = AcpiRead (&SleepStatus, &AcpiGbl_FADT.SleepStatus);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ } while (!(((UINT8) SleepStatus) & ACPI_X_WAKE_STATUS));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwExtendedWakePrep
+ *
+ * PARAMETERS: SleepState - Which sleep state we just exited
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after
+ * a sleep. Called with interrupts ENABLED.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwExtendedWakePrep (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+ UINT8 SleepTypeValue;
+
+
+ ACPI_FUNCTION_TRACE (HwExtendedWakePrep);
+
+
+ Status = AcpiGetSleepTypeData (ACPI_STATE_S0,
+ &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
+ if (ACPI_SUCCESS (Status))
+ {
+ SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) &
+ ACPI_X_SLEEP_TYPE_MASK);
+
+ (void) AcpiWrite ((SleepTypeValue | ACPI_X_SLEEP_ENABLE),
+ &AcpiGbl_FADT.SleepControl);
+ }
+
+ AcpiHwExecuteSleepMethod (METHOD_NAME__BFS, SleepState);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwExtendedWake
+ *
+ * PARAMETERS: SleepState - Which sleep state we just exited
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
+ * Called with interrupts ENABLED.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwExtendedWake (
+ UINT8 SleepState)
+{
+ ACPI_FUNCTION_TRACE (HwExtendedWake);
+
+
+ /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
+
+ AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
+
+ /* Execute the wake methods */
+
+ AcpiHwExecuteSleepMethod (METHOD_NAME__SST, ACPI_SST_WAKING);
+ AcpiHwExecuteSleepMethod (METHOD_NAME__WAK, SleepState);
+
+ /*
+ * Some BIOS code assumes that WAK_STS will be cleared on resume
+ * and use it to determine whether the system is rebooting or
+ * resuming. Clear WAK_STS for compatibility.
+ */
+ (void) AcpiWrite (ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus);
+ AcpiGbl_SystemAwakeAndRunning = TRUE;
+
+ AcpiHwExecuteSleepMethod (METHOD_NAME__SST, ACPI_SST_WORKING);
+ return_ACPI_STATUS (AE_OK);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwgpe.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwgpe.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,543 @@
+
+/******************************************************************************
+ *
+ * Module Name: hwgpe - Low level GPE enable/disable/clear 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_HARDWARE
+ ACPI_MODULE_NAME ("hwgpe")
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiHwEnableWakeupGpeBlock (
+ ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
+ ACPI_GPE_BLOCK_INFO *GpeBlock,
+ void *Context);
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetGpeRegisterBit
+ *
+ * PARAMETERS: GpeEventInfo - Info block for the GPE
+ * GpeRegisterInfo - Info block for the GPE register
+ *
+ * RETURN: Register mask with a one in the GPE bit position
+ *
+ * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
+ * correct position for the input GPE.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiHwGetGpeRegisterBit (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo,
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo)
+{
+
+ return ((UINT32) 1 <<
+ (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber));
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwLowSetGpe
+ *
+ * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled
+ * Action - Enable or disable
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwLowSetGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo,
+ UINT32 Action)
+{
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+ ACPI_STATUS Status;
+ UINT32 EnableMask;
+ UINT32 RegisterBit;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+ if (!GpeRegisterInfo)
+ {
+ return (AE_NOT_EXIST);
+ }
+
+ /* Get current value of the enable register that contains this GPE */
+
+ Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Set or clear just the bit that corresponds to this GPE */
+
+ RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
+ switch (Action)
+ {
+ case ACPI_GPE_CONDITIONAL_ENABLE:
+
+ /* Only enable if the EnableForRun bit is set */
+
+ if (!(RegisterBit & GpeRegisterInfo->EnableForRun))
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*lint -fallthrough */
+
+ case ACPI_GPE_ENABLE:
+ ACPI_SET_BIT (EnableMask, RegisterBit);
+ break;
+
+ case ACPI_GPE_DISABLE:
+ ACPI_CLEAR_BIT (EnableMask, RegisterBit);
+ break;
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u\n", Action));
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Write the updated enable mask */
+
+ Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwClearGpe
+ *
+ * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Clear the status bit for a single GPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwClearGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo)
+{
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+ ACPI_STATUS Status;
+ UINT32 RegisterBit;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+ if (!GpeRegisterInfo)
+ {
+ return (AE_NOT_EXIST);
+ }
+
+ /*
+ * Write a one to the appropriate bit in the status register to
+ * clear this GPE.
+ */
+ RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
+
+ Status = AcpiHwWrite (RegisterBit,
+ &GpeRegisterInfo->StatusAddress);
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetGpeStatus
+ *
+ * PARAMETERS: GpeEventInfo - Info block for the GPE to queried
+ * EventStatus - Where the GPE status is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Return the status of a single GPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwGetGpeStatus (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo,
+ ACPI_EVENT_STATUS *EventStatus)
+{
+ UINT32 InByte;
+ UINT32 RegisterBit;
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+ ACPI_EVENT_STATUS LocalEventStatus = 0;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!EventStatus)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+
+ /* Get the register bitmask for this GPE */
+
+ RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
+
+ /* GPE currently enabled? (enabled for runtime?) */
+
+ if (RegisterBit & GpeRegisterInfo->EnableForRun)
+ {
+ LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
+ }
+
+ /* GPE enabled for wake? */
+
+ if (RegisterBit & GpeRegisterInfo->EnableForWake)
+ {
+ LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
+ }
+
+ /* GPE currently active (status bit == 1)? */
+
+ Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (RegisterBit & InByte)
+ {
+ LocalEventStatus |= ACPI_EVENT_FLAG_SET;
+ }
+
+ /* Set return value */
+
+ (*EventStatus) = LocalEventStatus;
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwDisableGpeBlock
+ *
+ * PARAMETERS: GpeXruptInfo - GPE Interrupt info
+ * GpeBlock - Gpe Block info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Disable all GPEs within a single GPE block
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwDisableGpeBlock (
+ ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
+ ACPI_GPE_BLOCK_INFO *GpeBlock,
+ void *Context)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ /* Examine each GPE Register within the block */
+
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ /* Disable all GPEs in this register */
+
+ Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwClearGpeBlock
+ *
+ * PARAMETERS: GpeXruptInfo - GPE Interrupt info
+ * GpeBlock - Gpe Block info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwClearGpeBlock (
+ ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
+ ACPI_GPE_BLOCK_INFO *GpeBlock,
+ void *Context)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ /* Examine each GPE Register within the block */
+
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ /* Clear status on all GPEs in this register */
+
+ Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwEnableRuntimeGpeBlock
+ *
+ * PARAMETERS: GpeXruptInfo - GPE Interrupt info
+ * GpeBlock - Gpe Block info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
+ * combination wake/run GPEs.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwEnableRuntimeGpeBlock (
+ ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
+ ACPI_GPE_BLOCK_INFO *GpeBlock,
+ void *Context)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ /* NOTE: assumes that all GPEs are currently disabled */
+
+ /* Examine each GPE Register within the block */
+
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ if (!GpeBlock->RegisterInfo[i].EnableForRun)
+ {
+ continue;
+ }
+
+ /* Enable all "runtime" GPEs in this register */
+
+ Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun,
+ &GpeBlock->RegisterInfo[i].EnableAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwEnableWakeupGpeBlock
+ *
+ * PARAMETERS: GpeXruptInfo - GPE Interrupt info
+ * GpeBlock - Gpe Block info
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
+ * combination wake/run GPEs.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwEnableWakeupGpeBlock (
+ ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
+ ACPI_GPE_BLOCK_INFO *GpeBlock,
+ void *Context)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ /* Examine each GPE Register within the block */
+
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ if (!GpeBlock->RegisterInfo[i].EnableForWake)
+ {
+ continue;
+ }
+
+ /* Enable all "wake" GPEs in this register */
+
+ Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake,
+ &GpeBlock->RegisterInfo[i].EnableAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwDisableAllGpes
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwDisableAllGpes (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwDisableAllGpes);
+
+
+ Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
+ Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwEnableAllRuntimeGpes
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwEnableAllRuntimeGpes (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
+
+
+ Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwEnableAllWakeupGpes
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwEnableAllWakeupGpes (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
+
+
+ Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
+ return_ACPI_STATUS (Status);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwpci.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwpci.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,459 @@
+/*******************************************************************************
+ *
+ * Module Name: hwpci - Obtain PCI bus, device, and function numbers
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __HWPCI_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("hwpci")
+
+
+/* PCI configuration space values */
+
+#define PCI_CFG_HEADER_TYPE_REG 0x0E
+#define PCI_CFG_PRIMARY_BUS_NUMBER_REG 0x18
+#define PCI_CFG_SECONDARY_BUS_NUMBER_REG 0x19
+
+/* PCI header values */
+
+#define PCI_HEADER_TYPE_MASK 0x7F
+#define PCI_TYPE_BRIDGE 0x01
+#define PCI_TYPE_CARDBUS_BRIDGE 0x02
+
+typedef struct acpi_pci_device
+{
+ ACPI_HANDLE Device;
+ struct acpi_pci_device *Next;
+
+} ACPI_PCI_DEVICE;
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiHwBuildPciList (
+ ACPI_HANDLE RootPciDevice,
+ ACPI_HANDLE PciRegion,
+ ACPI_PCI_DEVICE **ReturnListHead);
+
+static ACPI_STATUS
+AcpiHwProcessPciList (
+ ACPI_PCI_ID *PciId,
+ ACPI_PCI_DEVICE *ListHead);
+
+static void
+AcpiHwDeletePciList (
+ ACPI_PCI_DEVICE *ListHead);
+
+static ACPI_STATUS
+AcpiHwGetPciDeviceInfo (
+ ACPI_PCI_ID *PciId,
+ ACPI_HANDLE PciDevice,
+ UINT16 *BusNumber,
+ BOOLEAN *IsBridge);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwDerivePciId
+ *
+ * PARAMETERS: PciId - Initial values for the PCI ID. May be
+ * modified by this function.
+ * RootPciDevice - A handle to a PCI device object. This
+ * object must be a PCI Root Bridge having a
+ * _HID value of either PNP0A03 or PNP0A08
+ * PciRegion - A handle to a PCI configuration space
+ * Operation Region being initialized
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function derives a full PCI ID for a PCI device,
+ * consisting of a Segment number, Bus number, Device number,
+ * and function code.
+ *
+ * The PCI hardware dynamically configures PCI bus numbers
+ * depending on the bus topology discovered during system
+ * initialization. This function is invoked during configuration
+ * of a PCI_Config Operation Region in order to (possibly) update
+ * the Bus/Device/Function numbers in the PciId with the actual
+ * values as determined by the hardware and operating system
+ * configuration.
+ *
+ * The PciId parameter is initially populated during the Operation
+ * Region initialization. This function is then called, and is
+ * will make any necessary modifications to the Bus, Device, or
+ * Function number PCI ID subfields as appropriate for the
+ * current hardware and OS configuration.
+ *
+ * NOTE: Created 08/2010. Replaces the previous OSL AcpiOsDerivePciId
+ * interface since this feature is OS-independent. This module
+ * specifically avoids any use of recursion by building a local
+ * temporary device list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwDerivePciId (
+ ACPI_PCI_ID *PciId,
+ ACPI_HANDLE RootPciDevice,
+ ACPI_HANDLE PciRegion)
+{
+ ACPI_STATUS Status;
+ ACPI_PCI_DEVICE *ListHead = NULL;
+
+
+ ACPI_FUNCTION_TRACE (HwDerivePciId);
+
+
+ if (!PciId)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Build a list of PCI devices, from PciRegion up to RootPciDevice */
+
+ Status = AcpiHwBuildPciList (RootPciDevice, PciRegion, &ListHead);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Walk the list, updating the PCI device/function/bus numbers */
+
+ Status = AcpiHwProcessPciList (PciId, ListHead);
+ }
+
+ /* Always delete the list */
+
+ AcpiHwDeletePciList (ListHead);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwBuildPciList
+ *
+ * PARAMETERS: RootPciDevice - A handle to a PCI device object. This
+ * object is guaranteed to be a PCI Root
+ * Bridge having a _HID value of either
+ * PNP0A03 or PNP0A08
+ * PciRegion - A handle to the PCI configuration space
+ * Operation Region
+ * ReturnListHead - Where the PCI device list is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Builds a list of devices from the input PCI region up to the
+ * Root PCI device for this namespace subtree.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwBuildPciList (
+ ACPI_HANDLE RootPciDevice,
+ ACPI_HANDLE PciRegion,
+ ACPI_PCI_DEVICE **ReturnListHead)
+{
+ ACPI_HANDLE CurrentDevice;
+ ACPI_HANDLE ParentDevice;
+ ACPI_STATUS Status;
+ ACPI_PCI_DEVICE *ListElement;
+ ACPI_PCI_DEVICE *ListHead = NULL;
+
+
+ /*
+ * Ascend namespace branch until the RootPciDevice is reached, building
+ * a list of device nodes. Loop will exit when either the PCI device is
+ * found, or the root of the namespace is reached.
+ */
+ CurrentDevice = PciRegion;
+ while (1)
+ {
+ Status = AcpiGetParent (CurrentDevice, &ParentDevice);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */
+
+ if (ParentDevice == RootPciDevice)
+ {
+ *ReturnListHead = ListHead;
+ return (AE_OK);
+ }
+
+ ListElement = ACPI_ALLOCATE (sizeof (ACPI_PCI_DEVICE));
+ if (!ListElement)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Put new element at the head of the list */
+
+ ListElement->Next = ListHead;
+ ListElement->Device = ParentDevice;
+ ListHead = ListElement;
+
+ CurrentDevice = ParentDevice;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwProcessPciList
+ *
+ * PARAMETERS: PciId - Initial values for the PCI ID. May be
+ * modified by this function.
+ * ListHead - Device list created by
+ * AcpiHwBuildPciList
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk downward through the PCI device list, getting the device
+ * info for each, via the PCI configuration space and updating
+ * the PCI ID as necessary. Deletes the list during traversal.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwProcessPciList (
+ ACPI_PCI_ID *PciId,
+ ACPI_PCI_DEVICE *ListHead)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PCI_DEVICE *Info;
+ UINT16 BusNumber;
+ BOOLEAN IsBridge = TRUE;
+
+
+ ACPI_FUNCTION_NAME (HwProcessPciList);
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Input PciId: Seg %4.4X Bus %4.4X Dev %4.4X Func %4.4X\n",
+ PciId->Segment, PciId->Bus, PciId->Device, PciId->Function));
+
+ BusNumber = PciId->Bus;
+
+ /*
+ * Descend down the namespace tree, collecting PCI device, function,
+ * and bus numbers. BusNumber is only important for PCI bridges.
+ * Algorithm: As we descend the tree, use the last valid PCI device,
+ * function, and bus numbers that are discovered, and assign them
+ * to the PCI ID for the target device.
+ */
+ Info = ListHead;
+ while (Info)
+ {
+ Status = AcpiHwGetPciDeviceInfo (PciId, Info->Device,
+ &BusNumber, &IsBridge);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Info = Info->Next;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Output PciId: Seg %4.4X Bus %4.4X Dev %4.4X Func %4.4X "
+ "Status %X BusNumber %X IsBridge %X\n",
+ PciId->Segment, PciId->Bus, PciId->Device, PciId->Function,
+ Status, BusNumber, IsBridge));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwDeletePciList
+ *
+ * PARAMETERS: ListHead - Device list created by
+ * AcpiHwBuildPciList
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Free the entire PCI list.
+ *
+ ******************************************************************************/
+
+static void
+AcpiHwDeletePciList (
+ ACPI_PCI_DEVICE *ListHead)
+{
+ ACPI_PCI_DEVICE *Next;
+ ACPI_PCI_DEVICE *Previous;
+
+
+ Next = ListHead;
+ while (Next)
+ {
+ Previous = Next;
+ Next = Previous->Next;
+ ACPI_FREE (Previous);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetPciDeviceInfo
+ *
+ * PARAMETERS: PciId - Initial values for the PCI ID. May be
+ * modified by this function.
+ * PciDevice - Handle for the PCI device object
+ * BusNumber - Where a PCI bridge bus number is returned
+ * IsBridge - Return value, indicates if this PCI
+ * device is a PCI bridge
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get the device info for a single PCI device object. Get the
+ * _ADR (contains PCI device and function numbers), and for PCI
+ * bridge devices, get the bus number from PCI configuration
+ * space.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwGetPciDeviceInfo (
+ ACPI_PCI_ID *PciId,
+ ACPI_HANDLE PciDevice,
+ UINT16 *BusNumber,
+ BOOLEAN *IsBridge)
+{
+ ACPI_STATUS Status;
+ ACPI_OBJECT_TYPE ObjectType;
+ UINT64 ReturnValue;
+ UINT64 PciValue;
+
+
+ /* We only care about objects of type Device */
+
+ Status = AcpiGetType (PciDevice, &ObjectType);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (ObjectType != ACPI_TYPE_DEVICE)
+ {
+ return (AE_OK);
+ }
+
+ /* We need an _ADR. Ignore device if not present */
+
+ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR,
+ PciDevice, &ReturnValue);
+ if (ACPI_FAILURE (Status))
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * From _ADR, get the PCI Device and Function and
+ * update the PCI ID.
+ */
+ PciId->Device = ACPI_HIWORD (ACPI_LODWORD (ReturnValue));
+ PciId->Function = ACPI_LOWORD (ACPI_LODWORD (ReturnValue));
+
+ /*
+ * If the previous device was a bridge, use the previous
+ * device bus number
+ */
+ if (*IsBridge)
+ {
+ PciId->Bus = *BusNumber;
+ }
+
+ /*
+ * Get the bus numbers from PCI Config space:
+ *
+ * First, get the PCI HeaderType
+ */
+ *IsBridge = FALSE;
+ Status = AcpiOsReadPciConfiguration (PciId,
+ PCI_CFG_HEADER_TYPE_REG, &PciValue, 8);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* We only care about bridges (1=PciBridge, 2=CardBusBridge) */
+
+ PciValue &= PCI_HEADER_TYPE_MASK;
+
+ if ((PciValue != PCI_TYPE_BRIDGE) &&
+ (PciValue != PCI_TYPE_CARDBUS_BRIDGE))
+ {
+ return (AE_OK);
+ }
+
+ /* Bridge: Get the Primary BusNumber */
+
+ Status = AcpiOsReadPciConfiguration (PciId,
+ PCI_CFG_PRIMARY_BUS_NUMBER_REG, &PciValue, 8);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ *IsBridge = TRUE;
+ PciId->Bus = (UINT16) PciValue;
+
+ /* Bridge: Get the Secondary BusNumber */
+
+ Status = AcpiOsReadPciConfiguration (PciId,
+ PCI_CFG_SECONDARY_BUS_NUMBER_REG, &PciValue, 8);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ *BusNumber = (UINT16) PciValue;
+ return (AE_OK);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwregs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwregs.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,741 @@
+
+/*******************************************************************************
+ *
+ * Module Name: hwregs - Read/write access functions for the various ACPI
+ * control and status registers.
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __HWREGS_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwregs")
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+
+/* Local Prototypes */
+
+static ACPI_STATUS
+AcpiHwReadMultiple (
+ UINT32 *Value,
+ ACPI_GENERIC_ADDRESS *RegisterA,
+ ACPI_GENERIC_ADDRESS *RegisterB);
+
+static ACPI_STATUS
+AcpiHwWriteMultiple (
+ UINT32 Value,
+ ACPI_GENERIC_ADDRESS *RegisterA,
+ ACPI_GENERIC_ADDRESS *RegisterB);
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwValidateRegister
+ *
+ * PARAMETERS: Reg - GAS register structure
+ * MaxBitWidth - Max BitWidth supported (32 or 64)
+ * Address - Pointer to where the gas->address
+ * is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS
+ * pointer, Address, SpaceId, BitWidth, and BitOffset.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwValidateRegister (
+ ACPI_GENERIC_ADDRESS *Reg,
+ UINT8 MaxBitWidth,
+ UINT64 *Address)
+{
+
+ /* Must have a valid pointer to a GAS structure */
+
+ if (!Reg)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Copy the target address. This handles possible alignment issues.
+ * Address must not be null. A null address also indicates an optional
+ * ACPI register that is not supported, so no error message.
+ */
+ ACPI_MOVE_64_TO_64 (Address, &Reg->Address);
+ if (!(*Address))
+ {
+ return (AE_BAD_ADDRESS);
+ }
+
+ /* Validate the SpaceID */
+
+ if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
+ (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Unsupported address space: 0x%X", Reg->SpaceId));
+ return (AE_SUPPORT);
+ }
+
+ /* Validate the BitWidth */
+
+ if ((Reg->BitWidth != 8) &&
+ (Reg->BitWidth != 16) &&
+ (Reg->BitWidth != 32) &&
+ (Reg->BitWidth != MaxBitWidth))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Unsupported register bit width: 0x%X", Reg->BitWidth));
+ return (AE_SUPPORT);
+ }
+
+ /* Validate the BitOffset. Just a warning for now. */
+
+ if (Reg->BitOffset != 0)
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Unsupported register bit offset: 0x%X", Reg->BitOffset));
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwRead
+ *
+ * PARAMETERS: Value - Where the value is returned
+ * Reg - GAS register structure
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max
+ * version of AcpiRead, used internally since the overhead of
+ * 64-bit values is not needed.
+ *
+ * LIMITATIONS: <These limitations also apply to AcpiHwWrite>
+ * BitWidth must be exactly 8, 16, or 32.
+ * SpaceID must be SystemMemory or SystemIO.
+ * BitOffset and AccessWidth are currently ignored, as there has
+ * not been a need to implement these.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwRead (
+ UINT32 *Value,
+ ACPI_GENERIC_ADDRESS *Reg)
+{
+ UINT64 Address;
+ UINT64 Value64;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME (HwRead);
+
+
+ /* Validate contents of the GAS register */
+
+ Status = AcpiHwValidateRegister (Reg, 32, &Address);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Initialize entire 32-bit return value to zero */
+
+ *Value = 0;
+
+ /*
+ * Two address spaces supported: Memory or IO. PCI_Config is
+ * not supported here because the GAS structure is insufficient
+ */
+ if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+ {
+ Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
+ Address, &Value64, Reg->BitWidth);
+
+ *Value = (UINT32) Value64;
+ }
+ else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
+ {
+ Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
+ Address, Value, Reg->BitWidth);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
+ *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
+ AcpiUtGetRegionName (Reg->SpaceId)));
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwWrite
+ *
+ * PARAMETERS: Value - Value to be written
+ * Reg - GAS register structure
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max
+ * version of AcpiWrite, used internally since the overhead of
+ * 64-bit values is not needed.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwWrite (
+ UINT32 Value,
+ ACPI_GENERIC_ADDRESS *Reg)
+{
+ UINT64 Address;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME (HwWrite);
+
+
+ /* Validate contents of the GAS register */
+
+ Status = AcpiHwValidateRegister (Reg, 32, &Address);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Two address spaces supported: Memory or IO. PCI_Config is
+ * not supported here because the GAS structure is insufficient
+ */
+ if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+ {
+ Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
+ Address, (UINT64) Value, Reg->BitWidth);
+ }
+ else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
+ {
+ Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
+ Address, Value, Reg->BitWidth);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
+ Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
+ AcpiUtGetRegionName (Reg->SpaceId)));
+
+ return (Status);
+}
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwClearAcpiStatus
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Clears all fixed and general purpose status bits
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwClearAcpiStatus (
+ void)
+{
+ ACPI_STATUS Status;
+ ACPI_CPU_FLAGS LockFlags = 0;
+
+
+ ACPI_FUNCTION_TRACE (HwClearAcpiStatus);
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
+ ACPI_BITMASK_ALL_FIXED_STATUS,
+ ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address)));
+
+ LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
+
+ /* Clear the fixed events in PM1 A/B */
+
+ Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
+ ACPI_BITMASK_ALL_FIXED_STATUS);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ /* Clear the GPE Bits in all GPE registers in all GPE blocks */
+
+ Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
+
+UnlockAndExit:
+ AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetBitRegisterInfo
+ *
+ * PARAMETERS: RegisterId - Index of ACPI Register to access
+ *
+ * RETURN: The bitmask to be used when accessing the register
+ *
+ * DESCRIPTION: Map RegisterId into a register bitmask.
+ *
+ ******************************************************************************/
+
+ACPI_BIT_REGISTER_INFO *
+AcpiHwGetBitRegisterInfo (
+ UINT32 RegisterId)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (RegisterId > ACPI_BITREG_MAX)
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: 0x%X", RegisterId));
+ return (NULL);
+ }
+
+ return (&AcpiGbl_BitRegisterInfo[RegisterId]);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwWritePm1Control
+ *
+ * PARAMETERS: Pm1aControl - Value to be written to PM1A control
+ * Pm1bControl - Value to be written to PM1B control
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write the PM1 A/B control registers. These registers are
+ * different than than the PM1 A/B status and enable registers
+ * in that different values can be written to the A/B registers.
+ * Most notably, the SLP_TYP bits can be different, as per the
+ * values returned from the _Sx predefined methods.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwWritePm1Control (
+ UINT32 Pm1aControl,
+ UINT32 Pm1bControl)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwWritePm1Control);
+
+
+ Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (AcpiGbl_FADT.XPm1bControlBlock.Address)
+ {
+ Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock);
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwRegisterRead
+ *
+ * PARAMETERS: RegisterId - ACPI Register ID
+ * ReturnValue - Where the register value is returned
+ *
+ * RETURN: Status and the value read.
+ *
+ * DESCRIPTION: Read from the specified ACPI register
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwRegisterRead (
+ UINT32 RegisterId,
+ UINT32 *ReturnValue)
+{
+ UINT32 Value = 0;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwRegisterRead);
+
+
+ switch (RegisterId)
+ {
+ case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
+
+ Status = AcpiHwReadMultiple (&Value,
+ &AcpiGbl_XPm1aStatus,
+ &AcpiGbl_XPm1bStatus);
+ break;
+
+
+ case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
+
+ Status = AcpiHwReadMultiple (&Value,
+ &AcpiGbl_XPm1aEnable,
+ &AcpiGbl_XPm1bEnable);
+ break;
+
+
+ case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
+
+ Status = AcpiHwReadMultiple (&Value,
+ &AcpiGbl_FADT.XPm1aControlBlock,
+ &AcpiGbl_FADT.XPm1bControlBlock);
+
+ /*
+ * Zero the write-only bits. From the ACPI specification, "Hardware
+ * Write-Only Bits": "Upon reads to registers with write-only bits,
+ * software masks out all write-only bits."
+ */
+ Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS;
+ break;
+
+
+ case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
+
+ Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock);
+ break;
+
+
+ case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
+
+ Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock);
+ break;
+
+
+ case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
+
+ Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8);
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
+ RegisterId));
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ *ReturnValue = Value;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwRegisterWrite
+ *
+ * PARAMETERS: RegisterId - ACPI Register ID
+ * Value - The value to write
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write to the specified ACPI register
+ *
+ * NOTE: In accordance with the ACPI specification, this function automatically
+ * preserves the value of the following bits, meaning that these bits cannot be
+ * changed via this interface:
+ *
+ * PM1_CONTROL[0] = SCI_EN
+ * PM1_CONTROL[9]
+ * PM1_STATUS[11]
+ *
+ * ACPI References:
+ * 1) Hardware Ignored Bits: When software writes to a register with ignored
+ * bit fields, it preserves the ignored bit fields
+ * 2) SCI_EN: OSPM always preserves this bit position
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwRegisterWrite (
+ UINT32 RegisterId,
+ UINT32 Value)
+{
+ ACPI_STATUS Status;
+ UINT32 ReadValue;
+
+
+ ACPI_FUNCTION_TRACE (HwRegisterWrite);
+
+
+ switch (RegisterId)
+ {
+ case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
+ /*
+ * Handle the "ignored" bit in PM1 Status. According to the ACPI
+ * specification, ignored bits are to be preserved when writing.
+ * Normally, this would mean a read/modify/write sequence. However,
+ * preserving a bit in the status register is different. Writing a
+ * one clears the status, and writing a zero preserves the status.
+ * Therefore, we must always write zero to the ignored bit.
+ *
+ * This behavior is clarified in the ACPI 4.0 specification.
+ */
+ Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS;
+
+ Status = AcpiHwWriteMultiple (Value,
+ &AcpiGbl_XPm1aStatus,
+ &AcpiGbl_XPm1bStatus);
+ break;
+
+
+ case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
+
+ Status = AcpiHwWriteMultiple (Value,
+ &AcpiGbl_XPm1aEnable,
+ &AcpiGbl_XPm1bEnable);
+ break;
+
+
+ case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
+
+ /*
+ * Perform a read first to preserve certain bits (per ACPI spec)
+ * Note: This includes SCI_EN, we never want to change this bit
+ */
+ Status = AcpiHwReadMultiple (&ReadValue,
+ &AcpiGbl_FADT.XPm1aControlBlock,
+ &AcpiGbl_FADT.XPm1bControlBlock);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+
+ /* Insert the bits to be preserved */
+
+ ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue);
+
+ /* Now we can write the data */
+
+ Status = AcpiHwWriteMultiple (Value,
+ &AcpiGbl_FADT.XPm1aControlBlock,
+ &AcpiGbl_FADT.XPm1bControlBlock);
+ break;
+
+
+ case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
+
+ /*
+ * For control registers, all reserved bits must be preserved,
+ * as per the ACPI spec.
+ */
+ Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+
+ /* Insert the bits to be preserved */
+
+ ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue);
+
+ Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock);
+ break;
+
+
+ case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
+
+ Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock);
+ break;
+
+
+ case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
+
+ /* SMI_CMD is currently always in IO space */
+
+ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8);
+ break;
+
+
+ default:
+ ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
+ RegisterId));
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+Exit:
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwReadMultiple
+ *
+ * PARAMETERS: Value - Where the register value is returned
+ * RegisterA - First ACPI register (required)
+ * RegisterB - Second ACPI register (optional)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwReadMultiple (
+ UINT32 *Value,
+ ACPI_GENERIC_ADDRESS *RegisterA,
+ ACPI_GENERIC_ADDRESS *RegisterB)
+{
+ UINT32 ValueA = 0;
+ UINT32 ValueB = 0;
+ ACPI_STATUS Status;
+
+
+ /* The first register is always required */
+
+ Status = AcpiHwRead (&ValueA, RegisterA);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Second register is optional */
+
+ if (RegisterB->Address)
+ {
+ Status = AcpiHwRead (&ValueB, RegisterB);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ /*
+ * OR the two return values together. No shifting or masking is necessary,
+ * because of how the PM1 registers are defined in the ACPI specification:
+ *
+ * "Although the bits can be split between the two register blocks (each
+ * register block has a unique pointer within the FADT), the bit positions
+ * are maintained. The register block with unimplemented bits (that is,
+ * those implemented in the other register block) always returns zeros,
+ * and writes have no side effects"
+ */
+ *Value = (ValueA | ValueB);
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwWriteMultiple
+ *
+ * PARAMETERS: Value - The value to write
+ * RegisterA - First ACPI register (required)
+ * RegisterB - Second ACPI register (optional)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwWriteMultiple (
+ UINT32 Value,
+ ACPI_GENERIC_ADDRESS *RegisterA,
+ ACPI_GENERIC_ADDRESS *RegisterB)
+{
+ ACPI_STATUS Status;
+
+
+ /* The first register is always required */
+
+ Status = AcpiHwWrite (Value, RegisterA);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Second register is optional
+ *
+ * No bit shifting or clearing is necessary, because of how the PM1
+ * registers are defined in the ACPI specification:
+ *
+ * "Although the bits can be split between the two register blocks (each
+ * register block has a unique pointer within the FADT), the bit positions
+ * are maintained. The register block with unimplemented bits (that is,
+ * those implemented in the other register block) always returns zeros,
+ * and writes have no side effects"
+ */
+ if (RegisterB->Address)
+ {
+ Status = AcpiHwWrite (Value, RegisterB);
+ }
+
+ return (Status);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwsleep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwsleep.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,398 @@
+/******************************************************************************
+ *
+ * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
+ * original/legacy sleep/PM registers.
+ *
+ *****************************************************************************/
+
+/*
+ * 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>
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwsleep")
+
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwLegacySleep
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwLegacySleep (
+ UINT8 SleepState)
+{
+ ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
+ ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
+ UINT32 Pm1aControl;
+ UINT32 Pm1bControl;
+ UINT32 InValue;
+ UINT32 Retry;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwLegacySleep);
+
+
+ SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE);
+ SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);
+
+ /* Clear wake status */
+
+ Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Clear all fixed and general purpose status bits */
+
+ Status = AcpiHwClearAcpiStatus ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (SleepState != ACPI_STATE_S5)
+ {
+ /*
+ * Disable BM arbitration. This feature is contained within an
+ * optional register (PM2 Control), so ignore a BAD_ADDRESS
+ * exception.
+ */
+ Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1);
+ if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * 1) Disable/Clear all GPEs
+ * 2) Enable all wakeup GPEs
+ */
+ Status = AcpiHwDisableAllGpes ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ AcpiGbl_SystemAwakeAndRunning = FALSE;
+
+ Status = AcpiHwEnableAllWakeupGpes ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Execute the _GTS method (Going To Sleep) */
+
+ AcpiHwExecuteSleepMethod (METHOD_NAME__GTS, SleepState);
+
+ /* Get current value of PM1A control */
+
+ Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL,
+ &Pm1aControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+ "Entering sleep state [S%u]\n", SleepState));
+
+ /* Clear the SLP_EN and SLP_TYP fields */
+
+ Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask |
+ SleepEnableRegInfo->AccessBitMask);
+ Pm1bControl = Pm1aControl;
+
+ /* Insert the SLP_TYP bits */
+
+ Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
+ Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
+
+ /*
+ * We split the writes of SLP_TYP and SLP_EN to workaround
+ * poorly implemented hardware.
+ */
+
+ /* Write #1: write the SLP_TYP data to the PM1 Control registers */
+
+ Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Insert the sleep enable (SLP_EN) bit */
+
+ Pm1aControl |= SleepEnableRegInfo->AccessBitMask;
+ Pm1bControl |= SleepEnableRegInfo->AccessBitMask;
+
+ /* Flush caches, as per ACPI specification */
+
+ ACPI_FLUSH_CPU_CACHE ();
+
+ /* Write #2: Write both SLP_TYP + SLP_EN */
+
+ Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (SleepState > ACPI_STATE_S3)
+ {
+ /*
+ * We wanted to sleep > S3, but it didn't happen (by virtue of the
+ * fact that we are still executing!)
+ *
+ * Wait ten seconds, then try again. This is to get S4/S5 to work on
+ * all machines.
+ *
+ * We wait so long to allow chipsets that poll this reg very slowly
+ * to still read the right value. Ideally, this block would go
+ * away entirely.
+ */
+ AcpiOsStall (10000000);
+
+ Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL,
+ SleepEnableRegInfo->AccessBitMask);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Wait for transition back to Working State */
+
+ Retry = 1000;
+ do
+ {
+ Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (AcpiGbl_EnableInterpreterSlack)
+ {
+ /*
+ * Some BIOSs don't set WAK_STS at all. Give up waiting after
+ * 1000 retries if it still isn't set.
+ */
+ if (Retry-- == 0)
+ {
+ break;
+ }
+ }
+
+ } while (!InValue);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwLegacyWakePrep
+ *
+ * PARAMETERS: SleepState - Which sleep state we just exited
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
+ * sleep.
+ * Called with interrupts ENABLED.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwLegacyWakePrep (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+ ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
+ ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
+ UINT32 Pm1aControl;
+ UINT32 Pm1bControl;
+
+
+ ACPI_FUNCTION_TRACE (HwLegacyWakePrep);
+
+ /*
+ * Set SLP_TYPE and SLP_EN to state S0.
+ * This is unclear from the ACPI Spec, but it is required
+ * by some machines.
+ */
+ Status = AcpiGetSleepTypeData (ACPI_STATE_S0,
+ &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
+ if (ACPI_SUCCESS (Status))
+ {
+ SleepTypeRegInfo =
+ AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE);
+ SleepEnableRegInfo =
+ AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);
+
+ /* Get current value of PM1A control */
+
+ Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL,
+ &Pm1aControl);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Clear the SLP_EN and SLP_TYP fields */
+
+ Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask |
+ SleepEnableRegInfo->AccessBitMask);
+ Pm1bControl = Pm1aControl;
+
+ /* Insert the SLP_TYP bits */
+
+ Pm1aControl |= (AcpiGbl_SleepTypeA <<
+ SleepTypeRegInfo->BitPosition);
+ Pm1bControl |= (AcpiGbl_SleepTypeB <<
+ SleepTypeRegInfo->BitPosition);
+
+ /* Write the control registers and ignore any errors */
+
+ (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
+ }
+ }
+
+ AcpiHwExecuteSleepMethod (METHOD_NAME__BFS, SleepState);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwLegacyWake
+ *
+ * PARAMETERS: SleepState - Which sleep state we just exited
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
+ * Called with interrupts ENABLED.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwLegacyWake (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (HwLegacyWake);
+
+
+ /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
+
+ AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
+ AcpiHwExecuteSleepMethod (METHOD_NAME__SST, ACPI_SST_WAKING);
+
+ /*
+ * GPEs must be enabled before _WAK is called as GPEs
+ * might get fired there
+ *
+ * Restore the GPEs:
+ * 1) Disable/Clear all GPEs
+ * 2) Enable all runtime GPEs
+ */
+ Status = AcpiHwDisableAllGpes ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiHwEnableAllRuntimeGpes ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now we can execute _WAK, etc. Some machines require that the GPEs
+ * are enabled before the wake methods are executed.
+ */
+ AcpiHwExecuteSleepMethod (METHOD_NAME__WAK, SleepState);
+
+ /*
+ * Some BIOS code assumes that WAK_STS will be cleared on resume
+ * and use it to determine whether the system is rebooting or
+ * resuming. Clear WAK_STS for compatibility.
+ */
+ (void) AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
+ AcpiGbl_SystemAwakeAndRunning = TRUE;
+
+ /* Enable power button */
+
+ (void) AcpiWriteBitRegister(
+ AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId,
+ ACPI_ENABLE_EVENT);
+
+ (void) AcpiWriteBitRegister(
+ AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId,
+ ACPI_CLEAR_STATUS);
+
+ /*
+ * Enable BM arbitration. This feature is contained within an
+ * optional register (PM2 Control), so ignore a BAD_ADDRESS
+ * exception.
+ */
+ Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0);
+ if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ AcpiHwExecuteSleepMethod (METHOD_NAME__SST, ACPI_SST_WORKING);
+ return_ACPI_STATUS (Status);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwtimer.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwtimer.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,218 @@
+
+/******************************************************************************
+ *
+ * Name: hwtimer.c - ACPI Power Management Timer Interface
+ *
+ *****************************************************************************/
+
+/*
+ * 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>
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwtimer")
+
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetTimerResolution
+ *
+ * PARAMETERS: Resolution - Where the resolution is returned
+ *
+ * RETURN: Status and timer resolution
+ *
+ * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits).
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTimerResolution (
+ UINT32 *Resolution)
+{
+ ACPI_FUNCTION_TRACE (AcpiGetTimerResolution);
+
+
+ if (!Resolution)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
+ {
+ *Resolution = 24;
+ }
+ else
+ {
+ *Resolution = 32;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetTimerResolution)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetTimer
+ *
+ * PARAMETERS: Ticks - Where the timer value is returned
+ *
+ * RETURN: Status and current timer value (ticks)
+ *
+ * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks).
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTimer (
+ UINT32 *Ticks)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetTimer);
+
+
+ if (!Ticks)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock);
+
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetTimer)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetTimerDuration
+ *
+ * PARAMETERS: StartTicks - Starting timestamp
+ * EndTicks - End timestamp
+ * TimeElapsed - Where the elapsed time is returned
+ *
+ * RETURN: Status and TimeElapsed
+ *
+ * DESCRIPTION: Computes the time elapsed (in microseconds) between two
+ * PM Timer time stamps, taking into account the possibility of
+ * rollovers, the timer resolution, and timer frequency.
+ *
+ * The PM Timer's clock ticks at roughly 3.6 times per
+ * _microsecond_, and its clock continues through Cx state
+ * transitions (unlike many CPU timestamp counters) -- making it
+ * a versatile and accurate timer.
+ *
+ * Note that this function accommodates only a single timer
+ * rollover. Thus for 24-bit timers, this function should only
+ * be used for calculating durations less than ~4.6 seconds
+ * (~20 minutes for 32-bit timers) -- calculations below:
+ *
+ * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec
+ * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTimerDuration (
+ UINT32 StartTicks,
+ UINT32 EndTicks,
+ UINT32 *TimeElapsed)
+{
+ ACPI_STATUS Status;
+ UINT32 DeltaTicks;
+ UINT64 Quotient;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetTimerDuration);
+
+
+ if (!TimeElapsed)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Compute Tick Delta:
+ * Handle (max one) timer rollovers on 24-bit versus 32-bit timers.
+ */
+ if (StartTicks < EndTicks)
+ {
+ DeltaTicks = EndTicks - StartTicks;
+ }
+ else if (StartTicks > EndTicks)
+ {
+ if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
+ {
+ /* 24-bit Timer */
+
+ DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF);
+ }
+ else
+ {
+ /* 32-bit Timer */
+
+ DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks;
+ }
+ }
+ else /* StartTicks == EndTicks */
+ {
+ *TimeElapsed = 0;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Compute Duration (Requires a 64-bit multiply and divide):
+ *
+ * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY;
+ */
+ Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000,
+ PM_TIMER_FREQUENCY, &Quotient, NULL);
+
+ *TimeElapsed = (UINT32) Quotient;
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetTimerDuration)
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwvalid.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwvalid.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,368 @@
+
+/******************************************************************************
+ *
+ * Module Name: hwvalid - I/O request validation
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __HWVALID_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwvalid")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiHwValidateIoRequest (
+ ACPI_IO_ADDRESS Address,
+ UINT32 BitWidth);
+
+
+/*
+ * Protected I/O ports. Some ports are always illegal, and some are
+ * conditionally illegal. This table must remain ordered by port address.
+ *
+ * The table is used to implement the Microsoft port access rules that
+ * first appeared in Windows XP. Some ports are always illegal, and some
+ * ports are only illegal if the BIOS calls _OSI with a WinXP string or
+ * later (meaning that the BIOS itelf is post-XP.)
+ *
+ * This provides ACPICA with the desired port protections and
+ * Microsoft compatibility.
+ *
+ * Description of port entries:
+ * DMA: DMA controller
+ * PIC0: Programmable Interrupt Controller (8259A)
+ * PIT1: System Timer 1
+ * PIT2: System Timer 2 failsafe
+ * RTC: Real-time clock
+ * CMOS: Extended CMOS
+ * DMA1: DMA 1 page registers
+ * DMA1L: DMA 1 Ch 0 low page
+ * DMA2: DMA 2 page registers
+ * DMA2L: DMA 2 low page refresh
+ * ARBC: Arbitration control
+ * SETUP: Reserved system board setup
+ * POS: POS channel select
+ * PIC1: Cascaded PIC
+ * IDMA: ISA DMA
+ * ELCR: PIC edge/level registers
+ * PCI: PCI configuration space
+ */
+static const ACPI_PORT_INFO AcpiProtectedPorts[] =
+{
+ {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP},
+ {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL},
+ {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP},
+ {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP},
+ {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP},
+ {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP},
+ {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP},
+ {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP},
+ {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP},
+ {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP},
+ {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP},
+ {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP},
+ {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP},
+ {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL},
+ {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP},
+ {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL},
+ {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP}
+};
+
+#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwValidateIoRequest
+ *
+ * PARAMETERS: Address Address of I/O port/register
+ * BitWidth Number of bits (8,16,32)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Validates an I/O request (address/length). Certain ports are
+ * always illegal and some ports are only illegal depending on
+ * the requests the BIOS AML code makes to the predefined
+ * _OSI method.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwValidateIoRequest (
+ ACPI_IO_ADDRESS Address,
+ UINT32 BitWidth)
+{
+ UINT32 i;
+ UINT32 ByteWidth;
+ ACPI_IO_ADDRESS LastAddress;
+ const ACPI_PORT_INFO *PortInfo;
+
+
+ ACPI_FUNCTION_TRACE (HwValidateIoRequest);
+
+
+ /* Supported widths are 8/16/32 */
+
+ if ((BitWidth != 8) &&
+ (BitWidth != 16) &&
+ (BitWidth != 32))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Bad BitWidth parameter: %8.8X", BitWidth));
+ return (AE_BAD_PARAMETER);
+ }
+
+ PortInfo = AcpiProtectedPorts;
+ ByteWidth = ACPI_DIV_8 (BitWidth);
+ LastAddress = Address + ByteWidth - 1;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X",
+ ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress),
+ ByteWidth));
+
+ /* Maximum 16-bit address in I/O space */
+
+ if (LastAddress > ACPI_UINT16_MAX)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Illegal I/O port address/length above 64K: %p/0x%X",
+ ACPI_CAST_PTR (void, Address), ByteWidth));
+ return_ACPI_STATUS (AE_LIMIT);
+ }
+
+ /* Exit if requested address is not within the protected port table */
+
+ if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Check request against the list of protected I/O ports */
+
+ for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++)
+ {
+ /*
+ * Check if the requested address range will write to a reserved
+ * port. Four cases to consider:
+ *
+ * 1) Address range is contained completely in the port address range
+ * 2) Address range overlaps port range at the port range start
+ * 3) Address range overlaps port range at the port range end
+ * 4) Address range completely encompasses the port range
+ */
+ if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start))
+ {
+ /* Port illegality may depend on the _OSI calls made by the BIOS */
+
+ if (AcpiGbl_OsiData >= PortInfo->OsiDependency)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)",
+ ACPI_CAST_PTR (void, Address), ByteWidth, PortInfo->Name,
+ PortInfo->Start, PortInfo->End));
+
+ return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS);
+ }
+ }
+
+ /* Finished if address range ends before the end of this port */
+
+ if (LastAddress <= PortInfo->End)
+ {
+ break;
+ }
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwReadPort
+ *
+ * PARAMETERS: Address Address of I/O port/register to read
+ * Value Where value is placed
+ * Width Number of bits
+ *
+ * RETURN: Status and value read from port
+ *
+ * DESCRIPTION: Read data from an I/O port or register. This is a front-end
+ * to AcpiOsReadPort that performs validation on both the port
+ * address and the length.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiHwReadPort (
+ ACPI_IO_ADDRESS Address,
+ UINT32 *Value,
+ UINT32 Width)
+{
+ ACPI_STATUS Status;
+ UINT32 OneByte;
+ UINT32 i;
+
+
+ /* Truncate address to 16 bits if requested */
+
+ if (AcpiGbl_TruncateIoAddresses)
+ {
+ Address &= ACPI_UINT16_MAX;
+ }
+
+ /* Validate the entire request and perform the I/O */
+
+ Status = AcpiHwValidateIoRequest (Address, Width);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiOsReadPort (Address, Value, Width);
+ return (Status);
+ }
+
+ if (Status != AE_AML_ILLEGAL_ADDRESS)
+ {
+ return (Status);
+ }
+
+ /*
+ * There has been a protection violation within the request. Fall
+ * back to byte granularity port I/O and ignore the failing bytes.
+ * This provides Windows compatibility.
+ */
+ for (i = 0, *Value = 0; i < Width; i += 8)
+ {
+ /* Validate and read one byte */
+
+ if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
+ {
+ Status = AcpiOsReadPort (Address, &OneByte, 8);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ *Value |= (OneByte << i);
+ }
+
+ Address++;
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwWritePort
+ *
+ * PARAMETERS: Address Address of I/O port/register to write
+ * Value Value to write
+ * Width Number of bits
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write data to an I/O port or register. This is a front-end
+ * to AcpiOsWritePort that performs validation on both the port
+ * address and the length.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiHwWritePort (
+ ACPI_IO_ADDRESS Address,
+ UINT32 Value,
+ UINT32 Width)
+{
+ ACPI_STATUS Status;
+ UINT32 i;
+
+
+ /* Truncate address to 16 bits if requested */
+
+ if (AcpiGbl_TruncateIoAddresses)
+ {
+ Address &= ACPI_UINT16_MAX;
+ }
+
+ /* Validate the entire request and perform the I/O */
+
+ Status = AcpiHwValidateIoRequest (Address, Width);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiOsWritePort (Address, Value, Width);
+ return (Status);
+ }
+
+ if (Status != AE_AML_ILLEGAL_ADDRESS)
+ {
+ return (Status);
+ }
+
+ /*
+ * There has been a protection violation within the request. Fall
+ * back to byte granularity port I/O and ignore the failing bytes.
+ * This provides Windows compatibility.
+ */
+ for (i = 0; i < Width; i += 8)
+ {
+ /* Validate and write one byte */
+
+ if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
+ {
+ Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ Address++;
+ }
+
+ return (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwxface.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwxface.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,617 @@
+
+/******************************************************************************
+ *
+ * Module Name: hwxface - Public ACPICA hardware 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/acnamesp.h>
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwxface")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiReset
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
+ * support reset register in PCI config space, this must be
+ * handled separately.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiReset (
+ void)
+{
+ ACPI_GENERIC_ADDRESS *ResetReg;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiReset);
+
+
+ ResetReg = &AcpiGbl_FADT.ResetRegister;
+
+ /* Check if the reset register is supported */
+
+ if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) ||
+ !ResetReg->Address)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO)
+ {
+ /*
+ * For I/O space, write directly to the OSL. This bypasses the port
+ * validation mechanism, which may block a valid write to the reset
+ * register.
+ */
+ Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address,
+ AcpiGbl_FADT.ResetValue, ResetReg->BitWidth);
+ }
+ else
+ {
+ /* Write the reset value to the reset register */
+
+ Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiReset)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiRead
+ *
+ * PARAMETERS: Value - Where the value is returned
+ * Reg - GAS register structure
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read from either memory or IO space.
+ *
+ * LIMITATIONS: <These limitations also apply to AcpiWrite>
+ * BitWidth must be exactly 8, 16, 32, or 64.
+ * SpaceID must be SystemMemory or SystemIO.
+ * BitOffset and AccessWidth are currently ignored, as there has
+ * not been a need to implement these.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRead (
+ UINT64 *ReturnValue,
+ ACPI_GENERIC_ADDRESS *Reg)
+{
+ UINT32 Value;
+ UINT32 Width;
+ UINT64 Address;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME (AcpiRead);
+
+
+ if (!ReturnValue)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Validate contents of the GAS register. Allow 64-bit transfers */
+
+ Status = AcpiHwValidateRegister (Reg, 64, &Address);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Initialize entire 64-bit return value to zero */
+
+ *ReturnValue = 0;
+ Value = 0;
+
+ /*
+ * Two address spaces supported: Memory or IO. PCI_Config is
+ * not supported here because the GAS structure is insufficient
+ */
+ if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+ {
+ Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
+ Address, ReturnValue, Reg->BitWidth);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
+ {
+ Width = Reg->BitWidth;
+ if (Width == 64)
+ {
+ Width = 32; /* Break into two 32-bit transfers */
+ }
+
+ Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
+ Address, &Value, Width);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ *ReturnValue = Value;
+
+ if (Reg->BitWidth == 64)
+ {
+ /* Read the top 32 bits */
+
+ Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
+ (Address + 4), &Value, 32);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ *ReturnValue |= ((UINT64) Value << 32);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n",
+ ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth,
+ ACPI_FORMAT_UINT64 (Address),
+ AcpiUtGetRegionName (Reg->SpaceId)));
+
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRead)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiWrite
+ *
+ * PARAMETERS: Value - Value to be written
+ * Reg - GAS register structure
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Write to either memory or IO space.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiWrite (
+ UINT64 Value,
+ ACPI_GENERIC_ADDRESS *Reg)
+{
+ UINT32 Width;
+ UINT64 Address;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME (AcpiWrite);
+
+
+ /* Validate contents of the GAS register. Allow 64-bit transfers */
+
+ Status = AcpiHwValidateRegister (Reg, 64, &Address);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Two address spaces supported: Memory or IO. PCI_Config is
+ * not supported here because the GAS structure is insufficient
+ */
+ if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+ {
+ Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
+ Address, Value, Reg->BitWidth);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
+ {
+ Width = Reg->BitWidth;
+ if (Width == 64)
+ {
+ Width = 32; /* Break into two 32-bit transfers */
+ }
+
+ Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
+ Address, ACPI_LODWORD (Value), Width);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (Reg->BitWidth == 64)
+ {
+ Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
+ (Address + 4), ACPI_HIDWORD (Value), 32);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n",
+ ACPI_FORMAT_UINT64 (Value), Reg->BitWidth,
+ ACPI_FORMAT_UINT64 (Address),
+ AcpiUtGetRegionName (Reg->SpaceId)));
+
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiWrite)
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiReadBitRegister
+ *
+ * PARAMETERS: RegisterId - ID of ACPI Bit Register to access
+ * ReturnValue - Value that was read from the register,
+ * normalized to bit position zero.
+ *
+ * RETURN: Status and the value read from the specified Register. Value
+ * returned is normalized to bit0 (is shifted all the way right)
+ *
+ * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock.
+ *
+ * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
+ * PM2 Control.
+ *
+ * Note: The hardware lock is not required when reading the ACPI bit registers
+ * since almost all of them are single bit and it does not matter that
+ * the parent hardware register can be split across two physical
+ * registers. The only multi-bit field is SLP_TYP in the PM1 control
+ * register, but this field does not cross an 8-bit boundary (nor does
+ * it make much sense to actually read this field.)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiReadBitRegister (
+ UINT32 RegisterId,
+ UINT32 *ReturnValue)
+{
+ ACPI_BIT_REGISTER_INFO *BitRegInfo;
+ UINT32 RegisterValue;
+ UINT32 Value;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId);
+
+
+ /* Get the info structure corresponding to the requested ACPI Register */
+
+ BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
+ if (!BitRegInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Read the entire parent register */
+
+ Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
+ &RegisterValue);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Normalize the value that was read, mask off other bits */
+
+ Value = ((RegisterValue & BitRegInfo->AccessBitMask)
+ >> BitRegInfo->BitPosition);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
+ RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
+
+ *ReturnValue = Value;
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiReadBitRegister)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiWriteBitRegister
+ *
+ * PARAMETERS: RegisterId - ID of ACPI Bit Register to access
+ * Value - Value to write to the register, in bit
+ * position zero. The bit is automaticallly
+ * shifted to the correct position.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
+ * since most operations require a read/modify/write sequence.
+ *
+ * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
+ * PM2 Control.
+ *
+ * Note that at this level, the fact that there may be actually two
+ * hardware registers (A and B - and B may not exist) is abstracted.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiWriteBitRegister (
+ UINT32 RegisterId,
+ UINT32 Value)
+{
+ ACPI_BIT_REGISTER_INFO *BitRegInfo;
+ ACPI_CPU_FLAGS LockFlags;
+ UINT32 RegisterValue;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId);
+
+
+ /* Get the info structure corresponding to the requested ACPI Register */
+
+ BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
+ if (!BitRegInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
+
+ /*
+ * At this point, we know that the parent register is one of the
+ * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
+ */
+ if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS)
+ {
+ /*
+ * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
+ *
+ * Perform a register read to preserve the bits that we are not
+ * interested in
+ */
+ Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
+ &RegisterValue);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ /*
+ * Insert the input bit into the value that was just read
+ * and write the register
+ */
+ ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
+ BitRegInfo->AccessBitMask, Value);
+
+ Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister,
+ RegisterValue);
+ }
+ else
+ {
+ /*
+ * 2) Case for PM1 Status
+ *
+ * The Status register is different from the rest. Clear an event
+ * by writing 1, writing 0 has no effect. So, the only relevant
+ * information is the single bit we're interested in, all others
+ * should be written as 0 so they will be left unchanged.
+ */
+ RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value,
+ BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
+
+ /* No need to write the register if value is all zeros */
+
+ if (RegisterValue)
+ {
+ Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
+ RegisterValue);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
+ RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue));
+
+
+UnlockAndExit:
+
+ AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister)
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetSleepTypeData
+ *
+ * PARAMETERS: SleepState - Numeric sleep state
+ * *SleepTypeA - Where SLP_TYPa is returned
+ * *SleepTypeB - Where SLP_TYPb is returned
+ *
+ * RETURN: Status - ACPI status
+ *
+ * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
+ * state.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetSleepTypeData (
+ UINT8 SleepState,
+ UINT8 *SleepTypeA,
+ UINT8 *SleepTypeB)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_EVALUATE_INFO *Info;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData);
+
+
+ /* Validate parameters */
+
+ if ((SleepState > ACPI_S_STATES_MAX) ||
+ !SleepTypeA ||
+ !SleepTypeB)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Allocate the evaluation information block */
+
+ Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
+ if (!Info)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]);
+
+ /* Evaluate the namespace object containing the values for this state */
+
+ Status = AcpiNsEvaluate (Info);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "%s while evaluating SleepState [%s]\n",
+ AcpiFormatException (Status), Info->Pathname));
+
+ goto Cleanup;
+ }
+
+ /* Must have a return object */
+
+ if (!Info->ReturnObject)
+ {
+ ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]",
+ Info->Pathname));
+ Status = AE_NOT_EXIST;
+ }
+
+ /* It must be of type Package */
+
+ else if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
+ {
+ ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package"));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+
+ /*
+ * The package must have at least two elements. NOTE (March 2005): This
+ * goes against the current ACPI spec which defines this object as a
+ * package with one encoded DWORD element. However, existing practice
+ * by BIOS vendors seems to be to have 2 or more elements, at least
+ * one per sleep type (A/B).
+ */
+ else if (Info->ReturnObject->Package.Count < 2)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Sleep State return package does not have at least two elements"));
+ Status = AE_AML_NO_OPERAND;
+ }
+
+ /* The first two elements must both be of type Integer */
+
+ else if (((Info->ReturnObject->Package.Elements[0])->Common.Type
+ != ACPI_TYPE_INTEGER) ||
+ ((Info->ReturnObject->Package.Elements[1])->Common.Type
+ != ACPI_TYPE_INTEGER))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Sleep State return package elements are not both Integers "
+ "(%s, %s)",
+ AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]),
+ AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1])));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ else
+ {
+ /* Valid _Sx_ package size, type, and value */
+
+ *SleepTypeA = (UINT8)
+ (Info->ReturnObject->Package.Elements[0])->Integer.Value;
+ *SleepTypeB = (UINT8)
+ (Info->ReturnObject->Package.Elements[1])->Integer.Value;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "While evaluating SleepState [%s], bad Sleep object %p type %s",
+ Info->Pathname, Info->ReturnObject,
+ AcpiUtGetObjectTypeName (Info->ReturnObject)));
+ }
+
+ AcpiUtRemoveReference (Info->ReturnObject);
+
+Cleanup:
+ ACPI_FREE (Info);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,474 @@
+/******************************************************************************
+ *
+ * Name: hwxfsleep.c - ACPI Hardware Sleep/Wake 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>
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwxfsleep")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiHwSleepDispatch (
+ UINT8 SleepState,
+ UINT32 FunctionId);
+
+/*
+ * Dispatch table used to efficiently branch to the various sleep
+ * functions.
+ */
+#define ACPI_SLEEP_FUNCTION_ID 0
+#define ACPI_WAKE_PREP_FUNCTION_ID 1
+#define ACPI_WAKE_FUNCTION_ID 2
+
+/* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
+
+static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[] =
+{
+ {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacySleep), AcpiHwExtendedSleep},
+ {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWakePrep), AcpiHwExtendedWakePrep},
+ {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWake), AcpiHwExtendedWake}
+};
+
+
+/*
+ * These functions are removed for the ACPI_REDUCED_HARDWARE case:
+ * AcpiSetFirmwareWakingVector
+ * AcpiSetFirmwareWakingVector64
+ * AcpiEnterSleepStateS4bios
+ */
+
+#if (!ACPI_REDUCED_HARDWARE)
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSetFirmwareWakingVector
+ *
+ * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode
+ * entry point.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetFirmwareWakingVector (
+ UINT32 PhysicalAddress)
+{
+ ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector);
+
+
+ /* Set the 32-bit vector */
+
+ AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress;
+
+ /* Clear the 64-bit vector if it exists */
+
+ if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1))
+ {
+ AcpiGbl_FACS->XFirmwareWakingVector = 0;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector)
+
+
+#if ACPI_MACHINE_WIDTH == 64
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSetFirmwareWakingVector64
+ *
+ * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected
+ * mode entry point.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if
+ * it exists in the table. This function is intended for use with
+ * 64-bit host operating systems.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetFirmwareWakingVector64 (
+ UINT64 PhysicalAddress)
+{
+ ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64);
+
+
+ /* Determine if the 64-bit vector actually exists */
+
+ if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1))
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /* Clear 32-bit vector, set the 64-bit X_ vector */
+
+ AcpiGbl_FACS->FirmwareWakingVector = 0;
+ AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress;
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64)
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepStateS4bios
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform a S4 bios request.
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepStateS4bios (
+ void)
+{
+ UINT32 InValue;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios);
+
+
+ /* Clear the wake status bit (PM1) */
+
+ Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiHwClearAcpiStatus ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * 1) Disable/Clear all GPEs
+ * 2) Enable all wakeup GPEs
+ */
+ Status = AcpiHwDisableAllGpes ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ AcpiGbl_SystemAwakeAndRunning = FALSE;
+
+ Status = AcpiHwEnableAllWakeupGpes ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_FLUSH_CPU_CACHE ();
+
+ Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
+ (UINT32) AcpiGbl_FADT.S4BiosRequest, 8);
+
+ do {
+ AcpiOsStall(1000);
+ Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ } while (!InValue);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios)
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwSleepDispatch
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter/exit
+ * FunctionId - Sleep, WakePrep, or Wake
+ *
+ * RETURN: Status from the invoked sleep handling function.
+ *
+ * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling
+ * function.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiHwSleepDispatch (
+ UINT8 SleepState,
+ UINT32 FunctionId)
+{
+ ACPI_STATUS Status;
+ ACPI_SLEEP_FUNCTIONS *SleepFunctions = &AcpiSleepDispatch[FunctionId];
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+
+ /*
+ * If the Hardware Reduced flag is set (from the FADT), we must
+ * use the extended sleep registers
+ */
+ if (AcpiGbl_ReducedHardware ||
+ AcpiGbl_FADT.SleepControl.Address)
+ {
+ Status = SleepFunctions->ExtendedFunction (SleepState);
+ }
+ else
+ {
+ /* Legacy sleep */
+
+ Status = SleepFunctions->LegacyFunction (SleepState);
+ }
+
+ return (Status);
+
+#else
+ /*
+ * For the case where reduced-hardware-only code is being generated,
+ * we know that only the extended sleep registers are available
+ */
+ Status = SleepFunctions->ExtendedFunction (SleepState);
+ return (Status);
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepStatePrep
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Prepare to enter a system sleep state.
+ * This function must execute with interrupts enabled.
+ * We break sleeping into 2 stages so that OSPM can handle
+ * various OS-specific tasks between the two steps.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepStatePrep (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+ ACPI_OBJECT_LIST ArgList;
+ ACPI_OBJECT Arg;
+ UINT32 SstValue;
+
+
+ ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep);
+
+
+ /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */
+
+ Status = AcpiGetSleepTypeData (SleepState,
+ &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Execute the _PTS method (Prepare To Sleep) */
+
+ ArgList.Count = 1;
+ ArgList.Pointer = &Arg;
+ Arg.Type = ACPI_TYPE_INTEGER;
+ Arg.Integer.Value = SleepState;
+
+ Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL);
+ if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Setup the argument to the _SST method (System STatus) */
+
+ switch (SleepState)
+ {
+ case ACPI_STATE_S0:
+ SstValue = ACPI_SST_WORKING;
+ break;
+
+ case ACPI_STATE_S1:
+ case ACPI_STATE_S2:
+ case ACPI_STATE_S3:
+ SstValue = ACPI_SST_SLEEPING;
+ break;
+
+ case ACPI_STATE_S4:
+ SstValue = ACPI_SST_SLEEP_CONTEXT;
+ break;
+
+ default:
+ SstValue = ACPI_SST_INDICATOR_OFF; /* Default is off */
+ break;
+ }
+
+ /*
+ * Set the system indicators to show the desired sleep state.
+ * _SST is an optional method (return no error if not found)
+ */
+ AcpiHwExecuteSleepMethod (METHOD_NAME__SST, SstValue);
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepState
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter a system sleep state
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepState (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiEnterSleepState);
+
+
+ if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) ||
+ (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX))
+ {
+ ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
+ AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+ Status = AcpiHwSleepDispatch (SleepState, ACPI_SLEEP_FUNCTION_ID);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnterSleepState)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiLeaveSleepStatePrep
+ *
+ * PARAMETERS: SleepState - Which sleep state we are exiting
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
+ * sleep. Called with interrupts DISABLED.
+ * We break wake/resume into 2 stages so that OSPM can handle
+ * various OS-specific tasks between the two steps.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiLeaveSleepStatePrep (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiLeaveSleepStatePrep);
+
+
+ Status = AcpiHwSleepDispatch (SleepState, ACPI_WAKE_PREP_FUNCTION_ID);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiLeaveSleepStatePrep)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiLeaveSleepState
+ *
+ * PARAMETERS: SleepState - Which sleep state we are exiting
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
+ * Called with interrupts ENABLED.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiLeaveSleepState (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiLeaveSleepState);
+
+
+ Status = AcpiHwSleepDispatch (SleepState, ACPI_WAKE_FUNCTION_ID);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsaccess.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsaccess.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,700 @@
+/*******************************************************************************
+ *
+ * Module Name: nsaccess - Top-level functions for accessing 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.
+ */
+
+#define __NSACCESS_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/acnamesp.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsaccess")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsRootInitialize
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Allocate and initialize the default root named objects
+ *
+ * MUTEX: Locks namespace for entire execution
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsRootInitialize (
+ void)
+{
+ ACPI_STATUS Status;
+ const ACPI_PREDEFINED_NAMES *InitVal = NULL;
+ ACPI_NAMESPACE_NODE *NewNode;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STRING Val = NULL;
+
+
+ ACPI_FUNCTION_TRACE (NsRootInitialize);
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The global root ptr is initially NULL, so a non-NULL value indicates
+ * that AcpiNsRootInitialize() has already been called; just return.
+ */
+ if (AcpiGbl_RootNode)
+ {
+ Status = AE_OK;
+ goto UnlockAndExit;
+ }
+
+ /*
+ * Tell the rest of the subsystem that the root is initialized
+ * (This is OK because the namespace is locked)
+ */
+ AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
+
+ /* Enter the pre-defined names in the name table */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Entering predefined entries into namespace\n"));
+
+ for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
+ {
+ /* _OSI is optional for now, will be permanent later */
+
+ if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
+ {
+ continue;
+ }
+
+ Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type,
+ ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,
+ NULL, &NewNode);
+
+ if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not create predefined name %s",
+ InitVal->Name));
+ }
+
+ /*
+ * Name entered successfully. If entry in PreDefinedNames[] specifies
+ * an initial value, create the initial value.
+ */
+ if (InitVal->Val)
+ {
+ Status = AcpiOsPredefinedOverride (InitVal, &Val);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not override predefined %s",
+ InitVal->Name));
+ }
+
+ if (!Val)
+ {
+ Val = InitVal->Val;
+ }
+
+ /*
+ * Entry requests an initial value, allocate a
+ * descriptor for it.
+ */
+ ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
+ if (!ObjDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto UnlockAndExit;
+ }
+
+ /*
+ * Convert value string from table entry to
+ * internal representation. Only types actually
+ * used for initial values are implemented here.
+ */
+ switch (InitVal->Type)
+ {
+ case ACPI_TYPE_METHOD:
+ ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
+ ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
+
+#if defined (ACPI_ASL_COMPILER)
+
+ /* Save the parameter count for the iASL compiler */
+
+ NewNode->Value = ObjDesc->Method.ParamCount;
+#else
+ /* Mark this as a very SPECIAL method */
+
+ ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
+ ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
+#endif
+ break;
+
+ case ACPI_TYPE_INTEGER:
+
+ ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ /* Build an object around the static string */
+
+ ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val);
+ ObjDesc->String.Pointer = Val;
+ ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
+ break;
+
+
+ case ACPI_TYPE_MUTEX:
+
+ ObjDesc->Mutex.Node = NewNode;
+ ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
+
+ /* Create a mutex */
+
+ Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ goto UnlockAndExit;
+ }
+
+ /* Special case for ACPI Global Lock */
+
+ if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
+ {
+ AcpiGbl_GlobalLockMutex = ObjDesc;
+
+ /* Create additional counting semaphore for global lock */
+
+ Status = AcpiOsCreateSemaphore (
+ 1, 0, &AcpiGbl_GlobalLockSemaphore);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ goto UnlockAndExit;
+ }
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
+ InitVal->Type));
+ AcpiUtRemoveReference (ObjDesc);
+ ObjDesc = NULL;
+ continue;
+ }
+
+ /* Store pointer to value descriptor in the Node */
+
+ Status = AcpiNsAttachObject (NewNode, ObjDesc,
+ ObjDesc->Common.Type);
+
+ /* Remove local reference to the object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ }
+
+
+UnlockAndExit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+ /* Save a handle to "_GPE", it is always present */
+
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
+ &AcpiGbl_FadtGpeDevice);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsLookup
+ *
+ * PARAMETERS: ScopeInfo - Current scope info block
+ * Pathname - Search pathname, in internal format
+ * (as represented in the AML stream)
+ * Type - Type associated with name
+ * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found
+ * Flags - Flags describing the search restrictions
+ * WalkState - Current state of the walk
+ * ReturnNode - Where the Node is placed (if found
+ * or created successfully)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Find or enter the passed name in the name space.
+ * Log an error if name not found in Exec mode.
+ *
+ * MUTEX: Assumes namespace is locked.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsLookup (
+ ACPI_GENERIC_STATE *ScopeInfo,
+ char *Pathname,
+ ACPI_OBJECT_TYPE Type,
+ ACPI_INTERPRETER_MODE InterpreterMode,
+ UINT32 Flags,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_STATUS Status;
+ char *Path = Pathname;
+ ACPI_NAMESPACE_NODE *PrefixNode;
+ ACPI_NAMESPACE_NODE *CurrentNode = NULL;
+ ACPI_NAMESPACE_NODE *ThisNode = NULL;
+ UINT32 NumSegments;
+ UINT32 NumCarats;
+ ACPI_NAME SimpleName;
+ ACPI_OBJECT_TYPE TypeToCheckFor;
+ ACPI_OBJECT_TYPE ThisSearchType;
+ UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT;
+ UINT32 LocalFlags;
+
+
+ ACPI_FUNCTION_TRACE (NsLookup);
+
+
+ if (!ReturnNode)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT);
+ *ReturnNode = ACPI_ENTRY_NOT_FOUND;
+ AcpiGbl_NsLookupCount++;
+
+ if (!AcpiGbl_RootNode)
+ {
+ return_ACPI_STATUS (AE_NO_NAMESPACE);
+ }
+
+ /* Get the prefix scope. A null scope means use the root scope */
+
+ if ((!ScopeInfo) ||
+ (!ScopeInfo->Scope.Node))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Null scope prefix, using root node (%p)\n",
+ AcpiGbl_RootNode));
+
+ PrefixNode = AcpiGbl_RootNode;
+ }
+ else
+ {
+ PrefixNode = ScopeInfo->Scope.Node;
+ if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]",
+ PrefixNode, AcpiUtGetDescriptorName (PrefixNode)));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE))
+ {
+ /*
+ * This node might not be a actual "scope" node (such as a
+ * Device/Method, etc.) It could be a Package or other object
+ * node. Backup up the tree to find the containing scope node.
+ */
+ while (!AcpiNsOpensScope (PrefixNode->Type) &&
+ PrefixNode->Type != ACPI_TYPE_ANY)
+ {
+ PrefixNode = PrefixNode->Parent;
+ }
+ }
+ }
+
+ /* Save type. TBD: may be no longer necessary */
+
+ TypeToCheckFor = Type;
+
+ /*
+ * Begin examination of the actual pathname
+ */
+ if (!Pathname)
+ {
+ /* A Null NamePath is allowed and refers to the root */
+
+ NumSegments = 0;
+ ThisNode = AcpiGbl_RootNode;
+ Path = "";
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Null Pathname (Zero segments), Flags=%X\n", Flags));
+ }
+ else
+ {
+ /*
+ * Name pointer is valid (and must be in internal name format)
+ *
+ * Check for scope prefixes:
+ *
+ * As represented in the AML stream, a namepath consists of an
+ * optional scope prefix followed by a name segment part.
+ *
+ * If present, the scope prefix is either a Root Prefix (in
+ * which case the name is fully qualified), or one or more
+ * Parent Prefixes (in which case the name's scope is relative
+ * to the current scope).
+ */
+ if (*Path == (UINT8) AML_ROOT_PREFIX)
+ {
+ /* Pathname is fully qualified, start from the root */
+
+ ThisNode = AcpiGbl_RootNode;
+ SearchParentFlag = ACPI_NS_NO_UPSEARCH;
+
+ /* Point to name segment part */
+
+ Path++;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Path is absolute from root [%p]\n", ThisNode));
+ }
+ else
+ {
+ /* Pathname is relative to current scope, start there */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Searching relative to prefix scope [%4.4s] (%p)\n",
+ AcpiUtGetNodeName (PrefixNode), PrefixNode));
+
+ /*
+ * Handle multiple Parent Prefixes (carat) by just getting
+ * the parent node for each prefix instance.
+ */
+ ThisNode = PrefixNode;
+ NumCarats = 0;
+ while (*Path == (UINT8) AML_PARENT_PREFIX)
+ {
+ /* Name is fully qualified, no search rules apply */
+
+ SearchParentFlag = ACPI_NS_NO_UPSEARCH;
+
+ /*
+ * Point past this prefix to the name segment
+ * part or the next Parent Prefix
+ */
+ Path++;
+
+ /* Backup to the parent node */
+
+ NumCarats++;
+ ThisNode = ThisNode->Parent;
+ if (!ThisNode)
+ {
+ /* Current scope has no parent scope */
+
+ ACPI_ERROR ((AE_INFO,
+ "ACPI path has too many parent prefixes (^) "
+ "- reached beyond root node"));
+ return_ACPI_STATUS (AE_NOT_FOUND);
+ }
+ }
+
+ if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Search scope is [%4.4s], path has %u carat(s)\n",
+ AcpiUtGetNodeName (ThisNode), NumCarats));
+ }
+ }
+
+ /*
+ * Determine the number of ACPI name segments in this pathname.
+ *
+ * The segment part consists of either:
+ * - A Null name segment (0)
+ * - A DualNamePrefix followed by two 4-byte name segments
+ * - A MultiNamePrefix followed by a byte indicating the
+ * number of segments and the segments themselves.
+ * - A single 4-byte name segment
+ *
+ * Examine the name prefix opcode, if any, to determine the number of
+ * segments.
+ */
+ switch (*Path)
+ {
+ case 0:
+ /*
+ * Null name after a root or parent prefixes. We already
+ * have the correct target node and there are no name segments.
+ */
+ NumSegments = 0;
+ Type = ThisNode->Type;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Prefix-only Pathname (Zero name segments), Flags=%X\n",
+ Flags));
+ break;
+
+ case AML_DUAL_NAME_PREFIX:
+
+ /* More than one NameSeg, search rules do not apply */
+
+ SearchParentFlag = ACPI_NS_NO_UPSEARCH;
+
+ /* Two segments, point to first name segment */
+
+ NumSegments = 2;
+ Path++;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Dual Pathname (2 segments, Flags=%X)\n", Flags));
+ break;
+
+ case AML_MULTI_NAME_PREFIX_OP:
+
+ /* More than one NameSeg, search rules do not apply */
+
+ SearchParentFlag = ACPI_NS_NO_UPSEARCH;
+
+ /* Extract segment count, point to first name segment */
+
+ Path++;
+ NumSegments = (UINT32) (UINT8) *Path;
+ Path++;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Multi Pathname (%u Segments, Flags=%X)\n",
+ NumSegments, Flags));
+ break;
+
+ default:
+ /*
+ * Not a Null name, no Dual or Multi prefix, hence there is
+ * only one name segment and Pathname is already pointing to it.
+ */
+ NumSegments = 1;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Simple Pathname (1 segment, Flags=%X)\n", Flags));
+ break;
+ }
+
+ ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path));
+ }
+
+
+ /*
+ * Search namespace for each segment of the name. Loop through and
+ * verify (or add to the namespace) each name segment.
+ *
+ * The object type is significant only at the last name
+ * segment. (We don't care about the types along the path, only
+ * the type of the final target object.)
+ */
+ ThisSearchType = ACPI_TYPE_ANY;
+ CurrentNode = ThisNode;
+ while (NumSegments && CurrentNode)
+ {
+ NumSegments--;
+ if (!NumSegments)
+ {
+ /* This is the last segment, enable typechecking */
+
+ ThisSearchType = Type;
+
+ /*
+ * Only allow automatic parent search (search rules) if the caller
+ * requested it AND we have a single, non-fully-qualified NameSeg
+ */
+ if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
+ (Flags & ACPI_NS_SEARCH_PARENT))
+ {
+ LocalFlags |= ACPI_NS_SEARCH_PARENT;
+ }
+
+ /* Set error flag according to caller */
+
+ if (Flags & ACPI_NS_ERROR_IF_FOUND)
+ {
+ LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
+ }
+ }
+
+ /* Extract one ACPI name from the front of the pathname */
+
+ ACPI_MOVE_32_TO_32 (&SimpleName, Path);
+
+ /* Try to find the single (4 character) ACPI name */
+
+ Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
+ InterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_FOUND)
+ {
+ /* Name not found in ACPI namespace */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Name [%4.4s] not found in scope [%4.4s] %p\n",
+ (char *) &SimpleName, (char *) &CurrentNode->Name,
+ CurrentNode));
+ }
+
+ *ReturnNode = ThisNode;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* More segments to follow? */
+
+ if (NumSegments > 0)
+ {
+ /*
+ * If we have an alias to an object that opens a scope (such as a
+ * device or processor), we need to dereference the alias here so
+ * that we can access any children of the original node (via the
+ * remaining segments).
+ */
+ if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS)
+ {
+ if (!ThisNode->Object)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *)
+ ThisNode->Object)->Type))
+ {
+ ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object;
+ }
+ }
+ }
+
+ /* Special handling for the last segment (NumSegments == 0) */
+
+ else
+ {
+ /*
+ * Sanity typecheck of the target object:
+ *
+ * If 1) This is the last segment (NumSegments == 0)
+ * 2) And we are looking for a specific type
+ * (Not checking for TYPE_ANY)
+ * 3) Which is not an alias
+ * 4) Which is not a local type (TYPE_SCOPE)
+ * 5) And the type of target object is known (not TYPE_ANY)
+ * 6) And target object does not match what we are looking for
+ *
+ * Then we have a type mismatch. Just warn and ignore it.
+ */
+ if ((TypeToCheckFor != ACPI_TYPE_ANY) &&
+ (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) &&
+ (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
+ (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) &&
+ (ThisNode->Type != ACPI_TYPE_ANY) &&
+ (ThisNode->Type != TypeToCheckFor))
+ {
+ /* Complain about a type mismatch */
+
+ ACPI_WARNING ((AE_INFO,
+ "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
+ ACPI_CAST_PTR (char, &SimpleName),
+ AcpiUtGetTypeName (ThisNode->Type),
+ AcpiUtGetTypeName (TypeToCheckFor)));
+ }
+
+ /*
+ * If this is the last name segment and we are not looking for a
+ * specific type, but the type of found object is known, use that
+ * type to (later) see if it opens a scope.
+ */
+ if (Type == ACPI_TYPE_ANY)
+ {
+ Type = ThisNode->Type;
+ }
+ }
+
+ /* Point to next name segment and make this node current */
+
+ Path += ACPI_NAME_SIZE;
+ CurrentNode = ThisNode;
+ }
+
+ /* Always check if we need to open a new scope */
+
+ if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
+ {
+ /*
+ * If entry is a type which opens a scope, push the new scope on the
+ * scope stack.
+ */
+ if (AcpiNsOpensScope (Type))
+ {
+ Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+
+ *ReturnNode = ThisNode;
+ return_ACPI_STATUS (AE_OK);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsalloc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsalloc.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,588 @@
+/*******************************************************************************
+ *
+ * Module Name: nsalloc - Namespace allocation and deletion 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 __NSALLOC_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsalloc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCreateNode
+ *
+ * PARAMETERS: Name - Name of the new node (4 char ACPI name)
+ *
+ * RETURN: New namespace node (Null on failure)
+ *
+ * DESCRIPTION: Create a namespace node
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+AcpiNsCreateNode (
+ UINT32 Name)
+{
+ ACPI_NAMESPACE_NODE *Node;
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ UINT32 Temp;
+#endif
+
+
+ ACPI_FUNCTION_TRACE (NsCreateNode);
+
+
+ Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache);
+ if (!Node)
+ {
+ return_PTR (NULL);
+ }
+
+ ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++);
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ Temp = AcpiGbl_NsNodeList->TotalAllocated -
+ AcpiGbl_NsNodeList->TotalFreed;
+ if (Temp > AcpiGbl_NsNodeList->MaxOccupied)
+ {
+ AcpiGbl_NsNodeList->MaxOccupied = Temp;
+ }
+#endif
+
+ Node->Name.Integer = Name;
+ ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED);
+ return_PTR (Node);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDeleteNode
+ *
+ * PARAMETERS: Node - Node to be deleted
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Delete a namespace node. All node deletions must come through
+ * here. Detaches any attached objects, including any attached
+ * data. If a handler is associated with attached data, it is
+ * invoked before the node is deleted.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDeleteNode (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_NAME (NsDeleteNode);
+
+
+ /* Detach an object if there is one */
+
+ AcpiNsDetachObject (Node);
+
+ /*
+ * Delete an attached data object if present (an object that was created
+ * and attached via AcpiAttachData). Note: After any normal object is
+ * detached above, the only possible remaining object is a data object.
+ */
+ ObjDesc = Node->Object;
+ if (ObjDesc &&
+ (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
+ {
+ /* Invoke the attached data deletion handler if present */
+
+ if (ObjDesc->Data.Handler)
+ {
+ ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer);
+ }
+
+ AcpiUtRemoveReference (ObjDesc);
+ }
+
+ /* Now we can delete the node */
+
+ (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node);
+
+ ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++);
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n",
+ Node, AcpiGbl_CurrentNodeCount));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsRemoveNode
+ *
+ * PARAMETERS: Node - Node to be removed/deleted
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Remove (unlink) and delete a namespace node
+ *
+ ******************************************************************************/
+
+void
+AcpiNsRemoveNode (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_NAMESPACE_NODE *ParentNode;
+ ACPI_NAMESPACE_NODE *PrevNode;
+ ACPI_NAMESPACE_NODE *NextNode;
+
+
+ ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node);
+
+
+ ParentNode = Node->Parent;
+
+ PrevNode = NULL;
+ NextNode = ParentNode->Child;
+
+ /* Find the node that is the previous peer in the parent's child list */
+
+ while (NextNode != Node)
+ {
+ PrevNode = NextNode;
+ NextNode = NextNode->Peer;
+ }
+
+ if (PrevNode)
+ {
+ /* Node is not first child, unlink it */
+
+ PrevNode->Peer = Node->Peer;
+ }
+ else
+ {
+ /*
+ * Node is first child (has no previous peer).
+ * Link peer list to parent
+ */
+ ParentNode->Child = Node->Peer;
+ }
+
+ /* Delete the node and any attached objects */
+
+ AcpiNsDeleteNode (Node);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsInstallNode
+ *
+ * PARAMETERS: WalkState - Current state of the walk
+ * ParentNode - The parent of the new Node
+ * Node - The new Node to install
+ * Type - ACPI object type of the new Node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize a new namespace node and install it amongst
+ * its peers.
+ *
+ * Note: Current namespace lookup is linear search. This appears
+ * to be sufficient as namespace searches consume only a small
+ * fraction of the execution time of the ACPI subsystem.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsInstallNode (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *ParentNode, /* Parent */
+ ACPI_NAMESPACE_NODE *Node, /* New Child*/
+ ACPI_OBJECT_TYPE Type)
+{
+ ACPI_OWNER_ID OwnerId = 0;
+ ACPI_NAMESPACE_NODE *ChildNode;
+
+
+ ACPI_FUNCTION_TRACE (NsInstallNode);
+
+
+ if (WalkState)
+ {
+ /*
+ * Get the owner ID from the Walk state. The owner ID is used to
+ * track table deletion and deletion of objects created by methods.
+ */
+ OwnerId = WalkState->OwnerId;
+
+ if ((WalkState->MethodDesc) &&
+ (ParentNode != WalkState->MethodNode))
+ {
+ /*
+ * A method is creating a new node that is not a child of the
+ * method (it is non-local). Mark the executing method as having
+ * modified the namespace. This is used for cleanup when the
+ * method exits.
+ */
+ WalkState->MethodDesc->Method.InfoFlags |= ACPI_METHOD_MODIFIED_NAMESPACE;
+ }
+ }
+
+ /* Link the new entry into the parent and existing children */
+
+ Node->Peer = NULL;
+ Node->Parent = ParentNode;
+ ChildNode = ParentNode->Child;
+
+ if (!ChildNode)
+ {
+ ParentNode->Child = Node;
+ }
+ else
+ {
+ /* Add node to the end of the peer list */
+
+ while (ChildNode->Peer)
+ {
+ ChildNode = ChildNode->Peer;
+ }
+
+ ChildNode->Peer = Node;
+ }
+
+ /* Init the new entry */
+
+ Node->OwnerId = OwnerId;
+ Node->Type = (UINT8) Type;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
+ AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId,
+ AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type),
+ ParentNode));
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDeleteChildren
+ *
+ * PARAMETERS: ParentNode - Delete this objects children
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Delete all children of the parent object. In other words,
+ * deletes a "scope".
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDeleteChildren (
+ ACPI_NAMESPACE_NODE *ParentNode)
+{
+ ACPI_NAMESPACE_NODE *NextNode;
+ ACPI_NAMESPACE_NODE *NodeToDelete;
+
+
+ ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode);
+
+
+ if (!ParentNode)
+ {
+ return_VOID;
+ }
+
+ /* Deallocate all children at this level */
+
+ NextNode = ParentNode->Child;
+ while (NextNode)
+ {
+ /* Grandchildren should have all been deleted already */
+
+ if (NextNode->Child)
+ {
+ ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p",
+ ParentNode, NextNode));
+ }
+
+ /*
+ * Delete this child node and move on to the next child in the list.
+ * No need to unlink the node since we are deleting the entire branch.
+ */
+ NodeToDelete = NextNode;
+ NextNode = NextNode->Peer;
+ AcpiNsDeleteNode (NodeToDelete);
+ };
+
+ /* Clear the parent's child pointer */
+
+ ParentNode->Child = NULL;
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDeleteNamespaceSubtree
+ *
+ * PARAMETERS: ParentNode - Root of the subtree to be deleted
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
+ * stored within the subtree.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDeleteNamespaceSubtree (
+ ACPI_NAMESPACE_NODE *ParentNode)
+{
+ ACPI_NAMESPACE_NODE *ChildNode = NULL;
+ UINT32 Level = 1;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree);
+
+
+ if (!ParentNode)
+ {
+ return_VOID;
+ }
+
+ /* Lock namespace for possible update */
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VOID;
+ }
+
+ /*
+ * Traverse the tree of objects until we bubble back up
+ * to where we started.
+ */
+ while (Level > 0)
+ {
+ /* Get the next node in this scope (NULL if none) */
+
+ ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
+ if (ChildNode)
+ {
+ /* Found a child node - detach any attached object */
+
+ AcpiNsDetachObject (ChildNode);
+
+ /* Check if this node has any children */
+
+ if (ChildNode->Child)
+ {
+ /*
+ * There is at least one child of this node,
+ * visit the node
+ */
+ Level++;
+ ParentNode = ChildNode;
+ ChildNode = NULL;
+ }
+ }
+ else
+ {
+ /*
+ * No more children of this parent node.
+ * Move up to the grandparent.
+ */
+ Level--;
+
+ /*
+ * Now delete all of the children of this parent
+ * all at the same time.
+ */
+ AcpiNsDeleteChildren (ParentNode);
+
+ /* New "last child" is this parent node */
+
+ ChildNode = ParentNode;
+
+ /* Move up the tree to the grandparent */
+
+ ParentNode = ParentNode->Parent;
+ }
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDeleteNamespaceByOwner
+ *
+ * PARAMETERS: OwnerId - All nodes with this owner will be deleted
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Delete entries within the namespace that are owned by a
+ * specific ID. Used to delete entire ACPI tables. All
+ * reference counts are updated.
+ *
+ * MUTEX: Locks namespace during deletion walk.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDeleteNamespaceByOwner (
+ ACPI_OWNER_ID OwnerId)
+{
+ ACPI_NAMESPACE_NODE *ChildNode;
+ ACPI_NAMESPACE_NODE *DeletionNode;
+ ACPI_NAMESPACE_NODE *ParentNode;
+ UINT32 Level;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId);
+
+
+ if (OwnerId == 0)
+ {
+ return_VOID;
+ }
+
+ /* Lock namespace for possible update */
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VOID;
+ }
+
+ DeletionNode = NULL;
+ ParentNode = AcpiGbl_RootNode;
+ ChildNode = NULL;
+ Level = 1;
+
+ /*
+ * Traverse the tree of nodes until we bubble back up
+ * to where we started.
+ */
+ while (Level > 0)
+ {
+ /*
+ * Get the next child of this parent node. When ChildNode is NULL,
+ * the first child of the parent is returned
+ */
+ ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
+
+ if (DeletionNode)
+ {
+ AcpiNsDeleteChildren (DeletionNode);
+ AcpiNsRemoveNode (DeletionNode);
+ DeletionNode = NULL;
+ }
+
+ if (ChildNode)
+ {
+ if (ChildNode->OwnerId == OwnerId)
+ {
+ /* Found a matching child node - detach any attached object */
+
+ AcpiNsDetachObject (ChildNode);
+ }
+
+ /* Check if this node has any children */
+
+ if (ChildNode->Child)
+ {
+ /*
+ * There is at least one child of this node,
+ * visit the node
+ */
+ Level++;
+ ParentNode = ChildNode;
+ ChildNode = NULL;
+ }
+ else if (ChildNode->OwnerId == OwnerId)
+ {
+ DeletionNode = ChildNode;
+ }
+ }
+ else
+ {
+ /*
+ * No more children of this parent node.
+ * Move up to the grandparent.
+ */
+ Level--;
+ if (Level != 0)
+ {
+ if (ParentNode->OwnerId == OwnerId)
+ {
+ DeletionNode = ParentNode;
+ }
+ }
+
+ /* New "last child" is this parent node */
+
+ ChildNode = ParentNode;
+
+ /* Move up the tree to the grandparent */
+
+ ParentNode = ParentNode->Parent;
+ }
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return_VOID;
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsdump.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsdump.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,769 @@
+/******************************************************************************
+ *
+ * Module Name: nsdump - table dumping routines for debug
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __NSDUMP_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsdump")
+
+/* Local prototypes */
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+void
+AcpiNsDumpRootDevices (
+ void);
+
+static ACPI_STATUS
+AcpiNsDumpOneDevice (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue);
+#endif
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsPrintPathname
+ *
+ * PARAMETERS: NumSegments - Number of ACPI name segments
+ * Pathname - The compressed (internal) path
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print an object's full namespace pathname
+ *
+ ******************************************************************************/
+
+void
+AcpiNsPrintPathname (
+ UINT32 NumSegments,
+ char *Pathname)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME (NsPrintPathname);
+
+
+ if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
+ {
+ return;
+ }
+
+ /* Print the entire name */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
+
+ while (NumSegments)
+ {
+ for (i = 0; i < 4; i++)
+ {
+ ACPI_IS_PRINT (Pathname[i]) ?
+ AcpiOsPrintf ("%c", Pathname[i]) :
+ AcpiOsPrintf ("?");
+ }
+
+ Pathname += ACPI_NAME_SIZE;
+ NumSegments--;
+ if (NumSegments)
+ {
+ AcpiOsPrintf (".");
+ }
+ }
+
+ AcpiOsPrintf ("]\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpPathname
+ *
+ * PARAMETERS: Handle - Object
+ * Msg - Prefix message
+ * Level - Desired debug level
+ * Component - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print an object's full namespace pathname
+ * Manages allocation/freeing of a pathname buffer
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDumpPathname (
+ ACPI_HANDLE Handle,
+ char *Msg,
+ UINT32 Level,
+ UINT32 Component)
+{
+
+ ACPI_FUNCTION_TRACE (NsDumpPathname);
+
+
+ /* Do this only if the requested debug level and component are enabled */
+
+ if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
+ {
+ return_VOID;
+ }
+
+ /* Convert handle to a full pathname and print it (with supplied message) */
+
+ AcpiNsPrintNodePathname (Handle, Msg);
+ AcpiOsPrintf ("\n");
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpOneObject
+ *
+ * PARAMETERS: ObjHandle - Node to be dumped
+ * Level - Nesting level of the handle
+ * Context - Passed into WalkNamespace
+ * ReturnValue - Not used
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Dump a single Node
+ * This procedure is a UserFunction called by AcpiNsWalkNamespace.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsDumpOneObject (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
+ ACPI_NAMESPACE_NODE *ThisNode;
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_OBJECT_TYPE ObjType;
+ ACPI_OBJECT_TYPE Type;
+ UINT32 BytesToDump;
+ UINT32 DbgLevel;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME (NsDumpOneObject);
+
+
+ /* Is output enabled? */
+
+ if (!(AcpiDbgLevel & Info->DebugLevel))
+ {
+ return (AE_OK);
+ }
+
+ if (!ObjHandle)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
+ return (AE_OK);
+ }
+
+ ThisNode = AcpiNsValidateHandle (ObjHandle);
+ if (!ThisNode)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
+ ObjHandle));
+ return (AE_OK);
+ }
+
+ Type = ThisNode->Type;
+
+ /* Check if the owner matches */
+
+ if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
+ (Info->OwnerId != ThisNode->OwnerId))
+ {
+ return (AE_OK);
+ }
+
+ if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
+ {
+ /* Indent the object according to the level */
+
+ AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
+
+ /* Check the node type and name */
+
+ if (Type > ACPI_TYPE_LOCAL_MAX)
+ {
+ ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type));
+ }
+
+ AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
+ }
+
+ /* Now we can print out the pertinent information */
+
+ AcpiOsPrintf (" %-12s %p %2.2X ",
+ AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
+
+ DbgLevel = AcpiDbgLevel;
+ AcpiDbgLevel = 0;
+ ObjDesc = AcpiNsGetAttachedObject (ThisNode);
+ AcpiDbgLevel = DbgLevel;
+
+ /* Temp nodes are those nodes created by a control method */
+
+ if (ThisNode->Flags & ANOBJ_TEMPORARY)
+ {
+ AcpiOsPrintf ("(T) ");
+ }
+
+ switch (Info->DisplayType & ACPI_DISPLAY_MASK)
+ {
+ case ACPI_DISPLAY_SUMMARY:
+
+ if (!ObjDesc)
+ {
+ /* No attached object, we are done */
+
+ AcpiOsPrintf ("\n");
+ return (AE_OK);
+ }
+
+ switch (Type)
+ {
+ case ACPI_TYPE_PROCESSOR:
+
+ AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
+ ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
+ ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
+ break;
+
+
+ case ACPI_TYPE_DEVICE:
+
+ AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_METHOD:
+
+ AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
+ (UINT32) ObjDesc->Method.ParamCount,
+ ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+
+ AcpiOsPrintf ("= %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
+ {
+ AcpiOsPrintf ("Elements %.2X\n",
+ ObjDesc->Package.Count);
+ }
+ else
+ {
+ AcpiOsPrintf ("[Length not yet evaluated]\n");
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
+ {
+ AcpiOsPrintf ("Len %.2X",
+ ObjDesc->Buffer.Length);
+
+ /* Dump some of the buffer */
+
+ if (ObjDesc->Buffer.Length > 0)
+ {
+ AcpiOsPrintf (" =");
+ for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
+ {
+ AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
+ }
+ }
+ AcpiOsPrintf ("\n");
+ }
+ else
+ {
+ AcpiOsPrintf ("[Length not yet evaluated]\n");
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
+ AcpiUtPrintString (ObjDesc->String.Pointer, 32);
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_TYPE_REGION:
+
+ AcpiOsPrintf ("[%s]",
+ AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
+ if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
+ {
+ AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
+ ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
+ ObjDesc->Region.Length);
+ }
+ else
+ {
+ AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ if (ObjDesc->BufferField.BufferObj &&
+ ObjDesc->BufferField.BufferObj->Buffer.Node)
+ {
+ AcpiOsPrintf ("Buf [%4.4s]",
+ AcpiUtGetNodeName (
+ ObjDesc->BufferField.BufferObj->Buffer.Node));
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ AcpiOsPrintf ("Rgn [%4.4s]",
+ AcpiUtGetNodeName (
+ ObjDesc->CommonField.RegionObj->Region.Node));
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
+ AcpiUtGetNodeName (
+ ObjDesc->CommonField.RegionObj->Region.Node),
+ AcpiUtGetNodeName (
+ ObjDesc->BankField.BankObj->CommonField.Node));
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
+ AcpiUtGetNodeName (
+ ObjDesc->IndexField.IndexObj->CommonField.Node),
+ AcpiUtGetNodeName (
+ ObjDesc->IndexField.DataObj->CommonField.Node));
+ break;
+
+
+ case ACPI_TYPE_LOCAL_ALIAS:
+ case ACPI_TYPE_LOCAL_METHOD_ALIAS:
+
+ AcpiOsPrintf ("Target %4.4s (%p)\n",
+ AcpiUtGetNodeName (ObjDesc), ObjDesc);
+ break;
+
+ default:
+
+ AcpiOsPrintf ("Object %p\n", ObjDesc);
+ break;
+ }
+
+ /* Common field handling */
+
+ switch (Type)
+ {
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
+ (ObjDesc->CommonField.BaseByteOffset * 8)
+ + ObjDesc->CommonField.StartFieldBitOffset,
+ ObjDesc->CommonField.BitLength,
+ ObjDesc->CommonField.AccessByteWidth);
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+
+ case ACPI_DISPLAY_OBJECTS:
+
+ AcpiOsPrintf ("O:%p", ObjDesc);
+ if (!ObjDesc)
+ {
+ /* No attached object, we are done */
+
+ AcpiOsPrintf ("\n");
+ return (AE_OK);
+ }
+
+ AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
+
+ switch (Type)
+ {
+ case ACPI_TYPE_METHOD:
+
+ /* Name is a Method and its AML offset/length are set */
+
+ AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
+ ObjDesc->Method.AmlLength);
+ break;
+
+ case ACPI_TYPE_INTEGER:
+
+ AcpiOsPrintf (" I:%8.8X8.8%X\n",
+ ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
+ ObjDesc->String.Length);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
+ ObjDesc->Buffer.Length);
+ break;
+
+ default:
+
+ AcpiOsPrintf ("\n");
+ break;
+ }
+ break;
+
+
+ default:
+ AcpiOsPrintf ("\n");
+ break;
+ }
+
+ /* If debug turned off, done */
+
+ if (!(AcpiDbgLevel & ACPI_LV_VALUES))
+ {
+ return (AE_OK);
+ }
+
+ /* If there is an attached object, display it */
+
+ DbgLevel = AcpiDbgLevel;
+ AcpiDbgLevel = 0;
+ ObjDesc = AcpiNsGetAttachedObject (ThisNode);
+ AcpiDbgLevel = DbgLevel;
+
+ /* Dump attached objects */
+
+ while (ObjDesc)
+ {
+ ObjType = ACPI_TYPE_INVALID;
+ AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
+
+ /* Decode the type of attached object and dump the contents */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_NAMED:
+
+ AcpiOsPrintf ("(Ptr to Node)\n");
+ BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
+ ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
+ break;
+
+ case ACPI_DESC_TYPE_OPERAND:
+
+ ObjType = ObjDesc->Common.Type;
+
+ if (ObjType > ACPI_TYPE_LOCAL_MAX)
+ {
+ AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
+ ObjType);
+ BytesToDump = 32;
+ }
+ else
+ {
+ AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
+ ObjType, AcpiUtGetTypeName (ObjType));
+ BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
+ }
+
+ ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
+ break;
+
+ default:
+
+ break;
+ }
+
+ /* If value is NOT an internal object, we are done */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
+ {
+ goto Cleanup;
+ }
+
+ /* Valid object, get the pointer to next level, if any */
+
+ switch (ObjType)
+ {
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_STRING:
+ /*
+ * NOTE: takes advantage of common fields between string/buffer
+ */
+ BytesToDump = ObjDesc->String.Length;
+ ObjDesc = (void *) ObjDesc->String.Pointer;
+ AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
+ ObjDesc, BytesToDump);
+ ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
+ goto Cleanup;
+
+ case ACPI_TYPE_BUFFER_FIELD:
+ ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ ObjDesc = (void *) ObjDesc->Package.Elements;
+ break;
+
+ case ACPI_TYPE_METHOD:
+ ObjDesc = (void *) ObjDesc->Method.AmlStart;
+ break;
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ ObjDesc = (void *) ObjDesc->Field.RegionObj;
+ break;
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ ObjDesc = (void *) ObjDesc->BankField.RegionObj;
+ break;
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
+ break;
+
+ default:
+ goto Cleanup;
+ }
+
+ ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
+ }
+
+Cleanup:
+ AcpiOsPrintf ("\n");
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpObjects
+ *
+ * PARAMETERS: Type - Object type to be dumped
+ * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
+ * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
+ * for an effectively unlimited depth.
+ * OwnerId - Dump only objects owned by this ID. Use
+ * ACPI_UINT32_MAX to match all owners.
+ * StartHandle - Where in namespace to start/end search
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
+ * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDumpObjects (
+ ACPI_OBJECT_TYPE Type,
+ UINT8 DisplayType,
+ UINT32 MaxDepth,
+ ACPI_OWNER_ID OwnerId,
+ ACPI_HANDLE StartHandle)
+{
+ ACPI_WALK_INFO Info;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Just lock the entire namespace for the duration of the dump.
+ * We don't want any changes to the namespace during this time,
+ * especially the temporary nodes since we are going to display
+ * them also.
+ */
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not acquire namespace mutex\n");
+ return;
+ }
+
+ Info.DebugLevel = ACPI_LV_TABLES;
+ Info.OwnerId = OwnerId;
+ Info.DisplayType = DisplayType;
+
+ (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
+ ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
+ AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpEntry
+ *
+ * PARAMETERS: Handle - Node to be dumped
+ * DebugLevel - Output level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump a single Node
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDumpEntry (
+ ACPI_HANDLE Handle,
+ UINT32 DebugLevel)
+{
+ ACPI_WALK_INFO Info;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Info.DebugLevel = DebugLevel;
+ Info.OwnerId = ACPI_OWNER_ID_MAX;
+ Info.DisplayType = ACPI_DISPLAY_SUMMARY;
+
+ (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
+}
+
+
+#ifdef ACPI_ASL_COMPILER
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpTables
+ *
+ * PARAMETERS: SearchBase - Root of subtree to be dumped, or
+ * NS_ALL to dump the entire namespace
+ * MaxDepth - Maximum depth of dump. Use INT_MAX
+ * for an effectively unlimited depth.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump the name space, or a portion of it.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDumpTables (
+ ACPI_HANDLE SearchBase,
+ UINT32 MaxDepth)
+{
+ ACPI_HANDLE SearchHandle = SearchBase;
+
+
+ ACPI_FUNCTION_TRACE (NsDumpTables);
+
+
+ if (!AcpiGbl_RootNode)
+ {
+ /*
+ * If the name space has not been initialized,
+ * there is nothing to dump.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
+ return_VOID;
+ }
+
+ if (ACPI_NS_ALL == SearchBase)
+ {
+ /* Entire namespace */
+
+ SearchHandle = AcpiGbl_RootNode;
+ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
+ }
+
+ AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
+ ACPI_OWNER_ID_MAX, SearchHandle);
+ return_VOID;
+}
+#endif
+#endif
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,161 @@
+/******************************************************************************
+ *
+ * Module Name: nsdump - table dumping routines for debug
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __NSDUMPDV_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+
+
+/* TBD: This entire module is apparently obsolete and should be removed */
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsdumpdv")
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpOneDevice
+ *
+ * PARAMETERS: Handle - Node to be dumped
+ * Level - Nesting level of the handle
+ * Context - Passed into WalkNamespace
+ * ReturnValue - Not used
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Dump a single Node that represents a device
+ * This procedure is a UserFunction called by AcpiNsWalkNamespace.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsDumpOneDevice (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_BUFFER Buffer;
+ ACPI_DEVICE_INFO *Info;
+ ACPI_STATUS Status;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME (NsDumpOneDevice);
+
+
+ Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue);
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiGetObjectInfo (ObjHandle, &Buffer);
+ if (ACPI_SUCCESS (Status))
+ {
+ Info = Buffer.Pointer;
+ for (i = 0; i < Level; i++)
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES,
+ " HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
+ Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address),
+ Info->CurrentStatus));
+ ACPI_FREE (Info);
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpRootDevices
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump all objects of type "device"
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDumpRootDevices (
+ void)
+{
+ ACPI_HANDLE SysBusHandle;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME (NsDumpRootDevices);
+
+
+ /* Only dump the table if tracing is enabled */
+
+ if (!(ACPI_LV_TABLES & AcpiDbgLevel))
+ {
+ return;
+ }
+
+ Status = AcpiGetHandle (NULL, ACPI_NS_SYSTEM_BUS, &SysBusHandle);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
+ "Display of all devices in the namespace:\n"));
+
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle,
+ ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
+ AcpiNsDumpOneDevice, NULL, NULL, NULL);
+}
+
+#endif
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nseval.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nseval.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,485 @@
+/*******************************************************************************
+ *
+ * Module Name: nseval - Object evaluation, includes 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.
+ */
+
+#define __NSEVAL_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/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nseval")
+
+/* Local prototypes */
+
+static void
+AcpiNsExecModuleCode (
+ ACPI_OPERAND_OBJECT *MethodObj,
+ ACPI_EVALUATE_INFO *Info);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsEvaluate
+ *
+ * PARAMETERS: Info - Evaluation info block, contains:
+ * PrefixNode - Prefix or Method/Object Node to execute
+ * Pathname - Name of method to execute, If NULL, the
+ * Node is the object to execute
+ * Parameters - List of parameters to pass to the method,
+ * terminated by NULL. Params itself may be
+ * NULL if no parameters are being passed.
+ * ReturnObject - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * ParameterType - Type of Parameter list
+ * ReturnObject - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * Flags - ACPI_IGNORE_RETURN_VALUE to delete return
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a control method or return the current value of an
+ * ACPI namespace object.
+ *
+ * MUTEX: Locks interpreter
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsEvaluate (
+ ACPI_EVALUATE_INFO *Info)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (NsEvaluate);
+
+
+ if (!Info)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Initialize the return value to an invalid object */
+
+ Info->ReturnObject = NULL;
+ Info->ParamCount = 0;
+
+ /*
+ * Get the actual namespace node for the target object. Handles these cases:
+ *
+ * 1) Null node, Pathname (absolute path)
+ * 2) Node, Pathname (path relative to Node)
+ * 3) Node, Null Pathname
+ */
+ Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname,
+ ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * For a method alias, we must grab the actual method node so that proper
+ * scoping context will be established before execution.
+ */
+ if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
+ {
+ Info->ResolvedNode =
+ ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname,
+ Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode)));
+
+ Node = Info->ResolvedNode;
+
+ /*
+ * Two major cases here:
+ *
+ * 1) The object is a control method -- execute it
+ * 2) The object is not a method -- just return it's current value
+ */
+ if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD)
+ {
+ /*
+ * 1) Object is a control method - execute it
+ */
+
+ /* Verify that there is a method object associated with this node */
+
+ Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode);
+ if (!Info->ObjDesc)
+ {
+ ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object"));
+ return_ACPI_STATUS (AE_NULL_OBJECT);
+ }
+
+ /* Count the number of arguments being passed to the method */
+
+ if (Info->Parameters)
+ {
+ while (Info->Parameters[Info->ParamCount])
+ {
+ if (Info->ParamCount > ACPI_METHOD_MAX_ARG)
+ {
+ return_ACPI_STATUS (AE_LIMIT);
+ }
+ Info->ParamCount++;
+ }
+ }
+
+ ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method",
+ ACPI_LV_INFO, _COMPONENT);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Method at AML address %p Length %X\n",
+ Info->ObjDesc->Method.AmlStart + 1,
+ Info->ObjDesc->Method.AmlLength - 1));
+
+ /*
+ * Any namespace deletion must acquire both the namespace and
+ * interpreter locks to ensure that no thread is using the portion of
+ * the namespace that is being deleted.
+ *
+ * Execute the method via the interpreter. The interpreter is locked
+ * here before calling into the AML parser
+ */
+ AcpiExEnterInterpreter ();
+ Status = AcpiPsExecuteMethod (Info);
+ AcpiExExitInterpreter ();
+ }
+ else
+ {
+ /*
+ * 2) Object is not a method, return its current value
+ *
+ * Disallow certain object types. For these, "evaluation" is undefined.
+ */
+ switch (Info->ResolvedNode->Type)
+ {
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_EVENT:
+ case ACPI_TYPE_MUTEX:
+ case ACPI_TYPE_REGION:
+ case ACPI_TYPE_THERMAL:
+ case ACPI_TYPE_LOCAL_SCOPE:
+
+ ACPI_ERROR ((AE_INFO,
+ "[%4.4s] Evaluation of object type [%s] is not supported",
+ Info->ResolvedNode->Name.Ascii,
+ AcpiUtGetTypeName (Info->ResolvedNode->Type)));
+
+ return_ACPI_STATUS (AE_TYPE);
+
+ default:
+ break;
+ }
+
+ /*
+ * Objects require additional resolution steps (e.g., the Node may be
+ * a field that must be read, etc.) -- we can't just grab the object
+ * out of the node.
+ *
+ * Use ResolveNodeToValue() to get the associated value.
+ *
+ * NOTE: we can get away with passing in NULL for a walk state because
+ * ResolvedNode is guaranteed to not be a reference to either a method
+ * local or a method argument (because this interface is never called
+ * from a running method.)
+ *
+ * Even though we do not directly invoke the interpreter for object
+ * resolution, we must lock it because we could access an opregion.
+ * The opregion access code assumes that the interpreter is locked.
+ */
+ AcpiExEnterInterpreter ();
+
+ /* Function has a strange interface */
+
+ Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL);
+ AcpiExExitInterpreter ();
+
+ /*
+ * If AcpiExResolveNodeToValue() succeeded, the return value was placed
+ * in ResolvedNode.
+ */
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AE_CTRL_RETURN_VALUE;
+ Info->ReturnObject =
+ ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n",
+ Info->ReturnObject,
+ AcpiUtGetObjectTypeName (Info->ReturnObject)));
+ }
+ }
+
+ /*
+ * Check input argument count against the ASL-defined count for a method.
+ * Also check predefined names: argument count and return value against
+ * the ACPI specification. Some incorrect return value types are repaired.
+ */
+ (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount,
+ Status, &Info->ReturnObject);
+
+ /* Check if there is a return value that must be dealt with */
+
+ if (Status == AE_CTRL_RETURN_VALUE)
+ {
+ /* If caller does not want the return value, delete it */
+
+ if (Info->Flags & ACPI_IGNORE_RETURN_VALUE)
+ {
+ AcpiUtRemoveReference (Info->ReturnObject);
+ Info->ReturnObject = NULL;
+ }
+
+ /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
+
+ Status = AE_OK;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "*** Completed evaluation of object %s ***\n", Info->Pathname));
+
+ /*
+ * Namespace was unlocked by the handling AcpiNs* function, so we
+ * just return
+ */
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsExecModuleCodeList
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None. Exceptions during method execution are ignored, since
+ * we cannot abort a table load.
+ *
+ * DESCRIPTION: Execute all elements of the global module-level code list.
+ * Each element is executed as a single control method.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsExecModuleCodeList (
+ void)
+{
+ ACPI_OPERAND_OBJECT *Prev;
+ ACPI_OPERAND_OBJECT *Next;
+ ACPI_EVALUATE_INFO *Info;
+ UINT32 MethodCount = 0;
+
+
+ ACPI_FUNCTION_TRACE (NsExecModuleCodeList);
+
+
+ /* Exit now if the list is empty */
+
+ Next = AcpiGbl_ModuleCodeList;
+ if (!Next)
+ {
+ return_VOID;
+ }
+
+ /* Allocate the evaluation information block */
+
+ Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO));
+ if (!Info)
+ {
+ return_VOID;
+ }
+
+ /* Walk the list, executing each "method" */
+
+ while (Next)
+ {
+ Prev = Next;
+ Next = Next->Method.Mutex;
+
+ /* Clear the link field and execute the method */
+
+ Prev->Method.Mutex = NULL;
+ AcpiNsExecModuleCode (Prev, Info);
+ MethodCount++;
+
+ /* Delete the (temporary) method object */
+
+ AcpiUtRemoveReference (Prev);
+ }
+
+ ACPI_INFO ((AE_INFO,
+ "Executed %u blocks of module-level executable AML code",
+ MethodCount));
+
+ ACPI_FREE (Info);
+ AcpiGbl_ModuleCodeList = NULL;
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsExecModuleCode
+ *
+ * PARAMETERS: MethodObj - Object container for the module-level code
+ * Info - Info block for method evaluation
+ *
+ * RETURN: None. Exceptions during method execution are ignored, since
+ * we cannot abort a table load.
+ *
+ * DESCRIPTION: Execute a control method containing a block of module-level
+ * executable AML code. The control method is temporarily
+ * installed to the root node, then evaluated.
+ *
+ ******************************************************************************/
+
+static void
+AcpiNsExecModuleCode (
+ ACPI_OPERAND_OBJECT *MethodObj,
+ ACPI_EVALUATE_INFO *Info)
+{
+ ACPI_OPERAND_OBJECT *ParentObj;
+ ACPI_NAMESPACE_NODE *ParentNode;
+ ACPI_OBJECT_TYPE Type;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (NsExecModuleCode);
+
+
+ /*
+ * Get the parent node. We cheat by using the NextObject field
+ * of the method object descriptor.
+ */
+ ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
+ MethodObj->Method.NextObject);
+ Type = AcpiNsGetType (ParentNode);
+
+ /*
+ * Get the region handler and save it in the method object. We may need
+ * this if an operation region declaration causes a _REG method to be run.
+ *
+ * We can't do this in AcpiPsLinkModuleCode because
+ * AcpiGbl_RootNode->Object is NULL at PASS1.
+ */
+ if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)
+ {
+ MethodObj->Method.Dispatch.Handler =
+ ParentNode->Object->Device.Handler;
+ }
+
+ /* Must clear NextObject (AcpiNsAttachObject needs the field) */
+
+ MethodObj->Method.NextObject = NULL;
+
+ /* Initialize the evaluation information block */
+
+ ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
+ Info->PrefixNode = ParentNode;
+
+ /*
+ * Get the currently attached parent object. Add a reference, because the
+ * ref count will be decreased when the method object is installed to
+ * the parent node.
+ */
+ ParentObj = AcpiNsGetAttachedObject (ParentNode);
+ if (ParentObj)
+ {
+ AcpiUtAddReference (ParentObj);
+ }
+
+ /* Install the method (module-level code) in the parent node */
+
+ Status = AcpiNsAttachObject (ParentNode, MethodObj,
+ ACPI_TYPE_METHOD);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+
+ /* Execute the parent node as a control method */
+
+ Status = AcpiNsEvaluate (Info);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n",
+ MethodObj->Method.AmlStart));
+
+ /* Delete a possible implicit return value (in slack mode) */
+
+ if (Info->ReturnObject)
+ {
+ AcpiUtRemoveReference (Info->ReturnObject);
+ }
+
+ /* Detach the temporary method object */
+
+ AcpiNsDetachObject (ParentNode);
+
+ /* Restore the original parent object */
+
+ if (ParentObj)
+ {
+ Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);
+ }
+ else
+ {
+ ParentNode->Type = (UINT8) Type;
+ }
+
+Exit:
+ if (ParentObj)
+ {
+ AcpiUtRemoveReference (ParentObj);
+ }
+ return_VOID;
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsinit.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsinit.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,665 @@
+/******************************************************************************
+ *
+ * Module Name: nsinit - namespace 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.
+ */
+
+
+#define __NSXFINIT_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/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsinit")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiNsInitOneObject (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue);
+
+static ACPI_STATUS
+AcpiNsInitOneDevice (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+static ACPI_STATUS
+AcpiNsFindIniMethods (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsInitializeObjects
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk the entire namespace and perform any necessary
+ * initialization on the objects found therein
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsInitializeObjects (
+ void)
+{
+ ACPI_STATUS Status;
+ ACPI_INIT_WALK_INFO Info;
+
+
+ ACPI_FUNCTION_TRACE (NsInitializeObjects);
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "**** Starting initialization of namespace objects ****\n"));
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+ "Completing Region/Field/Buffer/Package initialization:"));
+
+ /* Set all init info to zero */
+
+ ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
+
+ /* Walk entire namespace from the supplied root */
+
+ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL,
+ &Info, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+ "\nInitialized %u/%u Regions %u/%u Fields %u/%u "
+ "Buffers %u/%u Packages (%u nodes)\n",
+ Info.OpRegionInit, Info.OpRegionCount,
+ Info.FieldInit, Info.FieldCount,
+ Info.BufferInit, Info.BufferCount,
+ Info.PackageInit, Info.PackageCount, Info.ObjectCount));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "%u Control Methods found\n", Info.MethodCount));
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "%u Op Regions found\n", Info.OpRegionCount));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsInitializeDevices
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: ACPI_STATUS
+ *
+ * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
+ * This means running _INI on all present devices.
+ *
+ * Note: We install PCI config space handler on region access,
+ * not here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsInitializeDevices (
+ void)
+{
+ ACPI_STATUS Status;
+ ACPI_DEVICE_WALK_INFO Info;
+
+
+ ACPI_FUNCTION_TRACE (NsInitializeDevices);
+
+
+ /* Init counters */
+
+ Info.DeviceCount = 0;
+ Info.Num_STA = 0;
+ Info.Num_INI = 0;
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+ "Initializing Device/Processor/Thermal objects "
+ "by executing _INI methods:"));
+
+ /* Tree analysis: find all subtrees that contain _INI methods */
+
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ /* Allocate the evaluation information block */
+
+ Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
+ if (!Info.EvaluateInfo)
+ {
+ Status = AE_NO_MEMORY;
+ goto ErrorExit;
+ }
+
+ /*
+ * Execute the "global" _INI method that may appear at the root. This
+ * support is provided for Windows compatibility (Vista+) and is not
+ * part of the ACPI specification.
+ */
+ Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode;
+ Info.EvaluateInfo->Pathname = METHOD_NAME__INI;
+ Info.EvaluateInfo->Parameters = NULL;
+ Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE;
+
+ Status = AcpiNsEvaluate (Info.EvaluateInfo);
+ if (ACPI_SUCCESS (Status))
+ {
+ Info.Num_INI++;
+ }
+
+ /* Walk namespace to execute all _INIs on present devices */
+
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL);
+
+ /*
+ * Any _OSI requests should be completed by now. If the BIOS has
+ * requested any Windows OSI strings, we will always truncate
+ * I/O addresses to 16 bits -- for Windows compatibility.
+ */
+ if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000)
+ {
+ AcpiGbl_TruncateIoAddresses = TRUE;
+ }
+
+ ACPI_FREE (Info.EvaluateInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+ "\nExecuted %u _INI methods requiring %u _STA executions "
+ "(examined %u objects)\n",
+ Info.Num_INI, Info.Num_STA, Info.DeviceCount));
+
+ return_ACPI_STATUS (Status);
+
+
+ErrorExit:
+ ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization"));
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsInitOneObject
+ *
+ * PARAMETERS: ObjHandle - Node
+ * Level - Current nesting level
+ * Context - Points to a init info struct
+ * ReturnValue - Not used
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
+ * within the namespace.
+ *
+ * Currently, the only objects that require initialization are:
+ * 1) Methods
+ * 2) Op Regions
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsInitOneObject (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_OBJECT_TYPE Type;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
+ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_NAME (NsInitOneObject);
+
+
+ Info->ObjectCount++;
+
+ /* And even then, we are only interested in a few object types */
+
+ Type = AcpiNsGetType (ObjHandle);
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (!ObjDesc)
+ {
+ return (AE_OK);
+ }
+
+ /* Increment counters for object types we are looking for */
+
+ switch (Type)
+ {
+ case ACPI_TYPE_REGION:
+ Info->OpRegionCount++;
+ break;
+
+ case ACPI_TYPE_BUFFER_FIELD:
+ Info->FieldCount++;
+ break;
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ Info->FieldCount++;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Info->BufferCount++;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ Info->PackageCount++;
+ break;
+
+ default:
+
+ /* No init required, just exit now */
+ return (AE_OK);
+ }
+
+ /* If the object is already initialized, nothing else to do */
+
+ if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
+ {
+ return (AE_OK);
+ }
+
+ /* Must lock the interpreter before executing AML code */
+
+ AcpiExEnterInterpreter ();
+
+ /*
+ * Each of these types can contain executable AML code within the
+ * declaration.
+ */
+ switch (Type)
+ {
+ case ACPI_TYPE_REGION:
+
+ Info->OpRegionInit++;
+ Status = AcpiDsGetRegionArguments (ObjDesc);
+ break;
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ Info->FieldInit++;
+ Status = AcpiDsGetBufferFieldArguments (ObjDesc);
+ break;
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ Info->FieldInit++;
+ Status = AcpiDsGetBankFieldArguments (ObjDesc);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ Info->BufferInit++;
+ Status = AcpiDsGetBufferArguments (ObjDesc);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ Info->PackageInit++;
+ Status = AcpiDsGetPackageArguments (ObjDesc);
+ break;
+
+ default:
+ /* No other types can get here */
+ break;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not execute arguments for [%4.4s] (%s)",
+ AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type)));
+ }
+
+ /*
+ * Print a dot for each object unless we are going to print the entire
+ * pathname
+ */
+ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
+ }
+
+ /*
+ * We ignore errors from above, and always return OK, since we don't want
+ * to abort the walk on any single error.
+ */
+ AcpiExExitInterpreter ();
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsFindIniMethods
+ *
+ * PARAMETERS: ACPI_WALK_CALLBACK
+ *
+ * RETURN: ACPI_STATUS
+ *
+ * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
+ * device/processor/thermal objects, and marks the entire subtree
+ * with a SUBTREE_HAS_INI flag. This flag is used during the
+ * subsequent device initialization walk to avoid entire subtrees
+ * that do not contain an _INI.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsFindIniMethods (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_NAMESPACE_NODE *ParentNode;
+
+
+ /* Keep count of device/processor/thermal objects */
+
+ Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
+ if ((Node->Type == ACPI_TYPE_DEVICE) ||
+ (Node->Type == ACPI_TYPE_PROCESSOR) ||
+ (Node->Type == ACPI_TYPE_THERMAL))
+ {
+ Info->DeviceCount++;
+ return (AE_OK);
+ }
+
+ /* We are only looking for methods named _INI */
+
+ if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI))
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * The only _INI methods that we care about are those that are
+ * present under Device, Processor, and Thermal objects.
+ */
+ ParentNode = Node->Parent;
+ switch (ParentNode->Type)
+ {
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_THERMAL:
+
+ /* Mark parent and bubble up the INI present flag to the root */
+
+ while (ParentNode)
+ {
+ ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI;
+ ParentNode = ParentNode->Parent;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsInitOneDevice
+ *
+ * PARAMETERS: ACPI_WALK_CALLBACK
+ *
+ * RETURN: ACPI_STATUS
+ *
+ * DESCRIPTION: This is called once per device soon after ACPI is enabled
+ * to initialize each device. It determines if the device is
+ * present, and if so, calls _INI.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsInitOneDevice (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
+ ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo;
+ UINT32 Flags;
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *DeviceNode;
+
+
+ ACPI_FUNCTION_TRACE (NsInitOneDevice);
+
+
+ /* We are interested in Devices, Processors and ThermalZones only */
+
+ DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
+ if ((DeviceNode->Type != ACPI_TYPE_DEVICE) &&
+ (DeviceNode->Type != ACPI_TYPE_PROCESSOR) &&
+ (DeviceNode->Type != ACPI_TYPE_THERMAL))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Because of an earlier namespace analysis, all subtrees that contain an
+ * _INI method are tagged.
+ *
+ * If this device subtree does not contain any _INI methods, we
+ * can exit now and stop traversing this entire subtree.
+ */
+ if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI))
+ {
+ return_ACPI_STATUS (AE_CTRL_DEPTH);
+ }
+
+ /*
+ * Run _STA to determine if this device is present and functioning. We
+ * must know this information for two important reasons (from ACPI spec):
+ *
+ * 1) We can only run _INI if the device is present.
+ * 2) We must abort the device tree walk on this subtree if the device is
+ * not present and is not functional (we will not examine the children)
+ *
+ * The _STA method is not required to be present under the device, we
+ * assume the device is present if _STA does not exist.
+ */
+ ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
+ ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA));
+
+ Status = AcpiUtExecute_STA (DeviceNode, &Flags);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Ignore error and move on to next device */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Flags == -1 means that _STA was not found. In this case, we assume that
+ * the device is both present and functional.
+ *
+ * From the ACPI spec, description of _STA:
+ *
+ * "If a device object (including the processor object) does not have an
+ * _STA object, then OSPM assumes that all of the above bits are set (in
+ * other words, the device is present, ..., and functioning)"
+ */
+ if (Flags != ACPI_UINT32_MAX)
+ {
+ WalkInfo->Num_STA++;
+ }
+
+ /*
+ * Examine the PRESENT and FUNCTIONING status bits
+ *
+ * Note: ACPI spec does not seem to specify behavior for the present but
+ * not functioning case, so we assume functioning if present.
+ */
+ if (!(Flags & ACPI_STA_DEVICE_PRESENT))
+ {
+ /* Device is not present, we must examine the Functioning bit */
+
+ if (Flags & ACPI_STA_DEVICE_FUNCTIONING)
+ {
+ /*
+ * Device is not present but is "functioning". In this case,
+ * we will not run _INI, but we continue to examine the children
+ * of this device.
+ *
+ * From the ACPI spec, description of _STA: (Note - no mention
+ * of whether to run _INI or not on the device in question)
+ *
+ * "_STA may return bit 0 clear (not present) with bit 3 set
+ * (device is functional). This case is used to indicate a valid
+ * device for which no device driver should be loaded (for example,
+ * a bridge device.) Children of this device may be present and
+ * valid. OSPM should continue enumeration below a device whose
+ * _STA returns this bit combination"
+ */
+ return_ACPI_STATUS (AE_OK);
+ }
+ else
+ {
+ /*
+ * Device is not present and is not functioning. We must abort the
+ * walk of this subtree immediately -- don't look at the children
+ * of such a device.
+ *
+ * From the ACPI spec, description of _INI:
+ *
+ * "If the _STA method indicates that the device is not present,
+ * OSPM will not run the _INI and will not examine the children
+ * of the device for _INI methods"
+ */
+ return_ACPI_STATUS (AE_CTRL_DEPTH);
+ }
+ }
+
+ /*
+ * The device is present or is assumed present if no _STA exists.
+ * Run the _INI if it exists (not required to exist)
+ *
+ * Note: We know there is an _INI within this subtree, but it may not be
+ * under this particular device, it may be lower in the branch.
+ */
+ ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
+ ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI));
+
+ Info->PrefixNode = DeviceNode;
+ Info->Pathname = METHOD_NAME__INI;
+ Info->Parameters = NULL;
+ Info->Flags = ACPI_IGNORE_RETURN_VALUE;
+
+ Status = AcpiNsEvaluate (Info);
+ if (ACPI_SUCCESS (Status))
+ {
+ WalkInfo->Num_INI++;
+
+ if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) &&
+ (!(AcpiDbgLevel & ACPI_LV_INFO)))
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
+ }
+ }
+
+#ifdef ACPI_DEBUG_OUTPUT
+ else if (Status != AE_NOT_FOUND)
+ {
+ /* Ignore error and move on to next device */
+
+ char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode);
+
+ ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution",
+ ScopeName));
+ ACPI_FREE (ScopeName);
+ }
+#endif
+
+ /* Ignore errors from above */
+
+ Status = AE_OK;
+
+ /*
+ * The _INI method has been run if present; call the Global Initialization
+ * Handler for this device.
+ */
+ if (AcpiGbl_InitHandler)
+ {
+ Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI);
+ }
+
+ return_ACPI_STATUS (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsload.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsload.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,356 @@
+/******************************************************************************
+ *
+ * Module Name: nsload - namespace loading/expanding/contracting procedures
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __NSLOAD_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/acdispat.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsload")
+
+/* Local prototypes */
+
+#ifdef ACPI_FUTURE_IMPLEMENTATION
+ACPI_STATUS
+AcpiNsUnloadNamespace (
+ ACPI_HANDLE Handle);
+
+static ACPI_STATUS
+AcpiNsDeleteSubtree (
+ ACPI_HANDLE StartHandle);
+#endif
+
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsLoadTable
+ *
+ * PARAMETERS: TableIndex - Index for table to be loaded
+ * Node - Owning NS node
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load one ACPI table into the namespace
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsLoadTable (
+ UINT32 TableIndex,
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (NsLoadTable);
+
+
+ /*
+ * Parse the table and load the namespace with all named
+ * objects found within. Control methods are NOT parsed
+ * at this time. In fact, the control methods cannot be
+ * parsed until the entire namespace is loaded, because
+ * if a control method makes a forward reference (call)
+ * to another control method, we can't continue parsing
+ * because we don't know how many arguments to parse next!
+ */
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* If table already loaded into namespace, just return */
+
+ if (AcpiTbIsTableLoaded (TableIndex))
+ {
+ Status = AE_ALREADY_EXISTS;
+ goto Unlock;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "**** Loading table into namespace ****\n"));
+
+ Status = AcpiTbAllocateOwnerId (TableIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Unlock;
+ }
+
+ Status = AcpiNsParseTable (TableIndex, Node);
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiTbSetTableLoadedFlag (TableIndex, TRUE);
+ }
+ else
+ {
+ (void) AcpiTbReleaseOwnerId (TableIndex);
+ }
+
+Unlock:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now we can parse the control methods. We always parse
+ * them here for a sanity check, and if configured for
+ * just-in-time parsing, we delete the control method
+ * parse trees.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "**** Begin Table Method Parsing and Object Initialization\n"));
+
+ Status = AcpiDsInitializeObjects (TableIndex, Node);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "**** Completed Table Method Parsing and Object Initialization\n"));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiLoadNamespace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
+ * (DSDT points to either the BIOS or a buffer.)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsLoadNamespace (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiLoadNameSpace);
+
+
+ /* There must be at least a DSDT installed */
+
+ if (AcpiGbl_DSDT == NULL)
+ {
+ ACPI_ERROR ((AE_INFO, "DSDT is not in memory"));
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ /*
+ * Load the namespace. The DSDT is required,
+ * but the SSDT and PSDT tables are optional.
+ */
+ Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Ignore exceptions from these */
+
+ (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT);
+ (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT);
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+ "ACPI Namespace successfully loaded at root %p\n",
+ AcpiGbl_RootNode));
+
+ return_ACPI_STATUS (Status);
+}
+#endif
+
+#ifdef ACPI_FUTURE_IMPLEMENTATION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDeleteSubtree
+ *
+ * PARAMETERS: StartHandle - Handle in namespace where search begins
+ *
+ * RETURNS Status
+ *
+ * DESCRIPTION: Walks the namespace starting at the given handle and deletes
+ * all objects, entries, and scopes in the entire subtree.
+ *
+ * Namespace/Interpreter should be locked or the subsystem should
+ * be in shutdown before this routine is called.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsDeleteSubtree (
+ ACPI_HANDLE StartHandle)
+{
+ ACPI_STATUS Status;
+ ACPI_HANDLE ChildHandle;
+ ACPI_HANDLE ParentHandle;
+ ACPI_HANDLE NextChildHandle;
+ ACPI_HANDLE Dummy;
+ UINT32 Level;
+
+
+ ACPI_FUNCTION_TRACE (NsDeleteSubtree);
+
+
+ ParentHandle = StartHandle;
+ ChildHandle = NULL;
+ Level = 1;
+
+ /*
+ * Traverse the tree of objects until we bubble back up
+ * to where we started.
+ */
+ while (Level > 0)
+ {
+ /* Attempt to get the next object in this scope */
+
+ Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle,
+ ChildHandle, &NextChildHandle);
+
+ ChildHandle = NextChildHandle;
+
+ /* Did we get a new object? */
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Check if this object has any children */
+
+ if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle,
+ NULL, &Dummy)))
+ {
+ /*
+ * There is at least one child of this object,
+ * visit the object
+ */
+ Level++;
+ ParentHandle = ChildHandle;
+ ChildHandle = NULL;
+ }
+ }
+ else
+ {
+ /*
+ * No more children in this object, go back up to
+ * the object's parent
+ */
+ Level--;
+
+ /* Delete all children now */
+
+ AcpiNsDeleteChildren (ChildHandle);
+
+ ChildHandle = ParentHandle;
+ Status = AcpiGetParent (ParentHandle, &ParentHandle);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+
+ /* Now delete the starting object, and we are done */
+
+ AcpiNsRemoveNode (ChildHandle);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsUnloadNameSpace
+ *
+ * PARAMETERS: Handle - Root of namespace subtree to be deleted
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Shrinks the namespace, typically in response to an undocking
+ * event. Deletes an entire subtree starting from (and
+ * including) the given handle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsUnloadNamespace (
+ ACPI_HANDLE Handle)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (NsUnloadNameSpace);
+
+
+ /* Parameter validation */
+
+ if (!AcpiGbl_RootNode)
+ {
+ return_ACPI_STATUS (AE_NO_NAMESPACE);
+ }
+
+ if (!Handle)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* This function does the real work */
+
+ Status = AcpiNsDeleteSubtree (Handle);
+
+ return_ACPI_STATUS (Status);
+}
+#endif
+#endif
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsnames.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsnames.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,303 @@
+/*******************************************************************************
+ *
+ * Module Name: nsnames - Name manipulation and search
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __NSNAMES_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/acnamesp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsnames")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsBuildExternalPath
+ *
+ * PARAMETERS: Node - NS node whose pathname is needed
+ * Size - Size of the pathname
+ * *NameBuffer - Where to return the pathname
+ *
+ * RETURN: Status
+ * Places the pathname into the NameBuffer, in external format
+ * (name segments separated by path separators)
+ *
+ * DESCRIPTION: Generate a full pathaname
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsBuildExternalPath (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_SIZE Size,
+ char *NameBuffer)
+{
+ ACPI_SIZE Index;
+ ACPI_NAMESPACE_NODE *ParentNode;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Special case for root */
+
+ Index = Size - 1;
+ if (Index < ACPI_NAME_SIZE)
+ {
+ NameBuffer[0] = AML_ROOT_PREFIX;
+ NameBuffer[1] = 0;
+ return (AE_OK);
+ }
+
+ /* Store terminator byte, then build name backwards */
+
+ ParentNode = Node;
+ NameBuffer[Index] = 0;
+
+ while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode))
+ {
+ Index -= ACPI_NAME_SIZE;
+
+ /* Put the name into the buffer */
+
+ ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name);
+ ParentNode = ParentNode->Parent;
+
+ /* Prefix name with the path separator */
+
+ Index--;
+ NameBuffer[Index] = ACPI_PATH_SEPARATOR;
+ }
+
+ /* Overwrite final separator with the root prefix character */
+
+ NameBuffer[Index] = AML_ROOT_PREFIX;
+
+ if (Index != 0)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not construct external pathname; index=%u, size=%u, Path=%s",
+ (UINT32) Index, (UINT32) Size, &NameBuffer[Size]));
+
+ return (AE_BAD_PARAMETER);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetExternalPathname
+ *
+ * PARAMETERS: Node - Namespace node whose pathname is needed
+ *
+ * RETURN: Pointer to storage containing the fully qualified name of
+ * the node, In external format (name segments separated by path
+ * separators.)
+ *
+ * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
+ * for error and debug statements.
+ *
+ ******************************************************************************/
+
+char *
+AcpiNsGetExternalPathname (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_STATUS Status;
+ char *NameBuffer;
+ ACPI_SIZE Size;
+
+
+ ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node);
+
+
+ /* Calculate required buffer size based on depth below root */
+
+ Size = AcpiNsGetPathnameLength (Node);
+ if (!Size)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Allocate a buffer to be returned to caller */
+
+ NameBuffer = ACPI_ALLOCATE_ZEROED (Size);
+ if (!NameBuffer)
+ {
+ ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size));
+ return_PTR (NULL);
+ }
+
+ /* Build the path in the allocated buffer */
+
+ Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_FREE (NameBuffer);
+ return_PTR (NULL);
+ }
+
+ return_PTR (NameBuffer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetPathnameLength
+ *
+ * PARAMETERS: Node - Namespace node
+ *
+ * RETURN: Length of path, including prefix
+ *
+ * DESCRIPTION: Get the length of the pathname string for this node
+ *
+ ******************************************************************************/
+
+ACPI_SIZE
+AcpiNsGetPathnameLength (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_SIZE Size;
+ ACPI_NAMESPACE_NODE *NextNode;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Compute length of pathname as 5 * number of name segments.
+ * Go back up the parent tree to the root
+ */
+ Size = 0;
+ NextNode = Node;
+
+ while (NextNode && (NextNode != AcpiGbl_RootNode))
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Invalid Namespace Node (%p) while traversing namespace",
+ NextNode));
+ return 0;
+ }
+ Size += ACPI_PATH_SEGMENT_LENGTH;
+ NextNode = NextNode->Parent;
+ }
+
+ if (!Size)
+ {
+ Size = 1; /* Root node case */
+ }
+
+ return (Size + 1); /* +1 for null string terminator */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsHandleToPathname
+ *
+ * PARAMETERS: TargetHandle - Handle of named object whose name is
+ * to be found
+ * Buffer - Where the pathname is returned
+ *
+ * RETURN: Status, Buffer is filled with pathname if status is AE_OK
+ *
+ * DESCRIPTION: Build and return a full namespace pathname
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsHandleToPathname (
+ ACPI_HANDLE TargetHandle,
+ ACPI_BUFFER *Buffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_SIZE RequiredSize;
+
+
+ ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle);
+
+
+ Node = AcpiNsValidateHandle (TargetHandle);
+ if (!Node)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Determine size required for the caller buffer */
+
+ RequiredSize = AcpiNsGetPathnameLength (Node);
+ if (!RequiredSize)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (Buffer, RequiredSize);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Build the path in the caller buffer */
+
+ Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n",
+ (char *) Buffer->Pointer, (UINT32) RequiredSize));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsobject.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsobject.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,505 @@
+/*******************************************************************************
+ *
+ * Module Name: nsobject - Utilities for objects attached to namespace
+ * table entries
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __NSOBJECT_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsobject")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsAttachObject
+ *
+ * PARAMETERS: Node - Parent Node
+ * Object - Object to be attached
+ * Type - Type of object, or ACPI_TYPE_ANY if not
+ * known
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Record the given object as the value associated with the
+ * name whose ACPI_HANDLE is passed. If Object is NULL
+ * and Type is ACPI_TYPE_ANY, set the name as having no value.
+ * Note: Future may require that the Node->Flags field be passed
+ * as a parameter.
+ *
+ * MUTEX: Assumes namespace is locked
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsAttachObject (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_OPERAND_OBJECT *Object,
+ ACPI_OBJECT_TYPE Type)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *LastObjDesc;
+ ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY;
+
+
+ ACPI_FUNCTION_TRACE (NsAttachObject);
+
+
+ /*
+ * Parameter validation
+ */
+ if (!Node)
+ {
+ /* Invalid handle */
+
+ ACPI_ERROR ((AE_INFO, "Null NamedObj handle"));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (!Object && (ACPI_TYPE_ANY != Type))
+ {
+ /* Null object */
+
+ ACPI_ERROR ((AE_INFO,
+ "Null object, but type not ACPI_TYPE_ANY"));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
+ {
+ /* Not a name handle */
+
+ ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]",
+ Node, AcpiUtGetDescriptorName (Node)));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Check if this object is already attached */
+
+ if (Node->Object == Object)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Obj %p already installed in NameObj %p\n",
+ Object, Node));
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* If null object, we will just install it */
+
+ if (!Object)
+ {
+ ObjDesc = NULL;
+ ObjectType = ACPI_TYPE_ANY;
+ }
+
+ /*
+ * If the source object is a namespace Node with an attached object,
+ * we will use that (attached) object
+ */
+ else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) &&
+ ((ACPI_NAMESPACE_NODE *) Object)->Object)
+ {
+ /*
+ * Value passed is a name handle and that name has a
+ * non-null value. Use that name's value and type.
+ */
+ ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object;
+ ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type;
+ }
+
+ /*
+ * Otherwise, we will use the parameter object, but we must type
+ * it first
+ */
+ else
+ {
+ ObjDesc = (ACPI_OPERAND_OBJECT *) Object;
+
+ /* Use the given type */
+
+ ObjectType = Type;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
+ ObjDesc, Node, AcpiUtGetNodeName (Node)));
+
+ /* Detach an existing attached object if present */
+
+ if (Node->Object)
+ {
+ AcpiNsDetachObject (Node);
+ }
+
+ if (ObjDesc)
+ {
+ /*
+ * Must increment the new value's reference count
+ * (if it is an internal object)
+ */
+ AcpiUtAddReference (ObjDesc);
+
+ /*
+ * Handle objects with multiple descriptors - walk
+ * to the end of the descriptor list
+ */
+ LastObjDesc = ObjDesc;
+ while (LastObjDesc->Common.NextObject)
+ {
+ LastObjDesc = LastObjDesc->Common.NextObject;
+ }
+
+ /* Install the object at the front of the object list */
+
+ LastObjDesc->Common.NextObject = Node->Object;
+ }
+
+ Node->Type = (UINT8) ObjectType;
+ Node->Object = ObjDesc;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDetachObject
+ *
+ * PARAMETERS: Node - A Namespace node whose object will be detached
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Detach/delete an object associated with a namespace node.
+ * if the object is an allocated object, it is freed.
+ * Otherwise, the field is simply cleared.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDetachObject (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE (NsDetachObject);
+
+
+ ObjDesc = Node->Object;
+
+ if (!ObjDesc ||
+ (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
+ {
+ return_VOID;
+ }
+
+ if (Node->Flags & ANOBJ_ALLOCATED_BUFFER)
+ {
+ /* Free the dynamic aml buffer */
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_METHOD)
+ {
+ ACPI_FREE (ObjDesc->Method.AmlStart);
+ }
+ }
+
+ /* Clear the entry in all cases */
+
+ Node->Object = NULL;
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
+ {
+ Node->Object = ObjDesc->Common.NextObject;
+ if (Node->Object &&
+ ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA))
+ {
+ Node->Object = Node->Object->Common.NextObject;
+ }
+ }
+
+ /* Reset the node type to untyped */
+
+ Node->Type = ACPI_TYPE_ANY;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
+ Node, AcpiUtGetNodeName (Node), ObjDesc));
+
+ /* Remove one reference on the object (and all subobjects) */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetAttachedObject
+ *
+ * PARAMETERS: Node - Namespace node
+ *
+ * RETURN: Current value of the object field from the Node whose
+ * handle is passed
+ *
+ * DESCRIPTION: Obtain the object attached to a namespace node.
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiNsGetAttachedObject (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node);
+
+
+ if (!Node)
+ {
+ ACPI_WARNING ((AE_INFO, "Null Node ptr"));
+ return_PTR (NULL);
+ }
+
+ if (!Node->Object ||
+ ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) &&
+ (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) ||
+ ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA))
+ {
+ return_PTR (NULL);
+ }
+
+ return_PTR (Node->Object);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetSecondaryObject
+ *
+ * PARAMETERS: Node - Namespace node
+ *
+ * RETURN: Current value of the object field from the Node whose
+ * handle is passed.
+ *
+ * DESCRIPTION: Obtain a secondary object associated with a namespace node.
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiNsGetSecondaryObject (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc);
+
+
+ if ((!ObjDesc) ||
+ (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) ||
+ (!ObjDesc->Common.NextObject) ||
+ ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA))
+ {
+ return_PTR (NULL);
+ }
+
+ return_PTR (ObjDesc->Common.NextObject);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsAttachData
+ *
+ * PARAMETERS: Node - Namespace node
+ * Handler - Handler to be associated with the data
+ * Data - Data to be attached
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Low-level attach data. Create and attach a Data object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsAttachData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_OBJECT_HANDLER Handler,
+ void *Data)
+{
+ ACPI_OPERAND_OBJECT *PrevObjDesc;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *DataDesc;
+
+
+ /* We only allow one attachment per handler */
+
+ PrevObjDesc = NULL;
+ ObjDesc = Node->Object;
+ while (ObjDesc)
+ {
+ if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
+ (ObjDesc->Data.Handler == Handler))
+ {
+ return (AE_ALREADY_EXISTS);
+ }
+
+ PrevObjDesc = ObjDesc;
+ ObjDesc = ObjDesc->Common.NextObject;
+ }
+
+ /* Create an internal object for the data */
+
+ DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA);
+ if (!DataDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ DataDesc->Data.Handler = Handler;
+ DataDesc->Data.Pointer = Data;
+
+ /* Install the data object */
+
+ if (PrevObjDesc)
+ {
+ PrevObjDesc->Common.NextObject = DataDesc;
+ }
+ else
+ {
+ Node->Object = DataDesc;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDetachData
+ *
+ * PARAMETERS: Node - Namespace node
+ * Handler - Handler associated with the data
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Low-level detach data. Delete the data node, but the caller
+ * is responsible for the actual data.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsDetachData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_OBJECT_HANDLER Handler)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT *PrevObjDesc;
+
+
+ PrevObjDesc = NULL;
+ ObjDesc = Node->Object;
+ while (ObjDesc)
+ {
+ if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
+ (ObjDesc->Data.Handler == Handler))
+ {
+ if (PrevObjDesc)
+ {
+ PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject;
+ }
+ else
+ {
+ Node->Object = ObjDesc->Common.NextObject;
+ }
+
+ AcpiUtRemoveReference (ObjDesc);
+ return (AE_OK);
+ }
+
+ PrevObjDesc = ObjDesc;
+ ObjDesc = ObjDesc->Common.NextObject;
+ }
+
+ return (AE_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetAttachedData
+ *
+ * PARAMETERS: Node - Namespace node
+ * Handler - Handler associated with the data
+ * Data - Where the data is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Low level interface to obtain data previously associated with
+ * a namespace node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsGetAttachedData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_OBJECT_HANDLER Handler,
+ void **Data)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ObjDesc = Node->Object;
+ while (ObjDesc)
+ {
+ if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
+ (ObjDesc->Data.Handler == Handler))
+ {
+ *Data = ObjDesc->Data.Pointer;
+ return (AE_OK);
+ }
+
+ ObjDesc = ObjDesc->Common.NextObject;
+ }
+
+ return (AE_NOT_FOUND);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsparse.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsparse.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,225 @@
+/******************************************************************************
+ *
+ * Module Name: nsparse - namespace interface to AML parser
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __NSPARSE_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/acparser.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsparse")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: NsOneCompleteParse
+ *
+ * PARAMETERS: PassNumber - 1 or 2
+ * TableDesc - The table to be parsed.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsOneCompleteParse (
+ UINT32 PassNumber,
+ UINT32 TableIndex,
+ ACPI_NAMESPACE_NODE *StartNode)
+{
+ ACPI_PARSE_OBJECT *ParseRoot;
+ ACPI_STATUS Status;
+ UINT32 AmlLength;
+ UINT8 *AmlStart;
+ ACPI_WALK_STATE *WalkState;
+ ACPI_TABLE_HEADER *Table;
+ ACPI_OWNER_ID OwnerId;
+
+
+ ACPI_FUNCTION_TRACE (NsOneCompleteParse);
+
+
+ Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Create and init a Root Node */
+
+ ParseRoot = AcpiPsCreateScopeOp ();
+ if (!ParseRoot)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Create and initialize a new walk state */
+
+ WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ AcpiPsFreeOp (ParseRoot);
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiGetTableByIndex (TableIndex, &Table);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ AcpiPsFreeOp (ParseRoot);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Table must consist of at least a complete header */
+
+ if (Table->Length < sizeof (ACPI_TABLE_HEADER))
+ {
+ Status = AE_BAD_HEADER;
+ }
+ else
+ {
+ AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER);
+ AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
+ Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL,
+ AmlStart, AmlLength, NULL, (UINT8) PassNumber);
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ goto Cleanup;
+ }
+
+ /* StartNode is the default location to load the table */
+
+ if (StartNode && StartNode != AcpiGbl_RootNode)
+ {
+ Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ goto Cleanup;
+ }
+ }
+
+ /* Parse the AML */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %u parse\n", PassNumber));
+ Status = AcpiPsParseAml (WalkState);
+
+Cleanup:
+ AcpiPsDeleteParseTree (ParseRoot);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsParseTable
+ *
+ * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse
+ * StartNode - Where to enter the table into the namespace
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsParseTable (
+ UINT32 TableIndex,
+ ACPI_NAMESPACE_NODE *StartNode)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (NsParseTable);
+
+
+ /*
+ * AML Parse, pass 1
+ *
+ * In this pass, we load most of the namespace. Control methods
+ * are not parsed until later. A parse tree is not created. Instead,
+ * each Parser Op subtree is deleted when it is finished. This saves
+ * a great deal of memory, and allows a small cache of parse objects
+ * to service the entire parse. The second pass of the parse then
+ * performs another complete parse of the AML.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n"));
+ Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1,
+ TableIndex, StartNode);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * AML Parse, pass 2
+ *
+ * In this pass, we resolve forward references and other things
+ * that could not be completed during the first pass.
+ * Another complete parse of the AML is performed, but the
+ * overhead of this is compensated for by the fact that the
+ * parse objects are all cached.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n"));
+ Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2,
+ TableIndex, StartNode);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nspredef.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nspredef.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1243 @@
+/******************************************************************************
+ *
+ * Module Name: nspredef - Validation of ACPI predefined methods and objects
+ *
+ *****************************************************************************/
+
+/*
+ * 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 ACPI_CREATE_PREDEFINED_TABLE
+
+#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/acpredef.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nspredef")
+
+
+/*******************************************************************************
+ *
+ * This module validates predefined ACPI objects that appear in the namespace,
+ * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this
+ * validation is to detect problems with BIOS-exposed predefined ACPI objects
+ * before the results are returned to the ACPI-related drivers.
+ *
+ * There are several areas that are validated:
+ *
+ * 1) The number of input arguments as defined by the method/object in the
+ * ASL is validated against the ACPI specification.
+ * 2) The type of the return object (if any) is validated against the ACPI
+ * specification.
+ * 3) For returned package objects, the count of package elements is
+ * validated, as well as the type of each package element. Nested
+ * packages are supported.
+ *
+ * For any problems found, a warning message is issued.
+ *
+ ******************************************************************************/
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiNsCheckPackage (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+static ACPI_STATUS
+AcpiNsCheckPackageList (
+ ACPI_PREDEFINED_DATA *Data,
+ const ACPI_PREDEFINED_INFO *Package,
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT32 Count);
+
+static ACPI_STATUS
+AcpiNsCheckPackageElements (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT8 Type1,
+ UINT32 Count1,
+ UINT8 Type2,
+ UINT32 Count2,
+ UINT32 StartIndex);
+
+static ACPI_STATUS
+AcpiNsCheckObjectType (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr,
+ UINT32 ExpectedBtypes,
+ UINT32 PackageIndex);
+
+static ACPI_STATUS
+AcpiNsCheckReference (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT *ReturnObject);
+
+static void
+AcpiNsGetExpectedTypes (
+ char *Buffer,
+ UINT32 ExpectedBtypes);
+
+/*
+ * Names for the types that can be returned by the predefined objects.
+ * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
+ */
+static const char *AcpiRtypeNames[] =
+{
+ "/Integer",
+ "/String",
+ "/Buffer",
+ "/Package",
+ "/Reference",
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckPredefinedNames
+ *
+ * PARAMETERS: Node - Namespace node for the method/object
+ * UserParamCount - Number of parameters actually passed
+ * ReturnStatus - Status from the object evaluation
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check an ACPI name for a match in the predefined name list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsCheckPredefinedNames (
+ ACPI_NAMESPACE_NODE *Node,
+ UINT32 UserParamCount,
+ ACPI_STATUS ReturnStatus,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_STATUS Status = AE_OK;
+ const ACPI_PREDEFINED_INFO *Predefined;
+ char *Pathname;
+ ACPI_PREDEFINED_DATA *Data;
+
+
+ /* Match the name for this method/object against the predefined list */
+
+ Predefined = AcpiNsCheckForPredefinedName (Node);
+
+ /* Get the full pathname to the object, for use in warning messages */
+
+ Pathname = AcpiNsGetExternalPathname (Node);
+ if (!Pathname)
+ {
+ return (AE_OK); /* Could not get pathname, ignore */
+ }
+
+ /*
+ * Check that the parameter count for this method matches the ASL
+ * definition. For predefined names, ensure that both the caller and
+ * the method itself are in accordance with the ACPI specification.
+ */
+ AcpiNsCheckParameterCount (Pathname, Node, UserParamCount, Predefined);
+
+ /* If not a predefined name, we cannot validate the return object */
+
+ if (!Predefined)
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * If the method failed or did not actually return an object, we cannot
+ * validate the return object
+ */
+ if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * If there is no return value, check if we require a return value for
+ * this predefined name. Either one return value is expected, or none,
+ * for both methods and other objects.
+ *
+ * Exit now if there is no return object. Warning if one was expected.
+ */
+ if (!ReturnObject)
+ {
+ if ((Predefined->Info.ExpectedBtypes) &&
+ (!(Predefined->Info.ExpectedBtypes & ACPI_RTYPE_NONE)))
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+ "Missing expected return value"));
+
+ Status = AE_AML_NO_RETURN_VALUE;
+ }
+ goto Cleanup;
+ }
+
+ /*
+ * Return value validation and possible repair.
+ *
+ * 1) Don't perform return value validation/repair if this feature
+ * has been disabled via a global option.
+ *
+ * 2) We have a return value, but if one wasn't expected, just exit,
+ * this is not a problem. For example, if the "Implicit Return"
+ * feature is enabled, methods will always return a value.
+ *
+ * 3) If the return value can be of any type, then we cannot perform
+ * any validation, just exit.
+ */
+ if (AcpiGbl_DisableAutoRepair ||
+ (!Predefined->Info.ExpectedBtypes) ||
+ (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL))
+ {
+ goto Cleanup;
+ }
+
+ /* Create the parameter data block for object validation */
+
+ Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA));
+ if (!Data)
+ {
+ goto Cleanup;
+ }
+ Data->Predefined = Predefined;
+ Data->Node = Node;
+ Data->NodeFlags = Node->Flags;
+ Data->Pathname = Pathname;
+
+ /*
+ * Check that the type of the main return object is what is expected
+ * for this predefined name
+ */
+ Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr,
+ Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+
+ /*
+ * For returned Package objects, check the type of all sub-objects.
+ * Note: Package may have been newly created by call above.
+ */
+ if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE)
+ {
+ Data->ParentPackage = *ReturnObjectPtr;
+ Status = AcpiNsCheckPackage (Data, ReturnObjectPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+ }
+
+ /*
+ * The return object was OK, or it was successfully repaired above.
+ * Now make some additional checks such as verifying that package
+ * objects are sorted correctly (if required) or buffer objects have
+ * the correct data width (bytes vs. dwords). These repairs are
+ * performed on a per-name basis, i.e., the code is specific to
+ * particular predefined names.
+ */
+ Status = AcpiNsComplexRepairs (Data, Node, Status, ReturnObjectPtr);
+
+Exit:
+ /*
+ * If the object validation failed or if we successfully repaired one
+ * or more objects, mark the parent node to suppress further warning
+ * messages during the next evaluation of the same method/object.
+ */
+ if (ACPI_FAILURE (Status) || (Data->Flags & ACPI_OBJECT_REPAIRED))
+ {
+ Node->Flags |= ANOBJ_EVALUATED;
+ }
+ ACPI_FREE (Data);
+
+Cleanup:
+ ACPI_FREE (Pathname);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckParameterCount
+ *
+ * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
+ * Node - Namespace node for the method/object
+ * UserParamCount - Number of args passed in by the caller
+ * Predefined - Pointer to entry in predefined name table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a
+ * predefined name is what is expected (i.e., what is defined in
+ * the ACPI specification for this predefined name.)
+ *
+ ******************************************************************************/
+
+void
+AcpiNsCheckParameterCount (
+ char *Pathname,
+ ACPI_NAMESPACE_NODE *Node,
+ UINT32 UserParamCount,
+ const ACPI_PREDEFINED_INFO *Predefined)
+{
+ UINT32 ParamCount;
+ UINT32 RequiredParamsCurrent;
+ UINT32 RequiredParamsOld;
+
+
+ /* Methods have 0-7 parameters. All other types have zero. */
+
+ ParamCount = 0;
+ if (Node->Type == ACPI_TYPE_METHOD)
+ {
+ ParamCount = Node->Object->Method.ParamCount;
+ }
+
+ if (!Predefined)
+ {
+ /*
+ * Check the parameter count for non-predefined methods/objects.
+ *
+ * Warning if too few or too many arguments have been passed by the
+ * caller. An incorrect number of arguments may not cause the method
+ * to fail. However, the method will fail if there are too few
+ * arguments and the method attempts to use one of the missing ones.
+ */
+ if (UserParamCount < ParamCount)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+ "Insufficient arguments - needs %u, found %u",
+ ParamCount, UserParamCount));
+ }
+ else if (UserParamCount > ParamCount)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+ "Excess arguments - needs %u, found %u",
+ ParamCount, UserParamCount));
+ }
+ return;
+ }
+
+ /*
+ * Validate the user-supplied parameter count.
+ * Allow two different legal argument counts (_SCP, etc.)
+ */
+ RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F;
+ RequiredParamsOld = Predefined->Info.ParamCount >> 4;
+
+ if (UserParamCount != ACPI_UINT32_MAX)
+ {
+ if ((UserParamCount != RequiredParamsCurrent) &&
+ (UserParamCount != RequiredParamsOld))
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+ "Parameter count mismatch - "
+ "caller passed %u, ACPI requires %u",
+ UserParamCount, RequiredParamsCurrent));
+ }
+ }
+
+ /*
+ * Check that the ASL-defined parameter count is what is expected for
+ * this predefined name (parameter count as defined by the ACPI
+ * specification)
+ */
+ if ((ParamCount != RequiredParamsCurrent) &&
+ (ParamCount != RequiredParamsOld))
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, Node->Flags,
+ "Parameter count mismatch - ASL declared %u, ACPI requires %u",
+ ParamCount, RequiredParamsCurrent));
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckForPredefinedName
+ *
+ * PARAMETERS: Node - Namespace node for the method/object
+ *
+ * RETURN: Pointer to entry in predefined table. NULL indicates not found.
+ *
+ * DESCRIPTION: Check an object name against the predefined object list.
+ *
+ ******************************************************************************/
+
+const ACPI_PREDEFINED_INFO *
+AcpiNsCheckForPredefinedName (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ const ACPI_PREDEFINED_INFO *ThisName;
+
+
+ /* Quick check for a predefined name, first character must be underscore */
+
+ if (Node->Name.Ascii[0] != '_')
+ {
+ return (NULL);
+ }
+
+ /* Search info table for a predefined method/object name */
+
+ ThisName = PredefinedNames;
+ while (ThisName->Info.Name[0])
+ {
+ if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name))
+ {
+ return (ThisName);
+ }
+
+ /*
+ * Skip next entry in the table if this name returns a Package
+ * (next entry contains the package info)
+ */
+ if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)
+ {
+ ThisName++;
+ }
+
+ ThisName++;
+ }
+
+ return (NULL); /* Not found */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckPackage
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check a returned package object for the correct count and
+ * correct type of all sub-objects.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsCheckPackage (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ const ACPI_PREDEFINED_INFO *Package;
+ ACPI_OPERAND_OBJECT **Elements;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 ExpectedCount;
+ UINT32 Count;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME (NsCheckPackage);
+
+
+ /* The package info for this name is in the next table entry */
+
+ Package = Data->Predefined + 1;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "%s Validating return Package of Type %X, Count %X\n",
+ Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count));
+
+ /*
+ * For variable-length Packages, we can safely remove all embedded
+ * and trailing NULL package elements
+ */
+ AcpiNsRemoveNullElements (Data, Package->RetInfo.Type, ReturnObject);
+
+ /* Extract package count and elements array */
+
+ Elements = ReturnObject->Package.Elements;
+ Count = ReturnObject->Package.Count;
+
+ /* The package must have at least one element, else invalid */
+
+ if (!Count)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Return Package has no elements (empty)"));
+
+ return (AE_AML_OPERAND_VALUE);
+ }
+
+ /*
+ * Decode the type of the expected package contents
+ *
+ * PTYPE1 packages contain no subpackages
+ * PTYPE2 packages contain sub-packages
+ */
+ switch (Package->RetInfo.Type)
+ {
+ case ACPI_PTYPE1_FIXED:
+
+ /*
+ * The package count is fixed and there are no sub-packages
+ *
+ * If package is too small, exit.
+ * If package is larger than expected, issue warning but continue
+ */
+ ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
+ if (Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+ else if (Count > ExpectedCount)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Return Package is larger than needed - "
+ "found %u, expected %u\n",
+ Data->Pathname, Count, ExpectedCount));
+ }
+
+ /* Validate all elements of the returned package */
+
+ Status = AcpiNsCheckPackageElements (Data, Elements,
+ Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
+ Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0);
+ break;
+
+
+ case ACPI_PTYPE1_VAR:
+
+ /*
+ * The package count is variable, there are no sub-packages, and all
+ * elements must be of the same type
+ */
+ for (i = 0; i < Count; i++)
+ {
+ Status = AcpiNsCheckObjectType (Data, Elements,
+ Package->RetInfo.ObjectType1, i);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ Elements++;
+ }
+ break;
+
+
+ case ACPI_PTYPE1_OPTION:
+
+ /*
+ * The package count is variable, there are no sub-packages. There are
+ * a fixed number of required elements, and a variable number of
+ * optional elements.
+ *
+ * Check if package is at least as large as the minimum required
+ */
+ ExpectedCount = Package->RetInfo3.Count;
+ if (Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+
+ /* Variable number of sub-objects */
+
+ for (i = 0; i < Count; i++)
+ {
+ if (i < Package->RetInfo3.Count)
+ {
+ /* These are the required package elements (0, 1, or 2) */
+
+ Status = AcpiNsCheckObjectType (Data, Elements,
+ Package->RetInfo3.ObjectType[i], i);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ else
+ {
+ /* These are the optional package elements */
+
+ Status = AcpiNsCheckObjectType (Data, Elements,
+ Package->RetInfo3.TailObjectType, i);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ Elements++;
+ }
+ break;
+
+
+ case ACPI_PTYPE2_REV_FIXED:
+
+ /* First element is the (Integer) revision */
+
+ Status = AcpiNsCheckObjectType (Data, Elements,
+ ACPI_RTYPE_INTEGER, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Elements++;
+ Count--;
+
+ /* Examine the sub-packages */
+
+ Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
+ break;
+
+
+ case ACPI_PTYPE2_PKG_COUNT:
+
+ /* First element is the (Integer) count of sub-packages to follow */
+
+ Status = AcpiNsCheckObjectType (Data, Elements,
+ ACPI_RTYPE_INTEGER, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Count cannot be larger than the parent package length, but allow it
+ * to be smaller. The >= accounts for the Integer above.
+ */
+ ExpectedCount = (UINT32) (*Elements)->Integer.Value;
+ if (ExpectedCount >= Count)
+ {
+ goto PackageTooSmall;
+ }
+
+ Count = ExpectedCount;
+ Elements++;
+
+ /* Examine the sub-packages */
+
+ Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
+ break;
+
+
+ case ACPI_PTYPE2:
+ case ACPI_PTYPE2_FIXED:
+ case ACPI_PTYPE2_MIN:
+ case ACPI_PTYPE2_COUNT:
+ case ACPI_PTYPE2_FIX_VAR:
+
+ /*
+ * These types all return a single Package that consists of a
+ * variable number of sub-Packages.
+ *
+ * First, ensure that the first element is a sub-Package. If not,
+ * the BIOS may have incorrectly returned the object as a single
+ * package instead of a Package of Packages (a common error if
+ * there is only one entry). We may be able to repair this by
+ * wrapping the returned Package with a new outer Package.
+ */
+ if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE))
+ {
+ /* Create the new outer package and populate it */
+
+ Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Update locals to point to the new package (of 1 element) */
+
+ ReturnObject = *ReturnObjectPtr;
+ Elements = ReturnObject->Package.Elements;
+ Count = 1;
+ }
+
+ /* Examine the sub-packages */
+
+ Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
+ break;
+
+
+ default:
+
+ /* Should not get here if predefined info table is correct */
+
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Invalid internal return type in table entry: %X",
+ Package->RetInfo.Type));
+
+ return (AE_AML_INTERNAL);
+ }
+
+ return (Status);
+
+
+PackageTooSmall:
+
+ /* Error exit for the case with an incorrect package count */
+
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Return Package is too small - found %u elements, expected %u",
+ Count, ExpectedCount));
+
+ return (AE_AML_OPERAND_VALUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckPackageList
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * Package - Pointer to package-specific info for method
+ * Elements - Element list of parent package. All elements
+ * of this list should be of type Package.
+ * Count - Count of subpackages
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Examine a list of subpackages
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsCheckPackageList (
+ ACPI_PREDEFINED_DATA *Data,
+ const ACPI_PREDEFINED_INFO *Package,
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT32 Count)
+{
+ ACPI_OPERAND_OBJECT *SubPackage;
+ ACPI_OPERAND_OBJECT **SubElements;
+ ACPI_STATUS Status;
+ UINT32 ExpectedCount;
+ UINT32 i;
+ UINT32 j;
+
+
+ /*
+ * Validate each sub-Package in the parent Package
+ *
+ * NOTE: assumes list of sub-packages contains no NULL elements.
+ * Any NULL elements should have been removed by earlier call
+ * to AcpiNsRemoveNullElements.
+ */
+ for (i = 0; i < Count; i++)
+ {
+ SubPackage = *Elements;
+ SubElements = SubPackage->Package.Elements;
+ Data->ParentPackage = SubPackage;
+
+ /* Each sub-object must be of type Package */
+
+ Status = AcpiNsCheckObjectType (Data, &SubPackage,
+ ACPI_RTYPE_PACKAGE, i);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Examine the different types of expected sub-packages */
+
+ Data->ParentPackage = SubPackage;
+ switch (Package->RetInfo.Type)
+ {
+ case ACPI_PTYPE2:
+ case ACPI_PTYPE2_PKG_COUNT:
+ case ACPI_PTYPE2_REV_FIXED:
+
+ /* Each subpackage has a fixed number of elements */
+
+ ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+
+ Status = AcpiNsCheckPackageElements (Data, SubElements,
+ Package->RetInfo.ObjectType1,
+ Package->RetInfo.Count1,
+ Package->RetInfo.ObjectType2,
+ Package->RetInfo.Count2, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+
+ case ACPI_PTYPE2_FIX_VAR:
+ /*
+ * Each subpackage has a fixed number of elements and an
+ * optional element
+ */
+ ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+
+ Status = AcpiNsCheckPackageElements (Data, SubElements,
+ Package->RetInfo.ObjectType1,
+ Package->RetInfo.Count1,
+ Package->RetInfo.ObjectType2,
+ SubPackage->Package.Count - Package->RetInfo.Count1, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+
+ case ACPI_PTYPE2_FIXED:
+
+ /* Each sub-package has a fixed length */
+
+ ExpectedCount = Package->RetInfo2.Count;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+
+ /* Check the type of each sub-package element */
+
+ for (j = 0; j < ExpectedCount; j++)
+ {
+ Status = AcpiNsCheckObjectType (Data, &SubElements[j],
+ Package->RetInfo2.ObjectType[j], j);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ break;
+
+
+ case ACPI_PTYPE2_MIN:
+
+ /* Each sub-package has a variable but minimum length */
+
+ ExpectedCount = Package->RetInfo.Count1;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+
+ /* Check the type of each sub-package element */
+
+ Status = AcpiNsCheckPackageElements (Data, SubElements,
+ Package->RetInfo.ObjectType1,
+ SubPackage->Package.Count, 0, 0, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+
+ case ACPI_PTYPE2_COUNT:
+
+ /*
+ * First element is the (Integer) count of elements, including
+ * the count field (the ACPI name is NumElements)
+ */
+ Status = AcpiNsCheckObjectType (Data, SubElements,
+ ACPI_RTYPE_INTEGER, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Make sure package is large enough for the Count and is
+ * is as large as the minimum size
+ */
+ ExpectedCount = (UINT32) (*SubElements)->Integer.Value;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+ if (SubPackage->Package.Count < Package->RetInfo.Count1)
+ {
+ ExpectedCount = Package->RetInfo.Count1;
+ goto PackageTooSmall;
+ }
+ if (ExpectedCount == 0)
+ {
+ /*
+ * Either the NumEntries element was originally zero or it was
+ * a NULL element and repaired to an Integer of value zero.
+ * In either case, repair it by setting NumEntries to be the
+ * actual size of the subpackage.
+ */
+ ExpectedCount = SubPackage->Package.Count;
+ (*SubElements)->Integer.Value = ExpectedCount;
+ }
+
+ /* Check the type of each sub-package element */
+
+ Status = AcpiNsCheckPackageElements (Data, (SubElements + 1),
+ Package->RetInfo.ObjectType1,
+ (ExpectedCount - 1), 0, 0, 1);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+
+ default: /* Should not get here, type was validated by caller */
+
+ return (AE_AML_INTERNAL);
+ }
+
+ Elements++;
+ }
+
+ return (AE_OK);
+
+
+PackageTooSmall:
+
+ /* The sub-package count was smaller than required */
+
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Return Sub-Package[%u] is too small - found %u elements, expected %u",
+ i, SubPackage->Package.Count, ExpectedCount));
+
+ return (AE_AML_OPERAND_VALUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckPackageElements
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * Elements - Pointer to the package elements array
+ * Type1 - Object type for first group
+ * Count1 - Count for first group
+ * Type2 - Object type for second group
+ * Count2 - Count for second group
+ * StartIndex - Start of the first group of elements
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check that all elements of a package are of the correct object
+ * type. Supports up to two groups of different object types.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsCheckPackageElements (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT8 Type1,
+ UINT32 Count1,
+ UINT8 Type2,
+ UINT32 Count2,
+ UINT32 StartIndex)
+{
+ ACPI_OPERAND_OBJECT **ThisElement = Elements;
+ ACPI_STATUS Status;
+ UINT32 i;
+
+
+ /*
+ * Up to two groups of package elements are supported by the data
+ * structure. All elements in each group must be of the same type.
+ * The second group can have a count of zero.
+ */
+ for (i = 0; i < Count1; i++)
+ {
+ Status = AcpiNsCheckObjectType (Data, ThisElement,
+ Type1, i + StartIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ ThisElement++;
+ }
+
+ for (i = 0; i < Count2; i++)
+ {
+ Status = AcpiNsCheckObjectType (Data, ThisElement,
+ Type2, (i + Count1 + StartIndex));
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ ThisElement++;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckObjectType
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ * ExpectedBtypes - Bitmap of expected return type(s)
+ * PackageIndex - Index of object within parent package (if
+ * applicable - ACPI_NOT_PACKAGE_ELEMENT
+ * otherwise)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check the type of the return object against the expected object
+ * type(s). Use of Btype allows multiple expected object types.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsCheckObjectType (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr,
+ UINT32 ExpectedBtypes,
+ UINT32 PackageIndex)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 ReturnBtype;
+ char TypeBuffer[48]; /* Room for 5 types */
+
+
+ /*
+ * If we get a NULL ReturnObject here, it is a NULL package element.
+ * Since all extraneous NULL package elements were removed earlier by a
+ * call to AcpiNsRemoveNullElements, this is an unexpected NULL element.
+ * We will attempt to repair it.
+ */
+ if (!ReturnObject)
+ {
+ Status = AcpiNsRepairNullElement (Data, ExpectedBtypes,
+ PackageIndex, ReturnObjectPtr);
+ if (ACPI_SUCCESS (Status))
+ {
+ return (AE_OK); /* Repair was successful */
+ }
+ goto TypeErrorExit;
+ }
+
+ /* A Namespace node should not get here, but make sure */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Invalid return type - Found a Namespace node [%4.4s] type %s",
+ ReturnObject->Node.Name.Ascii,
+ AcpiUtGetTypeName (ReturnObject->Node.Type)));
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type.
+ * The bitmapped type allows multiple possible return types.
+ *
+ * Note, the cases below must handle all of the possible types returned
+ * from all of the predefined names (including elements of returned
+ * packages)
+ */
+ switch (ReturnObject->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ ReturnBtype = ACPI_RTYPE_INTEGER;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ ReturnBtype = ACPI_RTYPE_BUFFER;
+ break;
+
+ case ACPI_TYPE_STRING:
+ ReturnBtype = ACPI_RTYPE_STRING;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ ReturnBtype = ACPI_RTYPE_PACKAGE;
+ break;
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ ReturnBtype = ACPI_RTYPE_REFERENCE;
+ break;
+
+ default:
+ /* Not one of the supported objects, must be incorrect */
+
+ goto TypeErrorExit;
+ }
+
+ /* Is the object one of the expected types? */
+
+ if (ReturnBtype & ExpectedBtypes)
+ {
+ /* For reference objects, check that the reference type is correct */
+
+ if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ Status = AcpiNsCheckReference (Data, ReturnObject);
+ }
+
+ return (Status);
+ }
+
+ /* Type mismatch -- attempt repair of the returned object */
+
+ Status = AcpiNsRepairObject (Data, ExpectedBtypes,
+ PackageIndex, ReturnObjectPtr);
+ if (ACPI_SUCCESS (Status))
+ {
+ return (AE_OK); /* Repair was successful */
+ }
+
+
+TypeErrorExit:
+
+ /* Create a string with all expected types for this predefined object */
+
+ AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes);
+
+ if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Return type mismatch - found %s, expected %s",
+ AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
+ }
+ else
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Return Package type mismatch at index %u - "
+ "found %s, expected %s", PackageIndex,
+ AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
+ }
+
+ return (AE_AML_OPERAND_TYPE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckReference
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObject - Object returned from the evaluation of a
+ * method or object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check a returned reference object for the correct reference
+ * type. The only reference type that can be returned from a
+ * predefined method is a named reference. All others are invalid.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsCheckReference (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT *ReturnObject)
+{
+
+ /*
+ * Check the reference object for the correct reference type (opcode).
+ * The only type of reference that can be converted to an ACPI_OBJECT is
+ * a reference to a named object (reference class: NAME)
+ */
+ if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME)
+ {
+ return (AE_OK);
+ }
+
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Return type mismatch - unexpected reference object type [%s] %2.2X",
+ AcpiUtGetReferenceName (ReturnObject),
+ ReturnObject->Reference.Class));
+
+ return (AE_AML_OPERAND_TYPE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetExpectedTypes
+ *
+ * PARAMETERS: Buffer - Pointer to where the string is returned
+ * ExpectedBtypes - Bitmap of expected return type(s)
+ *
+ * RETURN: Buffer is populated with type names.
+ *
+ * DESCRIPTION: Translate the expected types bitmap into a string of ascii
+ * names of expected types, for use in warning messages.
+ *
+ ******************************************************************************/
+
+static void
+AcpiNsGetExpectedTypes (
+ char *Buffer,
+ UINT32 ExpectedBtypes)
+{
+ UINT32 ThisRtype;
+ UINT32 i;
+ UINT32 j;
+
+
+ j = 1;
+ Buffer[0] = 0;
+ ThisRtype = ACPI_RTYPE_INTEGER;
+
+ for (i = 0; i < ACPI_NUM_RTYPES; i++)
+ {
+ /* If one of the expected types, concatenate the name of this type */
+
+ if (ExpectedBtypes & ThisRtype)
+ {
+ ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]);
+ j = 0; /* Use name separator from now on */
+ }
+ ThisRtype <<= 1; /* Next Rtype */
+ }
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsrepair.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsrepair.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,802 @@
+/******************************************************************************
+ *
+ * Module Name: nsrepair - Repair for objects returned by predefined 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.
+ */
+
+#define __NSREPAIR_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/acinterp.h>
+#include <contrib/dev/acpica/include/acpredef.h>
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsrepair")
+
+
+/*******************************************************************************
+ *
+ * This module attempts to repair or convert objects returned by the
+ * predefined methods to an object type that is expected, as per the ACPI
+ * specification. The need for this code is dictated by the many machines that
+ * return incorrect types for the standard predefined methods. Performing these
+ * conversions here, in one place, eliminates the need for individual ACPI
+ * device drivers to do the same. Note: Most of these conversions are different
+ * than the internal object conversion routines used for implicit object
+ * conversion.
+ *
+ * The following conversions can be performed as necessary:
+ *
+ * Integer -> String
+ * Integer -> Buffer
+ * String -> Integer
+ * String -> Buffer
+ * Buffer -> Integer
+ * Buffer -> String
+ * Buffer -> Package of Integers
+ * Package -> Package of one Package
+ *
+ * Additional possible repairs:
+ *
+ * Required package elements that are NULL replaced by Integer/String/Buffer
+ * Incorrect standalone package wrapped with required outer package
+ *
+ ******************************************************************************/
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiNsConvertToInteger (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject);
+
+static ACPI_STATUS
+AcpiNsConvertToString (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject);
+
+static ACPI_STATUS
+AcpiNsConvertToBuffer (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject);
+
+static ACPI_STATUS
+AcpiNsConvertToPackage (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepairObject
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ExpectedBtypes - Object types expected
+ * PackageIndex - Index of object within parent package (if
+ * applicable - ACPI_NOT_PACKAGE_ELEMENT
+ * otherwise)
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if repair was successful.
+ *
+ * DESCRIPTION: Attempt to repair/convert a return object of a type that was
+ * not expected.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsRepairObject (
+ ACPI_PREDEFINED_DATA *Data,
+ UINT32 ExpectedBtypes,
+ UINT32 PackageIndex,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_OPERAND_OBJECT *NewObject;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME (NsRepairObject);
+
+
+ /*
+ * At this point, we know that the type of the returned object was not
+ * one of the expected types for this predefined name. Attempt to
+ * repair the object by converting it to one of the expected object
+ * types for this predefined name.
+ */
+ if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
+ {
+ Status = AcpiNsConvertToInteger (ReturnObject, &NewObject);
+ if (ACPI_SUCCESS (Status))
+ {
+ goto ObjectRepaired;
+ }
+ }
+ if (ExpectedBtypes & ACPI_RTYPE_STRING)
+ {
+ Status = AcpiNsConvertToString (ReturnObject, &NewObject);
+ if (ACPI_SUCCESS (Status))
+ {
+ goto ObjectRepaired;
+ }
+ }
+ if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
+ {
+ Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject);
+ if (ACPI_SUCCESS (Status))
+ {
+ goto ObjectRepaired;
+ }
+ }
+ if (ExpectedBtypes & ACPI_RTYPE_PACKAGE)
+ {
+ Status = AcpiNsConvertToPackage (ReturnObject, &NewObject);
+ if (ACPI_SUCCESS (Status))
+ {
+ goto ObjectRepaired;
+ }
+ }
+
+ /* We cannot repair this object */
+
+ return (AE_AML_OPERAND_TYPE);
+
+
+ObjectRepaired:
+
+ /* Object was successfully repaired */
+
+ /*
+ * If the original object is a package element, we need to:
+ * 1. Set the reference count of the new object to match the
+ * reference count of the old object.
+ * 2. Decrement the reference count of the original object.
+ */
+ if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
+ {
+ NewObject->Common.ReferenceCount =
+ ReturnObject->Common.ReferenceCount;
+
+ if (ReturnObject->Common.ReferenceCount > 1)
+ {
+ ReturnObject->Common.ReferenceCount--;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Converted %s to expected %s at index %u\n",
+ Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
+ AcpiUtGetObjectTypeName (NewObject), PackageIndex));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Converted %s to expected %s\n",
+ Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
+ AcpiUtGetObjectTypeName (NewObject)));
+ }
+
+ /* Delete old object, install the new return object */
+
+ AcpiUtRemoveReference (ReturnObject);
+ *ReturnObjectPtr = NewObject;
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsConvertToInteger
+ *
+ * PARAMETERS: OriginalObject - Object to be converted
+ * ReturnObject - Where the new converted object is returned
+ *
+ * RETURN: Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsConvertToInteger (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject)
+{
+ ACPI_OPERAND_OBJECT *NewObject;
+ ACPI_STATUS Status;
+ UINT64 Value = 0;
+ UINT32 i;
+
+
+ switch (OriginalObject->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ /* String-to-Integer conversion */
+
+ Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer,
+ ACPI_ANY_BASE, &Value);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
+
+ if (OriginalObject->Buffer.Length > 8)
+ {
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Extract each buffer byte to create the integer */
+
+ for (i = 0; i < OriginalObject->Buffer.Length; i++)
+ {
+ Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8));
+ }
+ break;
+
+ default:
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ NewObject = AcpiUtCreateIntegerObject (Value);
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ *ReturnObject = NewObject;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsConvertToString
+ *
+ * PARAMETERS: OriginalObject - Object to be converted
+ * ReturnObject - Where the new converted object is returned
+ *
+ * RETURN: Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsConvertToString (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject)
+{
+ ACPI_OPERAND_OBJECT *NewObject;
+ ACPI_SIZE Length;
+ ACPI_STATUS Status;
+
+
+ switch (OriginalObject->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ /*
+ * Integer-to-String conversion. Commonly, convert
+ * an integer of value 0 to a NULL string. The last element of
+ * _BIF and _BIX packages occasionally need this fix.
+ */
+ if (OriginalObject->Integer.Value == 0)
+ {
+ /* Allocate a new NULL string object */
+
+ NewObject = AcpiUtCreateStringObject (0);
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+ }
+ else
+ {
+ Status = AcpiExConvertToString (OriginalObject, &NewObject,
+ ACPI_IMPLICIT_CONVERT_HEX);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ /*
+ * Buffer-to-String conversion. Use a ToString
+ * conversion, no transform performed on the buffer data. The best
+ * example of this is the _BIF method, where the string data from
+ * the battery is often (incorrectly) returned as buffer object(s).
+ */
+ Length = 0;
+ while ((Length < OriginalObject->Buffer.Length) &&
+ (OriginalObject->Buffer.Pointer[Length]))
+ {
+ Length++;
+ }
+
+ /* Allocate a new string object */
+
+ NewObject = AcpiUtCreateStringObject (Length);
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /*
+ * Copy the raw buffer data with no transform. String is already NULL
+ * terminated at Length+1.
+ */
+ ACPI_MEMCPY (NewObject->String.Pointer,
+ OriginalObject->Buffer.Pointer, Length);
+ break;
+
+ default:
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ *ReturnObject = NewObject;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsConvertToBuffer
+ *
+ * PARAMETERS: OriginalObject - Object to be converted
+ * ReturnObject - Where the new converted object is returned
+ *
+ * RETURN: Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsConvertToBuffer (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject)
+{
+ ACPI_OPERAND_OBJECT *NewObject;
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT **Elements;
+ UINT32 *DwordBuffer;
+ UINT32 Count;
+ UINT32 i;
+
+
+ switch (OriginalObject->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ /*
+ * Integer-to-Buffer conversion.
+ * Convert the Integer to a packed-byte buffer. _MAT and other
+ * objects need this sometimes, if a read has been performed on a
+ * Field object that is less than or equal to the global integer
+ * size (32 or 64 bits).
+ */
+ Status = AcpiExConvertToBuffer (OriginalObject, &NewObject);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ /* String-to-Buffer conversion. Simple data copy */
+
+ NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length);
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ ACPI_MEMCPY (NewObject->Buffer.Pointer,
+ OriginalObject->String.Pointer, OriginalObject->String.Length);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ /*
+ * This case is often seen for predefined names that must return a
+ * Buffer object with multiple DWORD integers within. For example,
+ * _FDE and _GTM. The Package can be converted to a Buffer.
+ */
+
+ /* All elements of the Package must be integers */
+
+ Elements = OriginalObject->Package.Elements;
+ Count = OriginalObject->Package.Count;
+
+ for (i = 0; i < Count; i++)
+ {
+ if ((!*Elements) ||
+ ((*Elements)->Common.Type != ACPI_TYPE_INTEGER))
+ {
+ return (AE_AML_OPERAND_TYPE);
+ }
+ Elements++;
+ }
+
+ /* Create the new buffer object to replace the Package */
+
+ NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count));
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Copy the package elements (integers) to the buffer as DWORDs */
+
+ Elements = OriginalObject->Package.Elements;
+ DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer);
+
+ for (i = 0; i < Count; i++)
+ {
+ *DwordBuffer = (UINT32) (*Elements)->Integer.Value;
+ DwordBuffer++;
+ Elements++;
+ }
+ break;
+
+ default:
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ *ReturnObject = NewObject;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsConvertToPackage
+ *
+ * PARAMETERS: OriginalObject - Object to be converted
+ * ReturnObject - Where the new converted object is returned
+ *
+ * RETURN: Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
+ * the buffer is converted to a single integer package element.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsConvertToPackage (
+ ACPI_OPERAND_OBJECT *OriginalObject,
+ ACPI_OPERAND_OBJECT **ReturnObject)
+{
+ ACPI_OPERAND_OBJECT *NewObject;
+ ACPI_OPERAND_OBJECT **Elements;
+ UINT32 Length;
+ UINT8 *Buffer;
+
+
+ switch (OriginalObject->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+
+ /* Buffer-to-Package conversion */
+
+ Length = OriginalObject->Buffer.Length;
+ NewObject = AcpiUtCreatePackageObject (Length);
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Convert each buffer byte to an integer package element */
+
+ Elements = NewObject->Package.Elements;
+ Buffer = OriginalObject->Buffer.Pointer;
+
+ while (Length--)
+ {
+ *Elements = AcpiUtCreateIntegerObject ((UINT64) *Buffer);
+ if (!*Elements)
+ {
+ AcpiUtRemoveReference (NewObject);
+ return (AE_NO_MEMORY);
+ }
+ Elements++;
+ Buffer++;
+ }
+ break;
+
+ default:
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ *ReturnObject = NewObject;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepairNullElement
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ExpectedBtypes - Object types expected
+ * PackageIndex - Index of object within parent package (if
+ * applicable - ACPI_NOT_PACKAGE_ELEMENT
+ * otherwise)
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if repair was successful.
+ *
+ * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsRepairNullElement (
+ ACPI_PREDEFINED_DATA *Data,
+ UINT32 ExpectedBtypes,
+ UINT32 PackageIndex,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_OPERAND_OBJECT *NewObject;
+
+
+ ACPI_FUNCTION_NAME (NsRepairNullElement);
+
+
+ /* No repair needed if return object is non-NULL */
+
+ if (ReturnObject)
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * Attempt to repair a NULL element of a Package object. This applies to
+ * predefined names that return a fixed-length package and each element
+ * is required. It does not apply to variable-length packages where NULL
+ * elements are allowed, especially at the end of the package.
+ */
+ if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
+ {
+ /* Need an Integer - create a zero-value integer */
+
+ NewObject = AcpiUtCreateIntegerObject ((UINT64) 0);
+ }
+ else if (ExpectedBtypes & ACPI_RTYPE_STRING)
+ {
+ /* Need a String - create a NULL string */
+
+ NewObject = AcpiUtCreateStringObject (0);
+ }
+ else if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
+ {
+ /* Need a Buffer - create a zero-length buffer */
+
+ NewObject = AcpiUtCreateBufferObject (0);
+ }
+ else
+ {
+ /* Error for all other expected types */
+
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Set the reference count according to the parent Package object */
+
+ NewObject->Common.ReferenceCount = Data->ParentPackage->Common.ReferenceCount;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Converted NULL package element to expected %s at index %u\n",
+ Data->Pathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
+
+ *ReturnObjectPtr = NewObject;
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsRemoveNullElements
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * PackageType - An AcpiReturnPackageTypes value
+ * ObjDesc - A Package object
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Remove all NULL package elements from packages that contain
+ * a variable number of sub-packages. For these types of
+ * packages, NULL elements can be safely removed.
+ *
+ *****************************************************************************/
+
+void
+AcpiNsRemoveNullElements (
+ ACPI_PREDEFINED_DATA *Data,
+ UINT8 PackageType,
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_OPERAND_OBJECT **Source;
+ ACPI_OPERAND_OBJECT **Dest;
+ UINT32 Count;
+ UINT32 NewCount;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME (NsRemoveNullElements);
+
+
+ /*
+ * We can safely remove all NULL elements from these package types:
+ * PTYPE1_VAR packages contain a variable number of simple data types.
+ * PTYPE2 packages contain a variable number of sub-packages.
+ */
+ switch (PackageType)
+ {
+ case ACPI_PTYPE1_VAR:
+ case ACPI_PTYPE2:
+ case ACPI_PTYPE2_COUNT:
+ case ACPI_PTYPE2_PKG_COUNT:
+ case ACPI_PTYPE2_FIXED:
+ case ACPI_PTYPE2_MIN:
+ case ACPI_PTYPE2_REV_FIXED:
+ case ACPI_PTYPE2_FIX_VAR:
+ break;
+
+ default:
+ case ACPI_PTYPE1_FIXED:
+ case ACPI_PTYPE1_OPTION:
+ return;
+ }
+
+ Count = ObjDesc->Package.Count;
+ NewCount = Count;
+
+ Source = ObjDesc->Package.Elements;
+ Dest = Source;
+
+ /* Examine all elements of the package object, remove nulls */
+
+ for (i = 0; i < Count; i++)
+ {
+ if (!*Source)
+ {
+ NewCount--;
+ }
+ else
+ {
+ *Dest = *Source;
+ Dest++;
+ }
+ Source++;
+ }
+
+ /* Update parent package if any null elements were removed */
+
+ if (NewCount < Count)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Found and removed %u NULL elements\n",
+ Data->Pathname, (Count - NewCount)));
+
+ /* NULL terminate list and update the package count */
+
+ *Dest = NULL;
+ ObjDesc->Package.Count = NewCount;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepairPackageList
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ObjDescPtr - Pointer to the object to repair. The new
+ * package object is returned here,
+ * overwriting the old object.
+ *
+ * RETURN: Status, new object in *ObjDescPtr
+ *
+ * DESCRIPTION: Repair a common problem with objects that are defined to return
+ * a variable-length Package of Packages. If the variable-length
+ * is one, some BIOS code mistakenly simply declares a single
+ * Package instead of a Package with one sub-Package. This
+ * function attempts to repair this error by wrapping a Package
+ * object around the original Package, creating the correct
+ * Package with one sub-Package.
+ *
+ * Names that can be repaired in this manner include:
+ * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsRepairPackageList (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ObjDescPtr)
+{
+ ACPI_OPERAND_OBJECT *PkgObjDesc;
+
+
+ ACPI_FUNCTION_NAME (NsRepairPackageList);
+
+
+ /*
+ * Create the new outer package and populate it. The new package will
+ * have a single element, the lone subpackage.
+ */
+ PkgObjDesc = AcpiUtCreatePackageObject (1);
+ if (!PkgObjDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ PkgObjDesc->Package.Elements[0] = *ObjDescPtr;
+
+ /* Return the new object in the object pointer */
+
+ *ObjDescPtr = PkgObjDesc;
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Repaired incorrectly formed Package\n", Data->Pathname));
+
+ return (AE_OK);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsrepair2.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsrepair2.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,827 @@
+/******************************************************************************
+ *
+ * Module Name: nsrepair2 - Repair for objects returned by specific
+ * predefined 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.
+ */
+
+#define __NSREPAIR2_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsrepair2")
+
+
+/*
+ * Information structure and handler for ACPI predefined names that can
+ * be repaired on a per-name basis.
+ */
+typedef
+ACPI_STATUS (*ACPI_REPAIR_FUNCTION) (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+typedef struct acpi_repair_info
+{
+ char Name[ACPI_NAME_SIZE];
+ ACPI_REPAIR_FUNCTION RepairFunction;
+
+} ACPI_REPAIR_INFO;
+
+
+/* Local prototypes */
+
+static const ACPI_REPAIR_INFO *
+AcpiNsMatchRepairableName (
+ ACPI_NAMESPACE_NODE *Node);
+
+static ACPI_STATUS
+AcpiNsRepair_ALR (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+static ACPI_STATUS
+AcpiNsRepair_CID (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+static ACPI_STATUS
+AcpiNsRepair_FDE (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+static ACPI_STATUS
+AcpiNsRepair_HID (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+static ACPI_STATUS
+AcpiNsRepair_PSS (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+static ACPI_STATUS
+AcpiNsRepair_TSS (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr);
+
+static ACPI_STATUS
+AcpiNsCheckSortedList (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT *ReturnObject,
+ UINT32 ExpectedCount,
+ UINT32 SortIndex,
+ UINT8 SortDirection,
+ char *SortKeyName);
+
+static void
+AcpiNsSortList (
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT32 Count,
+ UINT32 Index,
+ UINT8 SortDirection);
+
+/* Values for SortDirection above */
+
+#define ACPI_SORT_ASCENDING 0
+#define ACPI_SORT_DESCENDING 1
+
+
+/*
+ * This table contains the names of the predefined methods for which we can
+ * perform more complex repairs.
+ *
+ * As necessary:
+ *
+ * _ALR: Sort the list ascending by AmbientIlluminance
+ * _CID: Strings: uppercase all, remove any leading asterisk
+ * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
+ * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
+ * _HID: Strings: uppercase all, remove any leading asterisk
+ * _PSS: Sort the list descending by Power
+ * _TSS: Sort the list descending by Power
+ *
+ * Names that must be packages, but cannot be sorted:
+ *
+ * _BCL: Values are tied to the Package index where they appear, and cannot
+ * be moved or sorted. These index values are used for _BQC and _BCM.
+ * However, we can fix the case where a buffer is returned, by converting
+ * it to a Package of integers.
+ */
+static const ACPI_REPAIR_INFO AcpiNsRepairableNames[] =
+{
+ {"_ALR", AcpiNsRepair_ALR},
+ {"_CID", AcpiNsRepair_CID},
+ {"_FDE", AcpiNsRepair_FDE},
+ {"_GTM", AcpiNsRepair_FDE}, /* _GTM has same repair as _FDE */
+ {"_HID", AcpiNsRepair_HID},
+ {"_PSS", AcpiNsRepair_PSS},
+ {"_TSS", AcpiNsRepair_TSS},
+ {{0,0,0,0}, NULL} /* Table terminator */
+};
+
+
+#define ACPI_FDE_FIELD_COUNT 5
+#define ACPI_FDE_BYTE_BUFFER_SIZE 5
+#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32))
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsComplexRepairs
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * Node - Namespace node for the method/object
+ * ValidateStatus - Original status of earlier validation
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if repair was successful. If name is not
+ * matched, ValidateStatus is returned.
+ *
+ * DESCRIPTION: Attempt to repair/convert a return object of a type that was
+ * not expected.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiNsComplexRepairs (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_STATUS ValidateStatus,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ const ACPI_REPAIR_INFO *Predefined;
+ ACPI_STATUS Status;
+
+
+ /* Check if this name is in the list of repairable names */
+
+ Predefined = AcpiNsMatchRepairableName (Node);
+ if (!Predefined)
+ {
+ return (ValidateStatus);
+ }
+
+ Status = Predefined->RepairFunction (Data, ReturnObjectPtr);
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsMatchRepairableName
+ *
+ * PARAMETERS: Node - Namespace node for the method/object
+ *
+ * RETURN: Pointer to entry in repair table. NULL indicates not found.
+ *
+ * DESCRIPTION: Check an object name against the repairable object list.
+ *
+ *****************************************************************************/
+
+static const ACPI_REPAIR_INFO *
+AcpiNsMatchRepairableName (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ const ACPI_REPAIR_INFO *ThisName;
+
+
+ /* Search info table for a repairable predefined method/object name */
+
+ ThisName = AcpiNsRepairableNames;
+ while (ThisName->RepairFunction)
+ {
+ if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name))
+ {
+ return (ThisName);
+ }
+ ThisName++;
+ }
+
+ return (NULL); /* Not found */
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepair_ALR
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if object is OK or was repaired successfully
+ *
+ * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list
+ * ascending by the ambient illuminance values.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+AcpiNsRepair_ALR (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_STATUS Status;
+
+
+ Status = AcpiNsCheckSortedList (Data, ReturnObject, 2, 1,
+ ACPI_SORT_ASCENDING, "AmbientIlluminance");
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepair_FDE
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if object is OK or was repaired successfully
+ *
+ * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
+ * value is a Buffer of 5 DWORDs. This function repairs a common
+ * problem where the return value is a Buffer of BYTEs, not
+ * DWORDs.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+AcpiNsRepair_FDE (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_OPERAND_OBJECT *BufferObject;
+ UINT8 *ByteBuffer;
+ UINT32 *DwordBuffer;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME (NsRepair_FDE);
+
+
+ switch (ReturnObject->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+
+ /* This is the expected type. Length should be (at least) 5 DWORDs */
+
+ if (ReturnObject->Buffer.Length >= ACPI_FDE_DWORD_BUFFER_SIZE)
+ {
+ return (AE_OK);
+ }
+
+ /* We can only repair if we have exactly 5 BYTEs */
+
+ if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Incorrect return buffer length %u, expected %u",
+ ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE));
+
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Create the new (larger) buffer object */
+
+ BufferObject = AcpiUtCreateBufferObject (ACPI_FDE_DWORD_BUFFER_SIZE);
+ if (!BufferObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Expand each byte to a DWORD */
+
+ ByteBuffer = ReturnObject->Buffer.Pointer;
+ DwordBuffer = ACPI_CAST_PTR (UINT32, BufferObject->Buffer.Pointer);
+
+ for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++)
+ {
+ *DwordBuffer = (UINT32) *ByteBuffer;
+ DwordBuffer++;
+ ByteBuffer++;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s Expanded Byte Buffer to expected DWord Buffer\n",
+ Data->Pathname));
+ break;
+
+ default:
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Delete the original return object, return the new buffer object */
+
+ AcpiUtRemoveReference (ReturnObject);
+ *ReturnObjectPtr = BufferObject;
+
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepair_CID
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if object is OK or was repaired successfully
+ *
+ * DESCRIPTION: Repair for the _CID object. If a string, ensure that all
+ * letters are uppercase and that there is no leading asterisk.
+ * If a Package, ensure same for all string elements.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+AcpiNsRepair_CID (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_OPERAND_OBJECT **ElementPtr;
+ ACPI_OPERAND_OBJECT *OriginalElement;
+ UINT16 OriginalRefCount;
+ UINT32 i;
+
+
+ /* Check for _CID as a simple string */
+
+ if (ReturnObject->Common.Type == ACPI_TYPE_STRING)
+ {
+ Status = AcpiNsRepair_HID (Data, ReturnObjectPtr);
+ return (Status);
+ }
+
+ /* Exit if not a Package */
+
+ if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
+ {
+ return (AE_OK);
+ }
+
+ /* Examine each element of the _CID package */
+
+ ElementPtr = ReturnObject->Package.Elements;
+ for (i = 0; i < ReturnObject->Package.Count; i++)
+ {
+ OriginalElement = *ElementPtr;
+ OriginalRefCount = OriginalElement->Common.ReferenceCount;
+
+ Status = AcpiNsRepair_HID (Data, ElementPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Take care with reference counts */
+
+ if (OriginalElement != *ElementPtr)
+ {
+ /* Element was replaced */
+
+ (*ElementPtr)->Common.ReferenceCount =
+ OriginalRefCount;
+
+ AcpiUtRemoveReference (OriginalElement);
+ }
+
+ ElementPtr++;
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepair_HID
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if object is OK or was repaired successfully
+ *
+ * DESCRIPTION: Repair for the _HID object. If a string, ensure that all
+ * letters are uppercase and that there is no leading asterisk.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+AcpiNsRepair_HID (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_OPERAND_OBJECT *NewString;
+ char *Source;
+ char *Dest;
+
+
+ ACPI_FUNCTION_NAME (NsRepair_HID);
+
+
+ /* We only care about string _HID objects (not integers) */
+
+ if (ReturnObject->Common.Type != ACPI_TYPE_STRING)
+ {
+ return (AE_OK);
+ }
+
+ if (ReturnObject->String.Length == 0)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Invalid zero-length _HID or _CID string"));
+
+ /* Return AE_OK anyway, let driver handle it */
+
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+ return (AE_OK);
+ }
+
+ /* It is simplest to always create a new string object */
+
+ NewString = AcpiUtCreateStringObject (ReturnObject->String.Length);
+ if (!NewString)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /*
+ * Remove a leading asterisk if present. For some unknown reason, there
+ * are many machines in the field that contains IDs like this.
+ *
+ * Examples: "*PNP0C03", "*ACPI0003"
+ */
+ Source = ReturnObject->String.Pointer;
+ if (*Source == '*')
+ {
+ Source++;
+ NewString->String.Length--;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Removed invalid leading asterisk\n", Data->Pathname));
+ }
+
+ /*
+ * Copy and uppercase the string. From the ACPI 5.0 specification:
+ *
+ * A valid PNP ID must be of the form "AAA####" where A is an uppercase
+ * letter and # is a hex digit. A valid ACPI ID must be of the form
+ * "NNNN####" where N is an uppercase letter or decimal digit, and
+ * # is a hex digit.
+ */
+ for (Dest = NewString->String.Pointer; *Source; Dest++, Source++)
+ {
+ *Dest = (char) ACPI_TOUPPER (*Source);
+ }
+
+ AcpiUtRemoveReference (ReturnObject);
+ *ReturnObjectPtr = NewString;
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepair_TSS
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if object is OK or was repaired successfully
+ *
+ * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list
+ * descending by the power dissipation values.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+AcpiNsRepair_TSS (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ /*
+ * We can only sort the _TSS return package if there is no _PSS in the
+ * same scope. This is because if _PSS is present, the ACPI specification
+ * dictates that the _TSS Power Dissipation field is to be ignored, and
+ * therefore some BIOSs leave garbage values in the _TSS Power field(s).
+ * In this case, it is best to just return the _TSS package as-is.
+ * (May, 2011)
+ */
+ Status = AcpiNsGetNode (Data->Node, "^_PSS", ACPI_NS_NO_UPSEARCH, &Node);
+ if (ACPI_SUCCESS (Status))
+ {
+ return (AE_OK);
+ }
+
+ Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1,
+ ACPI_SORT_DESCENDING, "PowerDissipation");
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepair_PSS
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if object is OK or was repaired successfully
+ *
+ * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list
+ * by the CPU frequencies. Check that the power dissipation values
+ * are all proportional to CPU frequency (i.e., sorting by
+ * frequency should be the same as sorting by power.)
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+AcpiNsRepair_PSS (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_OPERAND_OBJECT **OuterElements;
+ UINT32 OuterElementCount;
+ ACPI_OPERAND_OBJECT **Elements;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ UINT32 PreviousValue;
+ ACPI_STATUS Status;
+ UINT32 i;
+
+
+ /*
+ * Entries (sub-packages) in the _PSS Package must be sorted by power
+ * dissipation, in descending order. If it appears that the list is
+ * incorrectly sorted, sort it. We sort by CpuFrequency, since this
+ * should be proportional to the power.
+ */
+ Status =AcpiNsCheckSortedList (Data, ReturnObject, 6, 0,
+ ACPI_SORT_DESCENDING, "CpuFrequency");
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * We now know the list is correctly sorted by CPU frequency. Check if
+ * the power dissipation values are proportional.
+ */
+ PreviousValue = ACPI_UINT32_MAX;
+ OuterElements = ReturnObject->Package.Elements;
+ OuterElementCount = ReturnObject->Package.Count;
+
+ for (i = 0; i < OuterElementCount; i++)
+ {
+ Elements = (*OuterElements)->Package.Elements;
+ ObjDesc = Elements[1]; /* Index1 = PowerDissipation */
+
+ if ((UINT32) ObjDesc->Integer.Value > PreviousValue)
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "SubPackage[%u,%u] - suspicious power dissipation values",
+ i-1, i));
+ }
+
+ PreviousValue = (UINT32) ObjDesc->Integer.Value;
+ OuterElements++;
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckSortedList
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ReturnObject - Pointer to the top-level returned object
+ * ExpectedCount - Minimum length of each sub-package
+ * SortIndex - Sub-package entry to sort on
+ * SortDirection - Ascending or descending
+ * SortKeyName - Name of the SortIndex field
+ *
+ * RETURN: Status. AE_OK if the list is valid and is sorted correctly or
+ * has been repaired by sorting the list.
+ *
+ * DESCRIPTION: Check if the package list is valid and sorted correctly by the
+ * SortIndex. If not, then sort the list.
+ *
+ *****************************************************************************/
+
+static ACPI_STATUS
+AcpiNsCheckSortedList (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT *ReturnObject,
+ UINT32 ExpectedCount,
+ UINT32 SortIndex,
+ UINT8 SortDirection,
+ char *SortKeyName)
+{
+ UINT32 OuterElementCount;
+ ACPI_OPERAND_OBJECT **OuterElements;
+ ACPI_OPERAND_OBJECT **Elements;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ UINT32 i;
+ UINT32 PreviousValue;
+
+
+ ACPI_FUNCTION_NAME (NsCheckSortedList);
+
+
+ /* The top-level object must be a package */
+
+ if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
+ {
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * NOTE: assumes list of sub-packages contains no NULL elements.
+ * Any NULL elements should have been removed by earlier call
+ * to AcpiNsRemoveNullElements.
+ */
+ OuterElements = ReturnObject->Package.Elements;
+ OuterElementCount = ReturnObject->Package.Count;
+ if (!OuterElementCount)
+ {
+ return (AE_AML_PACKAGE_LIMIT);
+ }
+
+ PreviousValue = 0;
+ if (SortDirection == ACPI_SORT_DESCENDING)
+ {
+ PreviousValue = ACPI_UINT32_MAX;
+ }
+
+ /* Examine each subpackage */
+
+ for (i = 0; i < OuterElementCount; i++)
+ {
+ /* Each element of the top-level package must also be a package */
+
+ if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE)
+ {
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Each sub-package must have the minimum length */
+
+ if ((*OuterElements)->Package.Count < ExpectedCount)
+ {
+ return (AE_AML_PACKAGE_LIMIT);
+ }
+
+ Elements = (*OuterElements)->Package.Elements;
+ ObjDesc = Elements[SortIndex];
+
+ if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+ {
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * The list must be sorted in the specified order. If we detect a
+ * discrepancy, sort the entire list.
+ */
+ if (((SortDirection == ACPI_SORT_ASCENDING) &&
+ (ObjDesc->Integer.Value < PreviousValue)) ||
+ ((SortDirection == ACPI_SORT_DESCENDING) &&
+ (ObjDesc->Integer.Value > PreviousValue)))
+ {
+ AcpiNsSortList (ReturnObject->Package.Elements,
+ OuterElementCount, SortIndex, SortDirection);
+
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
+ "%s: Repaired unsorted list - now sorted by %s\n",
+ Data->Pathname, SortKeyName));
+ return (AE_OK);
+ }
+
+ PreviousValue = (UINT32) ObjDesc->Integer.Value;
+ OuterElements++;
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsSortList
+ *
+ * PARAMETERS: Elements - Package object element list
+ * Count - Element count for above
+ * Index - Sort by which package element
+ * SortDirection - Ascending or Descending sort
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Sort the objects that are in a package element list.
+ *
+ * NOTE: Assumes that all NULL elements have been removed from the package,
+ * and that all elements have been verified to be of type Integer.
+ *
+ *****************************************************************************/
+
+static void
+AcpiNsSortList (
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT32 Count,
+ UINT32 Index,
+ UINT8 SortDirection)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc1;
+ ACPI_OPERAND_OBJECT *ObjDesc2;
+ ACPI_OPERAND_OBJECT *TempObj;
+ UINT32 i;
+ UINT32 j;
+
+
+ /* Simple bubble sort */
+
+ for (i = 1; i < Count; i++)
+ {
+ for (j = (Count - 1); j >= i; j--)
+ {
+ ObjDesc1 = Elements[j-1]->Package.Elements[Index];
+ ObjDesc2 = Elements[j]->Package.Elements[Index];
+
+ if (((SortDirection == ACPI_SORT_ASCENDING) &&
+ (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) ||
+
+ ((SortDirection == ACPI_SORT_DESCENDING) &&
+ (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value)))
+ {
+ TempObj = Elements[j-1];
+ Elements[j-1] = Elements[j];
+ Elements[j] = TempObj;
+ }
+ }
+ }
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nssearch.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nssearch.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ *
+ * Module Name: nssearch - Namespace search
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __NSSEARCH_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#ifdef ACPI_ASL_COMPILER
+#include <contrib/dev/acpica/include/amlcode.h>
+#endif
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nssearch")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiNsSearchParentTree (
+ UINT32 TargetName,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_OBJECT_TYPE Type,
+ ACPI_NAMESPACE_NODE **ReturnNode);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsSearchOneScope
+ *
+ * PARAMETERS: TargetName - Ascii ACPI name to search for
+ * ParentNode - Starting node where search will begin
+ * Type - Object type to match
+ * ReturnNode - Where the matched Named obj is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Search a single level of the namespace. Performs a
+ * simple search of the specified level, and does not add
+ * entries or search parents.
+ *
+ *
+ * Named object lists are built (and subsequently dumped) in the
+ * order in which the names are encountered during the namespace load;
+ *
+ * All namespace searching is linear in this implementation, but
+ * could be easily modified to support any improved search
+ * algorithm. However, the linear search was chosen for simplicity
+ * and because the trees are small and the other interpreter
+ * execution overhead is relatively high.
+ *
+ * Note: CPU execution analysis has shown that the AML interpreter spends
+ * a very small percentage of its time searching the namespace. Therefore,
+ * the linear search seems to be sufficient, as there would seem to be
+ * little value in improving the search.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsSearchOneScope (
+ UINT32 TargetName,
+ ACPI_NAMESPACE_NODE *ParentNode,
+ ACPI_OBJECT_TYPE Type,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (NsSearchOneScope);
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+ if (ACPI_LV_NAMES & AcpiDbgLevel)
+ {
+ char *ScopeName;
+
+ ScopeName = AcpiNsGetExternalPathname (ParentNode);
+ if (ScopeName)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Searching %s (%p) For [%4.4s] (%s)\n",
+ ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName),
+ AcpiUtGetTypeName (Type)));
+
+ ACPI_FREE (ScopeName);
+ }
+ }
+#endif
+
+ /*
+ * Search for name at this namespace level, which is to say that we
+ * must search for the name among the children of this object
+ */
+ Node = ParentNode->Child;
+ while (Node)
+ {
+ /* Check for match against the name */
+
+ if (Node->Name.Integer == TargetName)
+ {
+ /* Resolve a control method alias if any */
+
+ if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
+ {
+ Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
+ }
+
+ /* Found matching entry */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
+ ACPI_CAST_PTR (char, &TargetName),
+ AcpiUtGetTypeName (Node->Type),
+ Node, AcpiUtGetNodeName (ParentNode), ParentNode));
+
+ *ReturnNode = Node;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Didn't match name, move on to the next peer object */
+
+ Node = Node->Peer;
+ }
+
+ /* Searched entire namespace level, not found */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Name [%4.4s] (%s) not found in search in scope [%4.4s] "
+ "%p first child %p\n",
+ ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type),
+ AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child));
+
+ return_ACPI_STATUS (AE_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsSearchParentTree
+ *
+ * PARAMETERS: TargetName - Ascii ACPI name to search for
+ * Node - Starting node where search will begin
+ * Type - Object type to match
+ * ReturnNode - Where the matched Node is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Called when a name has not been found in the current namespace
+ * level. Before adding it or giving up, ACPI scope rules require
+ * searching enclosing scopes in cases identified by AcpiNsLocal().
+ *
+ * "A name is located by finding the matching name in the current
+ * name space, and then in the parent name space. If the parent
+ * name space does not contain the name, the search continues
+ * recursively until either the name is found or the name space
+ * does not have a parent (the root of the name space). This
+ * indicates that the name is not found" (From ACPI Specification,
+ * section 5.3)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsSearchParentTree (
+ UINT32 TargetName,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_OBJECT_TYPE Type,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *ParentNode;
+
+
+ ACPI_FUNCTION_TRACE (NsSearchParentTree);
+
+
+ ParentNode = Node->Parent;
+
+ /*
+ * If there is no parent (i.e., we are at the root) or type is "local",
+ * we won't be searching the parent tree.
+ */
+ if (!ParentNode)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
+ ACPI_CAST_PTR (char, &TargetName)));
+ return_ACPI_STATUS (AE_NOT_FOUND);
+ }
+
+ if (AcpiNsLocal (Type))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
+ ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type)));
+ return_ACPI_STATUS (AE_NOT_FOUND);
+ }
+
+ /* Search the parent tree */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "Searching parent [%4.4s] for [%4.4s]\n",
+ AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName)));
+
+ /* Search parents until target is found or we have backed up to the root */
+
+ while (ParentNode)
+ {
+ /*
+ * Search parent scope. Use TYPE_ANY because we don't care about the
+ * object type at this point, we only care about the existence of
+ * the actual name we are searching for. Typechecking comes later.
+ */
+ Status = AcpiNsSearchOneScope (
+ TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Not found here, go up another level (until we reach the root) */
+
+ ParentNode = ParentNode->Parent;
+ }
+
+ /* Not found in parent tree */
+
+ return_ACPI_STATUS (AE_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsSearchAndEnter
+ *
+ * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars)
+ * WalkState - Current state of the walk
+ * Node - Starting node where search will begin
+ * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x.
+ * Otherwise,search only.
+ * Type - Object type to match
+ * Flags - Flags describing the search restrictions
+ * ReturnNode - Where the Node is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Search for a name segment in a single namespace level,
+ * optionally adding it if it is not found. If the passed
+ * Type is not Any and the type previously stored in the
+ * entry was Any (i.e. unknown), update the stored type.
+ *
+ * In ACPI_IMODE_EXECUTE, search only.
+ * In other modes, search and add if not found.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsSearchAndEnter (
+ UINT32 TargetName,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_INTERPRETER_MODE InterpreterMode,
+ ACPI_OBJECT_TYPE Type,
+ UINT32 Flags,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *NewNode;
+
+
+ ACPI_FUNCTION_TRACE (NsSearchAndEnter);
+
+
+ /* Parameter validation */
+
+ if (!Node || !TargetName || !ReturnNode)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Null parameter: Node %p Name 0x%X ReturnNode %p",
+ Node, TargetName, ReturnNode));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Name must consist of valid ACPI characters. We will repair the name if
+ * necessary because we don't want to abort because of this, but we want
+ * all namespace names to be printable. A warning message is appropriate.
+ *
+ * This issue came up because there are in fact machines that exhibit
+ * this problem, and we want to be able to enable ACPI support for them,
+ * even though there are a few bad names.
+ */
+ AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName));
+
+ /* Try to find the name in the namespace level specified by the caller */
+
+ *ReturnNode = ACPI_ENTRY_NOT_FOUND;
+ Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode);
+ if (Status != AE_NOT_FOUND)
+ {
+ /*
+ * If we found it AND the request specifies that a find is an error,
+ * return the error
+ */
+ if ((Status == AE_OK) &&
+ (Flags & ACPI_NS_ERROR_IF_FOUND))
+ {
+ Status = AE_ALREADY_EXISTS;
+ }
+
+#ifdef ACPI_ASL_COMPILER
+ if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY)
+ {
+ (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL;
+ }
+#endif
+
+ /* Either found it or there was an error: finished either way */
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The name was not found. If we are NOT performing the first pass
+ * (name entry) of loading the namespace, search the parent tree (all the
+ * way to the root if necessary.) We don't want to perform the parent
+ * search when the namespace is actually being loaded. We want to perform
+ * the search when namespace references are being resolved (load pass 2)
+ * and during the execution phase.
+ */
+ if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) &&
+ (Flags & ACPI_NS_SEARCH_PARENT))
+ {
+ /*
+ * Not found at this level - search parent tree according to the
+ * ACPI specification
+ */
+ Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* In execute mode, just search, never add names. Exit now */
+
+ if (InterpreterMode == ACPI_IMODE_EXECUTE)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "%4.4s Not found in %p [Not adding]\n",
+ ACPI_CAST_PTR (char, &TargetName), Node));
+
+ return_ACPI_STATUS (AE_NOT_FOUND);
+ }
+
+ /* Create the new named object */
+
+ NewNode = AcpiNsCreateNode (TargetName);
+ if (!NewNode)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+#ifdef ACPI_ASL_COMPILER
+
+ /* Node is an object defined by an External() statement */
+
+ if (Flags & ACPI_NS_EXTERNAL ||
+ (WalkState && WalkState->Opcode == AML_SCOPE_OP))
+ {
+ NewNode->Flags |= ANOBJ_IS_EXTERNAL;
+ }
+#endif
+
+ if (Flags & ACPI_NS_TEMPORARY)
+ {
+ NewNode->Flags |= ANOBJ_TEMPORARY;
+ }
+
+ /* Install the new object into the parent's list of children */
+
+ AcpiNsInstallNode (WalkState, Node, NewNode, Type);
+ *ReturnNode = NewNode;
+ return_ACPI_STATUS (AE_OK);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsutils.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsutils.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,875 @@
+/******************************************************************************
+ *
+ * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
+ * parents and siblings and Scope 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 __NSUTILS_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/amlcode.h>
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsutils")
+
+/* Local prototypes */
+
+static BOOLEAN
+AcpiNsValidPathSeparator (
+ char Sep);
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+ACPI_NAME
+AcpiNsFindParentName (
+ ACPI_NAMESPACE_NODE *NodeToSearch);
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsPrintNodePathname
+ *
+ * PARAMETERS: Node - Object
+ * Message - Prefix message
+ *
+ * DESCRIPTION: Print an object's full namespace pathname
+ * Manages allocation/freeing of a pathname buffer
+ *
+ ******************************************************************************/
+
+void
+AcpiNsPrintNodePathname (
+ ACPI_NAMESPACE_NODE *Node,
+ const char *Message)
+{
+ ACPI_BUFFER Buffer;
+ ACPI_STATUS Status;
+
+
+ if (!Node)
+ {
+ AcpiOsPrintf ("[NULL NAME]");
+ return;
+ }
+
+ /* Convert handle to full pathname and print it (with supplied message) */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+ Status = AcpiNsHandleToPathname (Node, &Buffer);
+ if (ACPI_SUCCESS (Status))
+ {
+ if (Message)
+ {
+ AcpiOsPrintf ("%s ", Message);
+ }
+
+ AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node);
+ ACPI_FREE (Buffer.Pointer);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsValidRootPrefix
+ *
+ * PARAMETERS: Prefix - Character to be checked
+ *
+ * RETURN: TRUE if a valid prefix
+ *
+ * DESCRIPTION: Check if a character is a valid ACPI Root prefix
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiNsValidRootPrefix (
+ char Prefix)
+{
+
+ return ((BOOLEAN) (Prefix == '\\'));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsValidPathSeparator
+ *
+ * PARAMETERS: Sep - Character to be checked
+ *
+ * RETURN: TRUE if a valid path separator
+ *
+ * DESCRIPTION: Check if a character is a valid ACPI path separator
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiNsValidPathSeparator (
+ char Sep)
+{
+
+ return ((BOOLEAN) (Sep == '.'));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetType
+ *
+ * PARAMETERS: Node - Parent Node to be examined
+ *
+ * RETURN: Type field from Node whose handle is passed
+ *
+ * DESCRIPTION: Return the type of a Namespace node
+ *
+ ******************************************************************************/
+
+ACPI_OBJECT_TYPE
+AcpiNsGetType (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_FUNCTION_TRACE (NsGetType);
+
+
+ if (!Node)
+ {
+ ACPI_WARNING ((AE_INFO, "Null Node parameter"));
+ return_UINT32 (ACPI_TYPE_ANY);
+ }
+
+ return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsLocal
+ *
+ * PARAMETERS: Type - A namespace object type
+ *
+ * RETURN: LOCAL if names must be found locally in objects of the
+ * passed type, 0 if enclosing scopes should be searched
+ *
+ * DESCRIPTION: Returns scope rule for the given object type.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiNsLocal (
+ ACPI_OBJECT_TYPE Type)
+{
+ ACPI_FUNCTION_TRACE (NsLocal);
+
+
+ if (!AcpiUtValidObjectType (Type))
+ {
+ /* Type code out of range */
+
+ ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));
+ return_UINT32 (ACPI_NS_NORMAL);
+ }
+
+ return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetInternalNameLength
+ *
+ * PARAMETERS: Info - Info struct initialized with the
+ * external name pointer.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Calculate the length of the internal (AML) namestring
+ * corresponding to the external (ASL) namestring.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsGetInternalNameLength (
+ ACPI_NAMESTRING_INFO *Info)
+{
+ const char *NextExternalChar;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ NextExternalChar = Info->ExternalName;
+ Info->NumCarats = 0;
+ Info->NumSegments = 0;
+ Info->FullyQualified = FALSE;
+
+ /*
+ * For the internal name, the required length is 4 bytes per segment, plus
+ * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null
+ * (which is not really needed, but no there's harm in putting it there)
+ *
+ * strlen() + 1 covers the first NameSeg, which has no path separator
+ */
+ if (AcpiNsValidRootPrefix (*NextExternalChar))
+ {
+ Info->FullyQualified = TRUE;
+ NextExternalChar++;
+
+ /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */
+
+ while (AcpiNsValidRootPrefix (*NextExternalChar))
+ {
+ NextExternalChar++;
+ }
+ }
+ else
+ {
+ /* Handle Carat prefixes */
+
+ while (*NextExternalChar == '^')
+ {
+ Info->NumCarats++;
+ NextExternalChar++;
+ }
+ }
+
+ /*
+ * Determine the number of ACPI name "segments" by counting the number of
+ * path separators within the string. Start with one segment since the
+ * segment count is [(# separators) + 1], and zero separators is ok.
+ */
+ if (*NextExternalChar)
+ {
+ Info->NumSegments = 1;
+ for (i = 0; NextExternalChar[i]; i++)
+ {
+ if (AcpiNsValidPathSeparator (NextExternalChar[i]))
+ {
+ Info->NumSegments++;
+ }
+ }
+ }
+
+ Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
+ 4 + Info->NumCarats;
+
+ Info->NextExternalChar = NextExternalChar;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsBuildInternalName
+ *
+ * PARAMETERS: Info - Info struct fully initialized
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Construct the internal (AML) namestring
+ * corresponding to the external (ASL) namestring.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsBuildInternalName (
+ ACPI_NAMESTRING_INFO *Info)
+{
+ UINT32 NumSegments = Info->NumSegments;
+ char *InternalName = Info->InternalName;
+ const char *ExternalName = Info->NextExternalChar;
+ char *Result = NULL;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (NsBuildInternalName);
+
+
+ /* Setup the correct prefixes, counts, and pointers */
+
+ if (Info->FullyQualified)
+ {
+ InternalName[0] = '\\';
+
+ if (NumSegments <= 1)
+ {
+ Result = &InternalName[1];
+ }
+ else if (NumSegments == 2)
+ {
+ InternalName[1] = AML_DUAL_NAME_PREFIX;
+ Result = &InternalName[2];
+ }
+ else
+ {
+ InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
+ InternalName[2] = (char) NumSegments;
+ Result = &InternalName[3];
+ }
+ }
+ else
+ {
+ /*
+ * Not fully qualified.
+ * Handle Carats first, then append the name segments
+ */
+ i = 0;
+ if (Info->NumCarats)
+ {
+ for (i = 0; i < Info->NumCarats; i++)
+ {
+ InternalName[i] = '^';
+ }
+ }
+
+ if (NumSegments <= 1)
+ {
+ Result = &InternalName[i];
+ }
+ else if (NumSegments == 2)
+ {
+ InternalName[i] = AML_DUAL_NAME_PREFIX;
+ Result = &InternalName[(ACPI_SIZE) i+1];
+ }
+ else
+ {
+ InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
+ InternalName[(ACPI_SIZE) i+1] = (char) NumSegments;
+ Result = &InternalName[(ACPI_SIZE) i+2];
+ }
+ }
+
+ /* Build the name (minus path separators) */
+
+ for (; NumSegments; NumSegments--)
+ {
+ for (i = 0; i < ACPI_NAME_SIZE; i++)
+ {
+ if (AcpiNsValidPathSeparator (*ExternalName) ||
+ (*ExternalName == 0))
+ {
+ /* Pad the segment with underscore(s) if segment is short */
+
+ Result[i] = '_';
+ }
+ else
+ {
+ /* Convert the character to uppercase and save it */
+
+ Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
+ ExternalName++;
+ }
+ }
+
+ /* Now we must have a path separator, or the pathname is bad */
+
+ if (!AcpiNsValidPathSeparator (*ExternalName) &&
+ (*ExternalName != 0))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Move on the next segment */
+
+ ExternalName++;
+ Result += ACPI_NAME_SIZE;
+ }
+
+ /* Terminate the string */
+
+ *Result = 0;
+
+ if (Info->FullyQualified)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",
+ InternalName, InternalName));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
+ InternalName, InternalName));
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsInternalizeName
+ *
+ * PARAMETERS: *ExternalName - External representation of name
+ * **Converted Name - Where to return the resulting
+ * internal represention of the name
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
+ * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
+ *
+ *******************************************************************************/
+
+ACPI_STATUS
+AcpiNsInternalizeName (
+ const char *ExternalName,
+ char **ConvertedName)
+{
+ char *InternalName;
+ ACPI_NAMESTRING_INFO Info;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (NsInternalizeName);
+
+
+ if ((!ExternalName) ||
+ (*ExternalName == 0) ||
+ (!ConvertedName))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Get the length of the new internal name */
+
+ Info.ExternalName = ExternalName;
+ AcpiNsGetInternalNameLength (&Info);
+
+ /* We need a segment to store the internal name */
+
+ InternalName = ACPI_ALLOCATE_ZEROED (Info.Length);
+ if (!InternalName)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Build the name */
+
+ Info.InternalName = InternalName;
+ Status = AcpiNsBuildInternalName (&Info);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_FREE (InternalName);
+ return_ACPI_STATUS (Status);
+ }
+
+ *ConvertedName = InternalName;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsExternalizeName
+ *
+ * PARAMETERS: InternalNameLength - Lenth of the internal name below
+ * InternalName - Internal representation of name
+ * ConvertedNameLength - Where the length is returned
+ * ConvertedName - Where the resulting external name
+ * is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
+ * to its external (printable) form (e.g. "\_PR_.CPU0")
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsExternalizeName (
+ UINT32 InternalNameLength,
+ const char *InternalName,
+ UINT32 *ConvertedNameLength,
+ char **ConvertedName)
+{
+ UINT32 NamesIndex = 0;
+ UINT32 NumSegments = 0;
+ UINT32 RequiredLength;
+ UINT32 PrefixLength = 0;
+ UINT32 i = 0;
+ UINT32 j = 0;
+
+
+ ACPI_FUNCTION_TRACE (NsExternalizeName);
+
+
+ if (!InternalNameLength ||
+ !InternalName ||
+ !ConvertedName)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Check for a prefix (one '\' | one or more '^') */
+
+ switch (InternalName[0])
+ {
+ case '\\':
+ PrefixLength = 1;
+ break;
+
+ case '^':
+ for (i = 0; i < InternalNameLength; i++)
+ {
+ if (InternalName[i] == '^')
+ {
+ PrefixLength = i + 1;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (i == InternalNameLength)
+ {
+ PrefixLength = i;
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * Check for object names. Note that there could be 0-255 of these
+ * 4-byte elements.
+ */
+ if (PrefixLength < InternalNameLength)
+ {
+ switch (InternalName[PrefixLength])
+ {
+ case AML_MULTI_NAME_PREFIX_OP:
+
+ /* <count> 4-byte names */
+
+ NamesIndex = PrefixLength + 2;
+ NumSegments = (UINT8)
+ InternalName[(ACPI_SIZE) PrefixLength + 1];
+ break;
+
+ case AML_DUAL_NAME_PREFIX:
+
+ /* Two 4-byte names */
+
+ NamesIndex = PrefixLength + 1;
+ NumSegments = 2;
+ break;
+
+ case 0:
+
+ /* NullName */
+
+ NamesIndex = 0;
+ NumSegments = 0;
+ break;
+
+ default:
+
+ /* one 4-byte name */
+
+ NamesIndex = PrefixLength;
+ NumSegments = 1;
+ break;
+ }
+ }
+
+ /*
+ * Calculate the length of ConvertedName, which equals the length
+ * of the prefix, length of all object names, length of any required
+ * punctuation ('.') between object names, plus the NULL terminator.
+ */
+ RequiredLength = PrefixLength + (4 * NumSegments) +
+ ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
+
+ /*
+ * Check to see if we're still in bounds. If not, there's a problem
+ * with InternalName (invalid format).
+ */
+ if (RequiredLength > InternalNameLength)
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid internal name"));
+ return_ACPI_STATUS (AE_BAD_PATHNAME);
+ }
+
+ /* Build the ConvertedName */
+
+ *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength);
+ if (!(*ConvertedName))
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ j = 0;
+
+ for (i = 0; i < PrefixLength; i++)
+ {
+ (*ConvertedName)[j++] = InternalName[i];
+ }
+
+ if (NumSegments > 0)
+ {
+ for (i = 0; i < NumSegments; i++)
+ {
+ if (i > 0)
+ {
+ (*ConvertedName)[j++] = '.';
+ }
+
+ (*ConvertedName)[j++] = InternalName[NamesIndex++];
+ (*ConvertedName)[j++] = InternalName[NamesIndex++];
+ (*ConvertedName)[j++] = InternalName[NamesIndex++];
+ (*ConvertedName)[j++] = InternalName[NamesIndex++];
+ }
+ }
+
+ if (ConvertedNameLength)
+ {
+ *ConvertedNameLength = (UINT32) RequiredLength;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsValidateHandle
+ *
+ * PARAMETERS: Handle - Handle to be validated and typecast to a
+ * namespace node.
+ *
+ * RETURN: A pointer to a namespace node
+ *
+ * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
+ * cases for the root node.
+ *
+ * NOTE: Real integer handles would allow for more verification
+ * and keep all pointers within this subsystem - however this introduces
+ * more overhead and has not been necessary to this point. Drivers
+ * holding handles are typically notified before a node becomes invalid
+ * due to a table unload.
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+AcpiNsValidateHandle (
+ ACPI_HANDLE Handle)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Parameter validation */
+
+ if ((!Handle) || (Handle == ACPI_ROOT_OBJECT))
+ {
+ return (AcpiGbl_RootNode);
+ }
+
+ /* We can at least attempt to verify the handle */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
+ {
+ return (NULL);
+ }
+
+ return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsTerminate
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsTerminate (
+ void)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE (NsTerminate);
+
+
+ /*
+ * 1) Free the entire namespace -- all nodes and objects
+ *
+ * Delete all object descriptors attached to namepsace nodes
+ */
+ AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
+
+ /* Detach any objects attached to the root */
+
+ ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
+ if (ObjDesc)
+ {
+ AcpiNsDetachObject (AcpiGbl_RootNode);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsOpensScope
+ *
+ * PARAMETERS: Type - A valid namespace type
+ *
+ * RETURN: NEWSCOPE if the passed type "opens a name scope" according
+ * to the ACPI specification, else 0
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiNsOpensScope (
+ ACPI_OBJECT_TYPE Type)
+{
+ ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type));
+
+
+ if (!AcpiUtValidObjectType (Type))
+ {
+ /* type code out of range */
+
+ ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));
+ return_UINT32 (ACPI_NS_NORMAL);
+ }
+
+ return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetNode
+ *
+ * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
+ * \ (backslash) and ^ (carat) prefixes, and the
+ * . (period) to separate segments are supported.
+ * PrefixNode - Root of subtree to be searched, or NS_ALL for the
+ * root of the name space. If Name is fully
+ * qualified (first INT8 is '\'), the passed value
+ * of Scope will not be accessed.
+ * Flags - Used to indicate whether to perform upsearch or
+ * not.
+ * ReturnNode - Where the Node is returned
+ *
+ * DESCRIPTION: Look up a name relative to a given scope and return the
+ * corresponding Node. NOTE: Scope can be null.
+ *
+ * MUTEX: Locks namespace
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsGetNode (
+ ACPI_NAMESPACE_NODE *PrefixNode,
+ const char *Pathname,
+ UINT32 Flags,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_GENERIC_STATE ScopeInfo;
+ ACPI_STATUS Status;
+ char *InternalPath;
+
+
+ ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname));
+
+
+ if (!Pathname)
+ {
+ *ReturnNode = PrefixNode;
+ if (!PrefixNode)
+ {
+ *ReturnNode = AcpiGbl_RootNode;
+ }
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Convert path to internal representation */
+
+ Status = AcpiNsInternalizeName (Pathname, &InternalPath);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Must lock namespace during lookup */
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Setup lookup scope (search starting point) */
+
+ ScopeInfo.Scope.Node = PrefixNode;
+
+ /* Lookup the name in the namespace */
+
+ Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,
+ ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE),
+ NULL, ReturnNode);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n",
+ Pathname, AcpiFormatException (Status)));
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+Cleanup:
+ ACPI_FREE (InternalPath);
+ return_ACPI_STATUS (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nswalk.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nswalk.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,386 @@
+/******************************************************************************
+ *
+ * Module Name: nswalk - Functions for walking 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.
+ */
+
+
+#define __NSWALK_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nswalk")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetNextNode
+ *
+ * PARAMETERS: ParentNode - Parent node whose children we are
+ * getting
+ * ChildNode - Previous child that was found.
+ * The NEXT child will be returned
+ *
+ * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
+ * none is found.
+ *
+ * DESCRIPTION: Return the next peer node within the namespace. If Handle
+ * is valid, Scope is ignored. Otherwise, the first node
+ * within Scope is returned.
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+AcpiNsGetNextNode (
+ ACPI_NAMESPACE_NODE *ParentNode,
+ ACPI_NAMESPACE_NODE *ChildNode)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!ChildNode)
+ {
+ /* It's really the parent's _scope_ that we want */
+
+ return (ParentNode->Child);
+ }
+
+ /* Otherwise just return the next peer */
+
+ return (ChildNode->Peer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetNextNodeTyped
+ *
+ * PARAMETERS: Type - Type of node to be searched for
+ * ParentNode - Parent node whose children we are
+ * getting
+ * ChildNode - Previous child that was found.
+ * The NEXT child will be returned
+ *
+ * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
+ * none is found.
+ *
+ * DESCRIPTION: Return the next peer node within the namespace. If Handle
+ * is valid, Scope is ignored. Otherwise, the first node
+ * within Scope is returned.
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+AcpiNsGetNextNodeTyped (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_NAMESPACE_NODE *ParentNode,
+ ACPI_NAMESPACE_NODE *ChildNode)
+{
+ ACPI_NAMESPACE_NODE *NextNode = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ NextNode = AcpiNsGetNextNode (ParentNode, ChildNode);
+
+ /* If any type is OK, we are done */
+
+ if (Type == ACPI_TYPE_ANY)
+ {
+ /* NextNode is NULL if we are at the end-of-list */
+
+ return (NextNode);
+ }
+
+ /* Must search for the node -- but within this scope only */
+
+ while (NextNode)
+ {
+ /* If type matches, we are done */
+
+ if (NextNode->Type == Type)
+ {
+ return (NextNode);
+ }
+
+ /* Otherwise, move on to the next peer node */
+
+ NextNode = NextNode->Peer;
+ }
+
+ /* Not found */
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsWalkNamespace
+ *
+ * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
+ * StartNode - Handle in namespace where search begins
+ * MaxDepth - Depth to which search is to reach
+ * Flags - Whether to unlock the NS before invoking
+ * the callback routine
+ * PreOrderVisit - Called during tree pre-order visit
+ * when an object of "Type" is found
+ * PostOrderVisit - Called during tree post-order visit
+ * when an object of "Type" is found
+ * Context - Passed to user function(s) above
+ * ReturnValue - from the UserFunction if terminated
+ * early. Otherwise, returns NULL.
+ * RETURNS: Status
+ *
+ * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
+ * starting (and ending) at the node specified by StartHandle.
+ * The callback function is called whenever a node that matches
+ * the type parameter is found. If the callback function returns
+ * a non-zero value, the search is terminated immediately and
+ * this value is returned to the caller.
+ *
+ * The point of this procedure is to provide a generic namespace
+ * walk routine that can be called from multiple places to
+ * provide multiple services; the callback function(s) can be
+ * tailored to each task, whether it is a print function,
+ * a compare function, etc.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsWalkNamespace (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_HANDLE StartNode,
+ UINT32 MaxDepth,
+ UINT32 Flags,
+ ACPI_WALK_CALLBACK PreOrderVisit,
+ ACPI_WALK_CALLBACK PostOrderVisit,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_STATUS Status;
+ ACPI_STATUS MutexStatus;
+ ACPI_NAMESPACE_NODE *ChildNode;
+ ACPI_NAMESPACE_NODE *ParentNode;
+ ACPI_OBJECT_TYPE ChildType;
+ UINT32 Level;
+ BOOLEAN NodePreviouslyVisited = FALSE;
+
+
+ ACPI_FUNCTION_TRACE (NsWalkNamespace);
+
+
+ /* Special case for the namespace Root Node */
+
+ if (StartNode == ACPI_ROOT_OBJECT)
+ {
+ StartNode = AcpiGbl_RootNode;
+ }
+
+ /* Null child means "get first node" */
+
+ ParentNode = StartNode;
+ ChildNode = AcpiNsGetNextNode (ParentNode, NULL);
+ ChildType = ACPI_TYPE_ANY;
+ Level = 1;
+
+ /*
+ * Traverse the tree of nodes until we bubble back up to where we
+ * started. When Level is zero, the loop is done because we have
+ * bubbled up to (and passed) the original parent handle (StartEntry)
+ */
+ while (Level > 0 && ChildNode)
+ {
+ Status = AE_OK;
+
+ /* Found next child, get the type if we are not searching for ANY */
+
+ if (Type != ACPI_TYPE_ANY)
+ {
+ ChildType = ChildNode->Type;
+ }
+
+ /*
+ * Ignore all temporary namespace nodes (created during control
+ * method execution) unless told otherwise. These temporary nodes
+ * can cause a race condition because they can be deleted during
+ * the execution of the user function (if the namespace is
+ * unlocked before invocation of the user function.) Only the
+ * debugger namespace dump will examine the temporary nodes.
+ */
+ if ((ChildNode->Flags & ANOBJ_TEMPORARY) &&
+ !(Flags & ACPI_NS_WALK_TEMP_NODES))
+ {
+ Status = AE_CTRL_DEPTH;
+ }
+
+ /* Type must match requested type */
+
+ else if (ChildType == Type)
+ {
+ /*
+ * Found a matching node, invoke the user callback function.
+ * Unlock the namespace if flag is set.
+ */
+ if (Flags & ACPI_NS_WALK_UNLOCK)
+ {
+ MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (MutexStatus))
+ {
+ return_ACPI_STATUS (MutexStatus);
+ }
+ }
+
+ /*
+ * Invoke the user function, either pre-order or post-order
+ * or both.
+ */
+ if (!NodePreviouslyVisited)
+ {
+ if (PreOrderVisit)
+ {
+ Status = PreOrderVisit (ChildNode, Level,
+ Context, ReturnValue);
+ }
+ }
+ else
+ {
+ if (PostOrderVisit)
+ {
+ Status = PostOrderVisit (ChildNode, Level,
+ Context, ReturnValue);
+ }
+ }
+
+ if (Flags & ACPI_NS_WALK_UNLOCK)
+ {
+ MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (MutexStatus))
+ {
+ return_ACPI_STATUS (MutexStatus);
+ }
+ }
+
+ switch (Status)
+ {
+ case AE_OK:
+ case AE_CTRL_DEPTH:
+
+ /* Just keep going */
+ break;
+
+ case AE_CTRL_TERMINATE:
+
+ /* Exit now, with OK status */
+
+ return_ACPI_STATUS (AE_OK);
+
+ default:
+
+ /* All others are valid exceptions */
+
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Depth first search: Attempt to go down another level in the
+ * namespace if we are allowed to. Don't go any further if we have
+ * reached the caller specified maximum depth or if the user
+ * function has specified that the maximum depth has been reached.
+ */
+ if (!NodePreviouslyVisited &&
+ (Level < MaxDepth) &&
+ (Status != AE_CTRL_DEPTH))
+ {
+ if (ChildNode->Child)
+ {
+ /* There is at least one child of this node, visit it */
+
+ Level++;
+ ParentNode = ChildNode;
+ ChildNode = AcpiNsGetNextNode (ParentNode, NULL);
+ continue;
+ }
+ }
+
+ /* No more children, re-visit this node */
+
+ if (!NodePreviouslyVisited)
+ {
+ NodePreviouslyVisited = TRUE;
+ continue;
+ }
+
+ /* No more children, visit peers */
+
+ ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
+ if (ChildNode)
+ {
+ NodePreviouslyVisited = FALSE;
+ }
+
+ /* No peers, re-visit parent */
+
+ else
+ {
+ /*
+ * No more children of this node (AcpiNsGetNextNode failed), go
+ * back upwards in the namespace tree to the node's parent.
+ */
+ Level--;
+ ChildNode = ParentNode;
+ ParentNode = ParentNode->Parent;
+
+ NodePreviouslyVisited = TRUE;
+ }
+ }
+
+ /* Complete walk, not terminated by user function */
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,960 @@
+/*******************************************************************************
+ *
+ * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
+ * ACPI Object evaluation 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.
+ */
+
+
+#define __NSXFEVAL_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/acinterp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsxfeval")
+
+/* Local prototypes */
+
+static void
+AcpiNsResolveReferences (
+ ACPI_EVALUATE_INFO *Info);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvaluateObjectTyped
+ *
+ * PARAMETERS: Handle - Object handle (optional)
+ * Pathname - Object pathname (optional)
+ * ExternalParams - List of parameters to pass to method,
+ * terminated by NULL. May be NULL
+ * if no parameters are being passed.
+ * ReturnBuffer - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * ReturnType - Expected type of return object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Find and evaluate the given object, passing the given
+ * parameters if necessary. One of "Handle" or "Pathname" must
+ * be valid (non-null)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvaluateObjectTyped (
+ ACPI_HANDLE Handle,
+ ACPI_STRING Pathname,
+ ACPI_OBJECT_LIST *ExternalParams,
+ ACPI_BUFFER *ReturnBuffer,
+ ACPI_OBJECT_TYPE ReturnType)
+{
+ ACPI_STATUS Status;
+ BOOLEAN MustFree = FALSE;
+
+
+ ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped);
+
+
+ /* Return buffer must be valid */
+
+ if (!ReturnBuffer)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER)
+ {
+ MustFree = TRUE;
+ }
+
+ /* Evaluate the object */
+
+ Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Type ANY means "don't care" */
+
+ if (ReturnType == ACPI_TYPE_ANY)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ if (ReturnBuffer->Length == 0)
+ {
+ /* Error because caller specifically asked for a return value */
+
+ ACPI_ERROR ((AE_INFO, "No return value"));
+ return_ACPI_STATUS (AE_NULL_OBJECT);
+ }
+
+ /* Examine the object type returned from EvaluateObject */
+
+ if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Return object type does not match requested type */
+
+ ACPI_ERROR ((AE_INFO,
+ "Incorrect return type [%s] requested [%s]",
+ AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type),
+ AcpiUtGetTypeName (ReturnType)));
+
+ if (MustFree)
+ {
+ /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
+
+ AcpiOsFree (ReturnBuffer->Pointer);
+ ReturnBuffer->Pointer = NULL;
+ }
+
+ ReturnBuffer->Length = 0;
+ return_ACPI_STATUS (AE_TYPE);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvaluateObject
+ *
+ * PARAMETERS: Handle - Object handle (optional)
+ * Pathname - Object pathname (optional)
+ * ExternalParams - List of parameters to pass to method,
+ * terminated by NULL. May be NULL
+ * if no parameters are being passed.
+ * ReturnBuffer - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Find and evaluate the given object, passing the given
+ * parameters if necessary. One of "Handle" or "Pathname" must
+ * be valid (non-null)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvaluateObject (
+ ACPI_HANDLE Handle,
+ ACPI_STRING Pathname,
+ ACPI_OBJECT_LIST *ExternalParams,
+ ACPI_BUFFER *ReturnBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_EVALUATE_INFO *Info;
+ ACPI_SIZE BufferSpaceNeeded;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (AcpiEvaluateObject);
+
+
+ /* Allocate and initialize the evaluation information block */
+
+ Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
+ if (!Info)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Info->Pathname = Pathname;
+
+ /* Convert and validate the device handle */
+
+ Info->PrefixNode = AcpiNsValidateHandle (Handle);
+ if (!Info->PrefixNode)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto Cleanup;
+ }
+
+ /*
+ * If there are parameters to be passed to a control method, the external
+ * objects must all be converted to internal objects
+ */
+ if (ExternalParams && ExternalParams->Count)
+ {
+ /*
+ * Allocate a new parameter block for the internal objects
+ * Add 1 to count to allow for null terminated internal list
+ */
+ Info->Parameters = ACPI_ALLOCATE_ZEROED (
+ ((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *));
+ if (!Info->Parameters)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Convert each external object in the list to an internal object */
+
+ for (i = 0; i < ExternalParams->Count; i++)
+ {
+ Status = AcpiUtCopyEobjectToIobject (
+ &ExternalParams->Pointer[i], &Info->Parameters[i]);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ }
+ Info->Parameters[ExternalParams->Count] = NULL;
+ }
+
+ /*
+ * Three major cases:
+ * 1) Fully qualified pathname
+ * 2) No handle, not fully qualified pathname (error)
+ * 3) Valid handle
+ */
+ if ((Pathname) &&
+ (AcpiNsValidRootPrefix (Pathname[0])))
+ {
+ /* The path is fully qualified, just evaluate by name */
+
+ Info->PrefixNode = NULL;
+ Status = AcpiNsEvaluate (Info);
+ }
+ else if (!Handle)
+ {
+ /*
+ * A handle is optional iff a fully qualified pathname is specified.
+ * Since we've already handled fully qualified names above, this is
+ * an error
+ */
+ if (!Pathname)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Both Handle and Pathname are NULL"));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Null Handle with relative pathname [%s]", Pathname));
+ }
+
+ Status = AE_BAD_PARAMETER;
+ }
+ else
+ {
+ /* We have a namespace a node and a possible relative path */
+
+ Status = AcpiNsEvaluate (Info);
+ }
+
+ /*
+ * If we are expecting a return value, and all went well above,
+ * copy the return value to an external object.
+ */
+ if (ReturnBuffer)
+ {
+ if (!Info->ReturnObject)
+ {
+ ReturnBuffer->Length = 0;
+ }
+ else
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
+ ACPI_DESC_TYPE_NAMED)
+ {
+ /*
+ * If we received a NS Node as a return object, this means that
+ * the object we are evaluating has nothing interesting to
+ * return (such as a mutex, etc.) We return an error because
+ * these types are essentially unsupported by this interface.
+ * We don't check up front because this makes it easier to add
+ * support for various types at a later date if necessary.
+ */
+ Status = AE_TYPE;
+ Info->ReturnObject = NULL; /* No need to delete a NS Node */
+ ReturnBuffer->Length = 0;
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Dereference Index and RefOf references */
+
+ AcpiNsResolveReferences (Info);
+
+ /* Get the size of the returned object */
+
+ Status = AcpiUtGetObjectSize (Info->ReturnObject,
+ &BufferSpaceNeeded);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (ReturnBuffer,
+ BufferSpaceNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * Caller's buffer is too small or a new one can't
+ * be allocated
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Needed buffer size %X, %s\n",
+ (UINT32) BufferSpaceNeeded,
+ AcpiFormatException (Status)));
+ }
+ else
+ {
+ /* We have enough space for the object, build it */
+
+ Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject,
+ ReturnBuffer);
+ }
+ }
+ }
+ }
+ }
+
+ if (Info->ReturnObject)
+ {
+ /*
+ * Delete the internal return object. NOTE: Interpreter must be
+ * locked to avoid race condition.
+ */
+ AcpiExEnterInterpreter ();
+
+ /* Remove one reference on the return object (should delete it) */
+
+ AcpiUtRemoveReference (Info->ReturnObject);
+ AcpiExExitInterpreter ();
+ }
+
+
+Cleanup:
+
+ /* Free the input parameter list (if we created one) */
+
+ if (Info->Parameters)
+ {
+ /* Free the allocated parameter block */
+
+ AcpiUtDeleteInternalObjectList (Info->Parameters);
+ }
+
+ ACPI_FREE (Info);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEvaluateObject)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsResolveReferences
+ *
+ * PARAMETERS: Info - Evaluation info block
+ *
+ * RETURN: Info->ReturnObject is replaced with the dereferenced object
+ *
+ * DESCRIPTION: Dereference certain reference objects. Called before an
+ * internal return object is converted to an external ACPI_OBJECT.
+ *
+ * Performs an automatic dereference of Index and RefOf reference objects.
+ * These reference objects are not supported by the ACPI_OBJECT, so this is a
+ * last resort effort to return something useful. Also, provides compatibility
+ * with other ACPI implementations.
+ *
+ * NOTE: does not handle references within returned package objects or nested
+ * references, but this support could be added later if found to be necessary.
+ *
+ ******************************************************************************/
+
+static void
+AcpiNsResolveReferences (
+ ACPI_EVALUATE_INFO *Info)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc = NULL;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ /* We are interested in reference objects only */
+
+ if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ return;
+ }
+
+ /*
+ * Two types of references are supported - those created by Index and
+ * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted
+ * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle
+ * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
+ * an ACPI_OBJECT.
+ */
+ switch (Info->ReturnObject->Reference.Class)
+ {
+ case ACPI_REFCLASS_INDEX:
+
+ ObjDesc = *(Info->ReturnObject->Reference.Where);
+ break;
+
+ case ACPI_REFCLASS_REFOF:
+
+ Node = Info->ReturnObject->Reference.Object;
+ if (Node)
+ {
+ ObjDesc = Node->Object;
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ /* Replace the existing reference object */
+
+ if (ObjDesc)
+ {
+ AcpiUtAddReference (ObjDesc);
+ AcpiUtRemoveReference (Info->ReturnObject);
+ Info->ReturnObject = ObjDesc;
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiWalkNamespace
+ *
+ * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
+ * StartObject - Handle in namespace where search begins
+ * MaxDepth - Depth to which search is to reach
+ * PreOrderVisit - Called during tree pre-order visit
+ * when an object of "Type" is found
+ * PostOrderVisit - Called during tree post-order visit
+ * when an object of "Type" is found
+ * Context - Passed to user function(s) above
+ * ReturnValue - Location where return value of
+ * UserFunction is put if terminated early
+ *
+ * RETURNS Return value from the UserFunction if terminated early.
+ * Otherwise, returns NULL.
+ *
+ * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
+ * starting (and ending) at the object specified by StartHandle.
+ * The callback function is called whenever an object that matches
+ * the type parameter is found. If the callback function returns
+ * a non-zero value, the search is terminated immediately and this
+ * value is returned to the caller.
+ *
+ * The point of this procedure is to provide a generic namespace
+ * walk routine that can be called from multiple places to
+ * provide multiple services; the callback function(s) can be
+ * tailored to each task, whether it is a print function,
+ * a compare function, etc.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiWalkNamespace (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_HANDLE StartObject,
+ UINT32 MaxDepth,
+ ACPI_WALK_CALLBACK PreOrderVisit,
+ ACPI_WALK_CALLBACK PostOrderVisit,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiWalkNamespace);
+
+
+ /* Parameter validation */
+
+ if ((Type > ACPI_TYPE_LOCAL_MAX) ||
+ (!MaxDepth) ||
+ (!PreOrderVisit && !PostOrderVisit))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Need to acquire the namespace reader lock to prevent interference
+ * with any concurrent table unloads (which causes the deletion of
+ * namespace objects). We cannot allow the deletion of a namespace node
+ * while the user function is using it. The exception to this are the
+ * nodes created and deleted during control method execution -- these
+ * nodes are marked as temporary nodes and are ignored by the namespace
+ * walk. Thus, control methods can be executed while holding the
+ * namespace deletion lock (and the user function can execute control
+ * methods.)
+ */
+ Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * Lock the namespace around the walk. The namespace will be
+ * unlocked/locked around each call to the user function - since the user
+ * function must be allowed to make ACPICA calls itself (for example, it
+ * will typically execute control methods during device enumeration.)
+ */
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth,
+ ACPI_NS_WALK_UNLOCK, PreOrderVisit,
+ PostOrderVisit, Context, ReturnValue);
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+UnlockAndExit:
+ (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiWalkNamespace)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetDeviceCallback
+ *
+ * PARAMETERS: Callback from AcpiGetDevice
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non-
+ * present devices, or if they specified a HID, it filters based
+ * on that.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiNsGetDeviceCallback (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_GET_DEVICES_INFO *Info = Context;
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+ UINT32 Flags;
+ ACPI_DEVICE_ID *Hid;
+ ACPI_DEVICE_ID_LIST *Cid;
+ UINT32 i;
+ BOOLEAN Found;
+ int NoMatch;
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Node = AcpiNsValidateHandle (ObjHandle);
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (!Node)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * First, filter based on the device HID and CID.
+ *
+ * 01/2010: For this case where a specific HID is requested, we don't
+ * want to run _STA until we have an actual HID match. Thus, we will
+ * not unnecessarily execute _STA on devices for which the caller
+ * doesn't care about. Previously, _STA was executed unconditionally
+ * on all devices found here.
+ *
+ * A side-effect of this change is that now we will continue to search
+ * for a matching HID even under device trees where the parent device
+ * would have returned a _STA that indicates it is not present or
+ * not functioning (thus aborting the search on that branch).
+ */
+ if (Info->Hid != NULL)
+ {
+ Status = AcpiUtExecute_HID (Node, &Hid);
+ if (Status == AE_NOT_FOUND)
+ {
+ return (AE_OK);
+ }
+ else if (ACPI_FAILURE (Status))
+ {
+ return (AE_CTRL_DEPTH);
+ }
+
+ NoMatch = ACPI_STRCMP (Hid->String, Info->Hid);
+ ACPI_FREE (Hid);
+
+ if (NoMatch)
+ {
+ /*
+ * HID does not match, attempt match within the
+ * list of Compatible IDs (CIDs)
+ */
+ Status = AcpiUtExecute_CID (Node, &Cid);
+ if (Status == AE_NOT_FOUND)
+ {
+ return (AE_OK);
+ }
+ else if (ACPI_FAILURE (Status))
+ {
+ return (AE_CTRL_DEPTH);
+ }
+
+ /* Walk the CID list */
+
+ Found = FALSE;
+ for (i = 0; i < Cid->Count; i++)
+ {
+ if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0)
+ {
+ /* Found a matching CID */
+
+ Found = TRUE;
+ break;
+ }
+ }
+
+ ACPI_FREE (Cid);
+ if (!Found)
+ {
+ return (AE_OK);
+ }
+ }
+ }
+
+ /* Run _STA to determine if device is present */
+
+ Status = AcpiUtExecute_STA (Node, &Flags);
+ if (ACPI_FAILURE (Status))
+ {
+ return (AE_CTRL_DEPTH);
+ }
+
+ if (!(Flags & ACPI_STA_DEVICE_PRESENT) &&
+ !(Flags & ACPI_STA_DEVICE_FUNCTIONING))
+ {
+ /*
+ * Don't examine the children of the device only when the
+ * device is neither present nor functional. See ACPI spec,
+ * description of _STA for more information.
+ */
+ return (AE_CTRL_DEPTH);
+ }
+
+ /* We have a valid device, invoke the user function */
+
+ Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context,
+ ReturnValue);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetDevices
+ *
+ * PARAMETERS: HID - HID to search for. Can be NULL.
+ * UserFunction - Called when a matching object is found
+ * Context - Passed to user function
+ * ReturnValue - Location where return value of
+ * UserFunction is put if terminated early
+ *
+ * RETURNS Return value from the UserFunction if terminated early.
+ * Otherwise, returns NULL.
+ *
+ * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
+ * starting (and ending) at the object specified by StartHandle.
+ * The UserFunction is called whenever an object of type
+ * Device is found. If the user function returns
+ * a non-zero value, the search is terminated immediately and this
+ * value is returned to the caller.
+ *
+ * This is a wrapper for WalkNamespace, but the callback performs
+ * additional filtering. Please see AcpiNsGetDeviceCallback.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetDevices (
+ char *HID,
+ ACPI_WALK_CALLBACK UserFunction,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_STATUS Status;
+ ACPI_GET_DEVICES_INFO Info;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetDevices);
+
+
+ /* Parameter validation */
+
+ if (!UserFunction)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * We're going to call their callback from OUR callback, so we need
+ * to know what it is, and their context parameter.
+ */
+ Info.Hid = HID;
+ Info.Context = Context;
+ Info.UserFunction = UserFunction;
+
+ /*
+ * Lock the namespace around the walk.
+ * The namespace will be unlocked/locked around each call
+ * to the user function - since this function
+ * must be allowed to make Acpi calls itself.
+ */
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
+ AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue);
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetDevices)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAttachData
+ *
+ * PARAMETERS: ObjHandle - Namespace node
+ * Handler - Handler for this attachment
+ * Data - Pointer to data to be attached
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAttachData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler,
+ void *Data)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!ObjHandle ||
+ !Handler ||
+ !Data)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Convert and validate the handle */
+
+ Node = AcpiNsValidateHandle (ObjHandle);
+ if (!Node)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiNsAttachData (Node, Handler, Data);
+
+UnlockAndExit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiAttachData)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDetachData
+ *
+ * PARAMETERS: ObjHandle - Namespace node handle
+ * Handler - Handler used in call to AcpiAttachData
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Remove data that was previously attached to a node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDetachData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!ObjHandle ||
+ !Handler)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Convert and validate the handle */
+
+ Node = AcpiNsValidateHandle (ObjHandle);
+ if (!Node)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiNsDetachData (Node, Handler);
+
+UnlockAndExit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiDetachData)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetData
+ *
+ * PARAMETERS: ObjHandle - Namespace node
+ * Handler - Handler used in call to AttachData
+ * Data - Where the data is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler,
+ void **Data)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!ObjHandle ||
+ !Handler ||
+ !Data)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Convert and validate the handle */
+
+ Node = AcpiNsValidateHandle (ObjHandle);
+ if (!Node)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiNsGetAttachedData (Node, Handler, Data);
+
+UnlockAndExit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetData)
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsxfname.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsxfname.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,702 @@
+/******************************************************************************
+ *
+ * Module Name: nsxfname - Public interfaces to the ACPI subsystem
+ * ACPI Namespace oriented 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.
+ */
+
+#define __NSXFNAME_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/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsxfname")
+
+/* Local prototypes */
+
+static char *
+AcpiNsCopyDeviceId (
+ ACPI_DEVICE_ID *Dest,
+ ACPI_DEVICE_ID *Source,
+ char *StringArea);
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetHandle
+ *
+ * PARAMETERS: Parent - Object to search under (search scope).
+ * Pathname - Pointer to an asciiz string containing the
+ * name
+ * RetHandle - Where the return handle is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This routine will search for a caller specified name in the
+ * name space. The caller can restrict the search region by
+ * specifying a non NULL parent. The parent value is itself a
+ * namespace handle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetHandle (
+ ACPI_HANDLE Parent,
+ ACPI_STRING Pathname,
+ ACPI_HANDLE *RetHandle)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node = NULL;
+ ACPI_NAMESPACE_NODE *PrefixNode = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Parameter Validation */
+
+ if (!RetHandle || !Pathname)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Convert a parent handle to a prefix node */
+
+ if (Parent)
+ {
+ PrefixNode = AcpiNsValidateHandle (Parent);
+ if (!PrefixNode)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+ }
+
+ /*
+ * Valid cases are:
+ * 1) Fully qualified pathname
+ * 2) Parent + Relative pathname
+ *
+ * Error for <null Parent + relative path>
+ */
+ if (AcpiNsValidRootPrefix (Pathname[0]))
+ {
+ /* Pathname is fully qualified (starts with '\') */
+
+ /* Special case for root-only, since we can't search for it */
+
+ if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH))
+ {
+ *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode);
+ return (AE_OK);
+ }
+ }
+ else if (!PrefixNode)
+ {
+ /* Relative path with null prefix is disallowed */
+
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Find the Node and convert to a handle */
+
+ Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node);
+ if (ACPI_SUCCESS (Status))
+ {
+ *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
+ }
+
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetHandle)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetName
+ *
+ * PARAMETERS: Handle - Handle to be converted to a pathname
+ * NameType - Full pathname or single segment
+ * Buffer - Buffer for returned path
+ *
+ * RETURN: Pointer to a string containing the fully qualified Name.
+ *
+ * DESCRIPTION: This routine returns the fully qualified name associated with
+ * the Handle parameter. This and the AcpiPathnameToHandle are
+ * complementary functions.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetName (
+ ACPI_HANDLE Handle,
+ UINT32 NameType,
+ ACPI_BUFFER *Buffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ /* Parameter validation */
+
+ if (NameType > ACPI_NAME_TYPE_MAX)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtValidateBuffer (Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (NameType == ACPI_FULL_PATHNAME)
+ {
+ /* Get the full pathname (From the namespace root) */
+
+ Status = AcpiNsHandleToPathname (Handle, Buffer);
+ return (Status);
+ }
+
+ /*
+ * Wants the single segment ACPI name.
+ * Validate handle and convert to a namespace Node
+ */
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Node = AcpiNsValidateHandle (Handle);
+ if (!Node)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ /* Just copy the ACPI name from the Node and zero terminate it */
+
+ ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node),
+ ACPI_NAME_SIZE);
+ ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0;
+ Status = AE_OK;
+
+
+UnlockAndExit:
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetName)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiNsCopyDeviceId
+ *
+ * PARAMETERS: Dest - Pointer to the destination DEVICE_ID
+ * Source - Pointer to the source DEVICE_ID
+ * StringArea - Pointer to where to copy the dest string
+ *
+ * RETURN: Pointer to the next string area
+ *
+ * DESCRIPTION: Copy a single DEVICE_ID, including the string data.
+ *
+ ******************************************************************************/
+
+static char *
+AcpiNsCopyDeviceId (
+ ACPI_DEVICE_ID *Dest,
+ ACPI_DEVICE_ID *Source,
+ char *StringArea)
+{
+ /* Create the destination DEVICE_ID */
+
+ Dest->String = StringArea;
+ Dest->Length = Source->Length;
+
+ /* Copy actual string and return a pointer to the next string area */
+
+ ACPI_MEMCPY (StringArea, Source->String, Source->Length);
+ return (StringArea + Source->Length);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetObjectInfo
+ *
+ * PARAMETERS: Handle - Object Handle
+ * ReturnBuffer - Where the info is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Returns information about an object as gleaned from the
+ * namespace node and possibly by running several standard
+ * control methods (Such as in the case of a device.)
+ *
+ * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA,
+ * _ADR, _SxW, and _SxD methods.
+ *
+ * Note: Allocates the return buffer, must be freed by the caller.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetObjectInfo (
+ ACPI_HANDLE Handle,
+ ACPI_DEVICE_INFO **ReturnBuffer)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_DEVICE_INFO *Info;
+ ACPI_DEVICE_ID_LIST *CidList = NULL;
+ ACPI_DEVICE_ID *Hid = NULL;
+ ACPI_DEVICE_ID *Uid = NULL;
+ char *NextIdString;
+ ACPI_OBJECT_TYPE Type;
+ ACPI_NAME Name;
+ UINT8 ParamCount= 0;
+ UINT8 Valid = 0;
+ UINT32 InfoSize;
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!Handle || !ReturnBuffer)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Node = AcpiNsValidateHandle (Handle);
+ if (!Node)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Get the namespace node data while the namespace is locked */
+
+ InfoSize = sizeof (ACPI_DEVICE_INFO);
+ Type = Node->Type;
+ Name = Node->Name.Integer;
+
+ if (Node->Type == ACPI_TYPE_METHOD)
+ {
+ ParamCount = Node->Object->Method.ParamCount;
+ }
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if ((Type == ACPI_TYPE_DEVICE) ||
+ (Type == ACPI_TYPE_PROCESSOR))
+ {
+ /*
+ * Get extra info for ACPI Device/Processor objects only:
+ * Run the Device _HID, _UID, and _CID methods.
+ *
+ * Note: none of these methods are required, so they may or may
+ * not be present for this device. The Info->Valid bitfield is used
+ * to indicate which methods were found and run successfully.
+ */
+
+ /* Execute the Device._HID method */
+
+ Status = AcpiUtExecute_HID (Node, &Hid);
+ if (ACPI_SUCCESS (Status))
+ {
+ InfoSize += Hid->Length;
+ Valid |= ACPI_VALID_HID;
+ }
+
+ /* Execute the Device._UID method */
+
+ Status = AcpiUtExecute_UID (Node, &Uid);
+ if (ACPI_SUCCESS (Status))
+ {
+ InfoSize += Uid->Length;
+ Valid |= ACPI_VALID_UID;
+ }
+
+ /* Execute the Device._CID method */
+
+ Status = AcpiUtExecute_CID (Node, &CidList);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Add size of CID strings and CID pointer array */
+
+ InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST));
+ Valid |= ACPI_VALID_CID;
+ }
+ }
+
+ /*
+ * Now that we have the variable-length data, we can allocate the
+ * return buffer
+ */
+ Info = ACPI_ALLOCATE_ZEROED (InfoSize);
+ if (!Info)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Get the fixed-length data */
+
+ if ((Type == ACPI_TYPE_DEVICE) ||
+ (Type == ACPI_TYPE_PROCESSOR))
+ {
+ /*
+ * Get extra info for ACPI Device/Processor objects only:
+ * Run the _STA, _ADR and, SxW, and _SxD methods.
+ *
+ * Note: none of these methods are required, so they may or may
+ * not be present for this device. The Info->Valid bitfield is used
+ * to indicate which methods were found and run successfully.
+ */
+
+ /* Execute the Device._STA method */
+
+ Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus);
+ if (ACPI_SUCCESS (Status))
+ {
+ Valid |= ACPI_VALID_STA;
+ }
+
+ /* Execute the Device._ADR method */
+
+ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node,
+ &Info->Address);
+ if (ACPI_SUCCESS (Status))
+ {
+ Valid |= ACPI_VALID_ADR;
+ }
+
+ /* Execute the Device._SxW methods */
+
+ Status = AcpiUtExecutePowerMethods (Node,
+ AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS,
+ Info->LowestDstates);
+ if (ACPI_SUCCESS (Status))
+ {
+ Valid |= ACPI_VALID_SXWS;
+ }
+
+ /* Execute the Device._SxD methods */
+
+ Status = AcpiUtExecutePowerMethods (Node,
+ AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS,
+ Info->HighestDstates);
+ if (ACPI_SUCCESS (Status))
+ {
+ Valid |= ACPI_VALID_SXDS;
+ }
+ }
+
+ /*
+ * Create a pointer to the string area of the return buffer.
+ * Point to the end of the base ACPI_DEVICE_INFO structure.
+ */
+ NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids);
+ if (CidList)
+ {
+ /* Point past the CID DEVICE_ID array */
+
+ NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID));
+ }
+
+ /*
+ * Copy the HID, UID, and CIDs to the return buffer. The variable-length
+ * strings are copied to the reserved area at the end of the buffer.
+ *
+ * For HID and CID, check if the ID is a PCI Root Bridge.
+ */
+ if (Hid)
+ {
+ NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId,
+ Hid, NextIdString);
+
+ if (AcpiUtIsPciRootBridge (Hid->String))
+ {
+ Info->Flags |= ACPI_PCI_ROOT_BRIDGE;
+ }
+ }
+
+ if (Uid)
+ {
+ NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId,
+ Uid, NextIdString);
+ }
+
+ if (CidList)
+ {
+ Info->CompatibleIdList.Count = CidList->Count;
+ Info->CompatibleIdList.ListSize = CidList->ListSize;
+
+ /* Copy each CID */
+
+ for (i = 0; i < CidList->Count; i++)
+ {
+ NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i],
+ &CidList->Ids[i], NextIdString);
+
+ if (AcpiUtIsPciRootBridge (CidList->Ids[i].String))
+ {
+ Info->Flags |= ACPI_PCI_ROOT_BRIDGE;
+ }
+ }
+ }
+
+ /* Copy the fixed-length data */
+
+ Info->InfoSize = InfoSize;
+ Info->Type = Type;
+ Info->Name = Name;
+ Info->ParamCount = ParamCount;
+ Info->Valid = Valid;
+
+ *ReturnBuffer = Info;
+ Status = AE_OK;
+
+
+Cleanup:
+ if (Hid)
+ {
+ ACPI_FREE (Hid);
+ }
+ if (Uid)
+ {
+ ACPI_FREE (Uid);
+ }
+ if (CidList)
+ {
+ ACPI_FREE (CidList);
+ }
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiInstallMethod
+ *
+ * PARAMETERS: Buffer - An ACPI table containing one control method
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install a control method into the namespace. If the method
+ * name already exists in the namespace, it is overwritten. The
+ * input buffer must contain a valid DSDT or SSDT containing a
+ * single control method.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInstallMethod (
+ UINT8 *Buffer)
+{
+ ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer);
+ UINT8 *AmlBuffer;
+ UINT8 *AmlStart;
+ char *Path;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OPERAND_OBJECT *MethodObj;
+ ACPI_PARSE_STATE ParserState;
+ UINT32 AmlLength;
+ UINT16 Opcode;
+ UINT8 MethodFlags;
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!Buffer)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Table must be a DSDT or SSDT */
+
+ if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) &&
+ !ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
+ {
+ return (AE_BAD_HEADER);
+ }
+
+ /* First AML opcode in the table must be a control method */
+
+ ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER);
+ Opcode = AcpiPsPeekOpcode (&ParserState);
+ if (Opcode != AML_METHOD_OP)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Extract method information from the raw AML */
+
+ ParserState.Aml += AcpiPsGetOpcodeSize (Opcode);
+ ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState);
+ Path = AcpiPsGetNextNamestring (&ParserState);
+ MethodFlags = *ParserState.Aml++;
+ AmlStart = ParserState.Aml;
+ AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart);
+
+ /*
+ * Allocate resources up-front. We don't want to have to delete a new
+ * node from the namespace if we cannot allocate memory.
+ */
+ AmlBuffer = ACPI_ALLOCATE (AmlLength);
+ if (!AmlBuffer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
+ if (!MethodObj)
+ {
+ ACPI_FREE (AmlBuffer);
+ return (AE_NO_MEMORY);
+ }
+
+ /* Lock namespace for AcpiNsLookup, we may be creating a new node */
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ /* The lookup either returns an existing node or creates a new one */
+
+ Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1,
+ ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node);
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+ if (ACPI_FAILURE (Status)) /* NsLookup */
+ {
+ if (Status != AE_ALREADY_EXISTS)
+ {
+ goto ErrorExit;
+ }
+
+ /* Node existed previously, make sure it is a method node */
+
+ if (Node->Type != ACPI_TYPE_METHOD)
+ {
+ Status = AE_TYPE;
+ goto ErrorExit;
+ }
+ }
+
+ /* Copy the method AML to the local buffer */
+
+ ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength);
+
+ /* Initialize the method object with the new method's information */
+
+ MethodObj->Method.AmlStart = AmlBuffer;
+ MethodObj->Method.AmlLength = AmlLength;
+
+ MethodObj->Method.ParamCount = (UINT8)
+ (MethodFlags & AML_METHOD_ARG_COUNT);
+
+ if (MethodFlags & AML_METHOD_SERIALIZED)
+ {
+ MethodObj->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
+
+ MethodObj->Method.SyncLevel = (UINT8)
+ ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
+ }
+
+ /*
+ * Now that it is complete, we can attach the new method object to
+ * the method Node (detaches/deletes any existing object)
+ */
+ Status = AcpiNsAttachObject (Node, MethodObj, ACPI_TYPE_METHOD);
+
+ /*
+ * Flag indicates AML buffer is dynamic, must be deleted later.
+ * Must be set only after attach above.
+ */
+ Node->Flags |= ANOBJ_ALLOCATED_BUFFER;
+
+ /* Remove local reference to the method object */
+
+ AcpiUtRemoveReference (MethodObj);
+ return (Status);
+
+
+ErrorExit:
+
+ ACPI_FREE (AmlBuffer);
+ ACPI_FREE (MethodObj);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallMethod)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/namespace/nsxfobj.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/namespace/nsxfobj.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ *
+ * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
+ * ACPI Object oriented 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.
+ */
+
+
+#define __NSXFOBJ_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsxfobj")
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetType
+ *
+ * PARAMETERS: Handle - Handle of object whose type is desired
+ * RetType - Where the type will be placed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This routine returns the type associatd with a particular handle
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetType (
+ ACPI_HANDLE Handle,
+ ACPI_OBJECT_TYPE *RetType)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ /* Parameter Validation */
+
+ if (!RetType)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Special case for the predefined Root Node
+ * (return type ANY)
+ */
+ if (Handle == ACPI_ROOT_OBJECT)
+ {
+ *RetType = ACPI_TYPE_ANY;
+ return (AE_OK);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Convert and validate the handle */
+
+ Node = AcpiNsValidateHandle (Handle);
+ if (!Node)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (AE_BAD_PARAMETER);
+ }
+
+ *RetType = Node->Type;
+
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetType)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetParent
+ *
+ * PARAMETERS: Handle - Handle of object whose parent is desired
+ * RetHandle - Where the parent handle will be placed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Returns a handle to the parent of the object represented by
+ * Handle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetParent (
+ ACPI_HANDLE Handle,
+ ACPI_HANDLE *RetHandle)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_NAMESPACE_NODE *ParentNode;
+ ACPI_STATUS Status;
+
+
+ if (!RetHandle)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Special case for the predefined Root Node (no parent) */
+
+ if (Handle == ACPI_ROOT_OBJECT)
+ {
+ return (AE_NULL_ENTRY);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Convert and validate the handle */
+
+ Node = AcpiNsValidateHandle (Handle);
+ if (!Node)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
+ /* Get the parent entry */
+
+ ParentNode = Node->Parent;
+ *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode);
+
+ /* Return exception if parent is null */
+
+ if (!ParentNode)
+ {
+ Status = AE_NULL_ENTRY;
+ }
+
+
+UnlockAndExit:
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetParent)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetNextObject
+ *
+ * PARAMETERS: Type - Type of object to be searched for
+ * Parent - Parent object whose children we are getting
+ * LastChild - Previous child that was found.
+ * The NEXT child will be returned
+ * RetHandle - Where handle to the next object is placed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Return the next peer object within the namespace. If Handle is
+ * valid, Scope is ignored. Otherwise, the first object within
+ * Scope is returned.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetNextObject (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_HANDLE Parent,
+ ACPI_HANDLE Child,
+ ACPI_HANDLE *RetHandle)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_NAMESPACE_NODE *ParentNode = NULL;
+ ACPI_NAMESPACE_NODE *ChildNode = NULL;
+
+
+ /* Parameter validation */
+
+ if (Type > ACPI_TYPE_EXTERNAL_MAX)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* If null handle, use the parent */
+
+ if (!Child)
+ {
+ /* Start search at the beginning of the specified scope */
+
+ ParentNode = AcpiNsValidateHandle (Parent);
+ if (!ParentNode)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+ }
+ else
+ {
+ /* Non-null handle, ignore the parent */
+ /* Convert and validate the handle */
+
+ ChildNode = AcpiNsValidateHandle (Child);
+ if (!ChildNode)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+ }
+
+ /* Internal function does the real work */
+
+ Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode);
+ if (!Node)
+ {
+ Status = AE_NOT_FOUND;
+ goto UnlockAndExit;
+ }
+
+ if (RetHandle)
+ {
+ *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
+ }
+
+
+UnlockAndExit:
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetNextObject)
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/psargs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/psargs.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,940 @@
+/******************************************************************************
+ *
+ * Module Name: psargs - Parse AML opcode arguments
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __PSARGS_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/acnamesp.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psargs")
+
+/* Local prototypes */
+
+static UINT32
+AcpiPsGetNextPackageLength (
+ ACPI_PARSE_STATE *ParserState);
+
+static ACPI_PARSE_OBJECT *
+AcpiPsGetNextField (
+ ACPI_PARSE_STATE *ParserState);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextPackageLength
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Decoded package length. On completion, the AML pointer points
+ * past the length byte or bytes.
+ *
+ * DESCRIPTION: Decode and return a package length field.
+ * Note: Largest package length is 28 bits, from ACPI specification
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiPsGetNextPackageLength (
+ ACPI_PARSE_STATE *ParserState)
+{
+ UINT8 *Aml = ParserState->Aml;
+ UINT32 PackageLength = 0;
+ UINT32 ByteCount;
+ UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */
+
+
+ ACPI_FUNCTION_TRACE (PsGetNextPackageLength);
+
+
+ /*
+ * Byte 0 bits [6:7] contain the number of additional bytes
+ * used to encode the package length, either 0,1,2, or 3
+ */
+ ByteCount = (Aml[0] >> 6);
+ ParserState->Aml += ((ACPI_SIZE) ByteCount + 1);
+
+ /* Get bytes 3, 2, 1 as needed */
+
+ while (ByteCount)
+ {
+ /*
+ * Final bit positions for the package length bytes:
+ * Byte3->[20:27]
+ * Byte2->[12:19]
+ * Byte1->[04:11]
+ * Byte0->[00:03]
+ */
+ PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4));
+
+ ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */
+ ByteCount--;
+ }
+
+ /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
+
+ PackageLength |= (Aml[0] & ByteZeroMask);
+ return_UINT32 (PackageLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextPackageEnd
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Pointer to end-of-package +1
+ *
+ * DESCRIPTION: Get next package length and return a pointer past the end of
+ * the package. Consumes the package length field
+ *
+ ******************************************************************************/
+
+UINT8 *
+AcpiPsGetNextPackageEnd (
+ ACPI_PARSE_STATE *ParserState)
+{
+ UINT8 *Start = ParserState->Aml;
+ UINT32 PackageLength;
+
+
+ ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
+
+
+ /* Function below updates ParserState->Aml */
+
+ PackageLength = AcpiPsGetNextPackageLength (ParserState);
+
+ return_PTR (Start + PackageLength); /* end of package */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextNamestring
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Pointer to the start of the name string (pointer points into
+ * the AML.
+ *
+ * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
+ * prefix characters. Set parser state to point past the string.
+ * (Name is consumed from the AML.)
+ *
+ ******************************************************************************/
+
+char *
+AcpiPsGetNextNamestring (
+ ACPI_PARSE_STATE *ParserState)
+{
+ UINT8 *Start = ParserState->Aml;
+ UINT8 *End = ParserState->Aml;
+
+
+ ACPI_FUNCTION_TRACE (PsGetNextNamestring);
+
+
+ /* Point past any namestring prefix characters (backslash or carat) */
+
+ while (AcpiPsIsPrefixChar (*End))
+ {
+ End++;
+ }
+
+ /* Decode the path prefix character */
+
+ switch (*End)
+ {
+ case 0:
+
+ /* NullName */
+
+ if (End == Start)
+ {
+ Start = NULL;
+ }
+ End++;
+ break;
+
+ case AML_DUAL_NAME_PREFIX:
+
+ /* Two name segments */
+
+ End += 1 + (2 * ACPI_NAME_SIZE);
+ break;
+
+ case AML_MULTI_NAME_PREFIX_OP:
+
+ /* Multiple name segments, 4 chars each, count in next byte */
+
+ End += 2 + (*(End + 1) * ACPI_NAME_SIZE);
+ break;
+
+ default:
+
+ /* Single name segment */
+
+ End += ACPI_NAME_SIZE;
+ break;
+ }
+
+ ParserState->Aml = End;
+ return_PTR ((char *) Start);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextNamepath
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * Arg - Where the namepath will be stored
+ * ArgCount - If the namepath points to a control method
+ * the method's argument is returned here.
+ * PossibleMethodCall - Whether the namepath can possibly be the
+ * start of a method call
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get next name (if method call, return # of required args).
+ * Names are looked up in the internal namespace to determine
+ * if the name represents a control method. If a method
+ * is found, the number of arguments to the method is returned.
+ * This information is critical for parsing to continue correctly.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsGetNextNamepath (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_PARSE_OBJECT *Arg,
+ BOOLEAN PossibleMethodCall)
+{
+ ACPI_STATUS Status;
+ char *Path;
+ ACPI_PARSE_OBJECT *NameOp;
+ ACPI_OPERAND_OBJECT *MethodDesc;
+ ACPI_NAMESPACE_NODE *Node;
+ UINT8 *Start = ParserState->Aml;
+
+
+ ACPI_FUNCTION_TRACE (PsGetNextNamepath);
+
+
+ Path = AcpiPsGetNextNamestring (ParserState);
+ AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
+
+ /* Null path case is allowed, just exit */
+
+ if (!Path)
+ {
+ Arg->Common.Value.Name = Path;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Lookup the name in the internal namespace, starting with the current
+ * scope. We don't want to add anything new to the namespace here,
+ * however, so we use MODE_EXECUTE.
+ * Allow searching of the parent tree, but don't open a new scope -
+ * we just want to lookup the object (must be mode EXECUTE to perform
+ * the upsearch)
+ */
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
+ ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
+
+ /*
+ * If this name is a control method invocation, we must
+ * setup the method call
+ */
+ if (ACPI_SUCCESS (Status) &&
+ PossibleMethodCall &&
+ (Node->Type == ACPI_TYPE_METHOD))
+ {
+ if (WalkState->Opcode == AML_UNLOAD_OP)
+ {
+ /*
+ * AcpiPsGetNextNamestring has increased the AML pointer,
+ * so we need to restore the saved AML pointer for method call.
+ */
+ WalkState->ParserState.Aml = Start;
+ WalkState->ArgCount = 1;
+ AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* This name is actually a control method invocation */
+
+ MethodDesc = AcpiNsGetAttachedObject (Node);
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path));
+
+ NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
+ if (!NameOp)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Change Arg into a METHOD CALL and attach name to it */
+
+ AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
+ NameOp->Common.Value.Name = Path;
+
+ /* Point METHODCALL/NAME to the METHOD Node */
+
+ NameOp->Common.Node = Node;
+ AcpiPsAppendArg (Arg, NameOp);
+
+ if (!MethodDesc)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Control Method %p has no attached object",
+ Node));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Control Method - %p Args %X\n",
+ Node, MethodDesc->Method.ParamCount));
+
+ /* Get the number of arguments to expect */
+
+ WalkState->ArgCount = MethodDesc->Method.ParamCount;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Special handling if the name was not found during the lookup -
+ * some NotFound cases are allowed
+ */
+ if (Status == AE_NOT_FOUND)
+ {
+ /* 1) NotFound is ok during load pass 1/2 (allow forward references) */
+
+ if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
+ ACPI_PARSE_EXECUTE)
+ {
+ Status = AE_OK;
+ }
+
+ /* 2) NotFound during a CondRefOf(x) is ok by definition */
+
+ else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP)
+ {
+ Status = AE_OK;
+ }
+
+ /*
+ * 3) NotFound while building a Package is ok at this point, we
+ * may flag as an error later if slack mode is not enabled.
+ * (Some ASL code depends on allowing this behavior)
+ */
+ else if ((Arg->Common.Parent) &&
+ ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
+ (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
+ {
+ Status = AE_OK;
+ }
+ }
+
+ /* Final exception check (may have been changed from code above) */
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_ERROR_NAMESPACE (Path, Status);
+
+ if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
+ ACPI_PARSE_EXECUTE)
+ {
+ /* Report a control method execution error */
+
+ Status = AcpiDsMethodError (Status, WalkState);
+ }
+ }
+
+ /* Save the namepath */
+
+ Arg->Common.Value.Name = Path;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextSimpleArg
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * ArgType - The argument type (AML_*_ARG)
+ * Arg - Where the argument is returned
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
+ *
+ ******************************************************************************/
+
+void
+AcpiPsGetNextSimpleArg (
+ ACPI_PARSE_STATE *ParserState,
+ UINT32 ArgType,
+ ACPI_PARSE_OBJECT *Arg)
+{
+ UINT32 Length;
+ UINT16 Opcode;
+ UINT8 *Aml = ParserState->Aml;
+
+
+ ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
+
+
+ switch (ArgType)
+ {
+ case ARGP_BYTEDATA:
+
+ /* Get 1 byte from the AML stream */
+
+ Opcode = AML_BYTE_OP;
+ Arg->Common.Value.Integer = (UINT64) *Aml;
+ Length = 1;
+ break;
+
+
+ case ARGP_WORDDATA:
+
+ /* Get 2 bytes from the AML stream */
+
+ Opcode = AML_WORD_OP;
+ ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
+ Length = 2;
+ break;
+
+
+ case ARGP_DWORDDATA:
+
+ /* Get 4 bytes from the AML stream */
+
+ Opcode = AML_DWORD_OP;
+ ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
+ Length = 4;
+ break;
+
+
+ case ARGP_QWORDDATA:
+
+ /* Get 8 bytes from the AML stream */
+
+ Opcode = AML_QWORD_OP;
+ ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
+ Length = 8;
+ break;
+
+
+ case ARGP_CHARLIST:
+
+ /* Get a pointer to the string, point past the string */
+
+ Opcode = AML_STRING_OP;
+ Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
+
+ /* Find the null terminator */
+
+ Length = 0;
+ while (Aml[Length])
+ {
+ Length++;
+ }
+ Length++;
+ break;
+
+
+ case ARGP_NAME:
+ case ARGP_NAMESTRING:
+
+ AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
+ Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
+ return_VOID;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
+ return_VOID;
+ }
+
+ AcpiPsInitOp (Arg, Opcode);
+ ParserState->Aml += Length;
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextField
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: A newly allocated FIELD op
+ *
+ * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
+ *
+ ******************************************************************************/
+
+static ACPI_PARSE_OBJECT *
+AcpiPsGetNextField (
+ ACPI_PARSE_STATE *ParserState)
+{
+ UINT32 AmlOffset;
+ ACPI_PARSE_OBJECT *Field;
+ ACPI_PARSE_OBJECT *Arg = NULL;
+ UINT16 Opcode;
+ UINT32 Name;
+ UINT8 AccessType;
+ UINT8 AccessAttribute;
+ UINT8 AccessLength;
+ UINT32 PkgLength;
+ UINT8 *PkgEnd;
+ UINT32 BufferLength;
+
+
+ ACPI_FUNCTION_TRACE (PsGetNextField);
+
+
+ AmlOffset = (UINT32) ACPI_PTR_DIFF (
+ ParserState->Aml, ParserState->AmlStart);
+
+ /* Determine field type */
+
+ switch (ACPI_GET8 (ParserState->Aml))
+ {
+ case AML_FIELD_OFFSET_OP:
+
+ Opcode = AML_INT_RESERVEDFIELD_OP;
+ ParserState->Aml++;
+ break;
+
+ case AML_FIELD_ACCESS_OP:
+
+ Opcode = AML_INT_ACCESSFIELD_OP;
+ ParserState->Aml++;
+ break;
+
+ case AML_FIELD_CONNECTION_OP:
+
+ Opcode = AML_INT_CONNECTION_OP;
+ ParserState->Aml++;
+ break;
+
+ case AML_FIELD_EXT_ACCESS_OP:
+
+ Opcode = AML_INT_EXTACCESSFIELD_OP;
+ ParserState->Aml++;
+ break;
+
+ default:
+
+ Opcode = AML_INT_NAMEDFIELD_OP;
+ break;
+ }
+
+ /* Allocate a new field op */
+
+ Field = AcpiPsAllocOp (Opcode);
+ if (!Field)
+ {
+ return_PTR (NULL);
+ }
+
+ Field->Common.AmlOffset = AmlOffset;
+
+ /* Decode the field type */
+
+ switch (Opcode)
+ {
+ case AML_INT_NAMEDFIELD_OP:
+
+ /* Get the 4-character name */
+
+ ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
+ AcpiPsSetName (Field, Name);
+ ParserState->Aml += ACPI_NAME_SIZE;
+
+ /* Get the length which is encoded as a package length */
+
+ Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
+ break;
+
+
+ case AML_INT_RESERVEDFIELD_OP:
+
+ /* Get the length which is encoded as a package length */
+
+ Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
+ break;
+
+
+ case AML_INT_ACCESSFIELD_OP:
+ case AML_INT_EXTACCESSFIELD_OP:
+
+ /*
+ * Get AccessType and AccessAttrib and merge into the field Op
+ * AccessType is first operand, AccessAttribute is second. stuff
+ * these bytes into the node integer value for convenience.
+ */
+
+ /* Get the two bytes (Type/Attribute) */
+
+ AccessType = ACPI_GET8 (ParserState->Aml);
+ ParserState->Aml++;
+ AccessAttribute = ACPI_GET8 (ParserState->Aml);
+ ParserState->Aml++;
+
+ Field->Common.Value.Integer = (UINT8) AccessType;
+ Field->Common.Value.Integer |= (UINT16) (AccessAttribute << 8);
+
+ /* This opcode has a third byte, AccessLength */
+
+ if (Opcode == AML_INT_EXTACCESSFIELD_OP)
+ {
+ AccessLength = ACPI_GET8 (ParserState->Aml);
+ ParserState->Aml++;
+
+ Field->Common.Value.Integer |= (UINT32) (AccessLength << 16);
+ }
+ break;
+
+
+ case AML_INT_CONNECTION_OP:
+
+ /*
+ * Argument for Connection operator can be either a Buffer
+ * (resource descriptor), or a NameString.
+ */
+ if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP)
+ {
+ ParserState->Aml++;
+
+ PkgEnd = ParserState->Aml;
+ PkgLength = AcpiPsGetNextPackageLength (ParserState);
+ PkgEnd += PkgLength;
+
+ if (ParserState->Aml < PkgEnd)
+ {
+ /* Non-empty list */
+
+ Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
+ if (!Arg)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Get the actual buffer length argument */
+
+ Opcode = ACPI_GET8 (ParserState->Aml);
+ ParserState->Aml++;
+
+ switch (Opcode)
+ {
+ case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
+ BufferLength = ACPI_GET8 (ParserState->Aml);
+ ParserState->Aml += 1;
+ break;
+
+ case AML_WORD_OP: /* AML_WORDDATA_ARG */
+ BufferLength = ACPI_GET16 (ParserState->Aml);
+ ParserState->Aml += 2;
+ break;
+
+ case AML_DWORD_OP: /* AML_DWORDATA_ARG */
+ BufferLength = ACPI_GET32 (ParserState->Aml);
+ ParserState->Aml += 4;
+ break;
+
+ default:
+ BufferLength = 0;
+ break;
+ }
+
+ /* Fill in bytelist data */
+
+ Arg->Named.Value.Size = BufferLength;
+ Arg->Named.Data = ParserState->Aml;
+ }
+
+ /* Skip to End of byte data */
+
+ ParserState->Aml = PkgEnd;
+ }
+ else
+ {
+ Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
+ if (!Arg)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Get the Namestring argument */
+
+ Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
+ }
+
+ /* Link the buffer/namestring to parent (CONNECTION_OP) */
+
+ AcpiPsAppendArg (Field, Arg);
+ break;
+
+
+ default:
+
+ /* Opcode was set in previous switch */
+ break;
+ }
+
+ return_PTR (Field);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextArg
+ *
+ * PARAMETERS: WalkState - Current state
+ * ParserState - Current parser state object
+ * ArgType - The argument type (AML_*_ARG)
+ * ReturnArg - Where the next arg is returned
+ *
+ * RETURN: Status, and an op object containing the next argument.
+ *
+ * DESCRIPTION: Get next argument (including complex list arguments that require
+ * pushing the parser stack)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsGetNextArg (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_STATE *ParserState,
+ UINT32 ArgType,
+ ACPI_PARSE_OBJECT **ReturnArg)
+{
+ ACPI_PARSE_OBJECT *Arg = NULL;
+ ACPI_PARSE_OBJECT *Prev = NULL;
+ ACPI_PARSE_OBJECT *Field;
+ UINT32 Subop;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
+
+
+ switch (ArgType)
+ {
+ case ARGP_BYTEDATA:
+ case ARGP_WORDDATA:
+ case ARGP_DWORDDATA:
+ case ARGP_CHARLIST:
+ case ARGP_NAME:
+ case ARGP_NAMESTRING:
+
+ /* Constants, strings, and namestrings are all the same size */
+
+ Arg = AcpiPsAllocOp (AML_BYTE_OP);
+ if (!Arg)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
+ break;
+
+
+ case ARGP_PKGLENGTH:
+
+ /* Package length, nothing returned */
+
+ ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
+ break;
+
+
+ case ARGP_FIELDLIST:
+
+ if (ParserState->Aml < ParserState->PkgEnd)
+ {
+ /* Non-empty list */
+
+ while (ParserState->Aml < ParserState->PkgEnd)
+ {
+ Field = AcpiPsGetNextField (ParserState);
+ if (!Field)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ if (Prev)
+ {
+ Prev->Common.Next = Field;
+ }
+ else
+ {
+ Arg = Field;
+ }
+ Prev = Field;
+ }
+
+ /* Skip to End of byte data */
+
+ ParserState->Aml = ParserState->PkgEnd;
+ }
+ break;
+
+
+ case ARGP_BYTELIST:
+
+ if (ParserState->Aml < ParserState->PkgEnd)
+ {
+ /* Non-empty list */
+
+ Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
+ if (!Arg)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Fill in bytelist data */
+
+ Arg->Common.Value.Size = (UINT32)
+ ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
+ Arg->Named.Data = ParserState->Aml;
+
+ /* Skip to End of byte data */
+
+ ParserState->Aml = ParserState->PkgEnd;
+ }
+ break;
+
+
+ case ARGP_TARGET:
+ case ARGP_SUPERNAME:
+ case ARGP_SIMPLENAME:
+
+ Subop = AcpiPsPeekOpcode (ParserState);
+ if (Subop == 0 ||
+ AcpiPsIsLeadingChar (Subop) ||
+ AcpiPsIsPrefixChar (Subop))
+ {
+ /* NullName or NameString */
+
+ Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
+ if (!Arg)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* To support SuperName arg of Unload */
+
+ if (WalkState->Opcode == AML_UNLOAD_OP)
+ {
+ Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
+
+ /*
+ * If the SuperName arg of Unload is a method call,
+ * we have restored the AML pointer, just free this Arg
+ */
+ if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
+ {
+ AcpiPsFreeOp (Arg);
+ Arg = NULL;
+ }
+ }
+ else
+ {
+ Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
+ }
+ }
+ else
+ {
+ /* Single complex argument, nothing returned */
+
+ WalkState->ArgCount = 1;
+ }
+ break;
+
+
+ case ARGP_DATAOBJ:
+ case ARGP_TERMARG:
+
+ /* Single complex argument, nothing returned */
+
+ WalkState->ArgCount = 1;
+ break;
+
+
+ case ARGP_DATAOBJLIST:
+ case ARGP_TERMLIST:
+ case ARGP_OBJLIST:
+
+ if (ParserState->Aml < ParserState->PkgEnd)
+ {
+ /* Non-empty list of variable arguments, nothing returned */
+
+ WalkState->ArgCount = ACPI_VAR_ARGS;
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+
+ *ReturnArg = Arg;
+ return_ACPI_STATUS (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/psloop.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/psloop.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1268 @@
+/******************************************************************************
+ *
+ * Module Name: psloop - Main AML parse loop
+ *
+ *****************************************************************************/
+
+/*
+ * 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.
+ */
+
+
+/*
+ * Parse the AML and build an operation tree as most interpreters, (such as
+ * Perl) do. Parsing is done by hand rather than with a YACC generated parser
+ * to tightly constrain stack and dynamic memory usage. Parsing is kept
+ * flexible and the code fairly compact by parsing based on a list of AML
+ * opcode templates in AmlOpInfo[].
+ */
+
+#include <contrib/dev/acpica/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/amlcode.h>
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psloop")
+
+static UINT32 AcpiGbl_Depth = 0;
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiPsGetAmlOpcode (
+ ACPI_WALK_STATE *WalkState);
+
+static ACPI_STATUS
+AcpiPsBuildNamedOp (
+ ACPI_WALK_STATE *WalkState,
+ UINT8 *AmlOpStart,
+ ACPI_PARSE_OBJECT *UnnamedOp,
+ ACPI_PARSE_OBJECT **Op);
+
+static ACPI_STATUS
+AcpiPsCreateOp (
+ ACPI_WALK_STATE *WalkState,
+ UINT8 *AmlOpStart,
+ ACPI_PARSE_OBJECT **NewOp);
+
+static ACPI_STATUS
+AcpiPsGetArguments (
+ ACPI_WALK_STATE *WalkState,
+ UINT8 *AmlOpStart,
+ ACPI_PARSE_OBJECT *Op);
+
+static ACPI_STATUS
+AcpiPsCompleteOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT **Op,
+ ACPI_STATUS Status);
+
+static ACPI_STATUS
+AcpiPsCompleteFinalOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_STATUS Status);
+
+static void
+AcpiPsLinkModuleCode (
+ ACPI_PARSE_OBJECT *ParentOp,
+ UINT8 *AmlStart,
+ UINT32 AmlLength,
+ ACPI_OWNER_ID OwnerId);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetAmlOpcode
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Extract the next AML opcode from the input stream.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiPsGetAmlOpcode (
+ ACPI_WALK_STATE *WalkState)
+{
+
+ ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
+
+
+ WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
+ WalkState->ParserState.AmlStart);
+ WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState));
+
+ /*
+ * First cut to determine what we have found:
+ * 1) A valid AML opcode
+ * 2) A name string
+ * 3) An unknown/invalid opcode
+ */
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
+
+ switch (WalkState->OpInfo->Class)
+ {
+ case AML_CLASS_ASCII:
+ case AML_CLASS_PREFIX:
+ /*
+ * Starts with a valid prefix or ASCII char, this is a name
+ * string. Convert the bare name string to a namepath.
+ */
+ WalkState->Opcode = AML_INT_NAMEPATH_OP;
+ WalkState->ArgTypes = ARGP_NAMESTRING;
+ break;
+
+ case AML_CLASS_UNKNOWN:
+
+ /* The opcode is unrecognized. Just skip unknown opcodes */
+
+ ACPI_ERROR ((AE_INFO,
+ "Found unknown opcode 0x%X at AML address %p offset 0x%X, ignoring",
+ WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset));
+
+ ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128);
+
+ /* Assume one-byte bad opcode */
+
+ WalkState->ParserState.Aml++;
+ return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
+
+ default:
+
+ /* Found opcode info, this is a normal opcode */
+
+ WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode);
+ WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
+ break;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsBuildNamedOp
+ *
+ * PARAMETERS: WalkState - Current state
+ * AmlOpStart - Begin of named Op in AML
+ * UnnamedOp - Early Op (not a named Op)
+ * Op - Returned Op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse a named Op
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiPsBuildNamedOp (
+ ACPI_WALK_STATE *WalkState,
+ UINT8 *AmlOpStart,
+ ACPI_PARSE_OBJECT *UnnamedOp,
+ ACPI_PARSE_OBJECT **Op)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PARSE_OBJECT *Arg = NULL;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState);
+
+
+ UnnamedOp->Common.Value.Arg = NULL;
+ UnnamedOp->Common.ArgListLength = 0;
+ UnnamedOp->Common.AmlOpcode = WalkState->Opcode;
+
+ /*
+ * Get and append arguments until we find the node that contains
+ * the name (the type ARGP_NAME).
+ */
+ while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
+ (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
+ {
+ Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
+ GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ AcpiPsAppendArg (UnnamedOp, Arg);
+ INCREMENT_ARG_LIST (WalkState->ArgTypes);
+ }
+
+ /*
+ * Make sure that we found a NAME and didn't run out of arguments
+ */
+ if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
+ {
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /* We know that this arg is a name, move to next arg */
+
+ INCREMENT_ARG_LIST (WalkState->ArgTypes);
+
+ /*
+ * Find the object. This will either insert the object into
+ * the namespace or simply look it up
+ */
+ WalkState->Op = NULL;
+
+ Status = WalkState->DescendingCallback (WalkState, Op);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog"));
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!*Op)
+ {
+ return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
+ }
+
+ Status = AcpiPsNextParseState (WalkState, *Op, Status);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_CTRL_PENDING)
+ {
+ return_ACPI_STATUS (AE_CTRL_PARSE_PENDING);
+ }
+ return_ACPI_STATUS (Status);
+ }
+
+ AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
+ AcpiGbl_Depth++;
+
+ if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
+ (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
+ {
+ /*
+ * Defer final parsing of an OperationRegion body, because we don't
+ * have enough info in the first pass to parse it correctly (i.e.,
+ * there may be method calls within the TermArg elements of the body.)
+ *
+ * However, we must continue parsing because the opregion is not a
+ * standalone package -- we don't know where the end is at this point.
+ *
+ * (Length is unknown until parse of the body complete)
+ */
+ (*Op)->Named.Data = AmlOpStart;
+ (*Op)->Named.Length = 0;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCreateOp
+ *
+ * PARAMETERS: WalkState - Current state
+ * AmlOpStart - Op start in AML
+ * NewOp - Returned Op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get Op from AML
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiPsCreateOp (
+ ACPI_WALK_STATE *WalkState,
+ UINT8 *AmlOpStart,
+ ACPI_PARSE_OBJECT **NewOp)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PARSE_OBJECT *Op;
+ ACPI_PARSE_OBJECT *NamedOp = NULL;
+ ACPI_PARSE_OBJECT *ParentScope;
+ UINT8 ArgumentCount;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState);
+
+
+ Status = AcpiPsGetAmlOpcode (WalkState);
+ if (Status == AE_CTRL_PARSE_CONTINUE)
+ {
+ return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
+ }
+
+ /* Create Op structure and append to parent's argument list */
+
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
+ Op = AcpiPsAllocOp (WalkState->Opcode);
+ if (!Op)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ if (WalkState->OpInfo->Flags & AML_NAMED)
+ {
+ Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp);
+ AcpiPsFreeOp (Op);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ *NewOp = NamedOp;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Not a named opcode, just allocate Op and append to parent */
+
+ if (WalkState->OpInfo->Flags & AML_CREATE)
+ {
+ /*
+ * Backup to beginning of CreateXXXfield declaration
+ * BodyLength is unknown until we parse the body
+ */
+ Op->Named.Data = AmlOpStart;
+ Op->Named.Length = 0;
+ }
+
+ if (WalkState->Opcode == AML_BANK_FIELD_OP)
+ {
+ /*
+ * Backup to beginning of BankField declaration
+ * BodyLength is unknown until we parse the body
+ */
+ Op->Named.Data = AmlOpStart;
+ Op->Named.Length = 0;
+ }
+
+ ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState));
+ AcpiPsAppendArg (ParentScope, Op);
+
+ if (ParentScope)
+ {
+ OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode);
+ if (OpInfo->Flags & AML_HAS_TARGET)
+ {
+ ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type);
+ if (ParentScope->Common.ArgListLength > ArgumentCount)
+ {
+ Op->Common.Flags |= ACPI_PARSEOP_TARGET;
+ }
+ }
+ else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP)
+ {
+ Op->Common.Flags |= ACPI_PARSEOP_TARGET;
+ }
+ }
+
+ if (WalkState->DescendingCallback != NULL)
+ {
+ /*
+ * Find the object. This will either insert the object into
+ * the namespace or simply look it up
+ */
+ WalkState->Op = *NewOp = Op;
+
+ Status = WalkState->DescendingCallback (WalkState, &Op);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ if (Status == AE_CTRL_PENDING)
+ {
+ Status = AE_CTRL_PARSE_PENDING;
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetArguments
+ *
+ * PARAMETERS: WalkState - Current state
+ * AmlOpStart - Op start in AML
+ * Op - Current Op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get arguments for passed Op.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiPsGetArguments (
+ ACPI_WALK_STATE *WalkState,
+ UINT8 *AmlOpStart,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PARSE_OBJECT *Arg = NULL;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState);
+
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
+ case AML_WORD_OP: /* AML_WORDDATA_ARG */
+ case AML_DWORD_OP: /* AML_DWORDATA_ARG */
+ case AML_QWORD_OP: /* AML_QWORDATA_ARG */
+ case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
+
+ /* Fill in constant or string argument directly */
+
+ AcpiPsGetNextSimpleArg (&(WalkState->ParserState),
+ GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op);
+ break;
+
+ case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
+
+ Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ WalkState->ArgTypes = 0;
+ break;
+
+ default:
+ /*
+ * Op is not a constant or string, append each argument to the Op
+ */
+ while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount)
+ {
+ WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
+ WalkState->ParserState.AmlStart);
+
+ Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
+ GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Arg)
+ {
+ Arg->Common.AmlOffset = WalkState->AmlOffset;
+ AcpiPsAppendArg (Op, Arg);
+ }
+
+ INCREMENT_ARG_LIST (WalkState->ArgTypes);
+ }
+
+
+ /*
+ * Handle executable code at "module-level". This refers to
+ * executable opcodes that appear outside of any control method.
+ */
+ if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) &&
+ ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0))
+ {
+ /*
+ * We want to skip If/Else/While constructs during Pass1 because we
+ * want to actually conditionally execute the code during Pass2.
+ *
+ * Except for disassembly, where we always want to walk the
+ * If/Else/While packages
+ */
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_IF_OP:
+ case AML_ELSE_OP:
+ case AML_WHILE_OP:
+
+ /*
+ * Currently supported module-level opcodes are:
+ * IF/ELSE/WHILE. These appear to be the most common,
+ * and easiest to support since they open an AML
+ * package.
+ */
+ if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1)
+ {
+ AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart,
+ (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart),
+ WalkState->OwnerId);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Pass1: Skipping an If/Else/While body\n"));
+
+ /* Skip body of if/else/while in pass 1 */
+
+ WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
+ WalkState->ArgCount = 0;
+ break;
+
+ default:
+ /*
+ * Check for an unsupported executable opcode at module
+ * level. We must be in PASS1, the parent must be a SCOPE,
+ * The opcode class must be EXECUTE, and the opcode must
+ * not be an argument to another opcode.
+ */
+ if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) &&
+ (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
+ {
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
+ (!Arg))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Detected an unsupported executable opcode "
+ "at module-level: [0x%.4X] at table offset 0x%.4X",
+ Op->Common.AmlOpcode,
+ (UINT32) (ACPI_PTR_DIFF (AmlOpStart,
+ WalkState->ParserState.AmlStart) +
+ sizeof (ACPI_TABLE_HEADER))));
+ }
+ }
+ break;
+ }
+ }
+
+ /* Special processing for certain opcodes */
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_METHOD_OP:
+ /*
+ * Skip parsing of control method because we don't have enough
+ * info in the first pass to parse it correctly.
+ *
+ * Save the length and address of the body
+ */
+ Op->Named.Data = WalkState->ParserState.Aml;
+ Op->Named.Length = (UINT32)
+ (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml);
+
+ /* Skip body of method */
+
+ WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
+ WalkState->ArgCount = 0;
+ break;
+
+ case AML_BUFFER_OP:
+ case AML_PACKAGE_OP:
+ case AML_VAR_PACKAGE_OP:
+
+ if ((Op->Common.Parent) &&
+ (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
+ (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
+ {
+ /*
+ * Skip parsing of Buffers and Packages because we don't have
+ * enough info in the first pass to parse them correctly.
+ */
+ Op->Named.Data = AmlOpStart;
+ Op->Named.Length = (UINT32)
+ (WalkState->ParserState.PkgEnd - AmlOpStart);
+
+ /* Skip body */
+
+ WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
+ WalkState->ArgCount = 0;
+ }
+ break;
+
+ case AML_WHILE_OP:
+
+ if (WalkState->ControlState)
+ {
+ WalkState->ControlState->Control.PackageEnd =
+ WalkState->ParserState.PkgEnd;
+ }
+ break;
+
+ default:
+
+ /* No action for all other opcodes */
+ break;
+ }
+
+ break;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsLinkModuleCode
+ *
+ * PARAMETERS: ParentOp - Parent parser op
+ * AmlStart - Pointer to the AML
+ * AmlLength - Length of executable AML
+ * OwnerId - OwnerId of module level code
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Wrap the module-level code with a method object and link the
+ * object to the global list. Note, the mutex field of the method
+ * object is used to link multiple module-level code objects.
+ *
+ ******************************************************************************/
+
+static void
+AcpiPsLinkModuleCode (
+ ACPI_PARSE_OBJECT *ParentOp,
+ UINT8 *AmlStart,
+ UINT32 AmlLength,
+ ACPI_OWNER_ID OwnerId)
+{
+ ACPI_OPERAND_OBJECT *Prev;
+ ACPI_OPERAND_OBJECT *Next;
+ ACPI_OPERAND_OBJECT *MethodObj;
+ ACPI_NAMESPACE_NODE *ParentNode;
+
+
+ /* Get the tail of the list */
+
+ Prev = Next = AcpiGbl_ModuleCodeList;
+ while (Next)
+ {
+ Prev = Next;
+ Next = Next->Method.Mutex;
+ }
+
+ /*
+ * Insert the module level code into the list. Merge it if it is
+ * adjacent to the previous element.
+ */
+ if (!Prev ||
+ ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart))
+ {
+ /* Create, initialize, and link a new temporary method object */
+
+ MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
+ if (!MethodObj)
+ {
+ return;
+ }
+
+ if (ParentOp->Common.Node)
+ {
+ ParentNode = ParentOp->Common.Node;
+ }
+ else
+ {
+ ParentNode = AcpiGbl_RootNode;
+ }
+
+ MethodObj->Method.AmlStart = AmlStart;
+ MethodObj->Method.AmlLength = AmlLength;
+ MethodObj->Method.OwnerId = OwnerId;
+ MethodObj->Method.InfoFlags |= ACPI_METHOD_MODULE_LEVEL;
+
+ /*
+ * Save the parent node in NextObject. This is cheating, but we
+ * don't want to expand the method object.
+ */
+ MethodObj->Method.NextObject =
+ ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode);
+
+ if (!Prev)
+ {
+ AcpiGbl_ModuleCodeList = MethodObj;
+ }
+ else
+ {
+ Prev->Method.Mutex = MethodObj;
+ }
+ }
+ else
+ {
+ Prev->Method.AmlLength += AmlLength;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCompleteOp
+ *
+ * PARAMETERS: WalkState - Current state
+ * Op - Returned Op
+ * Status - Parse status before complete Op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Complete Op
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiPsCompleteOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT **Op,
+ ACPI_STATUS Status)
+{
+ ACPI_STATUS Status2;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
+
+
+ /*
+ * Finished one argument of the containing scope
+ */
+ WalkState->ParserState.Scope->ParseScope.ArgCount--;
+
+ /* Close this Op (will result in parse subtree deletion) */
+
+ Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+
+ *Op = NULL;
+
+ switch (Status)
+ {
+ case AE_OK:
+ break;
+
+
+ case AE_CTRL_TRANSFER:
+
+ /* We are about to transfer to a called method */
+
+ WalkState->PrevOp = NULL;
+ WalkState->PrevArgTypes = WalkState->ArgTypes;
+ return_ACPI_STATUS (Status);
+
+
+ case AE_CTRL_END:
+
+ AcpiPsPopScope (&(WalkState->ParserState), Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ if (*Op)
+ {
+ WalkState->Op = *Op;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
+ WalkState->Opcode = (*Op)->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, *Op, Status);
+
+ Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ Status = AE_OK;
+ break;
+
+
+ case AE_CTRL_BREAK:
+ case AE_CTRL_CONTINUE:
+
+ /* Pop off scopes until we find the While */
+
+ while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
+ {
+ AcpiPsPopScope (&(WalkState->ParserState), Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ }
+
+ /* Close this iteration of the While loop */
+
+ WalkState->Op = *Op;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
+ WalkState->Opcode = (*Op)->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, *Op, Status);
+
+ Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+
+ Status = AE_OK;
+ break;
+
+
+ case AE_CTRL_TERMINATE:
+
+ /* Clean up */
+ do
+ {
+ if (*Op)
+ {
+ Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+
+ AcpiUtDeleteGenericState (
+ AcpiUtPopGenericState (&WalkState->ControlState));
+ }
+
+ AcpiPsPopScope (&(WalkState->ParserState), Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ } while (*Op);
+
+ return_ACPI_STATUS (AE_OK);
+
+
+ default: /* All other non-AE_OK status */
+
+ do
+ {
+ if (*Op)
+ {
+ Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ AcpiPsPopScope (&(WalkState->ParserState), Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ } while (*Op);
+
+
+#if 0
+ /*
+ * TBD: Cleanup parse ops on error
+ */
+ if (*Op == NULL)
+ {
+ AcpiPsPopScope (ParserState, Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ }
+#endif
+ WalkState->PrevOp = NULL;
+ WalkState->PrevArgTypes = WalkState->ArgTypes;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* This scope complete? */
+
+ if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
+ {
+ AcpiPsPopScope (&(WalkState->ParserState), Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
+ }
+ else
+ {
+ *Op = NULL;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCompleteFinalOp
+ *
+ * PARAMETERS: WalkState - Current state
+ * Op - Current Op
+ * Status - Current parse status before complete last
+ * Op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Complete last Op.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiPsCompleteFinalOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_STATUS Status)
+{
+ ACPI_STATUS Status2;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState);
+
+
+ /*
+ * Complete the last Op (if not completed), and clear the scope stack.
+ * It is easily possible to end an AML "package" with an unbounded number
+ * of open scopes (such as when several ASL blocks are closed with
+ * sequential closing braces). We want to terminate each one cleanly.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
+ do
+ {
+ if (Op)
+ {
+ if (WalkState->AscendingCallback != NULL)
+ {
+ WalkState->Op = Op;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ WalkState->Opcode = Op->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ if (Status == AE_CTRL_PENDING)
+ {
+ Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (Status == AE_CTRL_TERMINATE)
+ {
+ Status = AE_OK;
+
+ /* Clean up */
+ do
+ {
+ if (Op)
+ {
+ Status2 = AcpiPsCompleteThisOp (WalkState, Op);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ AcpiPsPopScope (&(WalkState->ParserState), &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ } while (Op);
+
+ return_ACPI_STATUS (Status);
+ }
+
+ else if (ACPI_FAILURE (Status))
+ {
+ /* First error is most important */
+
+ (void) AcpiPsCompleteThisOp (WalkState, Op);
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ Status2 = AcpiPsCompleteThisOp (WalkState, Op);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes,
+ &WalkState->ArgCount);
+
+ } while (Op);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsParseLoop
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
+ * a tree of ops.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsParseLoop (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PARSE_OBJECT *Op = NULL; /* current op */
+ ACPI_PARSE_STATE *ParserState;
+ UINT8 *AmlOpStart = NULL;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState);
+
+
+ if (WalkState->DescendingCallback == NULL)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ ParserState = &WalkState->ParserState;
+ WalkState->ArgTypes = 0;
+
+#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
+
+ if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART)
+ {
+ /* We are restarting a preempted control method */
+
+ if (AcpiPsHasCompletedScope (ParserState))
+ {
+ /*
+ * We must check if a predicate to an IF or WHILE statement
+ * was just completed
+ */
+ if ((ParserState->Scope->ParseScope.Op) &&
+ ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) ||
+ (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) &&
+ (WalkState->ControlState) &&
+ (WalkState->ControlState->Common.State ==
+ ACPI_CONTROL_PREDICATE_EXECUTING))
+ {
+ /*
+ * A predicate was just completed, get the value of the
+ * predicate and branch based on that value
+ */
+ WalkState->Op = NULL;
+ Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE));
+ if (ACPI_FAILURE (Status) &&
+ ((Status & AE_CODE_MASK) != AE_CODE_CONTROL))
+ {
+ if (Status == AE_AML_NO_RETURN_VALUE)
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Invoked method did not return a value"));
+ }
+
+ ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed"));
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ }
+
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
+ }
+ else if (WalkState->PrevOp)
+ {
+ /* We were in the middle of an op */
+
+ Op = WalkState->PrevOp;
+ WalkState->ArgTypes = WalkState->PrevArgTypes;
+ }
+ }
+#endif
+
+ /* Iterative parsing loop, while there is more AML to process: */
+
+ while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
+ {
+ AmlOpStart = ParserState->Aml;
+ if (!Op)
+ {
+ Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_CTRL_PARSE_CONTINUE)
+ {
+ continue;
+ }
+
+ if (Status == AE_CTRL_PARSE_PENDING)
+ {
+ Status = AE_OK;
+ }
+
+ Status = AcpiPsCompleteOp (WalkState, &Op, Status);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ continue;
+ }
+
+ Op->Common.AmlOffset = WalkState->AmlOffset;
+
+ if (WalkState->OpInfo)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
+ (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name,
+ Op, ParserState->Aml, Op->Common.AmlOffset));
+ }
+ }
+
+
+ /*
+ * Start ArgCount at zero because we don't know if there are
+ * any args yet
+ */
+ WalkState->ArgCount = 0;
+
+ /* Are there any arguments that must be processed? */
+
+ if (WalkState->ArgTypes)
+ {
+ /* Get arguments */
+
+ Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op);
+ if (ACPI_FAILURE (Status))
+ {
+ Status = AcpiPsCompleteOp (WalkState, &Op, Status);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ continue;
+ }
+ }
+
+ /* Check for arguments that need to be processed */
+
+ if (WalkState->ArgCount)
+ {
+ /*
+ * There are arguments (complex ones), push Op and
+ * prepare for argument
+ */
+ Status = AcpiPsPushScope (ParserState, Op,
+ WalkState->ArgTypes, WalkState->ArgCount);
+ if (ACPI_FAILURE (Status))
+ {
+ Status = AcpiPsCompleteOp (WalkState, &Op, Status);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ continue;
+ }
+
+ Op = NULL;
+ continue;
+ }
+
+ /*
+ * All arguments have been processed -- Op is complete,
+ * prepare for next
+ */
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (WalkState->OpInfo->Flags & AML_NAMED)
+ {
+ if (AcpiGbl_Depth)
+ {
+ AcpiGbl_Depth--;
+ }
+
+ if (Op->Common.AmlOpcode == AML_REGION_OP ||
+ Op->Common.AmlOpcode == AML_DATA_REGION_OP)
+ {
+ /*
+ * Skip parsing of control method or opregion body,
+ * because we don't have enough info in the first pass
+ * to parse them correctly.
+ *
+ * Completed parsing an OpRegion declaration, we now
+ * know the length.
+ */
+ Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
+ }
+ }
+
+ if (WalkState->OpInfo->Flags & AML_CREATE)
+ {
+ /*
+ * Backup to beginning of CreateXXXfield declaration (1 for
+ * Opcode)
+ *
+ * BodyLength is unknown until we parse the body
+ */
+ Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
+ }
+
+ if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
+ {
+ /*
+ * Backup to beginning of BankField declaration
+ *
+ * BodyLength is unknown until we parse the body
+ */
+ Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
+ }
+
+ /* This op complete, notify the dispatcher */
+
+ if (WalkState->AscendingCallback != NULL)
+ {
+ WalkState->Op = Op;
+ WalkState->Opcode = Op->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ if (Status == AE_CTRL_PENDING)
+ {
+ Status = AE_OK;
+ }
+ }
+
+ Status = AcpiPsCompleteOp (WalkState, &Op, Status);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ } /* while ParserState->Aml */
+
+ Status = AcpiPsCompleteFinalOp (WalkState, Op, Status);
+ return_ACPI_STATUS (Status);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/psopcode.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/psopcode.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,522 @@
+/******************************************************************************
+ *
+ * Module Name: psopcode - Parser/Interpreter opcode information table
+ *
+ *****************************************************************************/
+
+/*
+ * 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/acopcode.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psopcode")
+
+
+static const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6};
+
+
+/*******************************************************************************
+ *
+ * NAME: AcpiGbl_AmlOpInfo
+ *
+ * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands>
+ * The name is a simple ascii string, the operand specifier is an
+ * ascii string with one letter per operand. The letter specifies
+ * the operand type.
+ *
+ ******************************************************************************/
+
+/*
+ * Summary of opcode types/flags
+ *
+
+ Opcodes that have associated namespace objects (AML_NSOBJECT flag)
+
+ AML_SCOPE_OP
+ AML_DEVICE_OP
+ AML_THERMAL_ZONE_OP
+ AML_METHOD_OP
+ AML_POWER_RES_OP
+ AML_PROCESSOR_OP
+ AML_FIELD_OP
+ AML_INDEX_FIELD_OP
+ AML_BANK_FIELD_OP
+ AML_NAME_OP
+ AML_ALIAS_OP
+ AML_MUTEX_OP
+ AML_EVENT_OP
+ AML_REGION_OP
+ AML_CREATE_FIELD_OP
+ AML_CREATE_BIT_FIELD_OP
+ AML_CREATE_BYTE_FIELD_OP
+ AML_CREATE_WORD_FIELD_OP
+ AML_CREATE_DWORD_FIELD_OP
+ AML_CREATE_QWORD_FIELD_OP
+ AML_INT_NAMEDFIELD_OP
+ AML_INT_METHODCALL_OP
+ AML_INT_NAMEPATH_OP
+
+ Opcodes that are "namespace" opcodes (AML_NSOPCODE flag)
+
+ AML_SCOPE_OP
+ AML_DEVICE_OP
+ AML_THERMAL_ZONE_OP
+ AML_METHOD_OP
+ AML_POWER_RES_OP
+ AML_PROCESSOR_OP
+ AML_FIELD_OP
+ AML_INDEX_FIELD_OP
+ AML_BANK_FIELD_OP
+ AML_NAME_OP
+ AML_ALIAS_OP
+ AML_MUTEX_OP
+ AML_EVENT_OP
+ AML_REGION_OP
+ AML_INT_NAMEDFIELD_OP
+
+ Opcodes that have an associated namespace node (AML_NSNODE flag)
+
+ AML_SCOPE_OP
+ AML_DEVICE_OP
+ AML_THERMAL_ZONE_OP
+ AML_METHOD_OP
+ AML_POWER_RES_OP
+ AML_PROCESSOR_OP
+ AML_NAME_OP
+ AML_ALIAS_OP
+ AML_MUTEX_OP
+ AML_EVENT_OP
+ AML_REGION_OP
+ AML_CREATE_FIELD_OP
+ AML_CREATE_BIT_FIELD_OP
+ AML_CREATE_BYTE_FIELD_OP
+ AML_CREATE_WORD_FIELD_OP
+ AML_CREATE_DWORD_FIELD_OP
+ AML_CREATE_QWORD_FIELD_OP
+ AML_INT_NAMEDFIELD_OP
+ AML_INT_METHODCALL_OP
+ AML_INT_NAMEPATH_OP
+
+ Opcodes that define named ACPI objects (AML_NAMED flag)
+
+ AML_SCOPE_OP
+ AML_DEVICE_OP
+ AML_THERMAL_ZONE_OP
+ AML_METHOD_OP
+ AML_POWER_RES_OP
+ AML_PROCESSOR_OP
+ AML_NAME_OP
+ AML_ALIAS_OP
+ AML_MUTEX_OP
+ AML_EVENT_OP
+ AML_REGION_OP
+ AML_INT_NAMEDFIELD_OP
+
+ Opcodes that contain executable AML as part of the definition that
+ must be deferred until needed
+
+ AML_METHOD_OP
+ AML_VAR_PACKAGE_OP
+ AML_CREATE_FIELD_OP
+ AML_CREATE_BIT_FIELD_OP
+ AML_CREATE_BYTE_FIELD_OP
+ AML_CREATE_WORD_FIELD_OP
+ AML_CREATE_DWORD_FIELD_OP
+ AML_CREATE_QWORD_FIELD_OP
+ AML_REGION_OP
+ AML_BUFFER_OP
+
+ Field opcodes
+
+ AML_CREATE_FIELD_OP
+ AML_FIELD_OP
+ AML_INDEX_FIELD_OP
+ AML_BANK_FIELD_OP
+
+ Field "Create" opcodes
+
+ AML_CREATE_FIELD_OP
+ AML_CREATE_BIT_FIELD_OP
+ AML_CREATE_BYTE_FIELD_OP
+ AML_CREATE_WORD_FIELD_OP
+ AML_CREATE_DWORD_FIELD_OP
+ AML_CREATE_QWORD_FIELD_OP
+
+ ******************************************************************************/
+
+
+/*
+ * Master Opcode information table. A summary of everything we know about each
+ * opcode, all in one place.
+ */
+const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] =
+{
+/*! [Begin] no source code translation */
+/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */
+
+/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
+/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
+/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
+/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
+/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
+/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
+/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
+/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
+/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
+/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
+/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
+/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
+/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
+/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
+/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
+/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
+/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
+/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
+/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
+/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
+/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
+/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT),
+/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
+/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
+/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R),
+/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
+/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R),
+/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT),
+/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
+/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
+/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
+/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
+/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
+/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
+/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
+/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
+/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
+/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
+/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
+/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
+/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
+/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
+/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
+
+/* Prefixed opcodes (Two-byte opcodes with a prefix op) */
+
+/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
+/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
+/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
+/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R),
+/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
+/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
+/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
+/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
+/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
+/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
+/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
+/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
+/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
+/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
+/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R),
+/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
+/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
+/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
+/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | AML_DEFER),
+
+/* Internal opcodes that map to invalid AML opcodes */
+
+/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
+/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
+/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
+/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ),
+/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
+/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0),
+/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
+/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
+/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
+/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
+/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL),
+/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS),
+/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS),
+/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS),
+
+/* ACPI 2.0 opcodes */
+
+/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
+/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER),
+/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
+/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
+/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
+/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
+/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT),
+/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
+/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R),
+/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
+/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE),
+
+/* ACPI 3.0 opcodes */
+
+/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R),
+
+/* ACPI 5.0 opcodes */
+
+/* 7F */ ACPI_OP ("-ConnectField-", ARGP_CONNECTFIELD_OP, ARGI_CONNECTFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS),
+/* 80 */ ACPI_OP ("-ExtAccessField-", ARGP_CONNECTFIELD_OP, ARGI_CONNECTFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0)
+
+/*! [End] no source code translation !*/
+};
+
+/*
+ * This table is directly indexed by the opcodes, and returns an
+ * index into the table above
+ */
+static const UINT8 AcpiGbl_ShortOpIndex[256] =
+{
+/* 0 1 2 3 4 5 6 7 */
+/* 8 9 A B C D E F */
+/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
+/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
+/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
+/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
+/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
+/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
+/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
+/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
+/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
+/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
+/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
+/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
+/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
+/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
+/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
+/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
+/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
+/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
+/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
+/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
+};
+
+/*
+ * This table is indexed by the second opcode of the extended opcode
+ * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo)
+ */
+static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] =
+{
+/* 0 1 2 3 4 5 6 7 */
+/* 8 9 A B C D E F */
+/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
+/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
+/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
+/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
+/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+/* 0x88 */ 0x7C,
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetOpcodeInfo
+ *
+ * PARAMETERS: Opcode - The AML opcode
+ *
+ * RETURN: A pointer to the info about the opcode.
+ *
+ * DESCRIPTION: Find AML opcode description based on the opcode.
+ * NOTE: This procedure must ALWAYS return a valid pointer!
+ *
+ ******************************************************************************/
+
+const ACPI_OPCODE_INFO *
+AcpiPsGetOpcodeInfo (
+ UINT16 Opcode)
+{
+ ACPI_FUNCTION_NAME (PsGetOpcodeInfo);
+
+
+ /*
+ * Detect normal 8-bit opcode or extended 16-bit opcode
+ */
+ if (!(Opcode & 0xFF00))
+ {
+ /* Simple (8-bit) opcode: 0-255, can't index beyond table */
+
+ return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]);
+ }
+
+ if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
+ (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE))
+ {
+ /* Valid extended (16-bit) opcode */
+
+ return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]);
+ }
+
+ /* Unknown AML opcode */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Unknown AML opcode [%4.4X]\n", Opcode));
+
+ return (&AcpiGbl_AmlOpInfo [_UNK]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetOpcodeName
+ *
+ * PARAMETERS: Opcode - The AML opcode
+ *
+ * RETURN: A pointer to the name of the opcode (ASCII String)
+ * Note: Never returns NULL.
+ *
+ * DESCRIPTION: Translate an opcode into a human-readable string
+ *
+ ******************************************************************************/
+
+char *
+AcpiPsGetOpcodeName (
+ UINT16 Opcode)
+{
+#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
+
+ const ACPI_OPCODE_INFO *Op;
+
+
+ Op = AcpiPsGetOpcodeInfo (Opcode);
+
+ /* Always guaranteed to return a valid pointer */
+
+ return (Op->Name);
+
+#else
+ return ("OpcodeName unavailable");
+
+#endif
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetArgumentCount
+ *
+ * PARAMETERS: OpType - Type associated with the AML opcode
+ *
+ * RETURN: Argument count
+ *
+ * DESCRIPTION: Obtain the number of expected arguments for an AML opcode
+ *
+ ******************************************************************************/
+
+UINT8
+AcpiPsGetArgumentCount (
+ UINT32 OpType)
+{
+
+ if (OpType <= AML_TYPE_EXEC_6A_0T_1R)
+ {
+ return (AcpiGbl_ArgumentCount[OpType]);
+ }
+
+ return (0);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/psparse.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/psparse.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,711 @@
+/******************************************************************************
+ *
+ * Module Name: psparse - Parser top level AML parse 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.
+ */
+
+
+/*
+ * Parse the AML and build an operation tree as most interpreters,
+ * like Perl, do. Parsing is done by hand rather than with a YACC
+ * generated parser to tightly constrain stack and dynamic memory
+ * usage. At the same time, parsing is kept flexible and the code
+ * fairly compact by parsing based on a list of AML opcode
+ * templates in AmlOpInfo[]
+ */
+
+#include <contrib/dev/acpica/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/amlcode.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psparse")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetOpcodeSize
+ *
+ * PARAMETERS: Opcode - An AML opcode
+ *
+ * RETURN: Size of the opcode, in bytes (1 or 2)
+ *
+ * DESCRIPTION: Get the size of the current opcode.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiPsGetOpcodeSize (
+ UINT32 Opcode)
+{
+
+ /* Extended (2-byte) opcode if > 255 */
+
+ if (Opcode > 0x00FF)
+ {
+ return (2);
+ }
+
+ /* Otherwise, just a single byte opcode */
+
+ return (1);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsPeekOpcode
+ *
+ * PARAMETERS: ParserState - A parser state object
+ *
+ * RETURN: Next AML opcode
+ *
+ * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
+ *
+ ******************************************************************************/
+
+UINT16
+AcpiPsPeekOpcode (
+ ACPI_PARSE_STATE *ParserState)
+{
+ UINT8 *Aml;
+ UINT16 Opcode;
+
+
+ Aml = ParserState->Aml;
+ Opcode = (UINT16) ACPI_GET8 (Aml);
+
+ if (Opcode == AML_EXTENDED_OP_PREFIX)
+ {
+ /* Extended opcode, get the second opcode byte */
+
+ Aml++;
+ Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
+ }
+
+ return (Opcode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCompleteThisOp
+ *
+ * PARAMETERS: WalkState - Current State
+ * Op - Op to complete
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform any cleanup at the completion of an Op.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsCompleteThisOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Prev;
+ ACPI_PARSE_OBJECT *Next;
+ const ACPI_OPCODE_INFO *ParentInfo;
+ ACPI_PARSE_OBJECT *ReplacementOp = NULL;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
+
+
+ /* Check for null Op, can happen if AML code is corrupt */
+
+ if (!Op)
+ {
+ return_ACPI_STATUS (AE_OK); /* OK for now */
+ }
+
+ /* Delete this op and the subtree below it if asked to */
+
+ if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
+ (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Make sure that we only delete this subtree */
+
+ if (Op->Common.Parent)
+ {
+ Prev = Op->Common.Parent->Common.Value.Arg;
+ if (!Prev)
+ {
+ /* Nothing more to do */
+
+ goto Cleanup;
+ }
+
+ /*
+ * Check if we need to replace the operator and its subtree
+ * with a return value op (placeholder op)
+ */
+ ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
+
+ switch (ParentInfo->Class)
+ {
+ case AML_CLASS_CONTROL:
+ break;
+
+ case AML_CLASS_CREATE:
+
+ /*
+ * These opcodes contain TermArg operands. The current
+ * op must be replaced by a placeholder return op
+ */
+ ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ if (!ReplacementOp)
+ {
+ Status = AE_NO_MEMORY;
+ }
+ break;
+
+ case AML_CLASS_NAMED_OBJECT:
+
+ /*
+ * These opcodes contain TermArg operands. The current
+ * op must be replaced by a placeholder return op
+ */
+ if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ {
+ ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ if (!ReplacementOp)
+ {
+ Status = AE_NO_MEMORY;
+ }
+ }
+ else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
+ (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
+ {
+ if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
+ (Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
+ (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ {
+ ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
+ if (!ReplacementOp)
+ {
+ Status = AE_NO_MEMORY;
+ }
+ else
+ {
+ ReplacementOp->Named.Data = Op->Named.Data;
+ ReplacementOp->Named.Length = Op->Named.Length;
+ }
+ }
+ }
+ break;
+
+ default:
+
+ ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ if (!ReplacementOp)
+ {
+ Status = AE_NO_MEMORY;
+ }
+ }
+
+ /* We must unlink this op from the parent tree */
+
+ if (Prev == Op)
+ {
+ /* This op is the first in the list */
+
+ if (ReplacementOp)
+ {
+ ReplacementOp->Common.Parent = Op->Common.Parent;
+ ReplacementOp->Common.Value.Arg = NULL;
+ ReplacementOp->Common.Node = Op->Common.Node;
+ Op->Common.Parent->Common.Value.Arg = ReplacementOp;
+ ReplacementOp->Common.Next = Op->Common.Next;
+ }
+ else
+ {
+ Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
+ }
+ }
+
+ /* Search the parent list */
+
+ else while (Prev)
+ {
+ /* Traverse all siblings in the parent's argument list */
+
+ Next = Prev->Common.Next;
+ if (Next == Op)
+ {
+ if (ReplacementOp)
+ {
+ ReplacementOp->Common.Parent = Op->Common.Parent;
+ ReplacementOp->Common.Value.Arg = NULL;
+ ReplacementOp->Common.Node = Op->Common.Node;
+ Prev->Common.Next = ReplacementOp;
+ ReplacementOp->Common.Next = Op->Common.Next;
+ Next = NULL;
+ }
+ else
+ {
+ Prev->Common.Next = Op->Common.Next;
+ Next = NULL;
+ }
+ }
+ Prev = Next;
+ }
+ }
+
+
+Cleanup:
+
+ /* Now we can actually delete the subtree rooted at Op */
+
+ AcpiPsDeleteParseTree (Op);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsNextParseState
+ *
+ * PARAMETERS: WalkState - Current state
+ * Op - Current parse op
+ * CallbackStatus - Status from previous operation
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Update the parser state based upon the return exception from
+ * the parser callback.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsNextParseState (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_STATUS CallbackStatus)
+{
+ ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
+ ACPI_STATUS Status = AE_CTRL_PENDING;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
+
+
+ switch (CallbackStatus)
+ {
+ case AE_CTRL_TERMINATE:
+ /*
+ * A control method was terminated via a RETURN statement.
+ * The walk of this method is complete.
+ */
+ ParserState->Aml = ParserState->AmlEnd;
+ Status = AE_CTRL_TERMINATE;
+ break;
+
+
+ case AE_CTRL_BREAK:
+
+ ParserState->Aml = WalkState->AmlLastWhile;
+ WalkState->ControlState->Common.Value = FALSE;
+ Status = AE_CTRL_BREAK;
+ break;
+
+
+ case AE_CTRL_CONTINUE:
+
+ ParserState->Aml = WalkState->AmlLastWhile;
+ Status = AE_CTRL_CONTINUE;
+ break;
+
+
+ case AE_CTRL_PENDING:
+
+ ParserState->Aml = WalkState->AmlLastWhile;
+ break;
+
+#if 0
+ case AE_CTRL_SKIP:
+
+ ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
+ Status = AE_OK;
+ break;
+#endif
+
+ case AE_CTRL_TRUE:
+ /*
+ * Predicate of an IF was true, and we are at the matching ELSE.
+ * Just close out this package
+ */
+ ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
+ Status = AE_CTRL_PENDING;
+ break;
+
+
+ case AE_CTRL_FALSE:
+ /*
+ * Either an IF/WHILE Predicate was false or we encountered a BREAK
+ * opcode. In both cases, we do not execute the rest of the
+ * package; We simply close out the parent (finishing the walk of
+ * this branch of the tree) and continue execution at the parent
+ * level.
+ */
+ ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
+
+ /* In the case of a BREAK, just force a predicate (if any) to FALSE */
+
+ WalkState->ControlState->Common.Value = FALSE;
+ Status = AE_CTRL_END;
+ break;
+
+
+ case AE_CTRL_TRANSFER:
+
+ /* A method call (invocation) -- transfer control */
+
+ Status = AE_CTRL_TRANSFER;
+ WalkState->PrevOp = Op;
+ WalkState->MethodCallOp = Op;
+ WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
+
+ /* Will return value (if any) be used by the caller? */
+
+ WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
+ break;
+
+
+ default:
+
+ Status = CallbackStatus;
+ if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
+ {
+ Status = AE_OK;
+ }
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsParseAml
+ *
+ * PARAMETERS: WalkState - Current state
+ *
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse raw AML and return a tree of ops
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsParseAml (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_THREAD_STATE *Thread;
+ ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList;
+ ACPI_WALK_STATE *PreviousWalkState;
+
+
+ ACPI_FUNCTION_TRACE (PsParseAml);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Entered with WalkState=%p Aml=%p size=%X\n",
+ WalkState, WalkState->ParserState.Aml,
+ WalkState->ParserState.AmlSize));
+
+ if (!WalkState->ParserState.Aml)
+ {
+ return_ACPI_STATUS (AE_NULL_OBJECT);
+ }
+
+ /* Create and initialize a new thread state */
+
+ Thread = AcpiUtCreateThreadState ();
+ if (!Thread)
+ {
+ if (WalkState->MethodDesc)
+ {
+ /* Executing a control method - additional cleanup */
+
+ AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
+ }
+
+ AcpiDsDeleteWalkState (WalkState);
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ WalkState->Thread = Thread;
+
+ /*
+ * If executing a method, the starting SyncLevel is this method's
+ * SyncLevel
+ */
+ if (WalkState->MethodDesc)
+ {
+ WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel;
+ }
+
+ AcpiDsPushWalkState (WalkState, Thread);
+
+ /*
+ * This global allows the AML debugger to get a handle to the currently
+ * executing control method.
+ */
+ AcpiGbl_CurrentWalkList = Thread;
+
+ /*
+ * Execute the walk loop as long as there is a valid Walk State. This
+ * handles nested control method invocations without recursion.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
+
+ Status = AE_OK;
+ while (WalkState)
+ {
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * The ParseLoop executes AML until the method terminates
+ * or calls another method.
+ */
+ Status = AcpiPsParseLoop (WalkState);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Completed one call to walk loop, %s State=%p\n",
+ AcpiFormatException (Status), WalkState));
+
+ if (Status == AE_CTRL_TRANSFER)
+ {
+ /*
+ * A method call was detected.
+ * Transfer control to the called control method
+ */
+ Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ Status = AcpiDsMethodError (Status, WalkState);
+ }
+
+ /*
+ * If the transfer to the new method method call worked, a new walk
+ * state was created -- get it
+ */
+ WalkState = AcpiDsGetCurrentWalkState (Thread);
+ continue;
+ }
+ else if (Status == AE_CTRL_TERMINATE)
+ {
+ Status = AE_OK;
+ }
+ else if ((Status != AE_OK) && (WalkState->MethodDesc))
+ {
+ /* Either the method parse or actual execution failed */
+
+ ACPI_ERROR_METHOD ("Method parse/execution failed",
+ WalkState->MethodNode, NULL, Status);
+
+ /* Check for possible multi-thread reentrancy problem */
+
+ if ((Status == AE_ALREADY_EXISTS) &&
+ (!(WalkState->MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)))
+ {
+ /*
+ * Method is not serialized and tried to create an object
+ * twice. The probable cause is that the method cannot
+ * handle reentrancy. Mark as "pending serialized" now, and
+ * then mark "serialized" when the last thread exits.
+ */
+ WalkState->MethodDesc->Method.InfoFlags |=
+ ACPI_METHOD_SERIALIZED_PENDING;
+ }
+ }
+
+ /* We are done with this walk, move on to the parent if any */
+
+ WalkState = AcpiDsPopWalkState (Thread);
+
+ /* Reset the current scope to the beginning of scope stack */
+
+ AcpiDsScopeStackClear (WalkState);
+
+ /*
+ * If we just returned from the execution of a control method or if we
+ * encountered an error during the method parse phase, there's lots of
+ * cleanup to do
+ */
+ if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) ||
+ (ACPI_FAILURE (Status)))
+ {
+ AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
+ }
+
+ /* Delete this walk state and all linked control states */
+
+ AcpiPsCleanupScope (&WalkState->ParserState);
+ PreviousWalkState = WalkState;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "ReturnValue=%p, ImplicitValue=%p State=%p\n",
+ WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
+
+ /* Check if we have restarted a preempted walk */
+
+ WalkState = AcpiDsGetCurrentWalkState (Thread);
+ if (WalkState)
+ {
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * There is another walk state, restart it.
+ * If the method return value is not used by the parent,
+ * The object is deleted
+ */
+ if (!PreviousWalkState->ReturnDesc)
+ {
+ /*
+ * In slack mode execution, if there is no return value
+ * we should implicitly return zero (0) as a default value.
+ */
+ if (AcpiGbl_EnableInterpreterSlack &&
+ !PreviousWalkState->ImplicitReturnObj)
+ {
+ PreviousWalkState->ImplicitReturnObj =
+ AcpiUtCreateIntegerObject ((UINT64) 0);
+ if (!PreviousWalkState->ImplicitReturnObj)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ }
+
+ /* Restart the calling control method */
+
+ Status = AcpiDsRestartControlMethod (WalkState,
+ PreviousWalkState->ImplicitReturnObj);
+ }
+ else
+ {
+ /*
+ * We have a valid return value, delete any implicit
+ * return value.
+ */
+ AcpiDsClearImplicitReturn (PreviousWalkState);
+
+ Status = AcpiDsRestartControlMethod (WalkState,
+ PreviousWalkState->ReturnDesc);
+ }
+ if (ACPI_SUCCESS (Status))
+ {
+ WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
+ }
+ }
+ else
+ {
+ /* On error, delete any return object or implicit return */
+
+ AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
+ AcpiDsClearImplicitReturn (PreviousWalkState);
+ }
+ }
+
+ /*
+ * Just completed a 1st-level method, save the final internal return
+ * value (if any)
+ */
+ else if (PreviousWalkState->CallerReturnDesc)
+ {
+ if (PreviousWalkState->ImplicitReturnObj)
+ {
+ *(PreviousWalkState->CallerReturnDesc) =
+ PreviousWalkState->ImplicitReturnObj;
+ }
+ else
+ {
+ /* NULL if no return value */
+
+ *(PreviousWalkState->CallerReturnDesc) =
+ PreviousWalkState->ReturnDesc;
+ }
+ }
+ else
+ {
+ if (PreviousWalkState->ReturnDesc)
+ {
+ /* Caller doesn't want it, must delete it */
+
+ AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
+ }
+ if (PreviousWalkState->ImplicitReturnObj)
+ {
+ /* Caller doesn't want it, must delete it */
+
+ AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
+ }
+ }
+
+ AcpiDsDeleteWalkState (PreviousWalkState);
+ }
+
+ /* Normal exit */
+
+ AcpiExReleaseAllMutexes (Thread);
+ AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
+ AcpiGbl_CurrentWalkList = PrevWalkList;
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/psscope.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/psscope.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,302 @@
+/******************************************************************************
+ *
+ * Module Name: psscope - Parser scope stack 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.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psscope")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetParentScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Pointer to an Op object
+ *
+ * DESCRIPTION: Get parent of current op being parsed
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetParentScope (
+ ACPI_PARSE_STATE *ParserState)
+{
+
+ return (ParserState->Scope->ParseScope.Op);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsHasCompletedScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Boolean, TRUE = scope completed.
+ *
+ * DESCRIPTION: Is parsing of current argument complete? Determined by
+ * 1) AML pointer is at or beyond the end of the scope
+ * 2) The scope argument count has reached zero.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiPsHasCompletedScope (
+ ACPI_PARSE_STATE *ParserState)
+{
+
+ return ((BOOLEAN)
+ ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd ||
+ !ParserState->Scope->ParseScope.ArgCount)));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsInitScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * Root - the Root Node of this new scope
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Allocate and init a new scope object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsInitScope (
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_PARSE_OBJECT *RootOp)
+{
+ ACPI_GENERIC_STATE *Scope;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp);
+
+
+ Scope = AcpiUtCreateGenericState ();
+ if (!Scope)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE;
+ Scope->ParseScope.Op = RootOp;
+ Scope->ParseScope.ArgCount = ACPI_VAR_ARGS;
+ Scope->ParseScope.ArgEnd = ParserState->AmlEnd;
+ Scope->ParseScope.PkgEnd = ParserState->AmlEnd;
+
+ ParserState->Scope = Scope;
+ ParserState->StartOp = RootOp;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsPushScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * Op - Current op to be pushed
+ * RemainingArgs - List of args remaining
+ * ArgCount - Fixed or variable number of args
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Push current op to begin parsing its argument
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsPushScope (
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 RemainingArgs,
+ UINT32 ArgCount)
+{
+ ACPI_GENERIC_STATE *Scope;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op);
+
+
+ Scope = AcpiUtCreateGenericState ();
+ if (!Scope)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE;
+ Scope->ParseScope.Op = Op;
+ Scope->ParseScope.ArgList = RemainingArgs;
+ Scope->ParseScope.ArgCount = ArgCount;
+ Scope->ParseScope.PkgEnd = ParserState->PkgEnd;
+
+ /* Push onto scope stack */
+
+ AcpiUtPushGenericState (&ParserState->Scope, Scope);
+
+ if (ArgCount == ACPI_VAR_ARGS)
+ {
+ /* Multiple arguments */
+
+ Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
+ }
+ else
+ {
+ /* Single argument */
+
+ Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsPopScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * Op - Where the popped op is returned
+ * ArgList - Where the popped "next argument" is
+ * returned
+ * ArgCount - Count of objects in ArgList
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Return to parsing a previous op
+ *
+ ******************************************************************************/
+
+void
+AcpiPsPopScope (
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_PARSE_OBJECT **Op,
+ UINT32 *ArgList,
+ UINT32 *ArgCount)
+{
+ ACPI_GENERIC_STATE *Scope = ParserState->Scope;
+
+
+ ACPI_FUNCTION_TRACE (PsPopScope);
+
+
+ /* Only pop the scope if there is in fact a next scope */
+
+ if (Scope->Common.Next)
+ {
+ Scope = AcpiUtPopGenericState (&ParserState->Scope);
+
+ /* Return to parsing previous op */
+
+ *Op = Scope->ParseScope.Op;
+ *ArgList = Scope->ParseScope.ArgList;
+ *ArgCount = Scope->ParseScope.ArgCount;
+ ParserState->PkgEnd = Scope->ParseScope.PkgEnd;
+
+ /* All done with this scope state structure */
+
+ AcpiUtDeleteGenericState (Scope);
+ }
+ else
+ {
+ /* Empty parse stack, prepare to fetch next opcode */
+
+ *Op = NULL;
+ *ArgList = 0;
+ *ArgCount = 0;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Popped Op %p Args %X\n", *Op, *ArgCount));
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCleanupScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Destroy available list, remaining stack levels, and return
+ * root scope
+ *
+ ******************************************************************************/
+
+void
+AcpiPsCleanupScope (
+ ACPI_PARSE_STATE *ParserState)
+{
+ ACPI_GENERIC_STATE *Scope;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState);
+
+
+ if (!ParserState)
+ {
+ return_VOID;
+ }
+
+ /* Delete anything on the scope stack */
+
+ while (ParserState->Scope)
+ {
+ Scope = AcpiUtPopGenericState (&ParserState->Scope);
+ AcpiUtDeleteGenericState (Scope);
+ }
+
+ return_VOID;
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/pstree.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/pstree.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,360 @@
+/******************************************************************************
+ *
+ * Module Name: pstree - Parser op tree manipulation/traversal/search
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __PSTREE_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>
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("pstree")
+
+/* Local prototypes */
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+ACPI_PARSE_OBJECT *
+AcpiPsGetChild (
+ ACPI_PARSE_OBJECT *op);
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetArg
+ *
+ * PARAMETERS: Op - Get an argument for this op
+ * Argn - Nth argument to get
+ *
+ * RETURN: The argument (as an Op object). NULL if argument does not exist
+ *
+ * DESCRIPTION: Get the specified op's argument.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetArg (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Argn)
+{
+ ACPI_PARSE_OBJECT *Arg = NULL;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+/*
+ if (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)
+ {
+ return (Op->Common.Value.Arg);
+ }
+*/
+ /* Get the info structure for this opcode */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (OpInfo->Class == AML_CLASS_UNKNOWN)
+ {
+ /* Invalid opcode or ASCII character */
+
+ return (NULL);
+ }
+
+ /* Check if this opcode requires argument sub-objects */
+
+ if (!(OpInfo->Flags & AML_HAS_ARGS))
+ {
+ /* Has no linked argument objects */
+
+ return (NULL);
+ }
+
+ /* Get the requested argument object */
+
+ Arg = Op->Common.Value.Arg;
+ while (Arg && Argn)
+ {
+ Argn--;
+ Arg = Arg->Common.Next;
+ }
+
+ return (Arg);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsAppendArg
+ *
+ * PARAMETERS: Op - Append an argument to this Op.
+ * Arg - Argument Op to append
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK)
+ *
+ ******************************************************************************/
+
+void
+AcpiPsAppendArg (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_OBJECT *Arg)
+{
+ ACPI_PARSE_OBJECT *PrevArg;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Op)
+ {
+ return;
+ }
+
+ /* Get the info structure for this opcode */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (OpInfo->Class == AML_CLASS_UNKNOWN)
+ {
+ /* Invalid opcode */
+
+ ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
+ Op->Common.AmlOpcode));
+ return;
+ }
+
+ /* Check if this opcode requires argument sub-objects */
+
+ if (!(OpInfo->Flags & AML_HAS_ARGS))
+ {
+ /* Has no linked argument objects */
+
+ return;
+ }
+
+ /* Append the argument to the linked argument list */
+
+ if (Op->Common.Value.Arg)
+ {
+ /* Append to existing argument list */
+
+ PrevArg = Op->Common.Value.Arg;
+ while (PrevArg->Common.Next)
+ {
+ PrevArg = PrevArg->Common.Next;
+ }
+ PrevArg->Common.Next = Arg;
+ }
+ else
+ {
+ /* No argument list, this will be the first argument */
+
+ Op->Common.Value.Arg = Arg;
+ }
+
+ /* Set the parent in this arg and any args linked after it */
+
+ while (Arg)
+ {
+ Arg->Common.Parent = Op;
+ Arg = Arg->Common.Next;
+
+ Op->Common.ArgListLength++;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetDepthNext
+ *
+ * PARAMETERS: Origin - Root of subtree to search
+ * Op - Last (previous) Op that was found
+ *
+ * RETURN: Next Op found in the search.
+ *
+ * DESCRIPTION: Get next op in tree (walking the tree in depth-first order)
+ * Return NULL when reaching "origin" or when walking up from root
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetDepthNext (
+ ACPI_PARSE_OBJECT *Origin,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next = NULL;
+ ACPI_PARSE_OBJECT *Parent;
+ ACPI_PARSE_OBJECT *Arg;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Op)
+ {
+ return (NULL);
+ }
+
+ /* Look for an argument or child */
+
+ Next = AcpiPsGetArg (Op, 0);
+ if (Next)
+ {
+ return (Next);
+ }
+
+ /* Look for a sibling */
+
+ Next = Op->Common.Next;
+ if (Next)
+ {
+ return (Next);
+ }
+
+ /* Look for a sibling of parent */
+
+ Parent = Op->Common.Parent;
+
+ while (Parent)
+ {
+ Arg = AcpiPsGetArg (Parent, 0);
+ while (Arg && (Arg != Origin) && (Arg != Op))
+ {
+ Arg = Arg->Common.Next;
+ }
+
+ if (Arg == Origin)
+ {
+ /* Reached parent of origin, end search */
+
+ return (NULL);
+ }
+
+ if (Parent->Common.Next)
+ {
+ /* Found sibling of parent */
+
+ return (Parent->Common.Next);
+ }
+
+ Op = Parent;
+ Parent = Parent->Common.Parent;
+ }
+
+ return (Next);
+}
+
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetChild
+ *
+ * PARAMETERS: Op - Get the child of this Op
+ *
+ * RETURN: Child Op, Null if none is found.
+ *
+ * DESCRIPTION: Get op's children or NULL if none
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetChild (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Child = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_SCOPE_OP:
+ case AML_ELSE_OP:
+ case AML_DEVICE_OP:
+ case AML_THERMAL_ZONE_OP:
+ case AML_INT_METHODCALL_OP:
+
+ Child = AcpiPsGetArg (Op, 0);
+ break;
+
+
+ case AML_BUFFER_OP:
+ case AML_PACKAGE_OP:
+ case AML_METHOD_OP:
+ case AML_IF_OP:
+ case AML_WHILE_OP:
+ case AML_FIELD_OP:
+
+ Child = AcpiPsGetArg (Op, 1);
+ break;
+
+
+ case AML_POWER_RES_OP:
+ case AML_INDEX_FIELD_OP:
+
+ Child = AcpiPsGetArg (Op, 2);
+ break;
+
+
+ case AML_PROCESSOR_OP:
+ case AML_BANK_FIELD_OP:
+
+ Child = AcpiPsGetArg (Op, 3);
+ break;
+
+
+ default:
+ /* All others have no children */
+ break;
+ }
+
+ return (Child);
+}
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/psutils.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/psutils.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,290 @@
+/******************************************************************************
+ *
+ * Module Name: psutils - Parser miscellaneous utilities (Parser only)
+ *
+ *****************************************************************************/
+
+/*
+ * 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>
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psutils")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCreateScopeOp
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: A new Scope object, null on failure
+ *
+ * DESCRIPTION: Create a Scope and associated namepath op with the root name
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsCreateScopeOp (
+ void)
+{
+ ACPI_PARSE_OBJECT *ScopeOp;
+
+
+ ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP);
+ if (!ScopeOp)
+ {
+ return (NULL);
+ }
+
+ ScopeOp->Named.Name = ACPI_ROOT_NAME;
+ return (ScopeOp);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsInitOp
+ *
+ * PARAMETERS: Op - A newly allocated Op object
+ * Opcode - Opcode to store in the Op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize a parse (Op) object
+ *
+ ******************************************************************************/
+
+void
+AcpiPsInitOp (
+ ACPI_PARSE_OBJECT *Op,
+ UINT16 Opcode)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER;
+ Op->Common.AmlOpcode = Opcode;
+
+ ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName,
+ (AcpiPsGetOpcodeInfo (Opcode))->Name,
+ sizeof (Op->Common.AmlOpName)));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsAllocOp
+ *
+ * PARAMETERS: Opcode - Opcode that will be stored in the new Op
+ *
+ * RETURN: Pointer to the new Op, null on failure
+ *
+ * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
+ * opcode. A cache of opcodes is available for the pure
+ * GENERIC_OP, since this is by far the most commonly used.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT*
+AcpiPsAllocOp (
+ UINT16 Opcode)
+{
+ ACPI_PARSE_OBJECT *Op;
+ const ACPI_OPCODE_INFO *OpInfo;
+ UINT8 Flags = ACPI_PARSEOP_GENERIC;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+
+ /* Determine type of ParseOp required */
+
+ if (OpInfo->Flags & AML_DEFER)
+ {
+ Flags = ACPI_PARSEOP_DEFERRED;
+ }
+ else if (OpInfo->Flags & AML_NAMED)
+ {
+ Flags = ACPI_PARSEOP_NAMED;
+ }
+ else if (Opcode == AML_INT_BYTELIST_OP)
+ {
+ Flags = ACPI_PARSEOP_BYTELIST;
+ }
+
+ /* Allocate the minimum required size object */
+
+ if (Flags == ACPI_PARSEOP_GENERIC)
+ {
+ /* The generic op (default) is by far the most common (16 to 1) */
+
+ Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache);
+ }
+ else
+ {
+ /* Extended parseop */
+
+ Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache);
+ }
+
+ /* Initialize the Op */
+
+ if (Op)
+ {
+ AcpiPsInitOp (Op, Opcode);
+ Op->Common.Flags = Flags;
+ }
+
+ return (Op);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsFreeOp
+ *
+ * PARAMETERS: Op - Op to be freed
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list
+ * or actually free it.
+ *
+ ******************************************************************************/
+
+void
+AcpiPsFreeOp (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_FUNCTION_NAME (PsFreeOp);
+
+
+ if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op));
+ }
+
+ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
+ {
+ (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op);
+ }
+ else
+ {
+ (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Utility functions
+ *
+ * DESCRIPTION: Low level character and object functions
+ *
+ ******************************************************************************/
+
+
+/*
+ * Is "c" a namestring lead character?
+ */
+BOOLEAN
+AcpiPsIsLeadingChar (
+ UINT32 c)
+{
+ return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z')));
+}
+
+
+/*
+ * Is "c" a namestring prefix character?
+ */
+BOOLEAN
+AcpiPsIsPrefixChar (
+ UINT32 c)
+{
+ return ((BOOLEAN) (c == '\\' || c == '^'));
+}
+
+
+/*
+ * Get op's name (4-byte name segment) or 0 if unnamed
+ */
+UINT32
+AcpiPsGetName (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+ /* The "generic" object has no name associated with it */
+
+ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
+ {
+ return (0);
+ }
+
+ /* Only the "Extended" parse objects have a name */
+
+ return (Op->Named.Name);
+}
+
+
+/*
+ * Set op's name
+ */
+void
+AcpiPsSetName (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 name)
+{
+
+ /* The "generic" object has no name associated with it */
+
+ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
+ {
+ return;
+ }
+
+ Op->Named.Name = name;
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/pswalk.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/pswalk.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,121 @@
+/******************************************************************************
+ *
+ * Module Name: pswalk - Parser routines to walk parsed op tree(s)
+ *
+ *****************************************************************************/
+
+/*
+ * 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>
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("pswalk")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsDeleteParseTree
+ *
+ * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Delete a portion of or an entire parse tree.
+ *
+ ******************************************************************************/
+
+void
+AcpiPsDeleteParseTree (
+ ACPI_PARSE_OBJECT *SubtreeRoot)
+{
+ ACPI_PARSE_OBJECT *Op = SubtreeRoot;
+ ACPI_PARSE_OBJECT *Next = NULL;
+ ACPI_PARSE_OBJECT *Parent = NULL;
+
+
+ ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot);
+
+
+ /* Visit all nodes in the subtree */
+
+ while (Op)
+ {
+ /* Check if we are not ascending */
+
+ if (Op != Parent)
+ {
+ /* Look for an argument or child of the current op */
+
+ Next = AcpiPsGetArg (Op, 0);
+ if (Next)
+ {
+ /* Still going downward in tree (Op is not completed yet) */
+
+ Op = Next;
+ continue;
+ }
+ }
+
+ /* No more children, this Op is complete. */
+
+ Next = Op->Common.Next;
+ Parent = Op->Common.Parent;
+
+ AcpiPsFreeOp (Op);
+
+ /* If we are back to the starting point, the walk is complete. */
+
+ if (Op == SubtreeRoot)
+ {
+ return_VOID;
+ }
+ if (Next)
+ {
+ Op = Next;
+ }
+ else
+ {
+ Op = Parent;
+ }
+ }
+
+ return_VOID;
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/parser/psxface.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/parser/psxface.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,442 @@
+/******************************************************************************
+ *
+ * Module Name: psxface - Parser 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.
+ */
+
+#define __PSXFACE_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/acinterp.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psxface")
+
+/* Local Prototypes */
+
+static void
+AcpiPsStartTrace (
+ ACPI_EVALUATE_INFO *Info);
+
+static void
+AcpiPsStopTrace (
+ ACPI_EVALUATE_INFO *Info);
+
+static void
+AcpiPsUpdateParameterList (
+ ACPI_EVALUATE_INFO *Info,
+ UINT16 Action);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDebugTrace
+ *
+ * PARAMETERS: MethodName - Valid ACPI name string
+ * DebugLevel - Optional level mask. 0 to use default
+ * DebugLayer - Optional layer mask. 0 to use default
+ * Flags - bit 1: one shot(1) or persistent(0)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: External interface to enable debug tracing during control
+ * method execution
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDebugTrace (
+ char *Name,
+ UINT32 DebugLevel,
+ UINT32 DebugLayer,
+ UINT32 Flags)
+{
+ ACPI_STATUS Status;
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* TBDs: Validate name, allow full path or just nameseg */
+
+ AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name);
+ AcpiGbl_TraceFlags = Flags;
+
+ if (DebugLevel)
+ {
+ AcpiGbl_TraceDbgLevel = DebugLevel;
+ }
+ if (DebugLayer)
+ {
+ AcpiGbl_TraceDbgLayer = DebugLayer;
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsStartTrace
+ *
+ * PARAMETERS: Info - Method info struct
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Start control method execution trace
+ *
+ ******************************************************************************/
+
+static void
+AcpiPsStartTrace (
+ ACPI_EVALUATE_INFO *Info)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ if ((!AcpiGbl_TraceMethodName) ||
+ (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
+ {
+ goto Exit;
+ }
+
+ AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
+ AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
+
+ AcpiDbgLevel = 0x00FFFFFF;
+ AcpiDbgLayer = ACPI_UINT32_MAX;
+
+ if (AcpiGbl_TraceDbgLevel)
+ {
+ AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
+ }
+ if (AcpiGbl_TraceDbgLayer)
+ {
+ AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
+ }
+
+
+Exit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsStopTrace
+ *
+ * PARAMETERS: Info - Method info struct
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Stop control method execution trace
+ *
+ ******************************************************************************/
+
+static void
+AcpiPsStopTrace (
+ ACPI_EVALUATE_INFO *Info)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ if ((!AcpiGbl_TraceMethodName) ||
+ (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
+ {
+ goto Exit;
+ }
+
+ /* Disable further tracing if type is one-shot */
+
+ if (AcpiGbl_TraceFlags & 1)
+ {
+ AcpiGbl_TraceMethodName = 0;
+ AcpiGbl_TraceDbgLevel = 0;
+ AcpiGbl_TraceDbgLayer = 0;
+ }
+
+ AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
+ AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
+
+Exit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsExecuteMethod
+ *
+ * PARAMETERS: Info - Method info block, contains:
+ * Node - Method Node to execute
+ * ObjDesc - Method object
+ * Parameters - List of parameters to pass to the method,
+ * terminated by NULL. Params itself may be
+ * NULL if no parameters are being passed.
+ * ReturnObject - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * ParameterType - Type of Parameter list
+ * ReturnObject - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * PassNumber - Parse or execute pass
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a control method
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsExecuteMethod (
+ ACPI_EVALUATE_INFO *Info)
+{
+ ACPI_STATUS Status;
+ ACPI_PARSE_OBJECT *Op;
+ ACPI_WALK_STATE *WalkState;
+
+
+ ACPI_FUNCTION_TRACE (PsExecuteMethod);
+
+
+ /* Quick validation of DSDT header */
+
+ AcpiTbCheckDsdtHeader ();
+
+ /* Validate the Info and method Node */
+
+ if (!Info || !Info->ResolvedNode)
+ {
+ return_ACPI_STATUS (AE_NULL_ENTRY);
+ }
+
+ /* Init for new method, wait on concurrency semaphore */
+
+ Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The caller "owns" the parameters, so give each one an extra reference
+ */
+ AcpiPsUpdateParameterList (Info, REF_INCREMENT);
+
+ /* Begin tracing if requested */
+
+ AcpiPsStartTrace (Info);
+
+ /*
+ * Execute the method. Performs parse simultaneously
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
+ Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc));
+
+ /* Create and init a Root Node */
+
+ Op = AcpiPsCreateScopeOp ();
+ if (!Op)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Create and initialize a new walk state */
+
+ Info->PassNumber = ACPI_IMODE_EXECUTE;
+ WalkState = AcpiDsCreateWalkState (
+ Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode,
+ Info->ObjDesc->Method.AmlStart,
+ Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ goto Cleanup;
+ }
+
+ if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
+ {
+ WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
+ }
+
+ /* Invoke an internal method if necessary */
+
+ if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
+ {
+ Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState);
+ Info->ReturnObject = WalkState->ReturnDesc;
+
+ /* Cleanup states */
+
+ AcpiDsScopeStackClear (WalkState);
+ AcpiPsCleanupScope (&WalkState->ParserState);
+ AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
+ AcpiDsDeleteWalkState (WalkState);
+ goto Cleanup;
+ }
+
+ /*
+ * Start method evaluation with an implicit return of zero. This is done
+ * for Windows compatibility.
+ */
+ if (AcpiGbl_EnableInterpreterSlack)
+ {
+ WalkState->ImplicitReturnObj =
+ AcpiUtCreateIntegerObject ((UINT64) 0);
+ if (!WalkState->ImplicitReturnObj)
+ {
+ Status = AE_NO_MEMORY;
+ AcpiDsDeleteWalkState (WalkState);
+ goto Cleanup;
+ }
+ }
+
+ /* Parse the AML */
+
+ Status = AcpiPsParseAml (WalkState);
+
+ /* WalkState was deleted by ParseAml */
+
+Cleanup:
+ AcpiPsDeleteParseTree (Op);
+
+ /* End optional tracing */
+
+ AcpiPsStopTrace (Info);
+
+ /* Take away the extra reference that we gave the parameters above */
+
+ AcpiPsUpdateParameterList (Info, REF_DECREMENT);
+
+ /* Exit now if error above */
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * If the method has returned an object, signal this to the caller with
+ * a control exception code
+ */
+ if (Info->ReturnObject)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
+ Info->ReturnObject));
+ ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
+
+ Status = AE_CTRL_RETURN_VALUE;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsUpdateParameterList
+ *
+ * PARAMETERS: Info - See ACPI_EVALUATE_INFO
+ * (Used: ParameterType and Parameters)
+ * Action - Add or Remove reference
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Update reference count on all method parameter objects
+ *
+ ******************************************************************************/
+
+static void
+AcpiPsUpdateParameterList (
+ ACPI_EVALUATE_INFO *Info,
+ UINT16 Action)
+{
+ UINT32 i;
+
+
+ if (Info->Parameters)
+ {
+ /* Update reference count for each parameter */
+
+ for (i = 0; Info->Parameters[i]; i++)
+ {
+ /* Ignore errors, just do them all */
+
+ (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action);
+ }
+ }
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsaddr.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsaddr.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,407 @@
+/*******************************************************************************
+ *
+ * Module Name: rsaddr - Address resource descriptors (16/32/64)
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSADDR_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsaddr")
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertAddress16 - All WORD (16-bit) address resources
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
+ ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
+ sizeof (AML_RESOURCE_ADDRESS16),
+ 0},
+
+ /* Resource Type, General Flags, and Type-Specific Flags */
+
+ {ACPI_RSC_ADDRESS, 0, 0, 0},
+
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Address Granularity
+ * Address Range Minimum
+ * Address Range Maximum
+ * Address Translation Offset
+ * Address Length
+ */
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity),
+ AML_OFFSET (Address16.Granularity),
+ 5},
+
+ /* Optional ResourceSource (Index and String) */
+
+ {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource),
+ 0,
+ sizeof (AML_RESOURCE_ADDRESS16)}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
+ ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
+ sizeof (AML_RESOURCE_ADDRESS32),
+ 0},
+
+ /* Resource Type, General Flags, and Type-Specific Flags */
+
+ {ACPI_RSC_ADDRESS, 0, 0, 0},
+
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Address Granularity
+ * Address Range Minimum
+ * Address Range Maximum
+ * Address Translation Offset
+ * Address Length
+ */
+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity),
+ AML_OFFSET (Address32.Granularity),
+ 5},
+
+ /* Optional ResourceSource (Index and String) */
+
+ {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource),
+ 0,
+ sizeof (AML_RESOURCE_ADDRESS32)}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
+ ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
+ sizeof (AML_RESOURCE_ADDRESS64),
+ 0},
+
+ /* Resource Type, General Flags, and Type-Specific Flags */
+
+ {ACPI_RSC_ADDRESS, 0, 0, 0},
+
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Address Granularity
+ * Address Range Minimum
+ * Address Range Maximum
+ * Address Translation Offset
+ * Address Length
+ */
+ {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity),
+ AML_OFFSET (Address64.Granularity),
+ 5},
+
+ /* Optional ResourceSource (Index and String) */
+
+ {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource),
+ 0,
+ sizeof (AML_RESOURCE_ADDRESS64)}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
+ ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
+ sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),
+ 0},
+
+ /* Resource Type, General Flags, and Type-Specific Flags */
+
+ {ACPI_RSC_ADDRESS, 0, 0, 0},
+
+ /* Revision ID */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID),
+ AML_OFFSET (ExtAddress64.RevisionID),
+ 1},
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Address Granularity
+ * Address Range Minimum
+ * Address Range Maximum
+ * Address Translation Offset
+ * Address Length
+ * Type-Specific Attribute
+ */
+ {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity),
+ AML_OFFSET (ExtAddress64.Granularity),
+ 6}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertGeneralFlags - Flags common to all address descriptors
+ *
+ ******************************************************************************/
+
+static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] =
+{
+ {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)},
+
+ /* Resource Type (Memory, Io, BusNumber, etc.) */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType),
+ AML_OFFSET (Address.ResourceType),
+ 1},
+
+ /* General Flags - Consume, Decode, MinFixed, MaxFixed */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer),
+ AML_OFFSET (Address.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode),
+ AML_OFFSET (Address.Flags),
+ 1},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed),
+ AML_OFFSET (Address.Flags),
+ 2},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed),
+ AML_OFFSET (Address.Flags),
+ 3}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertMemFlags - Flags common to Memory address descriptors
+ *
+ ******************************************************************************/
+
+static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] =
+{
+ {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)},
+
+ /* Memory-specific flags */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect),
+ AML_OFFSET (Address.SpecificFlags),
+ 0},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching),
+ AML_OFFSET (Address.SpecificFlags),
+ 1},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType),
+ AML_OFFSET (Address.SpecificFlags),
+ 3},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation),
+ AML_OFFSET (Address.SpecificFlags),
+ 5}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertIoFlags - Flags common to I/O address descriptors
+ *
+ ******************************************************************************/
+
+static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] =
+{
+ {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)},
+
+ /* I/O-specific flags */
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType),
+ AML_OFFSET (Address.SpecificFlags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation),
+ AML_OFFSET (Address.SpecificFlags),
+ 4},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType),
+ AML_OFFSET (Address.SpecificFlags),
+ 5}
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetAddressCommon
+ *
+ * PARAMETERS: Resource - Pointer to the internal resource struct
+ * Aml - Pointer to the AML resource descriptor
+ *
+ * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise
+ *
+ * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
+ * to an internal resource descriptor
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiRsGetAddressCommon (
+ ACPI_RESOURCE *Resource,
+ AML_RESOURCE *Aml)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Validate the Resource Type */
+
+ if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0))
+ {
+ return (FALSE);
+ }
+
+ /* Get the Resource Type and General Flags */
+
+ (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags);
+
+ /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
+
+ if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
+ {
+ (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags);
+ }
+ else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
+ {
+ (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags);
+ }
+ else
+ {
+ /* Generic resource type, just grab the TypeSpecific byte */
+
+ Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags;
+ }
+
+ return (TRUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsSetAddressCommon
+ *
+ * PARAMETERS: Aml - Pointer to the AML resource descriptor
+ * Resource - Pointer to the internal resource struct
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Convert common flag fields from a resource descriptor to an
+ * AML descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiRsSetAddressCommon (
+ AML_RESOURCE *Aml,
+ ACPI_RESOURCE *Resource)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Set the Resource Type and General Flags */
+
+ (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags);
+
+ /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
+
+ if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
+ {
+ (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags);
+ }
+ else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
+ {
+ (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags);
+ }
+ else
+ {
+ /* Generic resource type, just copy the TypeSpecific byte */
+
+ Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific;
+ }
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rscalc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rscalc.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,730 @@
+/*******************************************************************************
+ *
+ * Module Name: rscalc - Calculate stream and list lengths
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSCALC_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rscalc")
+
+
+/* Local prototypes */
+
+static UINT8
+AcpiRsCountSetBits (
+ UINT16 BitField);
+
+static ACPI_RS_LENGTH
+AcpiRsStructOptionLength (
+ ACPI_RESOURCE_SOURCE *ResourceSource);
+
+static UINT32
+AcpiRsStreamOptionLength (
+ UINT32 ResourceLength,
+ UINT32 MinimumTotalLength);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCountSetBits
+ *
+ * PARAMETERS: BitField - Field in which to count bits
+ *
+ * RETURN: Number of bits set within the field
+ *
+ * DESCRIPTION: Count the number of bits set in a resource field. Used for
+ * (Short descriptor) interrupt and DMA lists.
+ *
+ ******************************************************************************/
+
+static UINT8
+AcpiRsCountSetBits (
+ UINT16 BitField)
+{
+ UINT8 BitsSet;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ for (BitsSet = 0; BitField; BitsSet++)
+ {
+ /* Zero the least significant bit that is set */
+
+ BitField &= (UINT16) (BitField - 1);
+ }
+
+ return (BitsSet);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsStructOptionLength
+ *
+ * PARAMETERS: ResourceSource - Pointer to optional descriptor field
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
+ * ResourceSource fields in some Large descriptors. Used during
+ * list-to-stream conversion
+ *
+ ******************************************************************************/
+
+static ACPI_RS_LENGTH
+AcpiRsStructOptionLength (
+ ACPI_RESOURCE_SOURCE *ResourceSource)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * If the ResourceSource string is valid, return the size of the string
+ * (StringLength includes the NULL terminator) plus the size of the
+ * ResourceSourceIndex (1).
+ */
+ if (ResourceSource->StringPtr)
+ {
+ return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1));
+ }
+
+ return (0);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsStreamOptionLength
+ *
+ * PARAMETERS: ResourceLength - Length from the resource header
+ * MinimumTotalLength - Minimum length of this resource, before
+ * any optional fields. Includes header size
+ *
+ * RETURN: Length of optional string (0 if no string present)
+ *
+ * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
+ * ResourceSource fields in some Large descriptors. Used during
+ * stream-to-list conversion
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiRsStreamOptionLength (
+ UINT32 ResourceLength,
+ UINT32 MinimumAmlResourceLength)
+{
+ UINT32 StringLength = 0;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * The ResourceSourceIndex and ResourceSource are optional elements of some
+ * Large-type resource descriptors.
+ */
+
+ /*
+ * If the length of the actual resource descriptor is greater than the ACPI
+ * spec-defined minimum length, it means that a ResourceSourceIndex exists
+ * and is followed by a (required) null terminated string. The string length
+ * (including the null terminator) is the resource length minus the minimum
+ * length, minus one byte for the ResourceSourceIndex itself.
+ */
+ if (ResourceLength > MinimumAmlResourceLength)
+ {
+ /* Compute the length of the optional string */
+
+ StringLength = ResourceLength - MinimumAmlResourceLength - 1;
+ }
+
+ /*
+ * Round the length up to a multiple of the native word in order to
+ * guarantee that the entire resource descriptor is native word aligned
+ */
+ return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetAmlLength
+ *
+ * PARAMETERS: Resource - Pointer to the resource linked list
+ * SizeNeeded - Where the required size is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Takes a linked list of internal resource descriptors and
+ * calculates the size buffer needed to hold the corresponding
+ * external resource byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetAmlLength (
+ ACPI_RESOURCE *Resource,
+ ACPI_SIZE *SizeNeeded)
+{
+ ACPI_SIZE AmlSizeNeeded = 0;
+ ACPI_RS_LENGTH TotalSize;
+
+
+ ACPI_FUNCTION_TRACE (RsGetAmlLength);
+
+
+ /* Traverse entire list of internal resource descriptors */
+
+ while (Resource)
+ {
+ /* Validate the descriptor type */
+
+ if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
+ {
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+
+ /* Get the base size of the (external stream) resource descriptor */
+
+ TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type];
+
+ /*
+ * Augment the base size for descriptors with optional and/or
+ * variable-length fields
+ */
+ switch (Resource->Type)
+ {
+ case ACPI_RESOURCE_TYPE_IRQ:
+
+ /* Length can be 3 or 2 */
+
+ if (Resource->Data.Irq.DescriptorLength == 2)
+ {
+ TotalSize--;
+ }
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_START_DEPENDENT:
+
+ /* Length can be 1 or 0 */
+
+ if (Resource->Data.Irq.DescriptorLength == 0)
+ {
+ TotalSize--;
+ }
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_VENDOR:
+ /*
+ * Vendor Defined Resource:
+ * For a Vendor Specific resource, if the Length is between 1 and 7
+ * it will be created as a Small Resource data type, otherwise it
+ * is a Large Resource data type.
+ */
+ if (Resource->Data.Vendor.ByteLength > 7)
+ {
+ /* Base size of a Large resource descriptor */
+
+ TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER);
+ }
+
+ /* Add the size of the vendor-specific data */
+
+ TotalSize = (ACPI_RS_LENGTH)
+ (TotalSize + Resource->Data.Vendor.ByteLength);
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_END_TAG:
+ /*
+ * End Tag:
+ * We are done -- return the accumulated total size.
+ */
+ *SizeNeeded = AmlSizeNeeded + TotalSize;
+
+ /* Normal exit */
+
+ return_ACPI_STATUS (AE_OK);
+
+
+ case ACPI_RESOURCE_TYPE_ADDRESS16:
+ /*
+ * 16-Bit Address Resource:
+ * Add the size of the optional ResourceSource info
+ */
+ TotalSize = (ACPI_RS_LENGTH)
+ (TotalSize + AcpiRsStructOptionLength (
+ &Resource->Data.Address16.ResourceSource));
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_ADDRESS32:
+ /*
+ * 32-Bit Address Resource:
+ * Add the size of the optional ResourceSource info
+ */
+ TotalSize = (ACPI_RS_LENGTH)
+ (TotalSize + AcpiRsStructOptionLength (
+ &Resource->Data.Address32.ResourceSource));
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_ADDRESS64:
+ /*
+ * 64-Bit Address Resource:
+ * Add the size of the optional ResourceSource info
+ */
+ TotalSize = (ACPI_RS_LENGTH)
+ (TotalSize + AcpiRsStructOptionLength (
+ &Resource->Data.Address64.ResourceSource));
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+ /*
+ * Extended IRQ Resource:
+ * Add the size of each additional optional interrupt beyond the
+ * required 1 (4 bytes for each UINT32 interrupt number)
+ */
+ TotalSize = (ACPI_RS_LENGTH)
+ (TotalSize +
+ ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +
+
+ /* Add the size of the optional ResourceSource info */
+
+ AcpiRsStructOptionLength (
+ &Resource->Data.ExtendedIrq.ResourceSource));
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_GPIO:
+
+ TotalSize = (ACPI_RS_LENGTH) (TotalSize + (Resource->Data.Gpio.PinTableLength * 2) +
+ Resource->Data.Gpio.ResourceSource.StringLength +
+ Resource->Data.Gpio.VendorLength);
+
+ break;
+
+
+ case ACPI_RESOURCE_TYPE_SERIAL_BUS:
+
+ TotalSize = AcpiGbl_AmlResourceSerialBusSizes [Resource->Data.CommonSerialBus.Type];
+
+ TotalSize = (ACPI_RS_LENGTH) (TotalSize +
+ Resource->Data.I2cSerialBus.ResourceSource.StringLength +
+ Resource->Data.I2cSerialBus.VendorLength);
+
+ break;
+
+
+ default:
+ break;
+ }
+
+ /* Update the total */
+
+ AmlSizeNeeded += TotalSize;
+
+ /* Point to the next object */
+
+ Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
+ }
+
+ /* Did not find an EndTag resource descriptor */
+
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetListLength
+ *
+ * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
+ * AmlBufferLength - Size of AmlBuffer
+ * SizeNeeded - Where the size needed is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Takes an external resource byte stream and calculates the size
+ * buffer needed to hold the corresponding internal resource
+ * descriptor linked list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetListLength (
+ UINT8 *AmlBuffer,
+ UINT32 AmlBufferLength,
+ ACPI_SIZE *SizeNeeded)
+{
+ ACPI_STATUS Status;
+ UINT8 *EndAml;
+ UINT8 *Buffer;
+ UINT32 BufferSize;
+ UINT16 Temp16;
+ UINT16 ResourceLength;
+ UINT32 ExtraStructBytes;
+ UINT8 ResourceIndex;
+ UINT8 MinimumAmlResourceLength;
+ AML_RESOURCE *AmlResource;
+
+
+ ACPI_FUNCTION_TRACE (RsGetListLength);
+
+
+ *SizeNeeded = ACPI_RS_SIZE_MIN; /* Minimum size is one EndTag */
+ EndAml = AmlBuffer + AmlBufferLength;
+
+ /* Walk the list of AML resource descriptors */
+
+ while (AmlBuffer < EndAml)
+ {
+ /* Validate the Resource Type and Resource Length */
+
+ Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * Exit on failure. Cannot continue because the descriptor length
+ * may be bogus also.
+ */
+ return_ACPI_STATUS (Status);
+ }
+
+ AmlResource = (void *) AmlBuffer;
+
+ /* Get the resource length and base (minimum) AML size */
+
+ ResourceLength = AcpiUtGetResourceLength (AmlBuffer);
+ MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
+
+ /*
+ * Augment the size for descriptors with optional
+ * and/or variable length fields
+ */
+ ExtraStructBytes = 0;
+ Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);
+
+ switch (AcpiUtGetResourceType (AmlBuffer))
+ {
+ case ACPI_RESOURCE_NAME_IRQ:
+ /*
+ * IRQ Resource:
+ * Get the number of bits set in the 16-bit IRQ mask
+ */
+ ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
+ ExtraStructBytes = AcpiRsCountSetBits (Temp16);
+ break;
+
+
+ case ACPI_RESOURCE_NAME_DMA:
+ /*
+ * DMA Resource:
+ * Get the number of bits set in the 8-bit DMA mask
+ */
+ ExtraStructBytes = AcpiRsCountSetBits (*Buffer);
+ break;
+
+
+ case ACPI_RESOURCE_NAME_VENDOR_SMALL:
+ case ACPI_RESOURCE_NAME_VENDOR_LARGE:
+ /*
+ * Vendor Resource:
+ * Get the number of vendor data bytes
+ */
+ ExtraStructBytes = ResourceLength;
+ break;
+
+
+ case ACPI_RESOURCE_NAME_END_TAG:
+ /*
+ * End Tag: This is the normal exit
+ */
+ return_ACPI_STATUS (AE_OK);
+
+
+ case ACPI_RESOURCE_NAME_ADDRESS32:
+ case ACPI_RESOURCE_NAME_ADDRESS16:
+ case ACPI_RESOURCE_NAME_ADDRESS64:
+ /*
+ * Address Resource:
+ * Add the size of the optional ResourceSource
+ */
+ ExtraStructBytes = AcpiRsStreamOptionLength (
+ ResourceLength, MinimumAmlResourceLength);
+ break;
+
+
+ case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
+ /*
+ * Extended IRQ Resource:
+ * Using the InterruptTableLength, add 4 bytes for each additional
+ * interrupt. Note: at least one interrupt is required and is
+ * included in the minimum descriptor size (reason for the -1)
+ */
+ ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);
+
+ /* Add the size of the optional ResourceSource */
+
+ ExtraStructBytes += AcpiRsStreamOptionLength (
+ ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);
+ break;
+
+ case ACPI_RESOURCE_NAME_GPIO:
+
+ /* Vendor data is optional */
+
+ if (AmlResource->Gpio.VendorLength)
+ {
+ ExtraStructBytes += AmlResource->Gpio.VendorOffset -
+ AmlResource->Gpio.PinTableOffset + AmlResource->Gpio.VendorLength;
+ }
+ else
+ {
+ ExtraStructBytes += AmlResource->LargeHeader.ResourceLength +
+ sizeof (AML_RESOURCE_LARGE_HEADER) -
+ AmlResource->Gpio.PinTableOffset;
+ }
+ break;
+
+ case ACPI_RESOURCE_NAME_SERIAL_BUS:
+
+ MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[
+ AmlResource->CommonSerialBus.Type];
+ ExtraStructBytes += AmlResource->CommonSerialBus.ResourceLength -
+ MinimumAmlResourceLength;
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * Update the required buffer size for the internal descriptor structs
+ *
+ * Important: Round the size up for the appropriate alignment. This
+ * is a requirement on IA64.
+ */
+ if (AcpiUtGetResourceType (AmlBuffer) == ACPI_RESOURCE_NAME_SERIAL_BUS)
+ {
+ BufferSize = AcpiGbl_ResourceStructSerialBusSizes[
+ AmlResource->CommonSerialBus.Type] + ExtraStructBytes;
+ }
+ else
+ {
+ BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +
+ ExtraStructBytes;
+ }
+ BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize);
+
+ *SizeNeeded += BufferSize;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
+ "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
+ AcpiUtGetResourceType (AmlBuffer),
+ AcpiUtGetDescriptorLength (AmlBuffer), BufferSize));
+
+ /*
+ * Point to the next resource within the AML stream using the length
+ * contained in the resource descriptor header
+ */
+ AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);
+ }
+
+ /* Did not find an EndTag resource descriptor */
+
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetPciRoutingTableLength
+ *
+ * PARAMETERS: PackageObject - Pointer to the package object
+ * BufferSizeNeeded - UINT32 pointer of the size buffer
+ * needed to properly return the
+ * parsed data
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Given a package representing a PCI routing table, this
+ * calculates the size of the corresponding linked list of
+ * descriptions.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetPciRoutingTableLength (
+ ACPI_OPERAND_OBJECT *PackageObject,
+ ACPI_SIZE *BufferSizeNeeded)
+{
+ UINT32 NumberOfElements;
+ ACPI_SIZE TempSizeNeeded = 0;
+ ACPI_OPERAND_OBJECT **TopObjectList;
+ UINT32 Index;
+ ACPI_OPERAND_OBJECT *PackageElement;
+ ACPI_OPERAND_OBJECT **SubObjectList;
+ BOOLEAN NameFound;
+ UINT32 TableIndex;
+
+
+ ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);
+
+
+ NumberOfElements = PackageObject->Package.Count;
+
+ /*
+ * Calculate the size of the return buffer.
+ * The base size is the number of elements * the sizes of the
+ * structures. Additional space for the strings is added below.
+ * The minus one is to subtract the size of the UINT8 Source[1]
+ * member because it is added below.
+ *
+ * But each PRT_ENTRY structure has a pointer to a string and
+ * the size of that string must be found.
+ */
+ TopObjectList = PackageObject->Package.Elements;
+
+ for (Index = 0; Index < NumberOfElements; Index++)
+ {
+ /* Dereference the sub-package */
+
+ PackageElement = *TopObjectList;
+
+ /* We must have a valid Package object */
+
+ if (!PackageElement ||
+ (PackageElement->Common.Type != ACPI_TYPE_PACKAGE))
+ {
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * The SubObjectList will now point to an array of the
+ * four IRQ elements: Address, Pin, Source and SourceIndex
+ */
+ SubObjectList = PackageElement->Package.Elements;
+
+ /* Scan the IrqTableElements for the Source Name String */
+
+ NameFound = FALSE;
+
+ for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++)
+ {
+ if (*SubObjectList && /* Null object allowed */
+
+ ((ACPI_TYPE_STRING ==
+ (*SubObjectList)->Common.Type) ||
+
+ ((ACPI_TYPE_LOCAL_REFERENCE ==
+ (*SubObjectList)->Common.Type) &&
+
+ ((*SubObjectList)->Reference.Class ==
+ ACPI_REFCLASS_NAME))))
+ {
+ NameFound = TRUE;
+ }
+ else
+ {
+ /* Look at the next element */
+
+ SubObjectList++;
+ }
+ }
+
+ TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
+
+ /* Was a String type found? */
+
+ if (NameFound)
+ {
+ if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING)
+ {
+ /*
+ * The length String.Length field does not include the
+ * terminating NULL, add 1
+ */
+ TempSizeNeeded += ((ACPI_SIZE)
+ (*SubObjectList)->String.Length + 1);
+ }
+ else
+ {
+ TempSizeNeeded += AcpiNsGetPathnameLength (
+ (*SubObjectList)->Reference.Node);
+ }
+ }
+ else
+ {
+ /*
+ * If no name was found, then this is a NULL, which is
+ * translated as a UINT32 zero.
+ */
+ TempSizeNeeded += sizeof (UINT32);
+ }
+
+ /* Round up the size since each element must be aligned */
+
+ TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);
+
+ /* Point to the next ACPI_OPERAND_OBJECT */
+
+ TopObjectList++;
+ }
+
+ /*
+ * Add an extra element to the end of the list, essentially a
+ * NULL terminator
+ */
+ *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);
+ return_ACPI_STATUS (AE_OK);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rscreate.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rscreate.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,534 @@
+/*******************************************************************************
+ *
+ * Module Name: rscreate - Create resource lists/tables
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSCREATE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rscreate")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiBufferToResource
+ *
+ * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
+ * AmlBufferLength - Length of the AmlBuffer
+ * ResourcePtr - Where the converted resource is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert a raw AML buffer to a resource list
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiBufferToResource (
+ UINT8 *AmlBuffer,
+ UINT16 AmlBufferLength,
+ ACPI_RESOURCE **ResourcePtr)
+{
+ ACPI_STATUS Status;
+ ACPI_SIZE ListSizeNeeded;
+ void *Resource;
+ void *CurrentResourcePtr;
+
+ /*
+ * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag
+ * is not required here.
+ */
+
+ /* Get the required length for the converted resource */
+
+ Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength,
+ &ListSizeNeeded);
+ if (Status == AE_AML_NO_RESOURCE_END_TAG)
+ {
+ Status = AE_OK;
+ }
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Allocate a buffer for the converted resource */
+
+ Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded);
+ CurrentResourcePtr = Resource;
+ if (!Resource)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Perform the AML-to-Resource conversion */
+
+ Status = AcpiUtWalkAmlResources (AmlBuffer, AmlBufferLength,
+ AcpiRsConvertAmlToResources, &CurrentResourcePtr);
+ if (Status == AE_AML_NO_RESOURCE_END_TAG)
+ {
+ Status = AE_OK;
+ }
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_FREE (Resource);
+ }
+ else
+ {
+ *ResourcePtr = Resource;
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreateResourceList
+ *
+ * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
+ * OutputBuffer - Pointer to the user's buffer
+ *
+ * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code
+ * If OutputBuffer is not large enough, OutputBufferLength
+ * indicates how large OutputBuffer should be, else it
+ * indicates how may UINT8 elements of OutputBuffer are valid.
+ *
+ * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
+ * execution and parses the stream to create a linked list
+ * of device resources.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreateResourceList (
+ ACPI_OPERAND_OBJECT *AmlBuffer,
+ ACPI_BUFFER *OutputBuffer)
+{
+
+ ACPI_STATUS Status;
+ UINT8 *AmlStart;
+ ACPI_SIZE ListSizeNeeded = 0;
+ UINT32 AmlBufferLength;
+ void *Resource;
+
+
+ ACPI_FUNCTION_TRACE (RsCreateResourceList);
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
+ AmlBuffer));
+
+ /* Params already validated, so we don't re-validate here */
+
+ AmlBufferLength = AmlBuffer->Buffer.Length;
+ AmlStart = AmlBuffer->Buffer.Pointer;
+
+ /*
+ * Pass the AmlBuffer into a module that can calculate
+ * the buffer size needed for the linked list
+ */
+ Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
+ &ListSizeNeeded);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
+ Status, (UINT32) ListSizeNeeded));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Do the conversion */
+
+ Resource = OutputBuffer->Pointer;
+ Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
+ AcpiRsConvertAmlToResources, &Resource);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreatePciRoutingTable
+ *
+ * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT
+ * package
+ * OutputBuffer - Pointer to the user's buffer
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
+ * If the OutputBuffer is too small, the error will be
+ * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
+ * to the size buffer needed.
+ *
+ * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
+ * linked list of PCI interrupt descriptions
+ *
+ * NOTE: It is the caller's responsibility to ensure that the start of the
+ * output buffer is aligned properly (if necessary).
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreatePciRoutingTable (
+ ACPI_OPERAND_OBJECT *PackageObject,
+ ACPI_BUFFER *OutputBuffer)
+{
+ UINT8 *Buffer;
+ ACPI_OPERAND_OBJECT **TopObjectList;
+ ACPI_OPERAND_OBJECT **SubObjectList;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_SIZE BufferSizeNeeded = 0;
+ UINT32 NumberOfElements;
+ UINT32 Index;
+ ACPI_PCI_ROUTING_TABLE *UserPrt;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+ ACPI_BUFFER PathBuffer;
+
+
+ ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
+
+
+ /* Params already validated, so we don't re-validate here */
+
+ /* Get the required buffer length */
+
+ Status = AcpiRsGetPciRoutingTableLength (PackageObject,
+ &BufferSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
+ (UINT32) BufferSizeNeeded));
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
+ * package that in turn contains an UINT64 Address, a UINT8 Pin,
+ * a Name, and a UINT8 SourceIndex.
+ */
+ TopObjectList = PackageObject->Package.Elements;
+ NumberOfElements = PackageObject->Package.Count;
+ Buffer = OutputBuffer->Pointer;
+ UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
+
+ for (Index = 0; Index < NumberOfElements; Index++)
+ {
+ /*
+ * Point UserPrt past this current structure
+ *
+ * NOTE: On the first iteration, UserPrt->Length will
+ * be zero because we cleared the return buffer earlier
+ */
+ Buffer += UserPrt->Length;
+ UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
+
+ /*
+ * Fill in the Length field with the information we have at this point.
+ * The minus four is to subtract the size of the UINT8 Source[4] member
+ * because it is added below.
+ */
+ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
+
+ /* Each element of the top-level package must also be a package */
+
+ if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "(PRT[%u]) Need sub-package, found %s",
+ Index, AcpiUtGetObjectTypeName (*TopObjectList)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Each sub-package must be of length 4 */
+
+ if ((*TopObjectList)->Package.Count != 4)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "(PRT[%u]) Need package of length 4, found length %u",
+ Index, (*TopObjectList)->Package.Count));
+ return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
+ }
+
+ /*
+ * Dereference the sub-package.
+ * The SubObjectList will now point to an array of the four IRQ
+ * elements: [Address, Pin, Source, SourceIndex]
+ */
+ SubObjectList = (*TopObjectList)->Package.Elements;
+
+ /* 1) First subobject: Dereference the PRT.Address */
+
+ ObjDesc = SubObjectList[0];
+ if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+ {
+ ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ UserPrt->Address = ObjDesc->Integer.Value;
+
+ /* 2) Second subobject: Dereference the PRT.Pin */
+
+ ObjDesc = SubObjectList[1];
+ if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+ {
+ ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
+
+ /*
+ * If the BIOS has erroneously reversed the _PRT SourceName (index 2)
+ * and the SourceIndex (index 3), fix it. _PRT is important enough to
+ * workaround this BIOS error. This also provides compatibility with
+ * other ACPI implementations.
+ */
+ ObjDesc = SubObjectList[3];
+ if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
+ {
+ SubObjectList[3] = SubObjectList[2];
+ SubObjectList[2] = ObjDesc;
+
+ ACPI_WARNING ((AE_INFO,
+ "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
+ Index));
+ }
+
+ /*
+ * 3) Third subobject: Dereference the PRT.SourceName
+ * The name may be unresolved (slack mode), so allow a null object
+ */
+ ObjDesc = SubObjectList[2];
+ if (ObjDesc)
+ {
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "(PRT[%u].Source) Need name, found Reference Class 0x%X",
+ Index, ObjDesc->Reference.Class));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ Node = ObjDesc->Reference.Node;
+
+ /* Use *remaining* length of the buffer as max for pathname */
+
+ PathBuffer.Length = OutputBuffer->Length -
+ (UINT32) ((UINT8 *) UserPrt->Source -
+ (UINT8 *) OutputBuffer->Pointer);
+ PathBuffer.Pointer = UserPrt->Source;
+
+ Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
+
+ /* +1 to include null terminator */
+
+ UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
+
+ /*
+ * Add to the Length field the length of the string
+ * (add 1 for terminator)
+ */
+ UserPrt->Length += ObjDesc->String.Length + 1;
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+ /*
+ * If this is a number, then the Source Name is NULL, since the
+ * entire buffer was zeroed out, we can leave this alone.
+ *
+ * Add to the Length field the length of the UINT32 NULL
+ */
+ UserPrt->Length += sizeof (UINT32);
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO,
+ "(PRT[%u].Source) Need Ref/String/Integer, found %s",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+ }
+
+ /* Now align the current length */
+
+ UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
+
+ /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
+
+ ObjDesc = SubObjectList[3];
+ if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "(PRT[%u].SourceIndex) Need Integer, found %s",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
+
+ /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
+
+ TopObjectList++;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreateAmlResources
+ *
+ * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's buffer
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
+ * If the OutputBuffer is too small, the error will be
+ * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
+ * to the size buffer needed.
+ *
+ * DESCRIPTION: Takes the linked list of device resources and
+ * creates a bytestream to be used as input for the
+ * _SRS control method.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreateAmlResources (
+ ACPI_RESOURCE *LinkedListBuffer,
+ ACPI_BUFFER *OutputBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_SIZE AmlSizeNeeded = 0;
+
+
+ ACPI_FUNCTION_TRACE (RsCreateAmlResources);
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
+ LinkedListBuffer));
+
+ /*
+ * Params already validated, so we don't re-validate here
+ *
+ * Pass the LinkedListBuffer into a module that calculates
+ * the buffer size needed for the byte stream.
+ */
+ Status = AcpiRsGetAmlLength (LinkedListBuffer,
+ &AmlSizeNeeded);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
+ (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Do the conversion */
+
+ Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded,
+ OutputBuffer->Pointer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
+ return_ACPI_STATUS (AE_OK);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsdump.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsdump.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,946 @@
+/*******************************************************************************
+ *
+ * Module Name: rsdump - Functions to display the resource structures.
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSDUMP_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsdump")
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/* Local prototypes */
+
+static void
+AcpiRsOutString (
+ char *Title,
+ char *Value);
+
+static void
+AcpiRsOutInteger8 (
+ char *Title,
+ UINT8 Value);
+
+static void
+AcpiRsOutInteger16 (
+ char *Title,
+ UINT16 Value);
+
+static void
+AcpiRsOutInteger32 (
+ char *Title,
+ UINT32 Value);
+
+static void
+AcpiRsOutInteger64 (
+ char *Title,
+ UINT64 Value);
+
+static void
+AcpiRsOutTitle (
+ char *Title);
+
+static void
+AcpiRsDumpByteList (
+ UINT16 Length,
+ UINT8 *Data);
+
+static void
+AcpiRsDumpWordList (
+ UINT16 Length,
+ UINT16 *Data);
+
+static void
+AcpiRsDumpDwordList (
+ UINT8 Length,
+ UINT32 *Data);
+
+static void
+AcpiRsDumpShortByteList (
+ UINT8 Length,
+ UINT8 *Data);
+
+static void
+AcpiRsDumpResourceSource (
+ ACPI_RESOURCE_SOURCE *ResourceSource);
+
+static void
+AcpiRsDumpAddressCommon (
+ ACPI_RESOURCE_DATA *Resource);
+
+static void
+AcpiRsDumpDescriptor (
+ void *Resource,
+ ACPI_RSDUMP_INFO *Table);
+
+
+#define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f)
+#define ACPI_PRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f)
+#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_RSDUMP_INFO))
+
+
+/*******************************************************************************
+ *
+ * Resource Descriptor info tables
+ *
+ * Note: The first table entry must be a Title or Literal and must contain
+ * the table length (number of table entries)
+ *
+ ******************************************************************************/
+
+ACPI_RSDUMP_INFO AcpiRsDumpIrq[7] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL},
+ {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.DescriptorLength), "Descriptor Length", NULL},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HeDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LlDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_ShrDecode},
+ {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL},
+ {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpDma[6] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TypDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BmDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SizDecode},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL},
+ {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[4] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf), "Start-Dependent-Functions",NULL},
+ {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (StartDpf.DescriptorLength), "Descriptor Length", NULL},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority), "Compatibility Priority", AcpiGbl_ConfigDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness), "Performance/Robustness", AcpiGbl_ConfigDecode}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[1] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf), "End-Dependent-Functions", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpIo[6] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo), "I/O", NULL},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode), "Address Decoding", AcpiGbl_IoDecode},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Minimum), "Address Minimum", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Maximum), "Address Maximum", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.Alignment), "Alignment", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.AddressLength), "Address Length", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[3] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo), "Fixed I/O", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedIo.Address), "Address", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedIo.AddressLength), "Address Length", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpVendor[3] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor), "Vendor Specific", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Vendor.ByteLength), "Length", NULL},
+ {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]), "Vendor Data", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag), "EndTag", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.AddressLength), "Address Length", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.AddressLength), "Address Length", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpAddress16[8] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16), "16-Bit WORD Address Space",NULL},
+ {ACPI_RSD_ADDRESS, 0, NULL, NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Granularity), "Granularity", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Minimum), "Address Minimum", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Maximum), "Address Maximum", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.TranslationOffset), "Translation Offset", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.AddressLength), "Address Length", NULL},
+ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address16.ResourceSource), NULL, NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpAddress32[8] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32), "32-Bit DWORD Address Space", NULL},
+ {ACPI_RSD_ADDRESS, 0, NULL, NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Granularity), "Granularity", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Minimum), "Address Minimum", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Maximum), "Address Maximum", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.TranslationOffset), "Translation Offset", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.AddressLength), "Address Length", NULL},
+ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address32.ResourceSource), NULL, NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpAddress64[8] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64), "64-Bit QWORD Address Space", NULL},
+ {ACPI_RSD_ADDRESS, 0, NULL, NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Granularity), "Granularity", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Minimum), "Address Minimum", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Maximum), "Address Maximum", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.TranslationOffset), "Translation Offset", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.AddressLength), "Address Length", NULL},
+ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address64.ResourceSource), NULL, NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[8] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64), "64-Bit Extended Address Space", NULL},
+ {ACPI_RSD_ADDRESS, 0, NULL, NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Granularity), "Granularity", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Minimum), "Address Minimum", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Maximum), "Address Maximum", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset), "Translation Offset", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.AddressLength), "Address Length", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific), "Type-Specific Attribute", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HeDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LlDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_ShrDecode},
+ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL},
+ {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[6] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg), "Generic Register", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.SpaceId), "Space ID", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitWidth), "Bit Width", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitOffset), "Bit Offset", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.AccessSize), "Access Size", NULL},
+ {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (GenericReg.Address), "Address", NULL}
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpGpio[16] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGpio), "GPIO", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Gpio.RevisionId), "RevisionId", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Gpio.ConnectionType), "ConnectionType", AcpiGbl_CtDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Gpio.ProducerConsumer), "ProducerConsumer", AcpiGbl_ConsumeDecode},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Gpio.PinConfig), "PinConfig", AcpiGbl_PpcDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Gpio.Sharable), "Sharable", AcpiGbl_ShrDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Gpio.IoRestriction), "IoRestriction", AcpiGbl_IorDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Gpio.Triggering), "Triggering", AcpiGbl_HeDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Gpio.Polarity), "Polarity", AcpiGbl_LlDecode},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.DriveStrength), "DriveStrength", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.DebounceTimeout), "DebounceTimeout", NULL},
+ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Gpio.ResourceSource), "ResourceSource", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.PinTableLength), "PinTableLength", NULL},
+ {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET (Gpio.PinTable), "PinTable", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.VendorLength), "VendorLength", NULL},
+ {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (Gpio.VendorData), "VendorData", NULL},
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpFixedDma[4] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedDma), "FixedDma", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedDma.RequestLines), "RequestLines", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedDma.Channels), "Channels", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedDma.Width), "TransferWidth", AcpiGbl_DtsDecode},
+};
+
+#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.RevisionId), "RevisionId", NULL}, \
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.Type), "Type", AcpiGbl_SbtDecode}, \
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (CommonSerialBus.ProducerConsumer), "ProducerConsumer", AcpiGbl_ConsumeDecode}, \
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (CommonSerialBus.SlaveMode), "SlaveMode", AcpiGbl_SmDecode}, \
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.TypeRevisionId), "TypeRevisionId", NULL}, \
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (CommonSerialBus.TypeDataLength), "TypeDataLength", NULL}, \
+ {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (CommonSerialBus.ResourceSource), "ResourceSource", NULL}, \
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (CommonSerialBus.VendorLength), "VendorLength", NULL}, \
+ {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (CommonSerialBus.VendorData), "VendorData", NULL},
+
+ACPI_RSDUMP_INFO AcpiRsDumpCommonSerialBus[10] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpCommonSerialBus), "Common Serial Bus", NULL},
+ ACPI_RS_DUMP_COMMON_SERIAL_BUS
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[13] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpI2cSerialBus), "I2C Serial Bus", NULL},
+ ACPI_RS_DUMP_COMMON_SERIAL_BUS
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (I2cSerialBus.AccessMode), "AccessMode", AcpiGbl_AmDecode},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (I2cSerialBus.ConnectionSpeed), "ConnectionSpeed", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (I2cSerialBus.SlaveAddress), "SlaveAddress", NULL},
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[17] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpSpiSerialBus), "Spi Serial Bus", NULL},
+ ACPI_RS_DUMP_COMMON_SERIAL_BUS
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (SpiSerialBus.WireMode), "WireMode", AcpiGbl_WmDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (SpiSerialBus.DevicePolarity), "DevicePolarity", AcpiGbl_DpDecode},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (SpiSerialBus.DataBitLength), "DataBitLength", NULL},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (SpiSerialBus.ClockPhase), "ClockPhase", AcpiGbl_CphDecode},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (SpiSerialBus.ClockPolarity), "ClockPolarity", AcpiGbl_CpoDecode},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (SpiSerialBus.DeviceSelection), "DeviceSelection", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (SpiSerialBus.ConnectionSpeed), "ConnectionSpeed", NULL},
+};
+
+ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[19] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpUartSerialBus), "Uart Serial Bus", NULL},
+ ACPI_RS_DUMP_COMMON_SERIAL_BUS
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.FlowControl), "FlowControl", AcpiGbl_FcDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.StopBits), "StopBits", AcpiGbl_SbDecode},
+ {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.DataBits), "DataBits", AcpiGbl_BpbDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.Endian), "Endian", AcpiGbl_EdDecode},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (UartSerialBus.Parity), "Parity", AcpiGbl_PtDecode},
+ {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (UartSerialBus.LinesEnabled), "LinesEnabled", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (UartSerialBus.RxFifoSize), "RxFifoSize", NULL},
+ {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (UartSerialBus.TxFifoSize), "TxFifoSize", NULL},
+ {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (UartSerialBus.DefaultBaudRate), "ConnectionSpeed", NULL},
+};
+
+/*
+ * Tables used for common address descriptor flag fields
+ */
+static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DecDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode}
+};
+
+static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] =
+{
+ {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", (void *) "Memory Range"},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MemDecode},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MtpDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TtpDecode}
+};
+
+static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] =
+{
+ {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", (void *) "I/O Range"},
+ {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RngDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TtpDecode},
+ {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TrsDecode}
+};
+
+
+/*
+ * Table used to dump _PRT contents
+ */
+static ACPI_RSDUMP_INFO AcpiRsDumpPrt[5] =
+{
+ {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt), NULL, NULL},
+ {ACPI_RSD_UINT64, ACPI_PRT_OFFSET (Address), "Address", NULL},
+ {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (Pin), "Pin", NULL},
+ {ACPI_RSD_STRING, ACPI_PRT_OFFSET (Source[0]), "Source", NULL},
+ {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (SourceIndex), "Source Index", NULL}
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpDescriptor
+ *
+ * PARAMETERS: Resource
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+static void
+AcpiRsDumpDescriptor (
+ void *Resource,
+ ACPI_RSDUMP_INFO *Table)
+{
+ UINT8 *Target = NULL;
+ UINT8 *PreviousTarget;
+ char *Name;
+ UINT8 Count;
+
+
+ /* First table entry must contain the table length (# of table entries) */
+
+ Count = Table->Offset;
+
+ while (Count)
+ {
+ PreviousTarget = Target;
+ Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
+ Name = Table->Name;
+
+ switch (Table->Opcode)
+ {
+ case ACPI_RSD_TITLE:
+ /*
+ * Optional resource title
+ */
+ if (Table->Name)
+ {
+ AcpiOsPrintf ("%s Resource\n", Name);
+ }
+ break;
+
+ /* Strings */
+
+ case ACPI_RSD_LITERAL:
+ AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
+ break;
+
+ case ACPI_RSD_STRING:
+ AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
+ break;
+
+ /* Data items, 8/16/32/64 bit */
+
+ case ACPI_RSD_UINT8:
+ if (Table->Pointer)
+ {
+ AcpiRsOutString (Name, ACPI_CAST_PTR (char,
+ Table->Pointer [*Target]));
+ }
+ else
+ {
+ AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
+ }
+ break;
+
+ case ACPI_RSD_UINT16:
+ AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
+ break;
+
+ case ACPI_RSD_UINT32:
+ AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
+ break;
+
+ case ACPI_RSD_UINT64:
+ AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
+ break;
+
+ /* Flags: 1-bit and 2-bit flags supported */
+
+ case ACPI_RSD_1BITFLAG:
+ AcpiRsOutString (Name, ACPI_CAST_PTR (char,
+ Table->Pointer [*Target & 0x01]));
+ break;
+
+ case ACPI_RSD_2BITFLAG:
+ AcpiRsOutString (Name, ACPI_CAST_PTR (char,
+ Table->Pointer [*Target & 0x03]));
+ break;
+
+ case ACPI_RSD_3BITFLAG:
+ AcpiRsOutString (Name, ACPI_CAST_PTR (char,
+ Table->Pointer [*Target & 0x07]));
+ break;
+
+ case ACPI_RSD_SHORTLIST:
+ /*
+ * Short byte list (single line output) for DMA and IRQ resources
+ * Note: The list length is obtained from the previous table entry
+ */
+ if (PreviousTarget)
+ {
+ AcpiRsOutTitle (Name);
+ AcpiRsDumpShortByteList (*PreviousTarget, Target);
+ }
+ break;
+
+ case ACPI_RSD_SHORTLISTX:
+ /*
+ * Short byte list (single line output) for GPIO vendor data
+ * Note: The list length is obtained from the previous table entry
+ */
+ if (PreviousTarget)
+ {
+ AcpiRsOutTitle (Name);
+ AcpiRsDumpShortByteList (*PreviousTarget,
+ *(ACPI_CAST_INDIRECT_PTR (UINT8, Target)));
+ }
+ break;
+
+ case ACPI_RSD_LONGLIST:
+ /*
+ * Long byte list for Vendor resource data
+ * Note: The list length is obtained from the previous table entry
+ */
+ if (PreviousTarget)
+ {
+ AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
+ }
+ break;
+
+ case ACPI_RSD_DWORDLIST:
+ /*
+ * Dword list for Extended Interrupt resources
+ * Note: The list length is obtained from the previous table entry
+ */
+ if (PreviousTarget)
+ {
+ AcpiRsDumpDwordList (*PreviousTarget,
+ ACPI_CAST_PTR (UINT32, Target));
+ }
+ break;
+
+ case ACPI_RSD_WORDLIST:
+ /*
+ * Word list for GPIO Pin Table
+ * Note: The list length is obtained from the previous table entry
+ */
+ if (PreviousTarget)
+ {
+ AcpiRsDumpWordList (*PreviousTarget,
+ *(ACPI_CAST_INDIRECT_PTR (UINT16, Target)));
+ }
+ break;
+
+ case ACPI_RSD_ADDRESS:
+ /*
+ * Common flags for all Address resources
+ */
+ AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
+ break;
+
+ case ACPI_RSD_SOURCE:
+ /*
+ * Optional ResourceSource for Address resources
+ */
+ AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
+ break;
+
+ default:
+ AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
+ Table->Opcode);
+ return;
+ }
+
+ Table++;
+ Count--;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpResourceSource
+ *
+ * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
+ * corresponding ResourceSourceIndex.
+ *
+ ******************************************************************************/
+
+static void
+AcpiRsDumpResourceSource (
+ ACPI_RESOURCE_SOURCE *ResourceSource)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (ResourceSource->Index == 0xFF)
+ {
+ return;
+ }
+
+ AcpiRsOutInteger8 ("Resource Source Index",
+ ResourceSource->Index);
+
+ AcpiRsOutString ("Resource Source",
+ ResourceSource->StringPtr ?
+ ResourceSource->StringPtr : "[Not Specified]");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpAddressCommon
+ *
+ * PARAMETERS: Resource - Pointer to an internal resource descriptor
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump the fields that are common to all Address resource
+ * descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiRsDumpAddressCommon (
+ ACPI_RESOURCE_DATA *Resource)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Decode the type-specific flags */
+
+ switch (Resource->Address.ResourceType)
+ {
+ case ACPI_MEMORY_RANGE:
+
+ AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
+ break;
+
+ case ACPI_IO_RANGE:
+
+ AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
+ break;
+
+ case ACPI_BUS_NUMBER_RANGE:
+
+ AcpiRsOutString ("Resource Type", "Bus Number Range");
+ break;
+
+ default:
+
+ AcpiRsOutInteger8 ("Resource Type",
+ (UINT8) Resource->Address.ResourceType);
+ break;
+ }
+
+ /* Decode the general flags */
+
+ AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpResourceList
+ *
+ * PARAMETERS: ResourceList - Pointer to a resource descriptor list
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dispatches the structure to the correct dump routine.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpResourceList (
+ ACPI_RESOURCE *ResourceList)
+{
+ UINT32 Count = 0;
+ UINT32 Type;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
+ {
+ return;
+ }
+
+ /* Walk list and dump all resource descriptors (END_TAG terminates) */
+
+ do
+ {
+ AcpiOsPrintf ("\n[%02X] ", Count);
+ Count++;
+
+ /* Validate Type before dispatch */
+
+ Type = ResourceList->Type;
+ if (Type > ACPI_RESOURCE_TYPE_MAX)
+ {
+ AcpiOsPrintf (
+ "Invalid descriptor type (%X) in resource list\n",
+ ResourceList->Type);
+ return;
+ }
+
+ /* Dump the resource descriptor */
+
+ if (Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
+ {
+ AcpiRsDumpDescriptor (&ResourceList->Data,
+ AcpiGbl_DumpSerialBusDispatch[ResourceList->Data.CommonSerialBus.Type]);
+ }
+ else
+ {
+ AcpiRsDumpDescriptor (&ResourceList->Data,
+ AcpiGbl_DumpResourceDispatch[Type]);
+ }
+
+ /* Point to the next resource structure */
+
+ ResourceList = ACPI_NEXT_RESOURCE (ResourceList);
+
+ /* Exit when END_TAG descriptor is reached */
+
+ } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpIrqList
+ *
+ * PARAMETERS: RouteTable - Pointer to the routing table to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print IRQ routing table
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpIrqList (
+ UINT8 *RouteTable)
+{
+ ACPI_PCI_ROUTING_TABLE *PrtElement;
+ UINT8 Count;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
+ {
+ return;
+ }
+
+ PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
+
+ /* Dump all table elements, Exit on zero length element */
+
+ for (Count = 0; PrtElement->Length; Count++)
+ {
+ AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
+ AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
+
+ PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
+ PrtElement, PrtElement->Length);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsOut*
+ *
+ * PARAMETERS: Title - Name of the resource field
+ * Value - Value of the resource field
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Miscellaneous helper functions to consistently format the
+ * output of the resource dump routines
+ *
+ ******************************************************************************/
+
+static void
+AcpiRsOutString (
+ char *Title,
+ char *Value)
+{
+ AcpiOsPrintf ("%27s : %s", Title, Value);
+ if (!*Value)
+ {
+ AcpiOsPrintf ("[NULL NAMESTRING]");
+ }
+ AcpiOsPrintf ("\n");
+}
+
+static void
+AcpiRsOutInteger8 (
+ char *Title,
+ UINT8 Value)
+{
+ AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
+}
+
+static void
+AcpiRsOutInteger16 (
+ char *Title,
+ UINT16 Value)
+{
+ AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
+}
+
+static void
+AcpiRsOutInteger32 (
+ char *Title,
+ UINT32 Value)
+{
+ AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
+}
+
+static void
+AcpiRsOutInteger64 (
+ char *Title,
+ UINT64 Value)
+{
+ AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
+ ACPI_FORMAT_UINT64 (Value));
+}
+
+static void
+AcpiRsOutTitle (
+ char *Title)
+{
+ AcpiOsPrintf ("%27s : ", Title);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDump*List
+ *
+ * PARAMETERS: Length - Number of elements in the list
+ * Data - Start of the list
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Miscellaneous functions to dump lists of raw data
+ *
+ ******************************************************************************/
+
+static void
+AcpiRsDumpByteList (
+ UINT16 Length,
+ UINT8 *Data)
+{
+ UINT8 i;
+
+
+ for (i = 0; i < Length; i++)
+ {
+ AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
+ "Byte", i, Data[i]);
+ }
+}
+
+static void
+AcpiRsDumpShortByteList (
+ UINT8 Length,
+ UINT8 *Data)
+{
+ UINT8 i;
+
+
+ for (i = 0; i < Length; i++)
+ {
+ AcpiOsPrintf ("%X ", Data[i]);
+ }
+ AcpiOsPrintf ("\n");
+}
+
+static void
+AcpiRsDumpDwordList (
+ UINT8 Length,
+ UINT32 *Data)
+{
+ UINT8 i;
+
+
+ for (i = 0; i < Length; i++)
+ {
+ AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
+ "Dword", i, Data[i]);
+ }
+}
+
+static void
+AcpiRsDumpWordList (
+ UINT16 Length,
+ UINT16 *Data)
+{
+ UINT16 i;
+
+
+ for (i = 0; i < Length; i++)
+ {
+ AcpiOsPrintf ("%25s%2.2X : %4.4X\n",
+ "Word", i, Data[i]);
+ }
+}
+
+#endif
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsinfo.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsinfo.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ *
+ * Module Name: rsinfo - Dispatch and Info tables
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSINFO_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsinfo")
+
+/*
+ * Resource dispatch and information tables. Any new resource types (either
+ * Large or Small) must be reflected in each of these tables, so they are here
+ * in one place.
+ *
+ * The tables for Large descriptors are indexed by bits 6:0 of the AML
+ * descriptor type byte. The tables for Small descriptors are indexed by
+ * bits 6:3 of the descriptor byte. The tables for internal resource
+ * descriptors are indexed by the ACPI_RESOURCE_TYPE field.
+ */
+
+
+/* Dispatch table for resource-to-AML (Set Resource) conversion functions */
+
+ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[] =
+{
+ AcpiRsSetIrq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
+ AcpiRsConvertDma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
+ AcpiRsSetStartDpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
+ AcpiRsConvertEndDpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
+ AcpiRsConvertIo, /* 0x04, ACPI_RESOURCE_TYPE_IO */
+ AcpiRsConvertFixedIo, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
+ AcpiRsSetVendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
+ AcpiRsConvertEndTag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
+ AcpiRsConvertMemory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
+ AcpiRsConvertMemory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
+ AcpiRsConvertFixedMemory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
+ AcpiRsConvertAddress16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
+ AcpiRsConvertAddress32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
+ AcpiRsConvertAddress64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
+ AcpiRsConvertExtAddress64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
+ AcpiRsConvertExtIrq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
+ AcpiRsConvertGenericReg, /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
+ AcpiRsConvertGpio, /* 0x11, ACPI_RESOURCE_TYPE_GPIO */
+ AcpiRsConvertFixedDma, /* 0x12, ACPI_RESOURCE_TYPE_FIXED_DMA */
+ NULL, /* 0x13, ACPI_RESOURCE_TYPE_SERIAL_BUS - Use subtype table below */
+};
+
+/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
+
+ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[] =
+{
+ /* Small descriptors */
+
+ NULL, /* 0x00, Reserved */
+ NULL, /* 0x01, Reserved */
+ NULL, /* 0x02, Reserved */
+ NULL, /* 0x03, Reserved */
+ AcpiRsGetIrq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
+ AcpiRsConvertDma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
+ AcpiRsGetStartDpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
+ AcpiRsConvertEndDpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
+ AcpiRsConvertIo, /* 0x08, ACPI_RESOURCE_NAME_IO */
+ AcpiRsConvertFixedIo, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
+ AcpiRsConvertFixedDma, /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
+ NULL, /* 0x0B, Reserved */
+ NULL, /* 0x0C, Reserved */
+ NULL, /* 0x0D, Reserved */
+ AcpiRsGetVendorSmall, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
+ AcpiRsConvertEndTag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
+
+ /* Large descriptors */
+
+ NULL, /* 0x00, Reserved */
+ AcpiRsConvertMemory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
+ AcpiRsConvertGenericReg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
+ NULL, /* 0x03, Reserved */
+ AcpiRsGetVendorLarge, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
+ AcpiRsConvertMemory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
+ AcpiRsConvertFixedMemory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
+ AcpiRsConvertAddress32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
+ AcpiRsConvertAddress16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
+ AcpiRsConvertExtIrq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
+ AcpiRsConvertAddress64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
+ AcpiRsConvertExtAddress64, /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
+ AcpiRsConvertGpio, /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
+ NULL, /* 0x0D, Reserved */
+ NULL, /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use subtype table below */
+};
+
+/* Subtype table for SerialBus -- I2C, SPI, and UART */
+
+ACPI_RSCONVERT_INFO *AcpiGbl_ConvertResourceSerialBusDispatch[] =
+{
+ NULL,
+ AcpiRsConvertI2cSerialBus,
+ AcpiRsConvertSpiSerialBus,
+ AcpiRsConvertUartSerialBus,
+};
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/* Dispatch table for resource dump functions */
+
+ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[] =
+{
+ AcpiRsDumpIrq, /* ACPI_RESOURCE_TYPE_IRQ */
+ AcpiRsDumpDma, /* ACPI_RESOURCE_TYPE_DMA */
+ AcpiRsDumpStartDpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
+ AcpiRsDumpEndDpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
+ AcpiRsDumpIo, /* ACPI_RESOURCE_TYPE_IO */
+ AcpiRsDumpFixedIo, /* ACPI_RESOURCE_TYPE_FIXED_IO */
+ AcpiRsDumpVendor, /* ACPI_RESOURCE_TYPE_VENDOR */
+ AcpiRsDumpEndTag, /* ACPI_RESOURCE_TYPE_END_TAG */
+ AcpiRsDumpMemory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */
+ AcpiRsDumpMemory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */
+ AcpiRsDumpFixedMemory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
+ AcpiRsDumpAddress16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
+ AcpiRsDumpAddress32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
+ AcpiRsDumpAddress64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
+ AcpiRsDumpExtAddress64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
+ AcpiRsDumpExtIrq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
+ AcpiRsDumpGenericReg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
+ AcpiRsDumpGpio, /* ACPI_RESOURCE_TYPE_GPIO */
+ AcpiRsDumpFixedDma, /* ACPI_RESOURCE_TYPE_FIXED_DMA */
+ NULL, /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
+};
+
+ACPI_RSDUMP_INFO *AcpiGbl_DumpSerialBusDispatch[] =
+{
+ NULL,
+ AcpiRsDumpI2cSerialBus, /* AML_RESOURCE_I2C_BUS_TYPE */
+ AcpiRsDumpSpiSerialBus, /* AML_RESOURCE_SPI_BUS_TYPE */
+ AcpiRsDumpUartSerialBus, /* AML_RESOURCE_UART_BUS_TYPE */
+};
+#endif
+
+
+/*
+ * Base sizes for external AML resource descriptors, indexed by internal type.
+ * Includes size of the descriptor header (1 byte for small descriptors,
+ * 3 bytes for large descriptors)
+ */
+const UINT8 AcpiGbl_AmlResourceSizes[] =
+{
+ sizeof (AML_RESOURCE_IRQ), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
+ sizeof (AML_RESOURCE_DMA), /* ACPI_RESOURCE_TYPE_DMA */
+ sizeof (AML_RESOURCE_START_DEPENDENT), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
+ sizeof (AML_RESOURCE_END_DEPENDENT), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
+ sizeof (AML_RESOURCE_IO), /* ACPI_RESOURCE_TYPE_IO */
+ sizeof (AML_RESOURCE_FIXED_IO), /* ACPI_RESOURCE_TYPE_FIXED_IO */
+ sizeof (AML_RESOURCE_VENDOR_SMALL), /* ACPI_RESOURCE_TYPE_VENDOR */
+ sizeof (AML_RESOURCE_END_TAG), /* ACPI_RESOURCE_TYPE_END_TAG */
+ sizeof (AML_RESOURCE_MEMORY24), /* ACPI_RESOURCE_TYPE_MEMORY24 */
+ sizeof (AML_RESOURCE_MEMORY32), /* ACPI_RESOURCE_TYPE_MEMORY32 */
+ sizeof (AML_RESOURCE_FIXED_MEMORY32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
+ sizeof (AML_RESOURCE_ADDRESS16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */
+ sizeof (AML_RESOURCE_ADDRESS32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */
+ sizeof (AML_RESOURCE_ADDRESS64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
+ sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
+ sizeof (AML_RESOURCE_EXTENDED_IRQ), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
+ sizeof (AML_RESOURCE_GENERIC_REGISTER), /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
+ sizeof (AML_RESOURCE_GPIO), /* ACPI_RESOURCE_TYPE_GPIO */
+ sizeof (AML_RESOURCE_FIXED_DMA), /* ACPI_RESOURCE_TYPE_FIXED_DMA */
+ sizeof (AML_RESOURCE_COMMON_SERIALBUS), /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
+};
+
+
+const UINT8 AcpiGbl_ResourceStructSizes[] =
+{
+ /* Small descriptors */
+
+ 0,
+ 0,
+ 0,
+ 0,
+ ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
+ ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
+ ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
+ ACPI_RS_SIZE_MIN,
+ ACPI_RS_SIZE (ACPI_RESOURCE_IO),
+ ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
+ ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_DMA),
+ 0,
+ 0,
+ 0,
+ ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
+ ACPI_RS_SIZE_MIN,
+
+ /* Large descriptors */
+
+ 0,
+ ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
+ ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
+ 0,
+ ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
+ ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
+ ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
+ ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
+ ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
+ ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
+ ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
+ ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
+ ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
+ ACPI_RS_SIZE (ACPI_RESOURCE_COMMON_SERIALBUS)
+};
+
+const UINT8 AcpiGbl_AmlResourceSerialBusSizes[] =
+{
+ 0,
+ sizeof (AML_RESOURCE_I2C_SERIALBUS),
+ sizeof (AML_RESOURCE_SPI_SERIALBUS),
+ sizeof (AML_RESOURCE_UART_SERIALBUS),
+};
+
+const UINT8 AcpiGbl_ResourceStructSerialBusSizes[] =
+{
+ 0,
+ ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
+ ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
+ ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
+};
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsio.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsio.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,304 @@
+/*******************************************************************************
+ *
+ * Module Name: rsio - IO and DMA resource descriptors
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSIO_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsio")
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertIo
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
+ ACPI_RS_SIZE (ACPI_RESOURCE_IO),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
+ sizeof (AML_RESOURCE_IO),
+ 0},
+
+ /* Decode flag */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode),
+ AML_OFFSET (Io.Flags),
+ 0},
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Address Alignment
+ * Length
+ * Minimum Base Address
+ * Maximum Base Address
+ */
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment),
+ AML_OFFSET (Io.Alignment),
+ 2},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum),
+ AML_OFFSET (Io.Minimum),
+ 2}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertFixedIo
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
+ ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
+ sizeof (AML_RESOURCE_FIXED_IO),
+ 0},
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Base Address
+ * Length
+ */
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength),
+ AML_OFFSET (FixedIo.AddressLength),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address),
+ AML_OFFSET (FixedIo.Address),
+ 1}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertGenericReg
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
+ ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
+ sizeof (AML_RESOURCE_GENERIC_REGISTER),
+ 0},
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Address Space ID
+ * Register Bit Width
+ * Register Bit Offset
+ * Access Size
+ */
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId),
+ AML_OFFSET (GenericReg.AddressSpaceId),
+ 4},
+
+ /* Get the Register Address */
+
+ {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address),
+ AML_OFFSET (GenericReg.Address),
+ 1}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertEndDpf
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
+ ACPI_RS_SIZE_MIN,
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
+ sizeof (AML_RESOURCE_END_DEPENDENT),
+ 0}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertEndTag
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
+ ACPI_RS_SIZE_MIN,
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)},
+
+ /*
+ * Note: The checksum field is set to zero, meaning that the resource
+ * data is treated as if the checksum operation succeeded.
+ * (ACPI Spec 1.0b Section 6.4.2.8)
+ */
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
+ sizeof (AML_RESOURCE_END_TAG),
+ 0}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsGetStartDpf
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
+ ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
+ ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)},
+
+ /* Defaults for Compatibility and Performance priorities */
+
+ {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
+ ACPI_ACCEPTABLE_CONFIGURATION,
+ 2},
+
+ /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength),
+ AML_OFFSET (StartDpf.DescriptorType),
+ 0},
+
+ /* All done if there is no flag byte present in the descriptor */
+
+ {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
+
+ /* Flag byte is present, get the flags */
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
+ AML_OFFSET (StartDpf.Flags),
+ 0},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
+ AML_OFFSET (StartDpf.Flags),
+ 2}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsSetStartDpf
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] =
+{
+ /* Start with a default descriptor of length 1 */
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
+ sizeof (AML_RESOURCE_START_DEPENDENT),
+ ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)},
+
+ /* Set the default flag values */
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
+ AML_OFFSET (StartDpf.Flags),
+ 0},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
+ AML_OFFSET (StartDpf.Flags),
+ 2},
+ /*
+ * All done if the output descriptor length is required to be 1
+ * (i.e., optimization to 0 bytes cannot be attempted)
+ */
+ {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
+ 1},
+
+ /* Set length to 0 bytes (no flags byte) */
+
+ {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)},
+
+ /*
+ * All done if the output descriptor length is required to be 0.
+ *
+ * TBD: Perhaps we should check for error if input flags are not
+ * compatible with a 0-byte descriptor.
+ */
+ {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
+ 0},
+
+ /* Reset length to 1 byte (descriptor with flags byte) */
+
+ {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)},
+
+
+ /*
+ * All done if flags byte is necessary -- if either priority value
+ * is not ACPI_ACCEPTABLE_CONFIGURATION
+ */
+ {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
+ ACPI_ACCEPTABLE_CONFIGURATION},
+
+ {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
+ ACPI_ACCEPTABLE_CONFIGURATION},
+
+ /* Flag byte is not necessary */
+
+ {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}
+};
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsirq.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsirq.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ *
+ * Module Name: rsirq - IRQ resource descriptors
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSIRQ_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsirq")
+
+
+/*******************************************************************************
+ *
+ * AcpiRsGetIrq
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsGetIrq[8] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
+ ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
+ ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)},
+
+ /* Get the IRQ mask (bytes 1:2) */
+
+ {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
+ AML_OFFSET (Irq.IrqMask),
+ ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
+
+ /* Set default flags (others are zero) */
+
+ {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering),
+ ACPI_EDGE_SENSITIVE,
+ 1},
+
+ /* Get the descriptor length (2 or 3 for IRQ descriptor) */
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength),
+ AML_OFFSET (Irq.DescriptorType),
+ 0},
+
+ /* All done if no flag byte present in descriptor */
+
+ {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
+
+ /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
+ AML_OFFSET (Irq.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
+ AML_OFFSET (Irq.Flags),
+ 3},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable),
+ AML_OFFSET (Irq.Flags),
+ 4}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsSetIrq
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsSetIrq[13] =
+{
+ /* Start with a default descriptor of length 3 */
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
+ sizeof (AML_RESOURCE_IRQ),
+ ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)},
+
+ /* Convert interrupt list to 16-bit IRQ bitmask */
+
+ {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
+ AML_OFFSET (Irq.IrqMask),
+ ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
+
+ /* Set the flags byte */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
+ AML_OFFSET (Irq.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
+ AML_OFFSET (Irq.Flags),
+ 3},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable),
+ AML_OFFSET (Irq.Flags),
+ 4},
+
+ /*
+ * All done if the output descriptor length is required to be 3
+ * (i.e., optimization to 2 bytes cannot be attempted)
+ */
+ {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
+ 3},
+
+ /* Set length to 2 bytes (no flags byte) */
+
+ {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)},
+
+ /*
+ * All done if the output descriptor length is required to be 2.
+ *
+ * TBD: Perhaps we should check for error if input flags are not
+ * compatible with a 2-byte descriptor.
+ */
+ {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
+ 2},
+
+ /* Reset length to 3 bytes (descriptor with flags byte) */
+
+ {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)},
+
+ /*
+ * Check if the flags byte is necessary. Not needed if the flags are:
+ * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
+ */
+ {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET (Data.Irq.Triggering),
+ ACPI_EDGE_SENSITIVE},
+
+ {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET (Data.Irq.Polarity),
+ ACPI_ACTIVE_HIGH},
+
+ {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
+ ACPI_RS_OFFSET (Data.Irq.Sharable),
+ ACPI_EXCLUSIVE},
+
+ /* We can optimize to a 2-byte IrqNoFlags() descriptor */
+
+ {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertExtIrq
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
+ ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
+ sizeof (AML_RESOURCE_EXTENDED_IRQ),
+ 0},
+
+ /* Flag bits */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer),
+ AML_OFFSET (ExtendedIrq.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering),
+ AML_OFFSET (ExtendedIrq.Flags),
+ 1},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity),
+ AML_OFFSET (ExtendedIrq.Flags),
+ 2},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable),
+ AML_OFFSET (ExtendedIrq.Flags),
+ 3},
+
+ /* IRQ Table length (Byte4) */
+
+ {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount),
+ AML_OFFSET (ExtendedIrq.InterruptCount),
+ sizeof (UINT32)},
+
+ /* Copy every IRQ in the table, each is 32 bits */
+
+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
+ AML_OFFSET (ExtendedIrq.Interrupts[0]),
+ 0},
+
+ /* Optional ResourceSource (Index and String) */
+
+ {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource),
+ ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
+ sizeof (AML_RESOURCE_EXTENDED_IRQ)}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertDma
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
+ ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
+ sizeof (AML_RESOURCE_DMA),
+ 0},
+
+ /* Flags: transfer preference, bus mastering, channel speed */
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer),
+ AML_OFFSET (Dma.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster),
+ AML_OFFSET (Dma.Flags),
+ 2},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type),
+ AML_OFFSET (Dma.Flags),
+ 5},
+
+ /* DMA channel mask bits */
+
+ {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]),
+ AML_OFFSET (Dma.DmaChannelMask),
+ ACPI_RS_OFFSET (Data.Dma.ChannelCount)}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertFixedDma
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma[4] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_DMA,
+ ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_DMA),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedDma)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_DMA,
+ sizeof (AML_RESOURCE_FIXED_DMA),
+ 0},
+
+ /*
+ * These fields are contiguous in both the source and destination:
+ * RequestLines
+ * Channels
+ */
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedDma.RequestLines),
+ AML_OFFSET (FixedDma.RequestLines),
+ 2},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedDma.Width),
+ AML_OFFSET (FixedDma.Width),
+ 1},
+
+};
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rslist.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rslist.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ *
+ * Module Name: rslist - Linked list 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 __RSLIST_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rslist")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsConvertAmlToResources
+ *
+ * PARAMETERS: ACPI_WALK_AML_CALLBACK
+ * ResourcePtr - Pointer to the buffer that will
+ * contain the output structures
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an AML resource to an internal representation of the
+ * resource that is aligned and easier to access.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsConvertAmlToResources (
+ UINT8 *Aml,
+ UINT32 Length,
+ UINT32 Offset,
+ UINT8 ResourceIndex,
+ void *Context)
+{
+ ACPI_RESOURCE **ResourcePtr = ACPI_CAST_INDIRECT_PTR (
+ ACPI_RESOURCE, Context);
+ ACPI_RESOURCE *Resource;
+ AML_RESOURCE *AmlResource;
+ ACPI_RSCONVERT_INFO *ConversionTable;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (RsConvertAmlToResources);
+
+
+ /*
+ * Check that the input buffer and all subsequent pointers into it
+ * are aligned on a native word boundary. Most important on IA64
+ */
+ Resource = *ResourcePtr;
+ if (ACPI_IS_MISALIGNED (Resource))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Misaligned resource pointer %p", Resource));
+ }
+
+ /* Get the appropriate conversion info table */
+
+ AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
+ if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_SERIAL_BUS)
+ {
+ if (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)
+ {
+ ConversionTable = NULL;
+ }
+ else
+ {
+ /* This is an I2C, SPI, or UART SerialBus descriptor */
+
+ ConversionTable =
+ AcpiGbl_ConvertResourceSerialBusDispatch[
+ AmlResource->CommonSerialBus.Type];
+ }
+ }
+ else
+ {
+ ConversionTable =
+ AcpiGbl_GetResourceDispatch[ResourceIndex];
+ }
+
+ if (!ConversionTable)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Invalid/unsupported resource descriptor: Type 0x%2.2X",
+ ResourceIndex));
+ return (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+
+ /* Convert the AML byte stream resource to a local resource struct */
+
+ Status = AcpiRsConvertAmlToResource (
+ Resource, AmlResource, ConversionTable);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not convert AML resource (Type 0x%X)", *Aml));
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
+ "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
+ AcpiUtGetResourceType (Aml), Length,
+ Resource->Length));
+
+ /* Point to the next structure in the output buffer */
+
+ *ResourcePtr = ACPI_NEXT_RESOURCE (Resource);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsConvertResourcesToAml
+ *
+ * PARAMETERS: Resource - Pointer to the resource linked list
+ * AmlSizeNeeded - Calculated size of the byte stream
+ * needed from calling AcpiRsGetAmlLength()
+ * The size of the OutputBuffer is
+ * guaranteed to be >= AmlSizeNeeded
+ * OutputBuffer - Pointer to the buffer that will
+ * contain the byte stream
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Takes the resource linked list and parses it, creating a
+ * byte stream of resources in the caller's output buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsConvertResourcesToAml (
+ ACPI_RESOURCE *Resource,
+ ACPI_SIZE AmlSizeNeeded,
+ UINT8 *OutputBuffer)
+{
+ UINT8 *Aml = OutputBuffer;
+ UINT8 *EndAml = OutputBuffer + AmlSizeNeeded;
+ ACPI_RSCONVERT_INFO *ConversionTable;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (RsConvertResourcesToAml);
+
+
+ /* Walk the resource descriptor list, convert each descriptor */
+
+ while (Aml < EndAml)
+ {
+ /* Validate the (internal) Resource Type */
+
+ if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Invalid descriptor type (0x%X) in resource list",
+ Resource->Type));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /* Perform the conversion */
+
+ if (Resource->Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
+ {
+ if (Resource->Data.CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)
+ {
+ ConversionTable = NULL;
+ }
+ else
+ {
+ /* This is an I2C, SPI, or UART SerialBus descriptor */
+
+ ConversionTable = AcpiGbl_ConvertResourceSerialBusDispatch[
+ Resource->Data.CommonSerialBus.Type];
+ }
+ }
+ else
+ {
+ ConversionTable = AcpiGbl_SetResourceDispatch[Resource->Type];
+ }
+
+ if (!ConversionTable)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Invalid/unsupported resource descriptor: Type 0x%2.2X",
+ Resource->Type));
+ return (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+
+ Status = AcpiRsConvertResourceToAml (Resource,
+ ACPI_CAST_PTR (AML_RESOURCE, Aml),
+ ConversionTable);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not convert resource (type 0x%X) to AML",
+ Resource->Type));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Perform final sanity check on the new AML resource descriptor */
+
+ Status = AcpiUtValidateResource (
+ ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Check for end-of-list, normal exit */
+
+ if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
+ {
+ /* An End Tag indicates the end of the input Resource Template */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Extract the total length of the new descriptor and set the
+ * Aml to point to the next (output) resource descriptor
+ */
+ Aml += AcpiUtGetDescriptorLength (Aml);
+
+ /* Point to the next input resource descriptor */
+
+ Resource = ACPI_NEXT_RESOURCE (Resource);
+ }
+
+ /* Completed buffer, but did not find an EndTag resource descriptor */
+
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsmemory.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsmemory.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ *
+ * Module Name: rsmem24 - Memory resource descriptors
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSMEMORY_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsmemory")
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertMemory24
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[4] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
+ ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
+ sizeof (AML_RESOURCE_MEMORY24),
+ 0},
+
+ /* Read/Write bit */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect),
+ AML_OFFSET (Memory24.Flags),
+ 0},
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Minimum Base Address
+ * Maximum Base Address
+ * Address Base Alignment
+ * Range Length
+ */
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Memory24.Minimum),
+ AML_OFFSET (Memory24.Minimum),
+ 4}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertMemory32
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[4] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
+ ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
+ sizeof (AML_RESOURCE_MEMORY32),
+ 0},
+
+ /* Read/Write bit */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect),
+ AML_OFFSET (Memory32.Flags),
+ 0},
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Minimum Base Address
+ * Maximum Base Address
+ * Address Base Alignment
+ * Range Length
+ */
+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Memory32.Minimum),
+ AML_OFFSET (Memory32.Minimum),
+ 4}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertFixedMemory32
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[4] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
+ ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
+ sizeof (AML_RESOURCE_FIXED_MEMORY32),
+ 0},
+
+ /* Read/Write bit */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect),
+ AML_OFFSET (FixedMemory32.Flags),
+ 0},
+ /*
+ * These fields are contiguous in both the source and destination:
+ * Base Address
+ * Range Length
+ */
+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.FixedMemory32.Address),
+ AML_OFFSET (FixedMemory32.Address),
+ 2}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsGetVendorSmall
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[3] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
+ ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
+ ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)},
+
+ /* Length of the vendor data (byte count) */
+
+ {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
+ 0,
+ sizeof (UINT8)},
+
+ /* Vendor data */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
+ sizeof (AML_RESOURCE_SMALL_HEADER),
+ 0}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsGetVendorLarge
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[3] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
+ ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
+ ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)},
+
+ /* Length of the vendor data (byte count) */
+
+ {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
+ 0,
+ sizeof (UINT8)},
+
+ /* Vendor data */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
+ sizeof (AML_RESOURCE_LARGE_HEADER),
+ 0}
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsSetVendor
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsSetVendor[7] =
+{
+ /* Default is a small vendor descriptor */
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
+ sizeof (AML_RESOURCE_SMALL_HEADER),
+ ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)},
+
+ /* Get the length and copy the data */
+
+ {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
+ 0,
+ 0},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
+ sizeof (AML_RESOURCE_SMALL_HEADER),
+ 0},
+
+ /*
+ * All done if the Vendor byte length is 7 or less, meaning that it will
+ * fit within a small descriptor
+ */
+ {ACPI_RSC_EXIT_LE, 0, 0, 7},
+
+ /* Must create a large vendor descriptor */
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
+ sizeof (AML_RESOURCE_LARGE_HEADER),
+ 0},
+
+ {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
+ 0,
+ 0},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
+ sizeof (AML_RESOURCE_LARGE_HEADER),
+ 0}
+};
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsmisc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsmisc.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,869 @@
+/*******************************************************************************
+ *
+ * Module Name: rsmisc - Miscellaneous resource descriptors
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSMISC_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsmisc")
+
+
+#define INIT_RESOURCE_TYPE(i) i->ResourceOffset
+#define INIT_RESOURCE_LENGTH(i) i->AmlOffset
+#define INIT_TABLE_LENGTH(i) i->Value
+
+#define COMPARE_OPCODE(i) i->ResourceOffset
+#define COMPARE_TARGET(i) i->AmlOffset
+#define COMPARE_VALUE(i) i->Value
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsConvertAmlToResource
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Aml - Where the AML descriptor is returned
+ * Info - Pointer to appropriate conversion table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
+ * internal resource descriptor
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsConvertAmlToResource (
+ ACPI_RESOURCE *Resource,
+ AML_RESOURCE *Aml,
+ ACPI_RSCONVERT_INFO *Info)
+{
+ ACPI_RS_LENGTH AmlResourceLength;
+ void *Source;
+ void *Destination;
+ char *Target;
+ UINT8 Count;
+ UINT8 FlagsMode = FALSE;
+ UINT16 ItemCount = 0;
+ UINT16 Temp16 = 0;
+
+
+ ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
+
+
+ if (!Info)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (((ACPI_SIZE) Resource) & 0x3)
+ {
+ /* Each internal resource struct is expected to be 32-bit aligned */
+
+ ACPI_WARNING ((AE_INFO,
+ "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
+ Resource, Resource->Type, Resource->Length));
+ }
+
+ /* Extract the resource Length field (does not include header length) */
+
+ AmlResourceLength = AcpiUtGetResourceLength (Aml);
+
+ /*
+ * First table entry must be ACPI_RSC_INITxxx and must contain the
+ * table length (# of table entries)
+ */
+ Count = INIT_TABLE_LENGTH (Info);
+ while (Count)
+ {
+ /*
+ * Source is the external AML byte stream buffer,
+ * destination is the internal resource descriptor
+ */
+ Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
+ Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
+
+ switch (Info->Opcode)
+ {
+ case ACPI_RSC_INITGET:
+ /*
+ * Get the resource type and the initial (minimum) length
+ */
+ ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
+ Resource->Type = INIT_RESOURCE_TYPE (Info);
+ Resource->Length = INIT_RESOURCE_LENGTH (Info);
+ break;
+
+
+ case ACPI_RSC_INITSET:
+ break;
+
+
+ case ACPI_RSC_FLAGINIT:
+
+ FlagsMode = TRUE;
+ break;
+
+
+ case ACPI_RSC_1BITFLAG:
+ /*
+ * Mask and shift the flag bit
+ */
+ ACPI_SET8 (Destination) = (UINT8)
+ ((ACPI_GET8 (Source) >> Info->Value) & 0x01);
+ break;
+
+
+ case ACPI_RSC_2BITFLAG:
+ /*
+ * Mask and shift the flag bits
+ */
+ ACPI_SET8 (Destination) = (UINT8)
+ ((ACPI_GET8 (Source) >> Info->Value) & 0x03);
+ break;
+
+
+ case ACPI_RSC_3BITFLAG:
+ /*
+ * Mask and shift the flag bits
+ */
+ ACPI_SET8 (Destination) = (UINT8)
+ ((ACPI_GET8 (Source) >> Info->Value) & 0x07);
+ break;
+
+
+ case ACPI_RSC_COUNT:
+
+ ItemCount = ACPI_GET8 (Source);
+ ACPI_SET8 (Destination) = (UINT8) ItemCount;
+
+ Resource->Length = Resource->Length +
+ (Info->Value * (ItemCount - 1));
+ break;
+
+
+ case ACPI_RSC_COUNT16:
+
+ ItemCount = AmlResourceLength;
+ ACPI_SET16 (Destination) = ItemCount;
+
+ Resource->Length = Resource->Length +
+ (Info->Value * (ItemCount - 1));
+ break;
+
+
+ case ACPI_RSC_COUNT_GPIO_PIN:
+
+ Target = ACPI_ADD_PTR (void, Aml, Info->Value);
+ ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
+
+ Resource->Length = Resource->Length + ItemCount;
+ ItemCount = ItemCount / 2;
+ ACPI_SET16 (Destination) = ItemCount;
+ break;
+
+
+ case ACPI_RSC_COUNT_GPIO_VEN:
+
+ ItemCount = ACPI_GET8 (Source);
+ ACPI_SET8 (Destination) = (UINT8) ItemCount;
+
+ Resource->Length = Resource->Length +
+ (Info->Value * ItemCount);
+ break;
+
+
+ case ACPI_RSC_COUNT_GPIO_RES:
+
+ /*
+ * Vendor data is optional (length/offset may both be zero)
+ * Examine vendor data length field first
+ */
+ Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2));
+ if (ACPI_GET16 (Target))
+ {
+ /* Use vendor offset to get resource source length */
+
+ Target = ACPI_ADD_PTR (void, Aml, Info->Value);
+ ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
+ }
+ else
+ {
+ /* No vendor data to worry about */
+
+ ItemCount = Aml->LargeHeader.ResourceLength +
+ sizeof (AML_RESOURCE_LARGE_HEADER) -
+ ACPI_GET16 (Source);
+ }
+
+ Resource->Length = Resource->Length + ItemCount;
+ ACPI_SET16 (Destination) = ItemCount;
+ break;
+
+
+ case ACPI_RSC_COUNT_SERIAL_VEN:
+
+ ItemCount = ACPI_GET16 (Source) - Info->Value;
+
+ Resource->Length = Resource->Length + ItemCount;
+ ACPI_SET16 (Destination) = ItemCount;
+ break;
+
+
+ case ACPI_RSC_COUNT_SERIAL_RES:
+
+ ItemCount = (AmlResourceLength +
+ sizeof (AML_RESOURCE_LARGE_HEADER)) -
+ ACPI_GET16 (Source) - Info->Value;
+
+ Resource->Length = Resource->Length + ItemCount;
+ ACPI_SET16 (Destination) = ItemCount;
+ break;
+
+
+ case ACPI_RSC_LENGTH:
+
+ Resource->Length = Resource->Length + Info->Value;
+ break;
+
+
+ case ACPI_RSC_MOVE8:
+ case ACPI_RSC_MOVE16:
+ case ACPI_RSC_MOVE32:
+ case ACPI_RSC_MOVE64:
+ /*
+ * Raw data move. Use the Info value field unless ItemCount has
+ * been previously initialized via a COUNT opcode
+ */
+ if (Info->Value)
+ {
+ ItemCount = Info->Value;
+ }
+ AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_GPIO_PIN:
+
+ /* Generate and set the PIN data pointer */
+
+ Target = (char *) ACPI_ADD_PTR (void, Resource,
+ (Resource->Length - ItemCount * 2));
+ *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target);
+
+ /* Copy the PIN data */
+
+ Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
+ AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_GPIO_RES:
+
+ /* Generate and set the ResourceSource string pointer */
+
+ Target = (char *) ACPI_ADD_PTR (void, Resource,
+ (Resource->Length - ItemCount));
+ *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
+
+ /* Copy the ResourceSource string */
+
+ Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
+ AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_SERIAL_VEN:
+
+ /* Generate and set the Vendor Data pointer */
+
+ Target = (char *) ACPI_ADD_PTR (void, Resource,
+ (Resource->Length - ItemCount));
+ *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
+
+ /* Copy the Vendor Data */
+
+ Source = ACPI_ADD_PTR (void, Aml, Info->Value);
+ AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_SERIAL_RES:
+
+ /* Generate and set the ResourceSource string pointer */
+
+ Target = (char *) ACPI_ADD_PTR (void, Resource,
+ (Resource->Length - ItemCount));
+ *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
+
+ /* Copy the ResourceSource string */
+
+ Source = ACPI_ADD_PTR (void, Aml, (ACPI_GET16 (Source) + Info->Value));
+ AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_SET8:
+
+ ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
+ break;
+
+
+ case ACPI_RSC_DATA8:
+
+ Target = ACPI_ADD_PTR (char, Resource, Info->Value);
+ ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target));
+ break;
+
+
+ case ACPI_RSC_ADDRESS:
+ /*
+ * Common handler for address descriptor flags
+ */
+ if (!AcpiRsGetAddressCommon (Resource, Aml))
+ {
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+ break;
+
+
+ case ACPI_RSC_SOURCE:
+ /*
+ * Optional ResourceSource (Index and String)
+ */
+ Resource->Length +=
+ AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
+ Destination, Aml, NULL);
+ break;
+
+
+ case ACPI_RSC_SOURCEX:
+ /*
+ * Optional ResourceSource (Index and String). This is the more
+ * complicated case used by the Interrupt() macro
+ */
+ Target = ACPI_ADD_PTR (char, Resource,
+ Info->AmlOffset + (ItemCount * 4));
+
+ Resource->Length +=
+ AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH)
+ (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
+ Destination, Aml, Target);
+ break;
+
+
+ case ACPI_RSC_BITMASK:
+ /*
+ * 8-bit encoded bitmask (DMA macro)
+ */
+ ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
+ if (ItemCount)
+ {
+ Resource->Length += (ItemCount - 1);
+ }
+
+ Target = ACPI_ADD_PTR (char, Resource, Info->Value);
+ ACPI_SET8 (Target) = (UINT8) ItemCount;
+ break;
+
+
+ case ACPI_RSC_BITMASK16:
+ /*
+ * 16-bit encoded bitmask (IRQ macro)
+ */
+ ACPI_MOVE_16_TO_16 (&Temp16, Source);
+
+ ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
+ if (ItemCount)
+ {
+ Resource->Length += (ItemCount - 1);
+ }
+
+ Target = ACPI_ADD_PTR (char, Resource, Info->Value);
+ ACPI_SET8 (Target) = (UINT8) ItemCount;
+ break;
+
+
+ case ACPI_RSC_EXIT_NE:
+ /*
+ * Control - Exit conversion if not equal
+ */
+ switch (Info->ResourceOffset)
+ {
+ case ACPI_RSC_COMPARE_AML_LENGTH:
+ if (AmlResourceLength != Info->Value)
+ {
+ goto Exit;
+ }
+ break;
+
+ case ACPI_RSC_COMPARE_VALUE:
+ if (ACPI_GET8 (Source) != Info->Value)
+ {
+ goto Exit;
+ }
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Count--;
+ Info++;
+ }
+
+Exit:
+ if (!FlagsMode)
+ {
+ /* Round the resource struct length up to the next boundary (32 or 64) */
+
+ Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
+ }
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsConvertResourceToAml
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Aml - Where the AML descriptor is returned
+ * Info - Pointer to appropriate conversion table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert an internal resource descriptor to the corresponding
+ * external AML resource descriptor.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsConvertResourceToAml (
+ ACPI_RESOURCE *Resource,
+ AML_RESOURCE *Aml,
+ ACPI_RSCONVERT_INFO *Info)
+{
+ void *Source = NULL;
+ void *Destination;
+ char *Target;
+ ACPI_RSDESC_SIZE AmlLength = 0;
+ UINT8 Count;
+ UINT16 Temp16 = 0;
+ UINT16 ItemCount = 0;
+
+
+ ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
+
+
+ if (!Info)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * First table entry must be ACPI_RSC_INITxxx and must contain the
+ * table length (# of table entries)
+ */
+ Count = INIT_TABLE_LENGTH (Info);
+
+ while (Count)
+ {
+ /*
+ * Source is the internal resource descriptor,
+ * destination is the external AML byte stream buffer
+ */
+ Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
+ Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
+
+ switch (Info->Opcode)
+ {
+ case ACPI_RSC_INITSET:
+
+ ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
+ AmlLength = INIT_RESOURCE_LENGTH (Info);
+ AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_INITGET:
+ break;
+
+
+ case ACPI_RSC_FLAGINIT:
+ /*
+ * Clear the flag byte
+ */
+ ACPI_SET8 (Destination) = 0;
+ break;
+
+
+ case ACPI_RSC_1BITFLAG:
+ /*
+ * Mask and shift the flag bit
+ */
+ ACPI_SET8 (Destination) |= (UINT8)
+ ((ACPI_GET8 (Source) & 0x01) << Info->Value);
+ break;
+
+
+ case ACPI_RSC_2BITFLAG:
+ /*
+ * Mask and shift the flag bits
+ */
+ ACPI_SET8 (Destination) |= (UINT8)
+ ((ACPI_GET8 (Source) & 0x03) << Info->Value);
+ break;
+
+
+ case ACPI_RSC_3BITFLAG:
+ /*
+ * Mask and shift the flag bits
+ */
+ ACPI_SET8 (Destination) |= (UINT8)
+ ((ACPI_GET8 (Source) & 0x07) << Info->Value);
+ break;
+
+
+ case ACPI_RSC_COUNT:
+
+ ItemCount = ACPI_GET8 (Source);
+ ACPI_SET8 (Destination) = (UINT8) ItemCount;
+
+ AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
+ break;
+
+
+ case ACPI_RSC_COUNT16:
+
+ ItemCount = ACPI_GET16 (Source);
+ AmlLength = (UINT16) (AmlLength + ItemCount);
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_COUNT_GPIO_PIN:
+
+ ItemCount = ACPI_GET16 (Source);
+ ACPI_SET16 (Destination) = (UINT16) AmlLength;
+
+ AmlLength = (UINT16) (AmlLength + ItemCount * 2);
+ Target = ACPI_ADD_PTR (void, Aml, Info->Value);
+ ACPI_SET16 (Target) = (UINT16) AmlLength;
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_COUNT_GPIO_VEN:
+
+ ItemCount = ACPI_GET16 (Source);
+ ACPI_SET16 (Destination) = (UINT16) ItemCount;
+
+ AmlLength = (UINT16) (AmlLength + (Info->Value * ItemCount));
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_COUNT_GPIO_RES:
+
+ /* Set resource source string length */
+
+ ItemCount = ACPI_GET16 (Source);
+ ACPI_SET16 (Destination) = (UINT16) AmlLength;
+
+ /* Compute offset for the Vendor Data */
+
+ AmlLength = (UINT16) (AmlLength + ItemCount);
+ Target = ACPI_ADD_PTR (void, Aml, Info->Value);
+
+ /* Set vendor offset only if there is vendor data */
+
+ if (Resource->Data.Gpio.VendorLength)
+ {
+ ACPI_SET16 (Target) = (UINT16) AmlLength;
+ }
+
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_COUNT_SERIAL_VEN:
+
+ ItemCount = ACPI_GET16 (Source);
+ ACPI_SET16 (Destination) = ItemCount + Info->Value;
+ AmlLength = (UINT16) (AmlLength + ItemCount);
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_COUNT_SERIAL_RES:
+
+ ItemCount = ACPI_GET16 (Source);
+ AmlLength = (UINT16) (AmlLength + ItemCount);
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_LENGTH:
+
+ AcpiRsSetResourceLength (Info->Value, Aml);
+ break;
+
+
+ case ACPI_RSC_MOVE8:
+ case ACPI_RSC_MOVE16:
+ case ACPI_RSC_MOVE32:
+ case ACPI_RSC_MOVE64:
+
+ if (Info->Value)
+ {
+ ItemCount = Info->Value;
+ }
+ AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_GPIO_PIN:
+
+ Destination = (char *) ACPI_ADD_PTR (void, Aml,
+ ACPI_GET16 (Destination));
+ Source = * (UINT16 **) Source;
+ AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_GPIO_RES:
+
+ /* Used for both ResourceSource string and VendorData */
+
+ Destination = (char *) ACPI_ADD_PTR (void, Aml,
+ ACPI_GET16 (Destination));
+ Source = * (UINT8 **) Source;
+ AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_SERIAL_VEN:
+
+ Destination = (char *) ACPI_ADD_PTR (void, Aml,
+ (AmlLength - ItemCount));
+ Source = * (UINT8 **) Source;
+ AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_MOVE_SERIAL_RES:
+
+ Destination = (char *) ACPI_ADD_PTR (void, Aml,
+ (AmlLength - ItemCount));
+ Source = * (UINT8 **) Source;
+ AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
+ break;
+
+
+ case ACPI_RSC_ADDRESS:
+
+ /* Set the Resource Type, General Flags, and Type-Specific Flags */
+
+ AcpiRsSetAddressCommon (Aml, Resource);
+ break;
+
+
+ case ACPI_RSC_SOURCEX:
+ /*
+ * Optional ResourceSource (Index and String)
+ */
+ AmlLength = AcpiRsSetResourceSource (
+ Aml, (ACPI_RS_LENGTH) AmlLength, Source);
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_SOURCE:
+ /*
+ * Optional ResourceSource (Index and String). This is the more
+ * complicated case used by the Interrupt() macro
+ */
+ AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
+ AcpiRsSetResourceLength (AmlLength, Aml);
+ break;
+
+
+ case ACPI_RSC_BITMASK:
+ /*
+ * 8-bit encoded bitmask (DMA macro)
+ */
+ ACPI_SET8 (Destination) = (UINT8)
+ AcpiRsEncodeBitmask (Source,
+ *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
+ break;
+
+
+ case ACPI_RSC_BITMASK16:
+ /*
+ * 16-bit encoded bitmask (IRQ macro)
+ */
+ Temp16 = AcpiRsEncodeBitmask (Source,
+ *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
+ ACPI_MOVE_16_TO_16 (Destination, &Temp16);
+ break;
+
+
+ case ACPI_RSC_EXIT_LE:
+ /*
+ * Control - Exit conversion if less than or equal
+ */
+ if (ItemCount <= Info->Value)
+ {
+ goto Exit;
+ }
+ break;
+
+
+ case ACPI_RSC_EXIT_NE:
+ /*
+ * Control - Exit conversion if not equal
+ */
+ switch (COMPARE_OPCODE (Info))
+ {
+ case ACPI_RSC_COMPARE_VALUE:
+
+ if (*ACPI_ADD_PTR (UINT8, Resource,
+ COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
+ {
+ goto Exit;
+ }
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+ break;
+
+
+ case ACPI_RSC_EXIT_EQ:
+ /*
+ * Control - Exit conversion if equal
+ */
+ if (*ACPI_ADD_PTR (UINT8, Resource,
+ COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
+ {
+ goto Exit;
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Count--;
+ Info++;
+ }
+
+Exit:
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+#if 0
+/* Previous resource validations */
+
+ if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
+ {
+ return_ACPI_STATUS (AE_SUPPORT);
+ }
+
+ if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
+ {
+ return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
+ }
+
+ if (((Aml->Irq.Flags & 0x09) == 0x00) ||
+ ((Aml->Irq.Flags & 0x09) == 0x09))
+ {
+ /*
+ * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
+ * polarity/trigger interrupts are allowed (ACPI spec, section
+ * "IRQ Format"), so 0x00 and 0x09 are illegal.
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Invalid interrupt polarity/trigger in resource list, 0x%X",
+ Aml->Irq.Flags));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ Resource->Data.ExtendedIrq.InterruptCount = Temp8;
+ if (Temp8 < 1)
+ {
+ /* Must have at least one IRQ */
+
+ return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
+ }
+
+ if (Resource->Data.Dma.Transfer == 0x03)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Invalid DMA.Transfer preference (3)"));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsserial.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsserial.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,425 @@
+/*******************************************************************************
+ *
+ * Module Name: rsserial - GPIO/SerialBus resource descriptors
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSIRQ_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsserial")
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertGpio
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertGpio[17] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,
+ ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertGpio)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO,
+ sizeof (AML_RESOURCE_GPIO),
+ 0},
+
+ /*
+ * These fields are contiguous in both the source and destination:
+ * RevisionId
+ * ConnectionType
+ */
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.RevisionId),
+ AML_OFFSET (Gpio.RevisionId),
+ 2},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.ProducerConsumer),
+ AML_OFFSET (Gpio.Flags),
+ 0},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Sharable),
+ AML_OFFSET (Gpio.IntFlags),
+ 3},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.IoRestriction),
+ AML_OFFSET (Gpio.IntFlags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Triggering),
+ AML_OFFSET (Gpio.IntFlags),
+ 0},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Polarity),
+ AML_OFFSET (Gpio.IntFlags),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.PinConfig),
+ AML_OFFSET (Gpio.PinConfig),
+ 1},
+
+ /*
+ * These fields are contiguous in both the source and destination:
+ * DriveStrength
+ * DebounceTimeout
+ */
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Gpio.DriveStrength),
+ AML_OFFSET (Gpio.DriveStrength),
+ 2},
+
+ /* Pin Table */
+
+ {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTableLength),
+ AML_OFFSET (Gpio.PinTableOffset),
+ AML_OFFSET (Gpio.ResSourceOffset)},
+
+ {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTable),
+ AML_OFFSET (Gpio.PinTableOffset),
+ 0},
+
+ /* Resource Source */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.Index),
+ AML_OFFSET (Gpio.ResSourceIndex),
+ 1},
+
+ {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringLength),
+ AML_OFFSET (Gpio.ResSourceOffset),
+ AML_OFFSET (Gpio.VendorOffset)},
+
+ {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringPtr),
+ AML_OFFSET (Gpio.ResSourceOffset),
+ 0},
+
+ /* Vendor Data */
+
+ {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET (Data.Gpio.VendorLength),
+ AML_OFFSET (Gpio.VendorLength),
+ 1},
+
+ {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.VendorData),
+ AML_OFFSET (Gpio.VendorOffset),
+ 0},
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertI2cSerialBus
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
+ ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
+ sizeof (AML_RESOURCE_I2C_SERIALBUS),
+ 0},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
+ AML_OFFSET (CommonSerialBus.RevisionId),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
+ AML_OFFSET (CommonSerialBus.Type),
+ 1},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
+ AML_OFFSET (CommonSerialBus.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
+ AML_OFFSET (CommonSerialBus.Flags),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
+ AML_OFFSET (CommonSerialBus.TypeRevisionId),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ 1},
+
+ /* Vendor data */
+
+ {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ AML_RESOURCE_I2C_MIN_DATA_LEN},
+
+ {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
+ 0,
+ sizeof (AML_RESOURCE_I2C_SERIALBUS)},
+
+ /* Resource Source */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
+ AML_OFFSET (CommonSerialBus.ResSourceIndex),
+ 1},
+
+ {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
+
+ {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
+
+ /* I2C bus type specific */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode),
+ AML_OFFSET (I2cSerialBus.TypeSpecificFlags),
+ 0},
+
+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed),
+ AML_OFFSET (I2cSerialBus.ConnectionSpeed),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress),
+ AML_OFFSET (I2cSerialBus.SlaveAddress),
+ 1},
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertSpiSerialBus
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
+ ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
+ sizeof (AML_RESOURCE_SPI_SERIALBUS),
+ 0},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
+ AML_OFFSET (CommonSerialBus.RevisionId),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
+ AML_OFFSET (CommonSerialBus.Type),
+ 1},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
+ AML_OFFSET (CommonSerialBus.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
+ AML_OFFSET (CommonSerialBus.Flags),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
+ AML_OFFSET (CommonSerialBus.TypeRevisionId),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ 1},
+
+ /* Vendor data */
+
+ {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ AML_RESOURCE_SPI_MIN_DATA_LEN},
+
+ {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
+ 0,
+ sizeof (AML_RESOURCE_SPI_SERIALBUS)},
+
+ /* Resource Source */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
+ AML_OFFSET (CommonSerialBus.ResSourceIndex),
+ 1},
+
+ {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
+
+ {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
+
+ /* Spi bus type specific */
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode),
+ AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity),
+ AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength),
+ AML_OFFSET (SpiSerialBus.DataBitLength),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase),
+ AML_OFFSET (SpiSerialBus.ClockPhase),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity),
+ AML_OFFSET (SpiSerialBus.ClockPolarity),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection),
+ AML_OFFSET (SpiSerialBus.DeviceSelection),
+ 1},
+
+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed),
+ AML_OFFSET (SpiSerialBus.ConnectionSpeed),
+ 1},
+};
+
+
+/*******************************************************************************
+ *
+ * AcpiRsConvertUartSerialBus
+ *
+ ******************************************************************************/
+
+ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[22] =
+{
+ {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
+ ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
+ ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)},
+
+ {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
+ sizeof (AML_RESOURCE_UART_SERIALBUS),
+ 0},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
+ AML_OFFSET (CommonSerialBus.RevisionId),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
+ AML_OFFSET (CommonSerialBus.Type),
+ 1},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
+ AML_OFFSET (CommonSerialBus.Flags),
+ 0},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
+ AML_OFFSET (CommonSerialBus.Flags),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
+ AML_OFFSET (CommonSerialBus.TypeRevisionId),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ 1},
+
+ /* Vendor data */
+
+ {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ AML_RESOURCE_UART_MIN_DATA_LEN},
+
+ {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
+ 0,
+ sizeof (AML_RESOURCE_UART_SERIALBUS)},
+
+ /* Resource Source */
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
+ AML_OFFSET (CommonSerialBus.ResSourceIndex),
+ 1},
+
+ {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
+
+ {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
+ AML_OFFSET (CommonSerialBus.TypeDataLength),
+ sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
+
+ /* Uart bus type specific */
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl),
+ AML_OFFSET (UartSerialBus.TypeSpecificFlags),
+ 0},
+
+ {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits),
+ AML_OFFSET (UartSerialBus.TypeSpecificFlags),
+ 2},
+
+ {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits),
+ AML_OFFSET (UartSerialBus.TypeSpecificFlags),
+ 4},
+
+ {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian),
+ AML_OFFSET (UartSerialBus.TypeSpecificFlags),
+ 7},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.Parity),
+ AML_OFFSET (UartSerialBus.Parity),
+ 1},
+
+ {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled),
+ AML_OFFSET (UartSerialBus.LinesEnabled),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize),
+ AML_OFFSET (UartSerialBus.RxFifoSize),
+ 1},
+
+ {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize),
+ AML_OFFSET (UartSerialBus.TxFifoSize),
+ 1},
+
+ {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate),
+ AML_OFFSET (UartSerialBus.DefaultBaudRate),
+ 1},
+};
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsutils.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsutils.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,861 @@
+/*******************************************************************************
+ *
+ * Module Name: rsutils - Utilities for the resource manager
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSUTILS_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/acresrc.h>
+
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsutils")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDecodeBitmask
+ *
+ * PARAMETERS: Mask - Bitmask to decode
+ * List - Where the converted list is returned
+ *
+ * RETURN: Count of bits set (length of list)
+ *
+ * DESCRIPTION: Convert a bit mask into a list of values
+ *
+ ******************************************************************************/
+
+UINT8
+AcpiRsDecodeBitmask (
+ UINT16 Mask,
+ UINT8 *List)
+{
+ UINT8 i;
+ UINT8 BitCount;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Decode the mask bits */
+
+ for (i = 0, BitCount = 0; Mask; i++)
+ {
+ if (Mask & 0x0001)
+ {
+ List[BitCount] = i;
+ BitCount++;
+ }
+
+ Mask >>= 1;
+ }
+
+ return (BitCount);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEncodeBitmask
+ *
+ * PARAMETERS: List - List of values to encode
+ * Count - Length of list
+ *
+ * RETURN: Encoded bitmask
+ *
+ * DESCRIPTION: Convert a list of values to an encoded bitmask
+ *
+ ******************************************************************************/
+
+UINT16
+AcpiRsEncodeBitmask (
+ UINT8 *List,
+ UINT8 Count)
+{
+ UINT32 i;
+ UINT16 Mask;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Encode the list into a single bitmask */
+
+ for (i = 0, Mask = 0; i < Count; i++)
+ {
+ Mask |= (0x1 << List[i]);
+ }
+
+ return (Mask);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMoveData
+ *
+ * PARAMETERS: Destination - Pointer to the destination descriptor
+ * Source - Pointer to the source descriptor
+ * ItemCount - How many items to move
+ * MoveType - Byte width
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
+ * alignment issues and endian issues if necessary, as configured
+ * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
+ *
+ ******************************************************************************/
+
+void
+AcpiRsMoveData (
+ void *Destination,
+ void *Source,
+ UINT16 ItemCount,
+ UINT8 MoveType)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* One move per item */
+
+ for (i = 0; i < ItemCount; i++)
+ {
+ switch (MoveType)
+ {
+ /*
+ * For the 8-bit case, we can perform the move all at once
+ * since there are no alignment or endian issues
+ */
+ case ACPI_RSC_MOVE8:
+ case ACPI_RSC_MOVE_GPIO_RES:
+ case ACPI_RSC_MOVE_SERIAL_VEN:
+ case ACPI_RSC_MOVE_SERIAL_RES:
+ ACPI_MEMCPY (Destination, Source, ItemCount);
+ return;
+
+ /*
+ * 16-, 32-, and 64-bit cases must use the move macros that perform
+ * endian conversion and/or accomodate hardware that cannot perform
+ * misaligned memory transfers
+ */
+ case ACPI_RSC_MOVE16:
+ case ACPI_RSC_MOVE_GPIO_PIN:
+ ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
+ &ACPI_CAST_PTR (UINT16, Source)[i]);
+ break;
+
+ case ACPI_RSC_MOVE32:
+ ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
+ &ACPI_CAST_PTR (UINT32, Source)[i]);
+ break;
+
+ case ACPI_RSC_MOVE64:
+ ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
+ &ACPI_CAST_PTR (UINT64, Source)[i]);
+ break;
+
+ default:
+ return;
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsSetResourceLength
+ *
+ * PARAMETERS: TotalLength - Length of the AML descriptor, including
+ * the header and length fields.
+ * Aml - Pointer to the raw AML descriptor
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Set the ResourceLength field of an AML
+ * resource descriptor, both Large and Small descriptors are
+ * supported automatically. Note: Descriptor Type field must
+ * be valid.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsSetResourceLength (
+ ACPI_RSDESC_SIZE TotalLength,
+ AML_RESOURCE *Aml)
+{
+ ACPI_RS_LENGTH ResourceLength;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Length is the total descriptor length minus the header length */
+
+ ResourceLength = (ACPI_RS_LENGTH)
+ (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
+
+ /* Length is stored differently for large and small descriptors */
+
+ if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
+ {
+ /* Large descriptor -- bytes 1-2 contain the 16-bit length */
+
+ ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
+ }
+ else
+ {
+ /* Small descriptor -- bits 2:0 of byte 0 contain the length */
+
+ Aml->SmallHeader.DescriptorType = (UINT8)
+
+ /* Clear any existing length, preserving descriptor type bits */
+
+ ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
+
+ | ResourceLength);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsSetResourceHeader
+ *
+ * PARAMETERS: DescriptorType - Byte to be inserted as the type
+ * TotalLength - Length of the AML descriptor, including
+ * the header and length fields.
+ * Aml - Pointer to the raw AML descriptor
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
+ * resource descriptor, both Large and Small descriptors are
+ * supported automatically
+ *
+ ******************************************************************************/
+
+void
+AcpiRsSetResourceHeader (
+ UINT8 DescriptorType,
+ ACPI_RSDESC_SIZE TotalLength,
+ AML_RESOURCE *Aml)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Set the Resource Type */
+
+ Aml->SmallHeader.DescriptorType = DescriptorType;
+
+ /* Set the Resource Length */
+
+ AcpiRsSetResourceLength (TotalLength, Aml);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsStrcpy
+ *
+ * PARAMETERS: Destination - Pointer to the destination string
+ * Source - Pointer to the source string
+ *
+ * RETURN: String length, including NULL terminator
+ *
+ * DESCRIPTION: Local string copy that returns the string length, saving a
+ * strcpy followed by a strlen.
+ *
+ ******************************************************************************/
+
+static UINT16
+AcpiRsStrcpy (
+ char *Destination,
+ char *Source)
+{
+ UINT16 i;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ for (i = 0; Source[i]; i++)
+ {
+ Destination[i] = Source[i];
+ }
+
+ Destination[i] = 0;
+
+ /* Return string length including the NULL terminator */
+
+ return ((UINT16) (i + 1));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetResourceSource
+ *
+ * PARAMETERS: ResourceLength - Length field of the descriptor
+ * MinimumLength - Minimum length of the descriptor (minus
+ * any optional fields)
+ * ResourceSource - Where the ResourceSource is returned
+ * Aml - Pointer to the raw AML descriptor
+ * StringPtr - (optional) where to store the actual
+ * ResourceSource string
+ *
+ * RETURN: Length of the string plus NULL terminator, rounded up to native
+ * word boundary
+ *
+ * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
+ * to an internal resource descriptor
+ *
+ ******************************************************************************/
+
+ACPI_RS_LENGTH
+AcpiRsGetResourceSource (
+ ACPI_RS_LENGTH ResourceLength,
+ ACPI_RS_LENGTH MinimumLength,
+ ACPI_RESOURCE_SOURCE *ResourceSource,
+ AML_RESOURCE *Aml,
+ char *StringPtr)
+{
+ ACPI_RSDESC_SIZE TotalLength;
+ UINT8 *AmlResourceSource;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
+ AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
+
+ /*
+ * ResourceSource is present if the length of the descriptor is longer than
+ * the minimum length.
+ *
+ * Note: Some resource descriptors will have an additional null, so
+ * we add 1 to the minimum length.
+ */
+ if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
+ {
+ /* Get the ResourceSourceIndex */
+
+ ResourceSource->Index = AmlResourceSource[0];
+
+ ResourceSource->StringPtr = StringPtr;
+ if (!StringPtr)
+ {
+ /*
+ * String destination pointer is not specified; Set the String
+ * pointer to the end of the current ResourceSource structure.
+ */
+ ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource,
+ sizeof (ACPI_RESOURCE_SOURCE));
+ }
+
+ /*
+ * In order for the Resource length to be a multiple of the native
+ * word, calculate the length of the string (+1 for NULL terminator)
+ * and expand to the next word multiple.
+ *
+ * Zero the entire area of the buffer.
+ */
+ TotalLength = (UINT32) ACPI_STRLEN (
+ ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
+ TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
+
+ ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
+
+ /* Copy the ResourceSource string to the destination */
+
+ ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
+ ACPI_CAST_PTR (char, &AmlResourceSource[1]));
+
+ return ((ACPI_RS_LENGTH) TotalLength);
+ }
+
+ /* ResourceSource is not present */
+
+ ResourceSource->Index = 0;
+ ResourceSource->StringLength = 0;
+ ResourceSource->StringPtr = NULL;
+ return (0);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsSetResourceSource
+ *
+ * PARAMETERS: Aml - Pointer to the raw AML descriptor
+ * MinimumLength - Minimum length of the descriptor (minus
+ * any optional fields)
+ * ResourceSource - Internal ResourceSource
+
+ *
+ * RETURN: Total length of the AML descriptor
+ *
+ * DESCRIPTION: Convert an optional ResourceSource from internal format to a
+ * raw AML resource descriptor
+ *
+ ******************************************************************************/
+
+ACPI_RSDESC_SIZE
+AcpiRsSetResourceSource (
+ AML_RESOURCE *Aml,
+ ACPI_RS_LENGTH MinimumLength,
+ ACPI_RESOURCE_SOURCE *ResourceSource)
+{
+ UINT8 *AmlResourceSource;
+ ACPI_RSDESC_SIZE DescriptorLength;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ DescriptorLength = MinimumLength;
+
+ /* Non-zero string length indicates presence of a ResourceSource */
+
+ if (ResourceSource->StringLength)
+ {
+ /* Point to the end of the AML descriptor */
+
+ AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
+
+ /* Copy the ResourceSourceIndex */
+
+ AmlResourceSource[0] = (UINT8) ResourceSource->Index;
+
+ /* Copy the ResourceSource string */
+
+ ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
+ ResourceSource->StringPtr);
+
+ /*
+ * Add the length of the string (+ 1 for null terminator) to the
+ * final descriptor length
+ */
+ DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
+ }
+
+ /* Return the new total length of the AML descriptor */
+
+ return (DescriptorLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetPrtMethodData
+ *
+ * PARAMETERS: Node - Device node
+ * RetBuffer - Pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _PRT value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetPrtMethodData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /* Execute the method, no parameters */
+
+ Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
+ ACPI_BTYPE_PACKAGE, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Create a resource linked list from the byte stream buffer that comes
+ * back from the _CRS method execution.
+ */
+ Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by EvaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetCrsMethodData
+ *
+ * PARAMETERS: Node - Device node
+ * RetBuffer - Pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _CRS value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetCrsMethodData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /* Execute the method, no parameters */
+
+ Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
+ ACPI_BTYPE_BUFFER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetPrsMethodData
+ *
+ * PARAMETERS: Node - Device node
+ * RetBuffer - Pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _PRS value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetPrsMethodData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /* Execute the method, no parameters */
+
+ Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
+ ACPI_BTYPE_BUFFER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetAeiMethodData
+ *
+ * PARAMETERS: Node - Device node
+ * RetBuffer - Pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _AEI value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetAeiMethodData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /* Execute the method, no parameters */
+
+ Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI,
+ ACPI_BTYPE_BUFFER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetMethodData
+ *
+ * PARAMETERS: Handle - Handle to the containing object
+ * Path - Path to method, relative to Handle
+ * RetBuffer - Pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
+ * object contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetMethodData (
+ ACPI_HANDLE Handle,
+ char *Path,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (RsGetMethodData);
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /* Execute the method, no parameters */
+
+ Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by EvaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsSetSrsMethodData
+ *
+ * PARAMETERS: Node - Device node
+ * InBuffer - Pointer to a buffer structure of the
+ * parameter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to set the _SRS of an object contained
+ * in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ * Note: Parameters guaranteed valid by caller
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsSetSrsMethodData (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_BUFFER *InBuffer)
+{
+ ACPI_EVALUATE_INFO *Info;
+ ACPI_OPERAND_OBJECT *Args[2];
+ ACPI_STATUS Status;
+ ACPI_BUFFER Buffer;
+
+
+ ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
+
+
+ /* 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 = Node;
+ Info->Pathname = METHOD_NAME__SRS;
+ Info->Parameters = Args;
+ Info->Flags = ACPI_IGNORE_RETURN_VALUE;
+
+ /*
+ * The InBuffer parameter will point to a linked list of
+ * resource parameters. It needs to be formatted into a
+ * byte stream to be sent in as an input parameter to _SRS
+ *
+ * Convert the linked list into a byte stream
+ */
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /* Create and initialize the method parameter object */
+
+ Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
+ if (!Args[0])
+ {
+ /*
+ * Must free the buffer allocated above (otherwise it is freed
+ * later)
+ */
+ ACPI_FREE (Buffer.Pointer);
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ Args[0]->Buffer.Length = (UINT32) Buffer.Length;
+ Args[0]->Buffer.Pointer = Buffer.Pointer;
+ Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
+ Args[1] = NULL;
+
+ /* Execute the method, no return value is expected */
+
+ Status = AcpiNsEvaluate (Info);
+
+ /* Clean up and return the status from AcpiNsEvaluate */
+
+ AcpiUtRemoveReference (Args[0]);
+
+Cleanup:
+ ACPI_FREE (Info);
+ return_ACPI_STATUS (Status);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/resources/rsxface.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/resources/rsxface.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,689 @@
+/*******************************************************************************
+ *
+ * Module Name: rsxface - Public interfaces to the resource manager
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __RSXFACE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsxface")
+
+/* Local macros for 16,32-bit to 64-bit conversion */
+
+#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field)
+#define ACPI_COPY_ADDRESS(Out, In) \
+ ACPI_COPY_FIELD(Out, In, ResourceType); \
+ ACPI_COPY_FIELD(Out, In, ProducerConsumer); \
+ ACPI_COPY_FIELD(Out, In, Decode); \
+ ACPI_COPY_FIELD(Out, In, MinAddressFixed); \
+ ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \
+ ACPI_COPY_FIELD(Out, In, Info); \
+ ACPI_COPY_FIELD(Out, In, Granularity); \
+ ACPI_COPY_FIELD(Out, In, Minimum); \
+ ACPI_COPY_FIELD(Out, In, Maximum); \
+ ACPI_COPY_FIELD(Out, In, TranslationOffset); \
+ ACPI_COPY_FIELD(Out, In, AddressLength); \
+ ACPI_COPY_FIELD(Out, In, ResourceSource);
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiRsMatchVendorResource (
+ ACPI_RESOURCE *Resource,
+ void *Context);
+
+static ACPI_STATUS
+AcpiRsValidateParameters (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *Buffer,
+ ACPI_NAMESPACE_NODE **ReturnNode);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsValidateParameters
+ *
+ * PARAMETERS: DeviceHandle - Handle to a device
+ * Buffer - Pointer to a data buffer
+ * ReturnNode - Pointer to where the device node is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Common parameter validation for resource interfaces
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiRsValidateParameters (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *Buffer,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (RsValidateParameters);
+
+
+ /*
+ * Must have a valid handle to an ACPI device
+ */
+ if (!DeviceHandle)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Node = AcpiNsValidateHandle (DeviceHandle);
+ if (!Node)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (Node->Type != ACPI_TYPE_DEVICE)
+ {
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /*
+ * Validate the user buffer object
+ *
+ * if there is a non-zero buffer length we also need a valid pointer in
+ * the buffer. If it's a zero buffer length, we'll be returning the
+ * needed buffer size (later), so keep going.
+ */
+ Status = AcpiUtValidateBuffer (Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ *ReturnNode = Node;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetIrqRoutingTable
+ *
+ * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying
+ * RetBuffer - Pointer to a buffer to receive the
+ * current resources for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the IRQ routing table for a
+ * specific bus. The caller must first acquire a handle for the
+ * desired bus. The routine table is placed in the buffer pointed
+ * to by the RetBuffer variable parameter.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ * This function attempts to execute the _PRT method contained in
+ * the object indicated by the passed DeviceHandle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetIrqRoutingTable (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
+
+
+ /* Validate parameters then dispatch to internal routine */
+
+ Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetCurrentResources
+ *
+ * PARAMETERS: DeviceHandle - Handle to the device object for the
+ * device we are querying
+ * RetBuffer - Pointer to a buffer to receive the
+ * current resources for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the current resources for a
+ * specific device. The caller must first acquire a handle for
+ * the desired device. The resource data is placed in the buffer
+ * pointed to by the RetBuffer variable parameter.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ * This function attempts to execute the _CRS method contained in
+ * the object indicated by the passed DeviceHandle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetCurrentResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
+
+
+ /* Validate parameters then dispatch to internal routine */
+
+ Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetPossibleResources
+ *
+ * PARAMETERS: DeviceHandle - Handle to the device object for the
+ * device we are querying
+ * RetBuffer - Pointer to a buffer to receive the
+ * resources for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get a list of the possible resources
+ * for a specific device. The caller must first acquire a handle
+ * for the desired device. The resource data is placed in the
+ * buffer pointed to by the RetBuffer variable.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetPossibleResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
+
+
+ /* Validate parameters then dispatch to internal routine */
+
+ Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSetCurrentResources
+ *
+ * PARAMETERS: DeviceHandle - Handle to the device object for the
+ * device we are setting resources
+ * InBuffer - Pointer to a buffer containing the
+ * resources to be set for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to set the current resources for a
+ * specific device. The caller must first acquire a handle for
+ * the desired device. The resource data is passed to the routine
+ * the buffer pointed to by the InBuffer variable.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetCurrentResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *InBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
+
+
+ /* Validate the buffer, don't allow zero length */
+
+ if ((!InBuffer) ||
+ (!InBuffer->Pointer) ||
+ (!InBuffer->Length))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Validate parameters then dispatch to internal routine */
+
+ Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsSetSrsMethodData (Node, InBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetEventResources
+ *
+ * PARAMETERS: DeviceHandle - Handle to the device object for the
+ * device we are getting resources
+ * InBuffer - Pointer to a buffer containing the
+ * resources to be set for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the event resources for a
+ * specific device. The caller must first acquire a handle for
+ * the desired device. The resource data is passed to the routine
+ * the buffer pointed to by the InBuffer variable. Uses the
+ * _AEI method.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetEventResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetEventResources);
+
+
+ /* Validate parameters then dispatch to internal routine */
+
+ Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsGetAeiMethodData (Node, RetBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetEventResources)
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiResourceToAddress64
+ *
+ * PARAMETERS: Resource - Pointer to a resource
+ * Out - Pointer to the users's return buffer
+ * (a struct acpi_resource_address64)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: If the resource is an address16, address32, or address64,
+ * copy it to the address64 return buffer. This saves the
+ * caller from having to duplicate code for different-sized
+ * addresses.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiResourceToAddress64 (
+ ACPI_RESOURCE *Resource,
+ ACPI_RESOURCE_ADDRESS64 *Out)
+{
+ ACPI_RESOURCE_ADDRESS16 *Address16;
+ ACPI_RESOURCE_ADDRESS32 *Address32;
+
+
+ if (!Resource || !Out)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Convert 16 or 32 address descriptor to 64 */
+
+ switch (Resource->Type)
+ {
+ case ACPI_RESOURCE_TYPE_ADDRESS16:
+
+ Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data);
+ ACPI_COPY_ADDRESS (Out, Address16);
+ break;
+
+ case ACPI_RESOURCE_TYPE_ADDRESS32:
+
+ Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data);
+ ACPI_COPY_ADDRESS (Out, Address32);
+ break;
+
+ case ACPI_RESOURCE_TYPE_ADDRESS64:
+
+ /* Simple copy for 64 bit source */
+
+ ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
+ break;
+
+ default:
+ return (AE_BAD_PARAMETER);
+ }
+
+ return (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetVendorResource
+ *
+ * PARAMETERS: DeviceHandle - Handle for the parent device object
+ * Name - Method name for the parent resource
+ * (METHOD_NAME__CRS or METHOD_NAME__PRS)
+ * Uuid - Pointer to the UUID to be matched.
+ * includes both subtype and 16-byte UUID
+ * RetBuffer - Where the vendor resource is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk a resource template for the specified evice to find a
+ * vendor-defined resource that matches the supplied UUID and
+ * UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetVendorResource (
+ ACPI_HANDLE DeviceHandle,
+ char *Name,
+ ACPI_VENDOR_UUID *Uuid,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_VENDOR_WALK_INFO Info;
+ ACPI_STATUS Status;
+
+
+ /* Other parameters are validated by AcpiWalkResources */
+
+ if (!Uuid || !RetBuffer)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Info.Uuid = Uuid;
+ Info.Buffer = RetBuffer;
+ Info.Status = AE_NOT_EXIST;
+
+ /* Walk the _CRS or _PRS resource list for this device */
+
+ Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource,
+ &Info);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ return (Info.Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetVendorResource)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMatchVendorResource
+ *
+ * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiRsMatchVendorResource (
+ ACPI_RESOURCE *Resource,
+ void *Context)
+{
+ ACPI_VENDOR_WALK_INFO *Info = Context;
+ ACPI_RESOURCE_VENDOR_TYPED *Vendor;
+ ACPI_BUFFER *Buffer;
+ ACPI_STATUS Status;
+
+
+ /* Ignore all descriptors except Vendor */
+
+ if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
+ {
+ return (AE_OK);
+ }
+
+ Vendor = &Resource->Data.VendorTyped;
+
+ /*
+ * For a valid match, these conditions must hold:
+ *
+ * 1) Length of descriptor data must be at least as long as a UUID struct
+ * 2) The UUID subtypes must match
+ * 3) The UUID data must match
+ */
+ if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
+ (Vendor->UuidSubtype != Info->Uuid->Subtype) ||
+ (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
+ {
+ return (AE_OK);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Buffer = Info->Buffer;
+ Status = AcpiUtInitializeBuffer (Buffer, Resource->Length);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Found the correct resource, copy and return it */
+
+ ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length);
+ Buffer->Length = Resource->Length;
+
+ /* Found the desired descriptor, terminate resource walk */
+
+ Info->Status = AE_OK;
+ return (AE_CTRL_TERMINATE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiWalkResources
+ *
+ * PARAMETERS: DeviceHandle - Handle to the device object for the
+ * device we are querying
+ * Name - Method name of the resources we want.
+ * (METHOD_NAME__CRS, METHOD_NAME__PRS, or
+ * METHOD_NAME__AEI)
+ * UserFunction - Called for each resource
+ * Context - Passed to UserFunction
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieves the current or possible resource list for the
+ * specified device. The UserFunction is called once for
+ * each resource in the list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiWalkResources (
+ ACPI_HANDLE DeviceHandle,
+ char *Name,
+ ACPI_WALK_RESOURCE_CALLBACK UserFunction,
+ void *Context)
+{
+ ACPI_STATUS Status;
+ ACPI_BUFFER Buffer;
+ ACPI_RESOURCE *Resource;
+ ACPI_RESOURCE *ResourceEnd;
+
+
+ ACPI_FUNCTION_TRACE (AcpiWalkResources);
+
+
+ /* Parameter validation */
+
+ if (!DeviceHandle || !UserFunction || !Name ||
+ (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
+ !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS) &&
+ !ACPI_COMPARE_NAME (Name, METHOD_NAME__AEI)))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Get the _CRS/_PRS/_AEI resource list */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Buffer now contains the resource list */
+
+ Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer);
+ ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length);
+
+ /* Walk the resource list until the EndTag is found (or buffer end) */
+
+ while (Resource < ResourceEnd)
+ {
+ /* Sanity check the resource */
+
+ if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
+ {
+ Status = AE_AML_INVALID_RESOURCE_TYPE;
+ break;
+ }
+
+ /* Invoke the user function, abort on any error returned */
+
+ Status = UserFunction (Resource, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_CTRL_TERMINATE)
+ {
+ /* This is an OK termination by the user function */
+
+ Status = AE_OK;
+ }
+ break;
+ }
+
+ /* EndTag indicates end-of-list */
+
+ if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
+ {
+ break;
+ }
+
+ /* Get the next resource descriptor */
+
+ Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
+ }
+
+ ACPI_FREE (Buffer.Pointer);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiWalkResources)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/tables/tbfadt.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/tables/tbfadt.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,704 @@
+/******************************************************************************
+ *
+ * Module Name: tbfadt - FADT table 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 __TBFADT_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_TABLES
+ ACPI_MODULE_NAME ("tbfadt")
+
+/* Local prototypes */
+
+static ACPI_INLINE void
+AcpiTbInitGenericAddress (
+ ACPI_GENERIC_ADDRESS *GenericAddress,
+ UINT8 SpaceId,
+ UINT8 ByteWidth,
+ UINT64 Address);
+
+static void
+AcpiTbConvertFadt (
+ void);
+
+static void
+AcpiTbValidateFadt (
+ void);
+
+static void
+AcpiTbSetupFadtRegisters (
+ void);
+
+
+/* Table for conversion of FADT to common internal format and FADT validation */
+
+typedef struct acpi_fadt_info
+{
+ char *Name;
+ UINT16 Address64;
+ UINT16 Address32;
+ UINT16 Length;
+ UINT8 DefaultLength;
+ UINT8 Type;
+
+} ACPI_FADT_INFO;
+
+#define ACPI_FADT_OPTIONAL 0
+#define ACPI_FADT_REQUIRED 1
+#define ACPI_FADT_SEPARATE_LENGTH 2
+
+static ACPI_FADT_INFO FadtInfoTable[] =
+{
+ {"Pm1aEventBlock",
+ ACPI_FADT_OFFSET (XPm1aEventBlock),
+ ACPI_FADT_OFFSET (Pm1aEventBlock),
+ ACPI_FADT_OFFSET (Pm1EventLength),
+ ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
+ ACPI_FADT_REQUIRED},
+
+ {"Pm1bEventBlock",
+ ACPI_FADT_OFFSET (XPm1bEventBlock),
+ ACPI_FADT_OFFSET (Pm1bEventBlock),
+ ACPI_FADT_OFFSET (Pm1EventLength),
+ ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
+ ACPI_FADT_OPTIONAL},
+
+ {"Pm1aControlBlock",
+ ACPI_FADT_OFFSET (XPm1aControlBlock),
+ ACPI_FADT_OFFSET (Pm1aControlBlock),
+ ACPI_FADT_OFFSET (Pm1ControlLength),
+ ACPI_PM1_REGISTER_WIDTH,
+ ACPI_FADT_REQUIRED},
+
+ {"Pm1bControlBlock",
+ ACPI_FADT_OFFSET (XPm1bControlBlock),
+ ACPI_FADT_OFFSET (Pm1bControlBlock),
+ ACPI_FADT_OFFSET (Pm1ControlLength),
+ ACPI_PM1_REGISTER_WIDTH,
+ ACPI_FADT_OPTIONAL},
+
+ {"Pm2ControlBlock",
+ ACPI_FADT_OFFSET (XPm2ControlBlock),
+ ACPI_FADT_OFFSET (Pm2ControlBlock),
+ ACPI_FADT_OFFSET (Pm2ControlLength),
+ ACPI_PM2_REGISTER_WIDTH,
+ ACPI_FADT_SEPARATE_LENGTH},
+
+ {"PmTimerBlock",
+ ACPI_FADT_OFFSET (XPmTimerBlock),
+ ACPI_FADT_OFFSET (PmTimerBlock),
+ ACPI_FADT_OFFSET (PmTimerLength),
+ ACPI_PM_TIMER_WIDTH,
+ ACPI_FADT_REQUIRED},
+
+ {"Gpe0Block",
+ ACPI_FADT_OFFSET (XGpe0Block),
+ ACPI_FADT_OFFSET (Gpe0Block),
+ ACPI_FADT_OFFSET (Gpe0BlockLength),
+ 0,
+ ACPI_FADT_SEPARATE_LENGTH},
+
+ {"Gpe1Block",
+ ACPI_FADT_OFFSET (XGpe1Block),
+ ACPI_FADT_OFFSET (Gpe1Block),
+ ACPI_FADT_OFFSET (Gpe1BlockLength),
+ 0,
+ ACPI_FADT_SEPARATE_LENGTH}
+};
+
+#define ACPI_FADT_INFO_ENTRIES \
+ (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
+
+
+/* Table used to split Event Blocks into separate status/enable registers */
+
+typedef struct acpi_fadt_pm_info
+{
+ ACPI_GENERIC_ADDRESS *Target;
+ UINT16 Source;
+ UINT8 RegisterNum;
+
+} ACPI_FADT_PM_INFO;
+
+static ACPI_FADT_PM_INFO FadtPmInfoTable[] =
+{
+ {&AcpiGbl_XPm1aStatus,
+ ACPI_FADT_OFFSET (XPm1aEventBlock),
+ 0},
+
+ {&AcpiGbl_XPm1aEnable,
+ ACPI_FADT_OFFSET (XPm1aEventBlock),
+ 1},
+
+ {&AcpiGbl_XPm1bStatus,
+ ACPI_FADT_OFFSET (XPm1bEventBlock),
+ 0},
+
+ {&AcpiGbl_XPm1bEnable,
+ ACPI_FADT_OFFSET (XPm1bEventBlock),
+ 1}
+};
+
+#define ACPI_FADT_PM_INFO_ENTRIES \
+ (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbInitGenericAddress
+ *
+ * PARAMETERS: GenericAddress - GAS struct to be initialized
+ * SpaceId - ACPI Space ID for this register
+ * ByteWidth - Width of this register, in bytes
+ * Address - Address of the register
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize a Generic Address Structure (GAS)
+ * See the ACPI specification for a full description and
+ * definition of this structure.
+ *
+ ******************************************************************************/
+
+static ACPI_INLINE void
+AcpiTbInitGenericAddress (
+ ACPI_GENERIC_ADDRESS *GenericAddress,
+ UINT8 SpaceId,
+ UINT8 ByteWidth,
+ UINT64 Address)
+{
+
+ /*
+ * The 64-bit Address field is non-aligned in the byte packed
+ * GAS struct.
+ */
+ ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address);
+
+ /* All other fields are byte-wide */
+
+ GenericAddress->SpaceId = SpaceId;
+ GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth);
+ GenericAddress->BitOffset = 0;
+ GenericAddress->AccessWidth = 0; /* Access width ANY */
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbParseFadt
+ *
+ * PARAMETERS: TableIndex - Index for the FADT
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
+ * (FADT contains the addresses of the DSDT and FACS)
+ *
+ ******************************************************************************/
+
+void
+AcpiTbParseFadt (
+ UINT32 TableIndex)
+{
+ UINT32 Length;
+ ACPI_TABLE_HEADER *Table;
+
+
+ /*
+ * The FADT has multiple versions with different lengths,
+ * and it contains pointers to both the DSDT and FACS tables.
+ *
+ * Get a local copy of the FADT and convert it to a common format
+ * Map entire FADT, assumed to be smaller than one page.
+ */
+ Length = AcpiGbl_RootTableList.Tables[TableIndex].Length;
+
+ Table = AcpiOsMapMemory (
+ AcpiGbl_RootTableList.Tables[TableIndex].Address, Length);
+ if (!Table)
+ {
+ return;
+ }
+
+ /*
+ * Validate the FADT checksum before we copy the table. Ignore
+ * checksum error as we want to try to get the DSDT and FACS.
+ */
+ (void) AcpiTbVerifyChecksum (Table, Length);
+
+ /* Create a local copy of the FADT in common ACPI 2.0+ format */
+
+ AcpiTbCreateLocalFadt (Table, Length);
+
+ /* All done with the real FADT, unmap it */
+
+ AcpiOsUnmapMemory (Table, Length);
+
+ /* Obtain the DSDT and FACS tables via their addresses within the FADT */
+
+ AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
+ ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
+
+ /* If Hardware Reduced flag is set, there is no FACS */
+
+ if (!AcpiGbl_ReducedHardware)
+ {
+ AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
+ ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbCreateLocalFadt
+ *
+ * PARAMETERS: Table - Pointer to BIOS FADT
+ * Length - Length of the table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
+ * Performs validation on some important FADT fields.
+ *
+ * NOTE: We create a local copy of the FADT regardless of the version.
+ *
+ ******************************************************************************/
+
+void
+AcpiTbCreateLocalFadt (
+ ACPI_TABLE_HEADER *Table,
+ UINT32 Length)
+{
+
+ /*
+ * Check if the FADT is larger than the largest table that we expect
+ * (the ACPI 5.0 version). If so, truncate the table, and issue
+ * a warning.
+ */
+ if (Length > sizeof (ACPI_TABLE_FADT))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "FADT (revision %u) is longer than ACPI 5.0 version, "
+ "truncating length %u to %u",
+ Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT)));
+ }
+
+ /* Clear the entire local FADT */
+
+ ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
+
+ /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
+
+ ACPI_MEMCPY (&AcpiGbl_FADT, Table,
+ ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
+
+ /* Take a copy of the Hardware Reduced flag */
+
+ AcpiGbl_ReducedHardware = FALSE;
+ if (AcpiGbl_FADT.Flags & ACPI_FADT_HW_REDUCED)
+ {
+ AcpiGbl_ReducedHardware = TRUE;
+ }
+
+ /* Convert the local copy of the FADT to the common internal format */
+
+ AcpiTbConvertFadt ();
+
+ /* Validate FADT values now, before we make any changes */
+
+ AcpiTbValidateFadt ();
+
+ /* Initialize the global ACPI register structures */
+
+ AcpiTbSetupFadtRegisters ();
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbConvertFadt
+ *
+ * PARAMETERS: None, uses AcpiGbl_FADT
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Converts all versions of the FADT to a common internal format.
+ * Expand 32-bit addresses to 64-bit as necessary.
+ *
+ * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT),
+ * and must contain a copy of the actual FADT.
+ *
+ * Notes on 64-bit register addresses:
+ *
+ * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
+ * fields of the FADT for all ACPI register addresses.
+ *
+ * The 64-bit "X" fields are optional extensions to the original 32-bit FADT
+ * V1.0 fields. Even if they are present in the FADT, they are optional and
+ * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
+ * 32-bit V1.0 fields if the corresponding X field is zero.
+ *
+ * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
+ * corresponding "X" fields in the internal FADT.
+ *
+ * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
+ * to the corresponding 64-bit X fields. For compatibility with other ACPI
+ * implementations, we ignore the 64-bit field if the 32-bit field is valid,
+ * regardless of whether the host OS is 32-bit or 64-bit.
+ *
+ ******************************************************************************/
+
+static void
+AcpiTbConvertFadt (
+ void)
+{
+ ACPI_GENERIC_ADDRESS *Address64;
+ UINT32 Address32;
+ UINT32 i;
+
+
+ /* Update the local FADT table header length */
+
+ AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
+
+ /*
+ * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
+ * Later code will always use the X 64-bit field.
+ */
+ if (!AcpiGbl_FADT.XFacs)
+ {
+ AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
+ }
+ if (!AcpiGbl_FADT.XDsdt)
+ {
+ AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
+ }
+
+ /*
+ * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
+ * should be zero are indeed zero. This will workaround BIOSs that
+ * inadvertently place values in these fields.
+ *
+ * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
+ * at offset 45, 55, 95, and the word located at offset 109, 110.
+ *
+ * Note: The FADT revision value is unreliable. Only the length can be
+ * trusted.
+ */
+ if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
+ {
+ AcpiGbl_FADT.PreferredProfile = 0;
+ AcpiGbl_FADT.PstateControl = 0;
+ AcpiGbl_FADT.CstControl = 0;
+ AcpiGbl_FADT.BootFlags = 0;
+ }
+
+ /*
+ * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
+ * generic address structures as necessary. Later code will always use
+ * the 64-bit address structures.
+ *
+ * March 2009:
+ * We now always use the 32-bit address if it is valid (non-null). This
+ * is not in accordance with the ACPI specification which states that
+ * the 64-bit address supersedes the 32-bit version, but we do this for
+ * compatibility with other ACPI implementations. Most notably, in the
+ * case where both the 32 and 64 versions are non-null, we use the 32-bit
+ * version. This is the only address that is guaranteed to have been
+ * tested by the BIOS manufacturer.
+ */
+ for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
+ {
+ Address32 = *ACPI_ADD_PTR (UINT32,
+ &AcpiGbl_FADT, FadtInfoTable[i].Address32);
+
+ Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
+ &AcpiGbl_FADT, FadtInfoTable[i].Address64);
+
+ /*
+ * If both 32- and 64-bit addresses are valid (non-zero),
+ * they must match.
+ */
+ if (Address64->Address && Address32 &&
+ (Address64->Address != (UINT64) Address32))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32",
+ FadtInfoTable[i].Name, Address32,
+ ACPI_FORMAT_UINT64 (Address64->Address)));
+ }
+
+ /* Always use 32-bit address if it is valid (non-null) */
+
+ if (Address32)
+ {
+ /*
+ * Copy the 32-bit address to the 64-bit GAS structure. The
+ * Space ID is always I/O for 32-bit legacy address fields
+ */
+ AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO,
+ *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length),
+ (UINT64) Address32);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbValidateFadt
+ *
+ * PARAMETERS: Table - Pointer to the FADT to be validated
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Validate various important fields within the FADT. If a problem
+ * is found, issue a message, but no status is returned.
+ * Used by both the table manager and the disassembler.
+ *
+ * Possible additional checks:
+ * (AcpiGbl_FADT.Pm1EventLength >= 4)
+ * (AcpiGbl_FADT.Pm1ControlLength >= 2)
+ * (AcpiGbl_FADT.PmTimerLength >= 4)
+ * Gpe block lengths must be multiple of 2
+ *
+ ******************************************************************************/
+
+static void
+AcpiTbValidateFadt (
+ void)
+{
+ char *Name;
+ ACPI_GENERIC_ADDRESS *Address64;
+ UINT8 Length;
+ UINT32 i;
+
+
+ /*
+ * Check for FACS and DSDT address mismatches. An address mismatch between
+ * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
+ * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
+ */
+ if (AcpiGbl_FADT.Facs &&
+ (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "32/64X FACS address mismatch in FADT - "
+ "0x%8.8X/0x%8.8X%8.8X, using 32",
+ AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs)));
+
+ AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
+ }
+
+ if (AcpiGbl_FADT.Dsdt &&
+ (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "32/64X DSDT address mismatch in FADT - "
+ "0x%8.8X/0x%8.8X%8.8X, using 32",
+ AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt)));
+
+ AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
+ }
+
+ /* If Hardware Reduced flag is set, we are all done */
+
+ if (AcpiGbl_ReducedHardware)
+ {
+ return;
+ }
+
+ /* Examine all of the 64-bit extended address fields (X fields) */
+
+ for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
+ {
+ /*
+ * Generate pointer to the 64-bit address, get the register
+ * length (width) and the register name
+ */
+ Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
+ &AcpiGbl_FADT, FadtInfoTable[i].Address64);
+ Length = *ACPI_ADD_PTR (UINT8,
+ &AcpiGbl_FADT, FadtInfoTable[i].Length);
+ Name = FadtInfoTable[i].Name;
+
+ /*
+ * For each extended field, check for length mismatch between the
+ * legacy length field and the corresponding 64-bit X length field.
+ */
+ if (Address64->Address &&
+ (Address64->BitWidth != ACPI_MUL_8 (Length)))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "32/64X length mismatch in %s: %u/%u",
+ Name, ACPI_MUL_8 (Length), Address64->BitWidth));
+ }
+
+ if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED)
+ {
+ /*
+ * Field is required (PM1aEvent, PM1aControl, PmTimer).
+ * Both the address and length must be non-zero.
+ */
+ if (!Address64->Address || !Length)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Required field %s has zero address and/or length:"
+ " 0x%8.8X%8.8X/0x%X",
+ Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
+ }
+ }
+ else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH)
+ {
+ /*
+ * Field is optional (PM2Control, GPE0, GPE1) AND has its own
+ * length field. If present, both the address and length must
+ * be valid.
+ */
+ if ((Address64->Address && !Length) ||
+ (!Address64->Address && Length))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Optional field %s has zero address or length: "
+ "0x%8.8X%8.8X/0x%X",
+ Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
+ }
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbSetupFadtRegisters
+ *
+ * PARAMETERS: None, uses AcpiGbl_FADT.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
+ * force FADT register definitions to their default lengths.
+ *
+ ******************************************************************************/
+
+static void
+AcpiTbSetupFadtRegisters (
+ void)
+{
+ ACPI_GENERIC_ADDRESS *Target64;
+ ACPI_GENERIC_ADDRESS *Source64;
+ UINT8 Pm1RegisterByteWidth;
+ UINT32 i;
+
+
+ /*
+ * Optionally check all register lengths against the default values and
+ * update them if they are incorrect.
+ */
+ if (AcpiGbl_UseDefaultRegisterWidths)
+ {
+ for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
+ {
+ Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
+ FadtInfoTable[i].Address64);
+
+ /*
+ * If a valid register (Address != 0) and the (DefaultLength > 0)
+ * (Not a GPE register), then check the width against the default.
+ */
+ if ((Target64->Address) &&
+ (FadtInfoTable[i].DefaultLength > 0) &&
+ (FadtInfoTable[i].DefaultLength != Target64->BitWidth))
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Invalid length for %s: %u, using default %u",
+ FadtInfoTable[i].Name, Target64->BitWidth,
+ FadtInfoTable[i].DefaultLength));
+
+ /* Incorrect size, set width to the default */
+
+ Target64->BitWidth = FadtInfoTable[i].DefaultLength;
+ }
+ }
+ }
+
+ /*
+ * Get the length of the individual PM1 registers (enable and status).
+ * Each register is defined to be (event block length / 2). Extra divide
+ * by 8 converts bits to bytes.
+ */
+ Pm1RegisterByteWidth = (UINT8)
+ ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth);
+
+ /*
+ * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
+ * registers. These addresses do not appear (directly) in the FADT, so it
+ * is useful to pre-calculate them from the PM1 Event Block definitions.
+ *
+ * The PM event blocks are split into two register blocks, first is the
+ * PM Status Register block, followed immediately by the PM Enable
+ * Register block. Each is of length (Pm1EventLength/2)
+ *
+ * Note: The PM1A event block is required by the ACPI specification.
+ * However, the PM1B event block is optional and is rarely, if ever,
+ * used.
+ */
+
+ for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++)
+ {
+ Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
+ FadtPmInfoTable[i].Source);
+
+ if (Source64->Address)
+ {
+ AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
+ Source64->SpaceId, Pm1RegisterByteWidth,
+ Source64->Address +
+ (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth));
+ }
+ }
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/tables/tbfind.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/tables/tbfind.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,143 @@
+/******************************************************************************
+ *
+ * Module Name: tbfind - find table
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __TBFIND_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_TABLES
+ ACPI_MODULE_NAME ("tbfind")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbFindTable
+ *
+ * PARAMETERS: Signature - String with ACPI table signature
+ * OemId - String with the table OEM ID
+ * OemTableId - String with the OEM Table ID
+ * TableIndex - Where the table index is returned
+ *
+ * RETURN: Status and table index
+ *
+ * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
+ * Signature, OEM ID and OEM Table ID. Returns an index that can
+ * be used to get the table header or entire table.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbFindTable (
+ char *Signature,
+ char *OemId,
+ char *OemTableId,
+ UINT32 *TableIndex)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+ ACPI_TABLE_HEADER Header;
+
+
+ ACPI_FUNCTION_TRACE (TbFindTable);
+
+
+ /* Normalize the input strings */
+
+ ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER));
+ ACPI_STRNCPY (Header.Signature, Signature, ACPI_NAME_SIZE);
+ ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE);
+ ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE);
+
+ /* Search for the table */
+
+ for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
+ {
+ if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ Header.Signature, ACPI_NAME_SIZE))
+ {
+ /* Not the requested table */
+
+ continue;
+ }
+
+ /* Table with matching signature has been found */
+
+ if (!AcpiGbl_RootTableList.Tables[i].Pointer)
+ {
+ /* Table is not currently mapped, map it */
+
+ Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!AcpiGbl_RootTableList.Tables[i].Pointer)
+ {
+ continue;
+ }
+ }
+
+ /* Check for table match on all IDs */
+
+ if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature,
+ Header.Signature, ACPI_NAME_SIZE) &&
+ (!OemId[0] ||
+ !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId,
+ Header.OemId, ACPI_OEM_ID_SIZE)) &&
+ (!OemTableId[0] ||
+ !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId,
+ Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE)))
+ {
+ *TableIndex = i;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
+ Header.Signature));
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ return_ACPI_STATUS (AE_NOT_FOUND);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/tables/tbinstal.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/tables/tbinstal.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,806 @@
+/******************************************************************************
+ *
+ * Module Name: tbinstal - ACPI table installation and removal
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __TBINSTAL_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/actables.h>
+
+
+#define _COMPONENT ACPI_TABLES
+ ACPI_MODULE_NAME ("tbinstal")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiTbVerifyTable
+ *
+ * PARAMETERS: TableDesc - table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: this function is called to verify and map table
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiTbVerifyTable (
+ ACPI_TABLE_DESC *TableDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (TbVerifyTable);
+
+
+ /* Map the table if necessary */
+
+ if (!TableDesc->Pointer)
+ {
+ if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
+ ACPI_TABLE_ORIGIN_MAPPED)
+ {
+ TableDesc->Pointer = AcpiOsMapMemory (
+ TableDesc->Address, TableDesc->Length);
+ }
+
+ if (!TableDesc->Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ }
+
+ /* FACS is the odd table, has no standard ACPI header and no checksum */
+
+ if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
+ {
+ /* Always calculate checksum, ignore bad checksum if requested */
+
+ Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbAddTable
+ *
+ * PARAMETERS: TableDesc - Table descriptor
+ * TableIndex - Where the table index is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to add an ACPI table. It is used to
+ * dynamically load tables via the Load and LoadTable AML
+ * operators.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbAddTable (
+ ACPI_TABLE_DESC *TableDesc,
+ UINT32 *TableIndex)
+{
+ UINT32 i;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (TbAddTable);
+
+
+ if (!TableDesc->Pointer)
+ {
+ Status = AcpiTbVerifyTable (TableDesc);
+ if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Validate the incoming table signature.
+ *
+ * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
+ * 2) We added support for OEMx tables, signature "OEM".
+ * 3) Valid tables were encountered with a null signature, so we just
+ * gave up on validating the signature, (05/2008).
+ * 4) We encountered non-AML tables such as the MADT, which caused
+ * interpreter errors and kernel faults. So now, we once again allow
+ * only "SSDT", "OEMx", and now, also a null signature. (05/2011).
+ */
+ if ((TableDesc->Pointer->Signature[0] != 0x00) &&
+ (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
+ (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
+ AcpiUtValidAcpiName (*(UINT32 *) TableDesc->Pointer->Signature) ?
+ TableDesc->Pointer->Signature : "????",
+ *(UINT32 *) TableDesc->Pointer->Signature));
+
+ return_ACPI_STATUS (AE_BAD_SIGNATURE);
+ }
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+
+ /* Check if table is already registered */
+
+ for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
+ {
+ if (!AcpiGbl_RootTableList.Tables[i].Pointer)
+ {
+ Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
+ if (ACPI_FAILURE (Status) ||
+ !AcpiGbl_RootTableList.Tables[i].Pointer)
+ {
+ continue;
+ }
+ }
+
+ /*
+ * Check for a table match on the entire table length,
+ * not just the header.
+ */
+ if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length)
+ {
+ continue;
+ }
+
+ if (ACPI_MEMCMP (TableDesc->Pointer,
+ AcpiGbl_RootTableList.Tables[i].Pointer,
+ AcpiGbl_RootTableList.Tables[i].Length))
+ {
+ continue;
+ }
+
+ /*
+ * Note: the current mechanism does not unregister a table if it is
+ * dynamically unloaded. The related namespace entries are deleted,
+ * but the table remains in the root table list.
+ *
+ * The assumption here is that the number of different tables that
+ * will be loaded is actually small, and there is minimal overhead
+ * in just keeping the table in case it is needed again.
+ *
+ * If this assumption changes in the future (perhaps on large
+ * machines with many table load/unload operations), tables will
+ * need to be unregistered when they are unloaded, and slots in the
+ * root table list should be reused when empty.
+ */
+
+ /*
+ * Table is already registered.
+ * We can delete the table that was passed as a parameter.
+ */
+ AcpiTbDeleteTable (TableDesc);
+ *TableIndex = i;
+
+ if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
+ {
+ /* Table is still loaded, this is an error */
+
+ Status = AE_ALREADY_EXISTS;
+ goto Release;
+ }
+ else
+ {
+ /* Table was unloaded, allow it to be reloaded */
+
+ TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
+ TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
+ Status = AE_OK;
+ goto PrintHeader;
+ }
+ }
+
+ /*
+ * ACPI Table Override:
+ * Allow the host to override dynamically loaded tables.
+ * NOTE: the table is fully mapped at this point, and the mapping will
+ * be deleted by TbTableOverride if the table is actually overridden.
+ */
+ (void) AcpiTbTableOverride (TableDesc->Pointer, TableDesc);
+
+ /* Add the table to the global root table list */
+
+ Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
+ TableDesc->Length, TableDesc->Flags, TableIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Release;
+ }
+
+PrintHeader:
+ AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
+
+Release:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbTableOverride
+ *
+ * PARAMETERS: TableHeader - Header for the original table
+ * TableDesc - Table descriptor initialized for the
+ * original table. May or may not be mapped.
+ *
+ * RETURN: Pointer to the entire new table. NULL if table not overridden.
+ * If overridden, installs the new table within the input table
+ * descriptor.
+ *
+ * DESCRIPTION: Attempt table override by calling the OSL override functions.
+ * Note: If the table is overridden, then the entire new table
+ * is mapped and returned by this function.
+ *
+ ******************************************************************************/
+
+ACPI_TABLE_HEADER *
+AcpiTbTableOverride (
+ ACPI_TABLE_HEADER *TableHeader,
+ ACPI_TABLE_DESC *TableDesc)
+{
+ ACPI_STATUS Status;
+ ACPI_TABLE_HEADER *NewTable = NULL;
+ ACPI_PHYSICAL_ADDRESS NewAddress = 0;
+ UINT32 NewTableLength = 0;
+ UINT8 NewFlags;
+ char *OverrideType;
+
+
+ /* (1) Attempt logical override (returns a logical address) */
+
+ Status = AcpiOsTableOverride (TableHeader, &NewTable);
+ if (ACPI_SUCCESS (Status) && NewTable)
+ {
+ NewAddress = ACPI_PTR_TO_PHYSADDR (NewTable);
+ NewTableLength = NewTable->Length;
+ NewFlags = ACPI_TABLE_ORIGIN_OVERRIDE;
+ OverrideType = "Logical";
+ goto FinishOverride;
+ }
+
+ /* (2) Attempt physical override (returns a physical address) */
+
+ Status = AcpiOsPhysicalTableOverride (TableHeader,
+ &NewAddress, &NewTableLength);
+ if (ACPI_SUCCESS (Status) && NewAddress && NewTableLength)
+ {
+ /* Map the entire new table */
+
+ NewTable = AcpiOsMapMemory (NewAddress, NewTableLength);
+ if (!NewTable)
+ {
+ ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
+ "%4.4s %p Attempted physical table override failed",
+ TableHeader->Signature,
+ ACPI_CAST_PTR (void, TableDesc->Address)));
+ return (NULL);
+ }
+
+ OverrideType = "Physical";
+ NewFlags = ACPI_TABLE_ORIGIN_MAPPED;
+ goto FinishOverride;
+ }
+
+ return (NULL); /* There was no override */
+
+
+FinishOverride:
+
+ ACPI_INFO ((AE_INFO,
+ "%4.4s %p %s table override, new table: %p",
+ TableHeader->Signature,
+ ACPI_CAST_PTR (void, TableDesc->Address),
+ OverrideType, NewTable));
+
+ /* We can now unmap/delete the original table (if fully mapped) */
+
+ AcpiTbDeleteTable (TableDesc);
+
+ /* Setup descriptor for the new table */
+
+ TableDesc->Address = NewAddress;
+ TableDesc->Pointer = NewTable;
+ TableDesc->Length = NewTableLength;
+ TableDesc->Flags = NewFlags;
+
+ return (NewTable);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbResizeRootTableList
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Expand the size of global table array
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbResizeRootTableList (
+ void)
+{
+ ACPI_TABLE_DESC *Tables;
+
+
+ ACPI_FUNCTION_TRACE (TbResizeRootTableList);
+
+
+ /* AllowResize flag is a parameter to AcpiInitializeTables */
+
+ if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
+ {
+ ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
+ return_ACPI_STATUS (AE_SUPPORT);
+ }
+
+ /* Increase the Table Array size */
+
+ Tables = ACPI_ALLOCATE_ZEROED (
+ ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
+ ACPI_ROOT_TABLE_SIZE_INCREMENT) *
+ sizeof (ACPI_TABLE_DESC));
+ if (!Tables)
+ {
+ ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy and free the previous table array */
+
+ if (AcpiGbl_RootTableList.Tables)
+ {
+ ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
+ (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
+
+ if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
+ {
+ ACPI_FREE (AcpiGbl_RootTableList.Tables);
+ }
+ }
+
+ AcpiGbl_RootTableList.Tables = Tables;
+ AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
+ AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbStoreTable
+ *
+ * PARAMETERS: Address - Table address
+ * Table - Table header
+ * Length - Table length
+ * Flags - flags
+ *
+ * RETURN: Status and table index.
+ *
+ * DESCRIPTION: Add an ACPI table to the global table list
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbStoreTable (
+ ACPI_PHYSICAL_ADDRESS Address,
+ ACPI_TABLE_HEADER *Table,
+ UINT32 Length,
+ UINT8 Flags,
+ UINT32 *TableIndex)
+{
+ ACPI_STATUS Status;
+ ACPI_TABLE_DESC *NewTable;
+
+
+ /* Ensure that there is room for the table in the Root Table List */
+
+ if (AcpiGbl_RootTableList.CurrentTableCount >=
+ AcpiGbl_RootTableList.MaxTableCount)
+ {
+ Status = AcpiTbResizeRootTableList();
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount];
+
+ /* Initialize added table */
+
+ NewTable->Address = Address;
+ NewTable->Pointer = Table;
+ NewTable->Length = Length;
+ NewTable->OwnerId = 0;
+ NewTable->Flags = Flags;
+
+ ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature);
+
+ *TableIndex = AcpiGbl_RootTableList.CurrentTableCount;
+ AcpiGbl_RootTableList.CurrentTableCount++;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbDeleteTable
+ *
+ * PARAMETERS: TableIndex - Table index
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Delete one internal ACPI table
+ *
+ ******************************************************************************/
+
+void
+AcpiTbDeleteTable (
+ ACPI_TABLE_DESC *TableDesc)
+{
+
+ /* Table must be mapped or allocated */
+
+ if (!TableDesc->Pointer)
+ {
+ return;
+ }
+
+ switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
+ {
+ case ACPI_TABLE_ORIGIN_MAPPED:
+ AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
+ break;
+
+ case ACPI_TABLE_ORIGIN_ALLOCATED:
+ ACPI_FREE (TableDesc->Pointer);
+ break;
+
+ default:
+ break;
+ }
+
+ TableDesc->Pointer = NULL;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbTerminate
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Delete all internal ACPI tables
+ *
+ ******************************************************************************/
+
+void
+AcpiTbTerminate (
+ void)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (TbTerminate);
+
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+
+ /* Delete the individual tables */
+
+ for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
+ {
+ AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
+ }
+
+ /*
+ * Delete the root table array if allocated locally. Array cannot be
+ * mapped, so we don't need to check for that flag.
+ */
+ if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
+ {
+ ACPI_FREE (AcpiGbl_RootTableList.Tables);
+ }
+
+ AcpiGbl_RootTableList.Tables = NULL;
+ AcpiGbl_RootTableList.Flags = 0;
+ AcpiGbl_RootTableList.CurrentTableCount = 0;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbDeleteNamespaceByOwner
+ *
+ * PARAMETERS: TableIndex - Table index
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Delete all namespace objects created when this table was loaded.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbDeleteNamespaceByOwner (
+ UINT32 TableIndex)
+{
+ ACPI_OWNER_ID OwnerId;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
+ {
+ /* The table index does not exist */
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /* Get the owner ID for this table, used to delete namespace nodes */
+
+ OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+
+ /*
+ * Need to acquire the namespace writer lock to prevent interference
+ * with any concurrent namespace walks. The interpreter must be
+ * released during the deletion since the acquisition of the deletion
+ * lock may block, and also since the execution of a namespace walk
+ * must be allowed to use the interpreter.
+ */
+ (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
+ Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
+
+ AcpiNsDeleteNamespaceByOwner (OwnerId);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbAllocateOwnerId
+ *
+ * PARAMETERS: TableIndex - Table index
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Allocates OwnerId in TableDesc
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbAllocateOwnerId (
+ UINT32 TableIndex)
+{
+ ACPI_STATUS Status = AE_BAD_PARAMETER;
+
+
+ ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
+
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
+ {
+ Status = AcpiUtAllocateOwnerId
+ (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbReleaseOwnerId
+ *
+ * PARAMETERS: TableIndex - Table index
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Releases OwnerId in TableDesc
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbReleaseOwnerId (
+ UINT32 TableIndex)
+{
+ ACPI_STATUS Status = AE_BAD_PARAMETER;
+
+
+ ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
+
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
+ {
+ AcpiUtReleaseOwnerId (
+ &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
+ Status = AE_OK;
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbGetOwnerId
+ *
+ * PARAMETERS: TableIndex - Table index
+ * OwnerId - Where the table OwnerId is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: returns OwnerId for the ACPI table
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbGetOwnerId (
+ UINT32 TableIndex,
+ ACPI_OWNER_ID *OwnerId)
+{
+ ACPI_STATUS Status = AE_BAD_PARAMETER;
+
+
+ ACPI_FUNCTION_TRACE (TbGetOwnerId);
+
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
+ {
+ *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
+ Status = AE_OK;
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbIsTableLoaded
+ *
+ * PARAMETERS: TableIndex - Table index
+ *
+ * RETURN: Table Loaded Flag
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiTbIsTableLoaded (
+ UINT32 TableIndex)
+{
+ BOOLEAN IsLoaded = FALSE;
+
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
+ {
+ IsLoaded = (BOOLEAN)
+ (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
+ ACPI_TABLE_IS_LOADED);
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return (IsLoaded);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbSetTableLoadedFlag
+ *
+ * PARAMETERS: TableIndex - Table index
+ * IsLoaded - TRUE if table is loaded, FALSE otherwise
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
+ *
+ ******************************************************************************/
+
+void
+AcpiTbSetTableLoadedFlag (
+ UINT32 TableIndex,
+ BOOLEAN IsLoaded)
+{
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
+ {
+ if (IsLoaded)
+ {
+ AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
+ ACPI_TABLE_IS_LOADED;
+ }
+ else
+ {
+ AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
+ ~ACPI_TABLE_IS_LOADED;
+ }
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/tables/tbutils.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/tables/tbutils.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,775 @@
+/******************************************************************************
+ *
+ * Module Name: tbutils - table 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 __TBUTILS_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_TABLES
+ ACPI_MODULE_NAME ("tbutils")
+
+
+/* Local prototypes */
+
+static void
+AcpiTbFixString (
+ char *String,
+ ACPI_SIZE Length);
+
+static void
+AcpiTbCleanupTableHeader (
+ ACPI_TABLE_HEADER *OutHeader,
+ ACPI_TABLE_HEADER *Header);
+
+static ACPI_PHYSICAL_ADDRESS
+AcpiTbGetRootTableEntry (
+ UINT8 *TableEntry,
+ UINT32 TableEntrySize);
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbInitializeFacs
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
+ * for accessing the Global Lock and Firmware Waking Vector
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbInitializeFacs (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ /* If Hardware Reduced flag is set, there is no FACS */
+
+ if (AcpiGbl_ReducedHardware)
+ {
+ AcpiGbl_FACS = NULL;
+ return (AE_OK);
+ }
+
+ Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS,
+ ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS));
+ return (Status);
+}
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbTablesLoaded
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: TRUE if required ACPI tables are loaded
+ *
+ * DESCRIPTION: Determine if the minimum required ACPI tables are present
+ * (FADT, FACS, DSDT)
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiTbTablesLoaded (
+ void)
+{
+
+ if (AcpiGbl_RootTableList.CurrentTableCount >= 3)
+ {
+ return (TRUE);
+ }
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbFixString
+ *
+ * PARAMETERS: String - String to be repaired
+ * Length - Maximum length
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
+ * with a question mark '?'.
+ *
+ ******************************************************************************/
+
+static void
+AcpiTbFixString (
+ char *String,
+ ACPI_SIZE Length)
+{
+
+ while (Length && *String)
+ {
+ if (!ACPI_IS_PRINT (*String))
+ {
+ *String = '?';
+ }
+ String++;
+ Length--;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbCleanupTableHeader
+ *
+ * PARAMETERS: OutHeader - Where the cleaned header is returned
+ * Header - Input ACPI table header
+ *
+ * RETURN: Returns the cleaned header in OutHeader
+ *
+ * DESCRIPTION: Copy the table header and ensure that all "string" fields in
+ * the header consist of printable characters.
+ *
+ ******************************************************************************/
+
+static void
+AcpiTbCleanupTableHeader (
+ ACPI_TABLE_HEADER *OutHeader,
+ ACPI_TABLE_HEADER *Header)
+{
+
+ ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER));
+
+ AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE);
+ AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE);
+ AcpiTbFixString (OutHeader->OemTableId, ACPI_OEM_TABLE_ID_SIZE);
+ AcpiTbFixString (OutHeader->AslCompilerId, ACPI_NAME_SIZE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbPrintTableHeader
+ *
+ * PARAMETERS: Address - Table physical address
+ * Header - Table header
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
+ *
+ ******************************************************************************/
+
+void
+AcpiTbPrintTableHeader (
+ ACPI_PHYSICAL_ADDRESS Address,
+ ACPI_TABLE_HEADER *Header)
+{
+ ACPI_TABLE_HEADER LocalHeader;
+
+
+ /*
+ * The reason that the Address is cast to a void pointer is so that we
+ * can use %p which will work properly on both 32-bit and 64-bit hosts.
+ */
+ if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS))
+ {
+ /* FACS only has signature and length fields */
+
+ ACPI_INFO ((AE_INFO, "%4.4s %p %05X",
+ Header->Signature, ACPI_CAST_PTR (void, Address),
+ Header->Length));
+ }
+ else if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_RSDP))
+ {
+ /* RSDP has no common fields */
+
+ ACPI_MEMCPY (LocalHeader.OemId,
+ ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE);
+ AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE);
+
+ ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)",
+ ACPI_CAST_PTR (void, Address),
+ (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ?
+ ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20,
+ ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision,
+ LocalHeader.OemId));
+ }
+ else
+ {
+ /* Standard ACPI table with full common header */
+
+ AcpiTbCleanupTableHeader (&LocalHeader, Header);
+
+ ACPI_INFO ((AE_INFO,
+ "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
+ LocalHeader.Signature, ACPI_CAST_PTR (void, Address),
+ LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId,
+ LocalHeader.OemTableId, LocalHeader.OemRevision,
+ LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision));
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbValidateChecksum
+ *
+ * PARAMETERS: Table - ACPI table to verify
+ * Length - Length of entire table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
+ * exception on bad checksum.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbVerifyChecksum (
+ ACPI_TABLE_HEADER *Table,
+ UINT32 Length)
+{
+ UINT8 Checksum;
+
+
+ /* Compute the checksum on the table */
+
+ Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length);
+
+ /* Checksum ok? (should be zero) */
+
+ if (Checksum)
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Incorrect checksum in table [%4.4s] - 0x%2.2X, should be 0x%2.2X",
+ Table->Signature, Table->Checksum,
+ (UINT8) (Table->Checksum - Checksum)));
+
+#if (ACPI_CHECKSUM_ABORT)
+ return (AE_BAD_CHECKSUM);
+#endif
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbChecksum
+ *
+ * PARAMETERS: Buffer - Pointer to memory region to be checked
+ * Length - Length of this memory region
+ *
+ * RETURN: Checksum (UINT8)
+ *
+ * DESCRIPTION: Calculates circular checksum of memory region.
+ *
+ ******************************************************************************/
+
+UINT8
+AcpiTbChecksum (
+ UINT8 *Buffer,
+ UINT32 Length)
+{
+ UINT8 Sum = 0;
+ UINT8 *End = Buffer + Length;
+
+
+ while (Buffer < End)
+ {
+ Sum = (UINT8) (Sum + *(Buffer++));
+ }
+
+ return Sum;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbCheckDsdtHeader
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Quick compare to check validity of the DSDT. This will detect
+ * if the DSDT has been replaced from outside the OS and/or if
+ * the DSDT header has been corrupted.
+ *
+ ******************************************************************************/
+
+void
+AcpiTbCheckDsdtHeader (
+ void)
+{
+
+ /* Compare original length and checksum to current values */
+
+ if (AcpiGbl_OriginalDsdtHeader.Length != AcpiGbl_DSDT->Length ||
+ AcpiGbl_OriginalDsdtHeader.Checksum != AcpiGbl_DSDT->Checksum)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "The DSDT has been corrupted or replaced - old, new headers below"));
+ AcpiTbPrintTableHeader (0, &AcpiGbl_OriginalDsdtHeader);
+ AcpiTbPrintTableHeader (0, AcpiGbl_DSDT);
+
+ /* Disable further error messages */
+
+ AcpiGbl_OriginalDsdtHeader.Length = AcpiGbl_DSDT->Length;
+ AcpiGbl_OriginalDsdtHeader.Checksum = AcpiGbl_DSDT->Checksum;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbCopyDsdt
+ *
+ * PARAMETERS: TableDesc - Installed table to copy
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Implements a subsystem option to copy the DSDT to local memory.
+ * Some very bad BIOSs are known to either corrupt the DSDT or
+ * install a new, bad DSDT. This copy works around the problem.
+ *
+ ******************************************************************************/
+
+ACPI_TABLE_HEADER *
+AcpiTbCopyDsdt (
+ UINT32 TableIndex)
+{
+ ACPI_TABLE_HEADER *NewTable;
+ ACPI_TABLE_DESC *TableDesc;
+
+
+ TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex];
+
+ NewTable = ACPI_ALLOCATE (TableDesc->Length);
+ if (!NewTable)
+ {
+ ACPI_ERROR ((AE_INFO, "Could not copy DSDT of length 0x%X",
+ TableDesc->Length));
+ return (NULL);
+ }
+
+ ACPI_MEMCPY (NewTable, TableDesc->Pointer, TableDesc->Length);
+ AcpiTbDeleteTable (TableDesc);
+ TableDesc->Pointer = NewTable;
+ TableDesc->Flags = ACPI_TABLE_ORIGIN_ALLOCATED;
+
+ ACPI_INFO ((AE_INFO,
+ "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
+ NewTable->Length));
+
+ return (NewTable);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbInstallTable
+ *
+ * PARAMETERS: Address - Physical address of DSDT or FACS
+ * Signature - Table signature, NULL if no need to
+ * match
+ * TableIndex - Index into root table array
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Install an ACPI table into the global data structure. The
+ * table override mechanism is called to allow the host
+ * OS to replace any table before it is installed in the root
+ * table array.
+ *
+ ******************************************************************************/
+
+void
+AcpiTbInstallTable (
+ ACPI_PHYSICAL_ADDRESS Address,
+ char *Signature,
+ UINT32 TableIndex)
+{
+ ACPI_TABLE_HEADER *Table;
+ ACPI_TABLE_HEADER *FinalTable;
+ ACPI_TABLE_DESC *TableDesc;
+
+
+ if (!Address)
+ {
+ ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]",
+ Signature));
+ return;
+ }
+
+ /* Map just the table header */
+
+ Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
+ if (!Table)
+ {
+ ACPI_ERROR ((AE_INFO, "Could not map memory for table [%s] at %p",
+ Signature, ACPI_CAST_PTR (void, Address)));
+ return;
+ }
+
+ /* Skip SSDT when DSDT is overriden */
+
+ if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT) &&
+ (AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags &
+ ACPI_TABLE_ORIGIN_OVERRIDE))
+ {
+ ACPI_INFO ((AE_INFO,
+ "%4.4s @ 0x%p Table override, replaced with:", ACPI_SIG_SSDT,
+ ACPI_CAST_PTR (void, Address)));
+ AcpiTbPrintTableHeader (
+ AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Address,
+ AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer);
+ goto UnmapAndExit;
+ }
+
+ /* If a particular signature is expected (DSDT/FACS), it must match */
+
+ if (Signature &&
+ !ACPI_COMPARE_NAME (Table->Signature, Signature))
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Invalid signature 0x%X for ACPI table, expected [%s]",
+ *ACPI_CAST_PTR (UINT32, Table->Signature), Signature));
+ goto UnmapAndExit;
+ }
+
+ /*
+ * Initialize the table entry. Set the pointer to NULL, since the
+ * table is not fully mapped at this time.
+ */
+ TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex];
+
+ TableDesc->Address = Address;
+ TableDesc->Pointer = NULL;
+ TableDesc->Length = Table->Length;
+ TableDesc->Flags = ACPI_TABLE_ORIGIN_MAPPED;
+ ACPI_MOVE_32_TO_32 (TableDesc->Signature.Ascii, Table->Signature);
+
+ /*
+ * ACPI Table Override:
+ *
+ * Before we install the table, let the host OS override it with a new
+ * one if desired. Any table within the RSDT/XSDT can be replaced,
+ * including the DSDT which is pointed to by the FADT.
+ *
+ * NOTE: If the table is overridden, then FinalTable will contain a
+ * mapped pointer to the full new table. If the table is not overridden,
+ * then the table will be fully mapped elsewhere (in verify table).
+ * In any case, we must unmap the header that was mapped above.
+ */
+ FinalTable = AcpiTbTableOverride (Table, TableDesc);
+ if (!FinalTable)
+ {
+ FinalTable = Table; /* There was no override */
+ }
+
+ AcpiTbPrintTableHeader (TableDesc->Address, FinalTable);
+
+ /* Set the global integer width (based upon revision of the DSDT) */
+
+ if (TableIndex == ACPI_TABLE_INDEX_DSDT)
+ {
+ AcpiUtSetIntegerWidth (FinalTable->Revision);
+ }
+
+UnmapAndExit:
+
+ /* Always unmap the table header that we mapped above */
+
+ AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbGetRootTableEntry
+ *
+ * PARAMETERS: TableEntry - Pointer to the RSDT/XSDT table entry
+ * TableEntrySize - sizeof 32 or 64 (RSDT or XSDT)
+ *
+ * RETURN: Physical address extracted from the root table
+ *
+ * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on
+ * both 32-bit and 64-bit platforms
+ *
+ * NOTE: ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on
+ * 64-bit platforms.
+ *
+ ******************************************************************************/
+
+static ACPI_PHYSICAL_ADDRESS
+AcpiTbGetRootTableEntry (
+ UINT8 *TableEntry,
+ UINT32 TableEntrySize)
+{
+ UINT64 Address64;
+
+
+ /*
+ * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
+ * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
+ */
+ if (TableEntrySize == sizeof (UINT32))
+ {
+ /*
+ * 32-bit platform, RSDT: Return 32-bit table entry
+ * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
+ */
+ return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (UINT32, TableEntry)));
+ }
+ else
+ {
+ /*
+ * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
+ * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
+ * return 64-bit
+ */
+ ACPI_MOVE_64_TO_64 (&Address64, TableEntry);
+
+#if ACPI_MACHINE_WIDTH == 32
+ if (Address64 > ACPI_UINT32_MAX)
+ {
+ /* Will truncate 64-bit address to 32 bits, issue warning */
+
+ ACPI_WARNING ((AE_INFO,
+ "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X),"
+ " truncating",
+ ACPI_FORMAT_UINT64 (Address64)));
+ }
+#endif
+ return ((ACPI_PHYSICAL_ADDRESS) (Address64));
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbParseRootTable
+ *
+ * PARAMETERS: Rsdp - Pointer to the RSDP
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to parse the Root System Description
+ * Table (RSDT or XSDT)
+ *
+ * NOTE: Tables are mapped (not copied) for efficiency. The FACS must
+ * be mapped and cannot be copied because it contains the actual
+ * memory location of the ACPI Global Lock.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbParseRootTable (
+ ACPI_PHYSICAL_ADDRESS RsdpAddress)
+{
+ ACPI_TABLE_RSDP *Rsdp;
+ UINT32 TableEntrySize;
+ UINT32 i;
+ UINT32 TableCount;
+ ACPI_TABLE_HEADER *Table;
+ ACPI_PHYSICAL_ADDRESS Address;
+ UINT32 Length;
+ UINT8 *TableEntry;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (TbParseRootTable);
+
+
+ /*
+ * Map the entire RSDP and extract the address of the RSDT or XSDT
+ */
+ Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP));
+ if (!Rsdp)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ AcpiTbPrintTableHeader (RsdpAddress,
+ ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp));
+
+ /* Differentiate between RSDT and XSDT root tables */
+
+ if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress)
+ {
+ /*
+ * Root table is an XSDT (64-bit physical addresses). We must use the
+ * XSDT if the revision is > 1 and the XSDT pointer is present, as per
+ * the ACPI specification.
+ */
+ Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress;
+ TableEntrySize = sizeof (UINT64);
+ }
+ else
+ {
+ /* Root table is an RSDT (32-bit physical addresses) */
+
+ Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress;
+ TableEntrySize = sizeof (UINT32);
+ }
+
+ /*
+ * It is not possible to map more than one entry in some environments,
+ * so unmap the RSDP here before mapping other tables
+ */
+ AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP));
+
+
+ /* Map the RSDT/XSDT table header to get the full table length */
+
+ Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
+ if (!Table)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ AcpiTbPrintTableHeader (Address, Table);
+
+ /* Get the length of the full table, verify length and map entire table */
+
+ Length = Table->Length;
+ AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER));
+
+ if (Length < sizeof (ACPI_TABLE_HEADER))
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", Length));
+ return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+ }
+
+ Table = AcpiOsMapMemory (Address, Length);
+ if (!Table)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Validate the root table checksum */
+
+ Status = AcpiTbVerifyChecksum (Table, Length);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsUnmapMemory (Table, Length);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Calculate the number of tables described in the root table */
+
+ TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) /
+ TableEntrySize);
+
+ /*
+ * First two entries in the table array are reserved for the DSDT
+ * and FACS, which are not actually present in the RSDT/XSDT - they
+ * come from the FADT
+ */
+ TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER);
+ AcpiGbl_RootTableList.CurrentTableCount = 2;
+
+ /*
+ * Initialize the root table array from the RSDT/XSDT
+ */
+ for (i = 0; i < TableCount; i++)
+ {
+ if (AcpiGbl_RootTableList.CurrentTableCount >=
+ AcpiGbl_RootTableList.MaxTableCount)
+ {
+ /* There is no more room in the root table array, attempt resize */
+
+ Status = AcpiTbResizeRootTableList ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_WARNING ((AE_INFO, "Truncating %u table entries!",
+ (unsigned) (TableCount -
+ (AcpiGbl_RootTableList.CurrentTableCount - 2))));
+ break;
+ }
+ }
+
+ /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
+
+ AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount].Address =
+ AcpiTbGetRootTableEntry (TableEntry, TableEntrySize);
+
+ TableEntry += TableEntrySize;
+ AcpiGbl_RootTableList.CurrentTableCount++;
+ }
+
+ /*
+ * It is not possible to map more than one entry in some environments,
+ * so unmap the root table here before mapping other tables
+ */
+ AcpiOsUnmapMemory (Table, Length);
+
+ /*
+ * Complete the initialization of the root table array by examining
+ * the header of each table
+ */
+ for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
+ {
+ AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address,
+ NULL, i);
+
+ /* Special case for FADT - get the DSDT and FACS */
+
+ if (ACPI_COMPARE_NAME (
+ &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT))
+ {
+ AcpiTbParseFadt (i);
+ }
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/tables/tbxface.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/tables/tbxface.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,722 @@
+/******************************************************************************
+ *
+ * Module Name: tbxface - Public interfaces to the ACPI subsystem
+ * ACPI table oriented 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.
+ */
+
+#define __TBXFACE_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/actables.h>
+
+#define _COMPONENT ACPI_TABLES
+ ACPI_MODULE_NAME ("tbxface")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiTbLoadNamespace (
+ void);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAllocateRootTable
+ *
+ * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of
+ * ACPI_TABLE_DESC structures
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Allocate a root table array. Used by iASL compiler and
+ * AcpiInitializeTables.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAllocateRootTable (
+ UINT32 InitialTableCount)
+{
+
+ AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
+ AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE;
+
+ return (AcpiTbResizeRootTableList ());
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiInitializeTables
+ *
+ * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated
+ * ACPI_TABLE_DESC structures. If NULL, the
+ * array is dynamically allocated.
+ * InitialTableCount - Size of InitialTableArray, in number of
+ * ACPI_TABLE_DESC structures
+ * AllowRealloc - Flag to tell Table Manager if resize of
+ * pre-allocated array is allowed. Ignored
+ * if InitialTableArray is NULL.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
+ *
+ * NOTE: Allows static allocation of the initial table array in order
+ * to avoid the use of dynamic memory in confined environments
+ * such as the kernel boot sequence where it may not be available.
+ *
+ * If the host OS memory managers are initialized, use NULL for
+ * InitialTableArray, and the table will be dynamically allocated.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInitializeTables (
+ ACPI_TABLE_DESC *InitialTableArray,
+ UINT32 InitialTableCount,
+ BOOLEAN AllowResize)
+{
+ ACPI_PHYSICAL_ADDRESS RsdpAddress;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiInitializeTables);
+
+
+ /*
+ * Set up the Root Table Array
+ * Allocate the table array if requested
+ */
+ if (!InitialTableArray)
+ {
+ Status = AcpiAllocateRootTable (InitialTableCount);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ else
+ {
+ /* Root Table Array has been statically allocated by the host */
+
+ ACPI_MEMSET (InitialTableArray, 0,
+ (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
+
+ AcpiGbl_RootTableList.Tables = InitialTableArray;
+ AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
+ AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN;
+ if (AllowResize)
+ {
+ AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;
+ }
+ }
+
+ /* Get the address of the RSDP */
+
+ RsdpAddress = AcpiOsGetRootPointer ();
+ if (!RsdpAddress)
+ {
+ return_ACPI_STATUS (AE_NOT_FOUND);
+ }
+
+ /*
+ * Get the root table (RSDT or XSDT) and extract all entries to the local
+ * Root Table Array. This array contains the information of the RSDT/XSDT
+ * in a common, more useable format.
+ */
+ Status = AcpiTbParseRootTable (RsdpAddress);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInitializeTables)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiReallocateRootTable
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
+ * root list from the previously provided scratch area. Should
+ * be called once dynamic memory allocation is available in the
+ * kernel
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiReallocateRootTable (
+ void)
+{
+ ACPI_TABLE_DESC *Tables;
+ ACPI_SIZE NewSize;
+ ACPI_SIZE CurrentSize;
+
+
+ ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
+
+
+ /*
+ * Only reallocate the root table if the host provided a static buffer
+ * for the table array in the call to AcpiInitializeTables.
+ */
+ if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
+ {
+ return_ACPI_STATUS (AE_SUPPORT);
+ }
+
+ /*
+ * Get the current size of the root table and add the default
+ * increment to create the new table size.
+ */
+ CurrentSize = (ACPI_SIZE)
+ AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC);
+
+ NewSize = CurrentSize +
+ (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC));
+
+ /* Create new array and copy the old array */
+
+ Tables = ACPI_ALLOCATE_ZEROED (NewSize);
+ if (!Tables)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize);
+
+ /*
+ * Update the root table descriptor. The new size will be the current
+ * number of tables plus the increment, independent of the reserved
+ * size of the original table list.
+ */
+ AcpiGbl_RootTableList.Tables = Tables;
+ AcpiGbl_RootTableList.MaxTableCount =
+ AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
+ AcpiGbl_RootTableList.Flags =
+ ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetTableHeader
+ *
+ * PARAMETERS: Signature - ACPI signature of needed table
+ * Instance - Which instance (for SSDTs)
+ * OutTableHeader - The pointer to the table header to fill
+ *
+ * RETURN: Status and pointer to mapped table header
+ *
+ * DESCRIPTION: Finds an ACPI table header.
+ *
+ * NOTE: Caller is responsible in unmapping the header with
+ * AcpiOsUnmapMemory
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTableHeader (
+ char *Signature,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER *OutTableHeader)
+{
+ UINT32 i;
+ UINT32 j;
+ ACPI_TABLE_HEADER *Header;
+
+
+ /* Parameter validation */
+
+ if (!Signature || !OutTableHeader)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Walk the root table list */
+
+ for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
+ {
+ if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ Signature))
+ {
+ continue;
+ }
+
+ if (++j < Instance)
+ {
+ continue;
+ }
+
+ if (!AcpiGbl_RootTableList.Tables[i].Pointer)
+ {
+ if ((AcpiGbl_RootTableList.Tables[i].Flags &
+ ACPI_TABLE_ORIGIN_MASK) ==
+ ACPI_TABLE_ORIGIN_MAPPED)
+ {
+ Header = AcpiOsMapMemory (
+ AcpiGbl_RootTableList.Tables[i].Address,
+ sizeof (ACPI_TABLE_HEADER));
+ if (!Header)
+ {
+ return AE_NO_MEMORY;
+ }
+
+ ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
+ AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
+ }
+ else
+ {
+ return AE_NOT_FOUND;
+ }
+ }
+ else
+ {
+ ACPI_MEMCPY (OutTableHeader,
+ AcpiGbl_RootTableList.Tables[i].Pointer,
+ sizeof(ACPI_TABLE_HEADER));
+ }
+
+ return (AE_OK);
+ }
+
+ return (AE_NOT_FOUND);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetTable
+ *
+ * PARAMETERS: Signature - ACPI signature of needed table
+ * Instance - Which instance (for SSDTs)
+ * OutTable - Where the pointer to the table is returned
+ *
+ * RETURN: Status and pointer to table
+ *
+ * DESCRIPTION: Finds and verifies an ACPI table.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTable (
+ char *Signature,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER **OutTable)
+{
+ UINT32 i;
+ UINT32 j;
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!Signature || !OutTable)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Walk the root table list */
+
+ for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
+ {
+ if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ Signature))
+ {
+ continue;
+ }
+
+ if (++j < Instance)
+ {
+ continue;
+ }
+
+ Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
+ if (ACPI_SUCCESS (Status))
+ {
+ *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
+ }
+
+ return (Status);
+ }
+
+ return (AE_NOT_FOUND);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetTable)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetTableByIndex
+ *
+ * PARAMETERS: TableIndex - Table index
+ * Table - Where the pointer to the table is returned
+ *
+ * RETURN: Status and pointer to the table
+ *
+ * DESCRIPTION: Obtain a table by an index into the global table list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTableByIndex (
+ UINT32 TableIndex,
+ ACPI_TABLE_HEADER **Table)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
+
+
+ /* Parameter validation */
+
+ if (!Table)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+
+ /* Validate index */
+
+ if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
+ {
+ /* Table is not mapped, map it */
+
+ Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
+ if (ACPI_FAILURE (Status))
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbLoadNamespace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
+ * the RSDT/XSDT.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiTbLoadNamespace (
+ void)
+{
+ ACPI_STATUS Status;
+ UINT32 i;
+ ACPI_TABLE_HEADER *NewDsdt;
+
+
+ ACPI_FUNCTION_TRACE (TbLoadNamespace);
+
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+
+ /*
+ * Load the namespace. The DSDT is required, but any SSDT and
+ * PSDT tables are optional. Verify the DSDT.
+ */
+ if (!AcpiGbl_RootTableList.CurrentTableCount ||
+ !ACPI_COMPARE_NAME (
+ &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
+ ACPI_SIG_DSDT) ||
+ ACPI_FAILURE (AcpiTbVerifyTable (
+ &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
+ {
+ Status = AE_NO_ACPI_TABLES;
+ goto UnlockAndExit;
+ }
+
+ /*
+ * Save the DSDT pointer for simple access. This is the mapped memory
+ * address. We must take care here because the address of the .Tables
+ * array can change dynamically as tables are loaded at run-time. Note:
+ * .Pointer field is not validated until after call to AcpiTbVerifyTable.
+ */
+ AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
+
+ /*
+ * Optionally copy the entire DSDT to local memory (instead of simply
+ * mapping it.) There are some BIOSs that corrupt or replace the original
+ * DSDT, creating the need for this option. Default is FALSE, do not copy
+ * the DSDT.
+ */
+ if (AcpiGbl_CopyDsdtLocally)
+ {
+ NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
+ if (NewDsdt)
+ {
+ AcpiGbl_DSDT = NewDsdt;
+ }
+ }
+
+ /*
+ * Save the original DSDT header for detection of table corruption
+ * and/or replacement of the DSDT from outside the OS.
+ */
+ ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
+ sizeof (ACPI_TABLE_HEADER));
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+
+ /* Load and parse tables */
+
+ Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
+
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
+ {
+ if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ ACPI_SIG_SSDT) &&
+ !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ ACPI_SIG_PSDT)) ||
+ ACPI_FAILURE (AcpiTbVerifyTable (
+ &AcpiGbl_RootTableList.Tables[i])))
+ {
+ continue;
+ }
+
+ /* Skip SSDT when DSDT is overriden */
+
+ if (ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
+ ACPI_SIG_SSDT) &&
+ (AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags &
+ ACPI_TABLE_ORIGIN_OVERRIDE))
+ {
+ continue;
+ }
+
+ /* Ignore errors while loading tables, get as many as possible */
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
+ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
+
+UnlockAndExit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiLoadTables
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiLoadTables (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiLoadTables);
+
+
+ /* Load the namespace from the tables */
+
+ Status = AcpiTbLoadNamespace ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "While loading namespace from ACPI tables"));
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiLoadTables)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiInstallTableHandler
+ *
+ * PARAMETERS: Handler - Table event handler
+ * Context - Value passed to the handler on each event
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install table event handler
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInstallTableHandler (
+ ACPI_TABLE_HANDLER Handler,
+ void *Context)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
+
+
+ if (!Handler)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Don't allow more than one handler */
+
+ if (AcpiGbl_TableHandler)
+ {
+ Status = AE_ALREADY_EXISTS;
+ goto Cleanup;
+ }
+
+ /* Install the handler */
+
+ AcpiGbl_TableHandler = Handler;
+ AcpiGbl_TableHandlerContext = Context;
+
+Cleanup:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRemoveTableHandler
+ *
+ * PARAMETERS: Handler - Table event handler that was installed
+ * previously.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Remove table event handler
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRemoveTableHandler (
+ ACPI_TABLE_HANDLER Handler)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Make sure that the installed handler is the same */
+
+ if (!Handler ||
+ Handler != AcpiGbl_TableHandler)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto Cleanup;
+ }
+
+ /* Remove the handler */
+
+ AcpiGbl_TableHandler = NULL;
+
+Cleanup:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/tables/tbxfroot.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/tables/tbxfroot.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,299 @@
+/******************************************************************************
+ *
+ * Module Name: tbxfroot - Find the root ACPI table (RSDT)
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __TBXFROOT_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_TABLES
+ ACPI_MODULE_NAME ("tbxfroot")
+
+/* Local prototypes */
+
+static UINT8 *
+AcpiTbScanMemoryForRsdp (
+ UINT8 *StartAddress,
+ UINT32 Length);
+
+static ACPI_STATUS
+AcpiTbValidateRsdp (
+ ACPI_TABLE_RSDP *Rsdp);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbValidateRsdp
+ *
+ * PARAMETERS: Rsdp - Pointer to unvalidated RSDP
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Validate the RSDP (ptr)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiTbValidateRsdp (
+ ACPI_TABLE_RSDP *Rsdp)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * The signature and checksum must both be correct
+ *
+ * Note: Sometimes there exists more than one RSDP in memory; the valid
+ * RSDP has a valid checksum, all others have an invalid checksum.
+ */
+ if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP,
+ sizeof (ACPI_SIG_RSDP)-1) != 0)
+ {
+ /* Nope, BAD Signature */
+
+ return (AE_BAD_SIGNATURE);
+ }
+
+ /* Check the standard checksum */
+
+ if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
+ {
+ return (AE_BAD_CHECKSUM);
+ }
+
+ /* Check extended checksum if table version >= 2 */
+
+ if ((Rsdp->Revision >= 2) &&
+ (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
+ {
+ return (AE_BAD_CHECKSUM);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiFindRootPointer
+ *
+ * PARAMETERS: TableAddress - Where the table pointer is returned
+ *
+ * RETURN: Status, RSDP physical address
+ *
+ * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
+ * pointer structure. If it is found, set *RSDP to point to it.
+ *
+ * NOTE1: The RSDP must be either in the first 1K of the Extended
+ * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
+ * Only a 32-bit physical address is necessary.
+ *
+ * NOTE2: This function is always available, regardless of the
+ * initialization state of the rest of ACPI.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiFindRootPointer (
+ ACPI_SIZE *TableAddress)
+{
+ UINT8 *TablePtr;
+ UINT8 *MemRover;
+ UINT32 PhysicalAddress;
+
+
+ ACPI_FUNCTION_TRACE (AcpiFindRootPointer);
+
+
+ /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
+
+ TablePtr = AcpiOsMapMemory (
+ (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
+ ACPI_EBDA_PTR_LENGTH);
+ if (!TablePtr)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not map memory at 0x%8.8X for length %u",
+ ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
+
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
+
+ /* Convert segment part to physical address */
+
+ PhysicalAddress <<= 4;
+ AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
+
+ /* EBDA present? */
+
+ if (PhysicalAddress > 0x400)
+ {
+ /*
+ * 1b) Search EBDA paragraphs (EBDA is required to be a
+ * minimum of 1K length)
+ */
+ TablePtr = AcpiOsMapMemory (
+ (ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
+ ACPI_EBDA_WINDOW_SIZE);
+ if (!TablePtr)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not map memory at 0x%8.8X for length %u",
+ PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
+
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE);
+ AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
+
+ if (MemRover)
+ {
+ /* Return the physical address */
+
+ PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr);
+
+ *TableAddress = PhysicalAddress;
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ /*
+ * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
+ */
+ TablePtr = AcpiOsMapMemory (
+ (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
+ ACPI_HI_RSDP_WINDOW_SIZE);
+
+ if (!TablePtr)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Could not map memory at 0x%8.8X for length %u",
+ ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
+
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
+ AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
+
+ if (MemRover)
+ {
+ /* Return the physical address */
+
+ PhysicalAddress = (UINT32)
+ (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
+
+ *TableAddress = PhysicalAddress;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* A valid RSDP was not found */
+
+ ACPI_ERROR ((AE_INFO, "A valid RSDP was not found"));
+ return_ACPI_STATUS (AE_NOT_FOUND);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbScanMemoryForRsdp
+ *
+ * PARAMETERS: StartAddress - Starting pointer for search
+ * Length - Maximum length to search
+ *
+ * RETURN: Pointer to the RSDP if found, otherwise NULL.
+ *
+ * DESCRIPTION: Search a block of memory for the RSDP signature
+ *
+ ******************************************************************************/
+
+static UINT8 *
+AcpiTbScanMemoryForRsdp (
+ UINT8 *StartAddress,
+ UINT32 Length)
+{
+ ACPI_STATUS Status;
+ UINT8 *MemRover;
+ UINT8 *EndAddress;
+
+
+ ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
+
+
+ EndAddress = StartAddress + Length;
+
+ /* Search from given start address for the requested length */
+
+ for (MemRover = StartAddress; MemRover < EndAddress;
+ MemRover += ACPI_RSDP_SCAN_STEP)
+ {
+ /* The RSDP signature and checksum must both be correct */
+
+ Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover));
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Sig and checksum valid, we have found a real RSDP */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "RSDP located at physical address %p\n", MemRover));
+ return_PTR (MemRover);
+ }
+
+ /* No sig match or bad checksum, keep searching */
+ }
+
+ /* Searched entire block, no RSDP was found */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Searched entire block from %p, valid RSDP was not found\n",
+ StartAddress));
+ return_PTR (NULL);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utaddress.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utaddress.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,322 @@
+/******************************************************************************
+ *
+ * Module Name: utaddress - OpRegion address range check
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __UTADDRESS_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utaddress")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAddAddressRange
+ *
+ * PARAMETERS: SpaceId - Address space ID
+ * Address - OpRegion start address
+ * Length - OpRegion length
+ * RegionNode - OpRegion namespace node
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Add the Operation Region address range to the global list.
+ * The only supported Space IDs are Memory and I/O. Called when
+ * the OpRegion address/length operands are fully evaluated.
+ *
+ * MUTEX: Locks the namespace
+ *
+ * NOTE: Because this interface is only called when an OpRegion argument
+ * list is evaluated, there cannot be any duplicate RegionNodes.
+ * Duplicate Address/Length values are allowed, however, so that multiple
+ * address conflicts can be detected.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtAddAddressRange (
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 Length,
+ ACPI_NAMESPACE_NODE *RegionNode)
+{
+ ACPI_ADDRESS_RANGE *RangeInfo;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtAddAddressRange);
+
+
+ if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
+ (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Allocate/init a new info block, add it to the appropriate list */
+
+ RangeInfo = ACPI_ALLOCATE (sizeof (ACPI_ADDRESS_RANGE));
+ if (!RangeInfo)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ RangeInfo->StartAddress = Address;
+ RangeInfo->EndAddress = (Address + Length - 1);
+ RangeInfo->RegionNode = RegionNode;
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_FREE (RangeInfo);
+ return_ACPI_STATUS (Status);
+ }
+
+ RangeInfo->Next = AcpiGbl_AddressRangeList[SpaceId];
+ AcpiGbl_AddressRangeList[SpaceId] = RangeInfo;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "\nAdded [%4.4s] address range: 0x%p-0x%p\n",
+ AcpiUtGetNodeName (RangeInfo->RegionNode),
+ ACPI_CAST_PTR (void, Address),
+ ACPI_CAST_PTR (void, RangeInfo->EndAddress)));
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtRemoveAddressRange
+ *
+ * PARAMETERS: SpaceId - Address space ID
+ * RegionNode - OpRegion namespace node
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Remove the Operation Region from the global list. The only
+ * supported Space IDs are Memory and I/O. Called when an
+ * OpRegion is deleted.
+ *
+ * MUTEX: Assumes the namespace is locked
+ *
+ ******************************************************************************/
+
+void
+AcpiUtRemoveAddressRange (
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ ACPI_NAMESPACE_NODE *RegionNode)
+{
+ ACPI_ADDRESS_RANGE *RangeInfo;
+ ACPI_ADDRESS_RANGE *Prev;
+
+
+ ACPI_FUNCTION_TRACE (UtRemoveAddressRange);
+
+
+ if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
+ (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
+ {
+ return_VOID;
+ }
+
+ /* Get the appropriate list head and check the list */
+
+ RangeInfo = Prev = AcpiGbl_AddressRangeList[SpaceId];
+ while (RangeInfo)
+ {
+ if (RangeInfo->RegionNode == RegionNode)
+ {
+ if (RangeInfo == Prev) /* Found at list head */
+ {
+ AcpiGbl_AddressRangeList[SpaceId] = RangeInfo->Next;
+ }
+ else
+ {
+ Prev->Next = RangeInfo->Next;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+ "\nRemoved [%4.4s] address range: 0x%p-0x%p\n",
+ AcpiUtGetNodeName (RangeInfo->RegionNode),
+ ACPI_CAST_PTR (void, RangeInfo->StartAddress),
+ ACPI_CAST_PTR (void, RangeInfo->EndAddress)));
+
+ ACPI_FREE (RangeInfo);
+ return_VOID;
+ }
+
+ Prev = RangeInfo;
+ RangeInfo = RangeInfo->Next;
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCheckAddressRange
+ *
+ * PARAMETERS: SpaceId - Address space ID
+ * Address - Start address
+ * Length - Length of address range
+ * Warn - TRUE if warning on overlap desired
+ *
+ * RETURN: Count of the number of conflicts detected. Zero is always
+ * returned for Space IDs other than Memory or I/O.
+ *
+ * DESCRIPTION: Check if the input address range overlaps any of the
+ * ASL operation region address ranges. The only supported
+ * Space IDs are Memory and I/O.
+ *
+ * MUTEX: Assumes the namespace is locked.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiUtCheckAddressRange (
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 Length,
+ BOOLEAN Warn)
+{
+ ACPI_ADDRESS_RANGE *RangeInfo;
+ ACPI_PHYSICAL_ADDRESS EndAddress;
+ char *Pathname;
+ UINT32 OverlapCount = 0;
+
+
+ ACPI_FUNCTION_TRACE (UtCheckAddressRange);
+
+
+ if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
+ (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
+ {
+ return_UINT32 (0);
+ }
+
+ RangeInfo = AcpiGbl_AddressRangeList[SpaceId];
+ EndAddress = Address + Length - 1;
+
+ /* Check entire list for all possible conflicts */
+
+ while (RangeInfo)
+ {
+ /*
+ * Check if the requested Address/Length overlaps this AddressRange.
+ * Four cases to consider:
+ *
+ * 1) Input address/length is contained completely in the address range
+ * 2) Input address/length overlaps range at the range start
+ * 3) Input address/length overlaps range at the range end
+ * 4) Input address/length completely encompasses the range
+ */
+ if ((Address <= RangeInfo->EndAddress) &&
+ (EndAddress >= RangeInfo->StartAddress))
+ {
+ /* Found an address range overlap */
+
+ OverlapCount++;
+ if (Warn) /* Optional warning message */
+ {
+ Pathname = AcpiNsGetExternalPathname (RangeInfo->RegionNode);
+
+ ACPI_WARNING ((AE_INFO,
+ "0x%p-0x%p %s conflicts with Region %s %d",
+ ACPI_CAST_PTR (void, Address),
+ ACPI_CAST_PTR (void, EndAddress),
+ AcpiUtGetRegionName (SpaceId), Pathname, OverlapCount));
+ ACPI_FREE (Pathname);
+ }
+ }
+
+ RangeInfo = RangeInfo->Next;
+ }
+
+ return_UINT32 (OverlapCount);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteAddressLists
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Delete all global address range lists (called during
+ * subsystem shutdown).
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDeleteAddressLists (
+ void)
+{
+ ACPI_ADDRESS_RANGE *Next;
+ ACPI_ADDRESS_RANGE *RangeInfo;
+ int i;
+
+
+ /* Delete all elements in all address range lists */
+
+ for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
+ {
+ Next = AcpiGbl_AddressRangeList[i];
+
+ while (Next)
+ {
+ RangeInfo = Next;
+ Next = RangeInfo->Next;
+ ACPI_FREE (RangeInfo);
+ }
+
+ AcpiGbl_AddressRangeList[i] = NULL;
+ }
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utalloc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utalloc.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,416 @@
+/******************************************************************************
+ *
+ * Module Name: utalloc - local memory allocation 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 __UTALLOC_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utalloc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateCaches
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create all local caches
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCreateCaches (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ /* Object Caches, for frequently used objects */
+
+ Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE),
+ ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE),
+ ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON),
+ ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED),
+ ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT),
+ ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+ /* Memory allocation lists */
+
+ Status = AcpiUtCreateList ("Acpi-Global", 0,
+ &AcpiGbl_GlobalList);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE),
+ &AcpiGbl_NsNodeList);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+#endif
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteCaches
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Purge and delete all local caches
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtDeleteCaches (
+ void)
+{
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ char Buffer[7];
+
+ if (AcpiGbl_DisplayFinalMemStats)
+ {
+ ACPI_STRCPY (Buffer, "MEMORY");
+ (void) AcpiDbDisplayStatistics (Buffer);
+ }
+#endif
+
+ (void) AcpiOsDeleteCache (AcpiGbl_NamespaceCache);
+ AcpiGbl_NamespaceCache = NULL;
+
+ (void) AcpiOsDeleteCache (AcpiGbl_StateCache);
+ AcpiGbl_StateCache = NULL;
+
+ (void) AcpiOsDeleteCache (AcpiGbl_OperandCache);
+ AcpiGbl_OperandCache = NULL;
+
+ (void) AcpiOsDeleteCache (AcpiGbl_PsNodeCache);
+ AcpiGbl_PsNodeCache = NULL;
+
+ (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache);
+ AcpiGbl_PsNodeExtCache = NULL;
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+ /* Debug only - display leftover memory allocation, if any */
+
+ AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL);
+
+ /* Free memory lists */
+
+ AcpiOsFree (AcpiGbl_GlobalList);
+ AcpiGbl_GlobalList = NULL;
+
+ AcpiOsFree (AcpiGbl_NsNodeList);
+ AcpiGbl_NsNodeList = NULL;
+#endif
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidateBuffer
+ *
+ * PARAMETERS: Buffer - Buffer descriptor to be validated
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtValidateBuffer (
+ ACPI_BUFFER *Buffer)
+{
+
+ /* Obviously, the structure pointer must be valid */
+
+ if (!Buffer)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Special semantics for the length */
+
+ if ((Buffer->Length == ACPI_NO_BUFFER) ||
+ (Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
+ (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
+ {
+ return (AE_OK);
+ }
+
+ /* Length is valid, the buffer pointer must be also */
+
+ if (!Buffer->Pointer)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtInitializeBuffer
+ *
+ * PARAMETERS: Buffer - Buffer to be validated
+ * RequiredLength - Length needed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Validate that the buffer is of the required length or
+ * allocate a new buffer. Returned buffer is always zeroed.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtInitializeBuffer (
+ ACPI_BUFFER *Buffer,
+ ACPI_SIZE RequiredLength)
+{
+ ACPI_SIZE InputBufferLength;
+
+
+ /* Parameter validation */
+
+ if (!Buffer || !RequiredLength)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Buffer->Length is used as both an input and output parameter. Get the
+ * input actual length and set the output required buffer length.
+ */
+ InputBufferLength = Buffer->Length;
+ Buffer->Length = RequiredLength;
+
+ /*
+ * The input buffer length contains the actual buffer length, or the type
+ * of buffer to be allocated by this routine.
+ */
+ switch (InputBufferLength)
+ {
+ case ACPI_NO_BUFFER:
+
+ /* Return the exception (and the required buffer length) */
+
+ return (AE_BUFFER_OVERFLOW);
+
+ case ACPI_ALLOCATE_BUFFER:
+
+ /* Allocate a new buffer */
+
+ Buffer->Pointer = AcpiOsAllocate (RequiredLength);
+ break;
+
+ case ACPI_ALLOCATE_LOCAL_BUFFER:
+
+ /* Allocate a new buffer with local interface to allow tracking */
+
+ Buffer->Pointer = ACPI_ALLOCATE (RequiredLength);
+ break;
+
+ default:
+
+ /* Existing buffer: Validate the size of the buffer */
+
+ if (InputBufferLength < RequiredLength)
+ {
+ return (AE_BUFFER_OVERFLOW);
+ }
+ break;
+ }
+
+ /* Validate allocation from above or input buffer pointer */
+
+ if (!Buffer->Pointer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Have a valid buffer, clear it */
+
+ ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocate
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAllocate (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line)
+{
+ void *Allocation;
+
+
+ ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size);
+
+
+ /* Check for an inadvertent size of zero bytes */
+
+ if (!Size)
+ {
+ ACPI_WARNING ((Module, Line,
+ "Attempt to allocate zero bytes, allocating 1 byte"));
+ Size = 1;
+ }
+
+ Allocation = AcpiOsAllocate (Size);
+ if (!Allocation)
+ {
+ /* Report allocation error */
+
+ ACPI_WARNING ((Module, Line,
+ "Could not allocate size %u", (UINT32) Size));
+
+ return_PTR (NULL);
+ }
+
+ return_PTR (Allocation);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocateZeroed
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAllocateZeroed (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line)
+{
+ void *Allocation;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Allocation = AcpiUtAllocate (Size, Component, Module, Line);
+ if (Allocation)
+ {
+ /* Clear the memory block */
+
+ ACPI_MEMSET (Allocation, 0, Size);
+ }
+
+ return (Allocation);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utcache.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utcache.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,361 @@
+/******************************************************************************
+ *
+ * Module Name: utcache - local cache allocation 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 __UTCACHE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utcache")
+
+
+#ifdef ACPI_USE_LOCAL_CACHE
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiOsCreateCache
+ *
+ * PARAMETERS: CacheName - Ascii name for the cache
+ * ObjectSize - Size of each cached object
+ * MaxDepth - Maximum depth of the cache (in objects)
+ * ReturnCache - Where the new cache object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a cache object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiOsCreateCache (
+ char *CacheName,
+ UINT16 ObjectSize,
+ UINT16 MaxDepth,
+ ACPI_MEMORY_LIST **ReturnCache)
+{
+ ACPI_MEMORY_LIST *Cache;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!CacheName || !ReturnCache || (ObjectSize < 16))
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Create the cache object */
+
+ Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
+ if (!Cache)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Populate the cache object and return it */
+
+ ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
+ Cache->LinkOffset = 8;
+ Cache->ListName = CacheName;
+ Cache->ObjectSize = ObjectSize;
+ Cache->MaxDepth = MaxDepth;
+
+ *ReturnCache = Cache;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiOsPurgeCache
+ *
+ * PARAMETERS: Cache - Handle to cache object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Free all objects within the requested cache.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiOsPurgeCache (
+ ACPI_MEMORY_LIST *Cache)
+{
+ char *Next;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Cache)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Walk the list of objects in this cache */
+
+ while (Cache->ListHead)
+ {
+ /* Delete and unlink one cached state object */
+
+ Next = *(ACPI_CAST_INDIRECT_PTR (char,
+ &(((char *) Cache->ListHead)[Cache->LinkOffset])));
+ ACPI_FREE (Cache->ListHead);
+
+ Cache->ListHead = Next;
+ Cache->CurrentDepth--;
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiOsDeleteCache
+ *
+ * PARAMETERS: Cache - Handle to cache object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Free all objects within the requested cache and delete the
+ * cache object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiOsDeleteCache (
+ ACPI_MEMORY_LIST *Cache)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Purge all objects in the cache */
+
+ Status = AcpiOsPurgeCache (Cache);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Now we can delete the cache object */
+
+ AcpiOsFree (Cache);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiOsReleaseObject
+ *
+ * PARAMETERS: Cache - Handle to cache object
+ * Object - The object to be released
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Release an object to the specified cache. If cache is full,
+ * the object is deleted.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiOsReleaseObject (
+ ACPI_MEMORY_LIST *Cache,
+ void *Object)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Cache || !Object)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* If cache is full, just free this object */
+
+ if (Cache->CurrentDepth >= Cache->MaxDepth)
+ {
+ ACPI_FREE (Object);
+ ACPI_MEM_TRACKING (Cache->TotalFreed++);
+ }
+
+ /* Otherwise put this object back into the cache */
+
+ else
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Mark the object as cached */
+
+ ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize);
+ ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
+
+ /* Put the object at the head of the cache list */
+
+ * (ACPI_CAST_INDIRECT_PTR (char,
+ &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead;
+ Cache->ListHead = Object;
+ Cache->CurrentDepth++;
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiOsAcquireObject
+ *
+ * PARAMETERS: Cache - Handle to cache object
+ *
+ * RETURN: the acquired object. NULL on error
+ *
+ * DESCRIPTION: Get an object from the specified cache. If cache is empty,
+ * the object is allocated.
+ *
+ ******************************************************************************/
+
+void *
+AcpiOsAcquireObject (
+ ACPI_MEMORY_LIST *Cache)
+{
+ ACPI_STATUS Status;
+ void *Object;
+
+
+ ACPI_FUNCTION_NAME (OsAcquireObject);
+
+
+ if (!Cache)
+ {
+ return (NULL);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
+ if (ACPI_FAILURE (Status))
+ {
+ return (NULL);
+ }
+
+ ACPI_MEM_TRACKING (Cache->Requests++);
+
+ /* Check the cache first */
+
+ if (Cache->ListHead)
+ {
+ /* There is an object available, use it */
+
+ Object = Cache->ListHead;
+ Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char,
+ &(((char *) Object)[Cache->LinkOffset])));
+
+ Cache->CurrentDepth--;
+
+ ACPI_MEM_TRACKING (Cache->Hits++);
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Object %p from %s cache\n", Object, Cache->ListName));
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ if (ACPI_FAILURE (Status))
+ {
+ return (NULL);
+ }
+
+ /* Clear (zero) the previously used Object */
+
+ ACPI_MEMSET (Object, 0, Cache->ObjectSize);
+ }
+ else
+ {
+ /* The cache is empty, create a new object */
+
+ ACPI_MEM_TRACKING (Cache->TotalAllocated++);
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied)
+ {
+ Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed;
+ }
+#endif
+
+ /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ if (ACPI_FAILURE (Status))
+ {
+ return (NULL);
+ }
+
+ Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize);
+ if (!Object)
+ {
+ return (NULL);
+ }
+ }
+
+ return (Object);
+}
+#endif /* ACPI_USE_LOCAL_CACHE */
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utcopy.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utcopy.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1078 @@
+/******************************************************************************
+ *
+ * Module Name: utcopy - Internal to external object translation 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 __UTCOPY_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utcopy")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiUtCopyIsimpleToEsimple (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ ACPI_OBJECT *ExternalObject,
+ UINT8 *DataSpace,
+ ACPI_SIZE *BufferSpaceUsed);
+
+static ACPI_STATUS
+AcpiUtCopyIelementToIelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context);
+
+static ACPI_STATUS
+AcpiUtCopyIpackageToEpackage (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ UINT8 *Buffer,
+ ACPI_SIZE *SpaceUsed);
+
+static ACPI_STATUS
+AcpiUtCopyEsimpleToIsimple(
+ ACPI_OBJECT *UserObj,
+ ACPI_OPERAND_OBJECT **ReturnObj);
+
+static ACPI_STATUS
+AcpiUtCopyEpackageToIpackage (
+ ACPI_OBJECT *ExternalObject,
+ ACPI_OPERAND_OBJECT **InternalObject);
+
+static ACPI_STATUS
+AcpiUtCopySimpleObject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *DestDesc);
+
+static ACPI_STATUS
+AcpiUtCopyIelementToEelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context);
+
+static ACPI_STATUS
+AcpiUtCopyIpackageToIpackage (
+ ACPI_OPERAND_OBJECT *SourceObj,
+ ACPI_OPERAND_OBJECT *DestObj,
+ ACPI_WALK_STATE *WalkState);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyIsimpleToEsimple
+ *
+ * PARAMETERS: InternalObject - Source object to be copied
+ * ExternalObject - Where to return the copied object
+ * DataSpace - Where object data is returned (such as
+ * buffer and string data)
+ * BufferSpaceUsed - Length of DataSpace that was used
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to copy a simple internal object to
+ * an external object.
+ *
+ * The DataSpace buffer is assumed to have sufficient space for
+ * the object.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopyIsimpleToEsimple (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ ACPI_OBJECT *ExternalObject,
+ UINT8 *DataSpace,
+ ACPI_SIZE *BufferSpaceUsed)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple);
+
+
+ *BufferSpaceUsed = 0;
+
+ /*
+ * Check for NULL object case (could be an uninitialized
+ * package element)
+ */
+ if (!InternalObject)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Always clear the external object */
+
+ ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT));
+
+ /*
+ * In general, the external object will be the same type as
+ * the internal object
+ */
+ ExternalObject->Type = InternalObject->Common.Type;
+
+ /* However, only a limited number of external types are supported */
+
+ switch (InternalObject->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ ExternalObject->String.Pointer = (char *) DataSpace;
+ ExternalObject->String.Length = InternalObject->String.Length;
+ *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (
+ (ACPI_SIZE) InternalObject->String.Length + 1);
+
+ ACPI_MEMCPY ((void *) DataSpace,
+ (void *) InternalObject->String.Pointer,
+ (ACPI_SIZE) InternalObject->String.Length + 1);
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ ExternalObject->Buffer.Pointer = DataSpace;
+ ExternalObject->Buffer.Length = InternalObject->Buffer.Length;
+ *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (
+ InternalObject->String.Length);
+
+ ACPI_MEMCPY ((void *) DataSpace,
+ (void *) InternalObject->Buffer.Pointer,
+ InternalObject->Buffer.Length);
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+
+ ExternalObject->Integer.Value = InternalObject->Integer.Value;
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ /* This is an object reference. */
+
+ switch (InternalObject->Reference.Class)
+ {
+ case ACPI_REFCLASS_NAME:
+
+ /*
+ * For namepath, return the object handle ("reference")
+ * We are referring to the namespace node
+ */
+ ExternalObject->Reference.Handle =
+ InternalObject->Reference.Node;
+ ExternalObject->Reference.ActualType =
+ AcpiNsGetType (InternalObject->Reference.Node);
+ break;
+
+ default:
+
+ /* All other reference types are unsupported */
+
+ return_ACPI_STATUS (AE_TYPE);
+ }
+ break;
+
+
+ case ACPI_TYPE_PROCESSOR:
+
+ ExternalObject->Processor.ProcId =
+ InternalObject->Processor.ProcId;
+ ExternalObject->Processor.PblkAddress =
+ InternalObject->Processor.Address;
+ ExternalObject->Processor.PblkLength =
+ InternalObject->Processor.Length;
+ break;
+
+
+ case ACPI_TYPE_POWER:
+
+ ExternalObject->PowerResource.SystemLevel =
+ InternalObject->PowerResource.SystemLevel;
+
+ ExternalObject->PowerResource.ResourceOrder =
+ InternalObject->PowerResource.ResourceOrder;
+ break;
+
+
+ default:
+ /*
+ * There is no corresponding external object type
+ */
+ ACPI_ERROR ((AE_INFO,
+ "Unsupported object type, cannot convert to external object: %s",
+ AcpiUtGetTypeName (InternalObject->Common.Type)));
+
+ return_ACPI_STATUS (AE_SUPPORT);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyIelementToEelement
+ *
+ * PARAMETERS: ACPI_PKG_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy one package element to another package element
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopyIelementToEelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
+ ACPI_SIZE ObjectSpace;
+ UINT32 ThisIndex;
+ ACPI_OBJECT *TargetObject;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ ThisIndex = State->Pkg.Index;
+ TargetObject = (ACPI_OBJECT *)
+ &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex];
+
+ switch (ObjectType)
+ {
+ case ACPI_COPY_TYPE_SIMPLE:
+
+ /*
+ * This is a simple or null object
+ */
+ Status = AcpiUtCopyIsimpleToEsimple (SourceObject,
+ TargetObject, Info->FreeSpace, &ObjectSpace);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+
+ case ACPI_COPY_TYPE_PACKAGE:
+
+ /*
+ * Build the package object
+ */
+ TargetObject->Type = ACPI_TYPE_PACKAGE;
+ TargetObject->Package.Count = SourceObject->Package.Count;
+ TargetObject->Package.Elements =
+ ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace);
+
+ /*
+ * Pass the new package object back to the package walk routine
+ */
+ State->Pkg.ThisTargetObj = TargetObject;
+
+ /*
+ * Save space for the array of objects (Package elements)
+ * update the buffer length counter
+ */
+ ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD (
+ (ACPI_SIZE) TargetObject->Package.Count *
+ sizeof (ACPI_OBJECT));
+ break;
+
+
+ default:
+ return (AE_BAD_PARAMETER);
+ }
+
+ Info->FreeSpace += ObjectSpace;
+ Info->Length += ObjectSpace;
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyIpackageToEpackage
+ *
+ * PARAMETERS: InternalObject - Pointer to the object we are returning
+ * Buffer - Where the object is returned
+ * SpaceUsed - Where the object length is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to place a package object in a user
+ * buffer. A package object by definition contains other objects.
+ *
+ * The buffer is assumed to have sufficient space for the object.
+ * The caller must have verified the buffer length needed using
+ * the AcpiUtGetObjectSize function before calling this function.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopyIpackageToEpackage (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ UINT8 *Buffer,
+ ACPI_SIZE *SpaceUsed)
+{
+ ACPI_OBJECT *ExternalObject;
+ ACPI_STATUS Status;
+ ACPI_PKG_INFO Info;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage);
+
+
+ /*
+ * First package at head of the buffer
+ */
+ ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer);
+
+ /*
+ * Free space begins right after the first package
+ */
+ Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
+ Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (
+ sizeof (ACPI_OBJECT));
+ Info.ObjectSpace = 0;
+ Info.NumPackages = 1;
+
+ ExternalObject->Type = InternalObject->Common.Type;
+ ExternalObject->Package.Count = InternalObject->Package.Count;
+ ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT,
+ Info.FreeSpace);
+
+ /*
+ * Leave room for an array of ACPI_OBJECTS in the buffer
+ * and move the free space past it
+ */
+ Info.Length += (ACPI_SIZE) ExternalObject->Package.Count *
+ ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
+ Info.FreeSpace += ExternalObject->Package.Count *
+ ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
+
+ Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject,
+ AcpiUtCopyIelementToEelement, &Info);
+
+ *SpaceUsed = Info.Length;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyIobjectToEobject
+ *
+ * PARAMETERS: InternalObject - The internal object to be converted
+ * RetBuffer - Where the object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to build an API object to be returned
+ * to the caller.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCopyIobjectToEobject (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject);
+
+
+ if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)
+ {
+ /*
+ * Package object: Copy all subobjects (including
+ * nested packages)
+ */
+ Status = AcpiUtCopyIpackageToEpackage (InternalObject,
+ RetBuffer->Pointer, &RetBuffer->Length);
+ }
+ else
+ {
+ /*
+ * Build a simple object (no nested objects)
+ */
+ Status = AcpiUtCopyIsimpleToEsimple (InternalObject,
+ ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer),
+ ACPI_ADD_PTR (UINT8, RetBuffer->Pointer,
+ ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))),
+ &RetBuffer->Length);
+ /*
+ * build simple does not include the object size in the length
+ * so we add it in here
+ */
+ RetBuffer->Length += sizeof (ACPI_OBJECT);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyEsimpleToIsimple
+ *
+ * PARAMETERS: ExternalObject - The external object to be converted
+ * RetInternalObject - Where the internal object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function copies an external object to an internal one.
+ * NOTE: Pointers can be copied, we don't need to copy data.
+ * (The pointers have to be valid in our address space no matter
+ * what we do with them!)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopyEsimpleToIsimple (
+ ACPI_OBJECT *ExternalObject,
+ ACPI_OPERAND_OBJECT **RetInternalObject)
+{
+ ACPI_OPERAND_OBJECT *InternalObject;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple);
+
+
+ /*
+ * Simple types supported are: String, Buffer, Integer
+ */
+ switch (ExternalObject->Type)
+ {
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ InternalObject = AcpiUtCreateInternalObject (
+ (UINT8) ExternalObject->Type);
+ if (!InternalObject)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ break;
+
+ case ACPI_TYPE_ANY: /* This is the case for a NULL object */
+
+ *RetInternalObject = NULL;
+ return_ACPI_STATUS (AE_OK);
+
+ default:
+ /* All other types are not supported */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unsupported object type, cannot convert to internal object: %s",
+ AcpiUtGetTypeName (ExternalObject->Type)));
+
+ return_ACPI_STATUS (AE_SUPPORT);
+ }
+
+
+ /* Must COPY string and buffer contents */
+
+ switch (ExternalObject->Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ InternalObject->String.Pointer =
+ ACPI_ALLOCATE_ZEROED ((ACPI_SIZE)
+ ExternalObject->String.Length + 1);
+
+ if (!InternalObject->String.Pointer)
+ {
+ goto ErrorExit;
+ }
+
+ ACPI_MEMCPY (InternalObject->String.Pointer,
+ ExternalObject->String.Pointer,
+ ExternalObject->String.Length);
+
+ InternalObject->String.Length = ExternalObject->String.Length;
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ InternalObject->Buffer.Pointer =
+ ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length);
+ if (!InternalObject->Buffer.Pointer)
+ {
+ goto ErrorExit;
+ }
+
+ ACPI_MEMCPY (InternalObject->Buffer.Pointer,
+ ExternalObject->Buffer.Pointer,
+ ExternalObject->Buffer.Length);
+
+ InternalObject->Buffer.Length = ExternalObject->Buffer.Length;
+
+ /* Mark buffer data valid */
+
+ InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID;
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+
+ InternalObject->Integer.Value = ExternalObject->Integer.Value;
+ break;
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ /* TBD: should validate incoming handle */
+
+ InternalObject->Reference.Class = ACPI_REFCLASS_NAME;
+ InternalObject->Reference.Node = ExternalObject->Reference.Handle;
+ break;
+
+ default:
+ /* Other types can't get here */
+ break;
+ }
+
+ *RetInternalObject = InternalObject;
+ return_ACPI_STATUS (AE_OK);
+
+
+ErrorExit:
+ AcpiUtRemoveReference (InternalObject);
+ return_ACPI_STATUS (AE_NO_MEMORY);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyEpackageToIpackage
+ *
+ * PARAMETERS: ExternalObject - The external object to be converted
+ * InternalObject - Where the internal object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy an external package object to an internal package.
+ * Handles nested packages.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopyEpackageToIpackage (
+ ACPI_OBJECT *ExternalObject,
+ ACPI_OPERAND_OBJECT **InternalObject)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *PackageObject;
+ ACPI_OPERAND_OBJECT **PackageElements;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage);
+
+
+ /* Create the package object */
+
+ PackageObject = AcpiUtCreatePackageObject (ExternalObject->Package.Count);
+ if (!PackageObject)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ PackageElements = PackageObject->Package.Elements;
+
+ /*
+ * Recursive implementation. Probably ok, since nested external packages
+ * as parameters should be very rare.
+ */
+ for (i = 0; i < ExternalObject->Package.Count; i++)
+ {
+ Status = AcpiUtCopyEobjectToIobject (
+ &ExternalObject->Package.Elements[i],
+ &PackageElements[i]);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Truncate package and delete it */
+
+ PackageObject->Package.Count = i;
+ PackageElements[i] = NULL;
+ AcpiUtRemoveReference (PackageObject);
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Mark package data valid */
+
+ PackageObject->Package.Flags |= AOPOBJ_DATA_VALID;
+
+ *InternalObject = PackageObject;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyEobjectToIobject
+ *
+ * PARAMETERS: ExternalObject - The external object to be converted
+ * InternalObject - Where the internal object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Converts an external object to an internal object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCopyEobjectToIobject (
+ ACPI_OBJECT *ExternalObject,
+ ACPI_OPERAND_OBJECT **InternalObject)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject);
+
+
+ if (ExternalObject->Type == ACPI_TYPE_PACKAGE)
+ {
+ Status = AcpiUtCopyEpackageToIpackage (ExternalObject, InternalObject);
+ }
+ else
+ {
+ /*
+ * Build a simple object (no nested objects)
+ */
+ Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopySimpleObject
+ *
+ * PARAMETERS: SourceDesc - The internal object to be copied
+ * DestDesc - New target object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Simple copy of one internal object to another. Reference count
+ * of the destination object is preserved.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopySimpleObject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *DestDesc)
+{
+ UINT16 ReferenceCount;
+ ACPI_OPERAND_OBJECT *NextObject;
+ ACPI_STATUS Status;
+ ACPI_SIZE CopySize;
+
+
+ /* Save fields from destination that we don't want to overwrite */
+
+ ReferenceCount = DestDesc->Common.ReferenceCount;
+ NextObject = DestDesc->Common.NextObject;
+
+ /*
+ * Copy the entire source object over the destination object.
+ * Note: Source can be either an operand object or namespace node.
+ */
+ CopySize = sizeof (ACPI_OPERAND_OBJECT);
+ if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
+ {
+ CopySize = sizeof (ACPI_NAMESPACE_NODE);
+ }
+
+ ACPI_MEMCPY (ACPI_CAST_PTR (char, DestDesc),
+ ACPI_CAST_PTR (char, SourceDesc), CopySize);
+
+ /* Restore the saved fields */
+
+ DestDesc->Common.ReferenceCount = ReferenceCount;
+ DestDesc->Common.NextObject = NextObject;
+
+ /* New object is not static, regardless of source */
+
+ DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
+
+ /* Handle the objects with extra data */
+
+ switch (DestDesc->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+ /*
+ * Allocate and copy the actual buffer if and only if:
+ * 1) There is a valid buffer pointer
+ * 2) The buffer has a length > 0
+ */
+ if ((SourceDesc->Buffer.Pointer) &&
+ (SourceDesc->Buffer.Length))
+ {
+ DestDesc->Buffer.Pointer =
+ ACPI_ALLOCATE (SourceDesc->Buffer.Length);
+ if (!DestDesc->Buffer.Pointer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Copy the actual buffer data */
+
+ ACPI_MEMCPY (DestDesc->Buffer.Pointer,
+ SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length);
+ }
+ break;
+
+ case ACPI_TYPE_STRING:
+ /*
+ * Allocate and copy the actual string if and only if:
+ * 1) There is a valid string pointer
+ * (Pointer to a NULL string is allowed)
+ */
+ if (SourceDesc->String.Pointer)
+ {
+ DestDesc->String.Pointer =
+ ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1);
+ if (!DestDesc->String.Pointer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Copy the actual string data */
+
+ ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer,
+ (ACPI_SIZE) SourceDesc->String.Length + 1);
+ }
+ break;
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ /*
+ * We copied the reference object, so we now must add a reference
+ * to the object pointed to by the reference
+ *
+ * DDBHandle reference (from Load/LoadTable) is a special reference,
+ * it does not have a Reference.Object, so does not need to
+ * increase the reference count
+ */
+ if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
+ {
+ break;
+ }
+
+ AcpiUtAddReference (SourceDesc->Reference.Object);
+ break;
+
+ case ACPI_TYPE_REGION:
+ /*
+ * We copied the Region Handler, so we now must add a reference
+ */
+ if (DestDesc->Region.Handler)
+ {
+ AcpiUtAddReference (DestDesc->Region.Handler);
+ }
+ break;
+
+ /*
+ * For Mutex and Event objects, we cannot simply copy the underlying
+ * OS object. We must create a new one.
+ */
+ case ACPI_TYPE_MUTEX:
+
+ Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+ case ACPI_TYPE_EVENT:
+
+ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
+ &DestDesc->Event.OsSemaphore);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+ default:
+ /* Nothing to do for other simple objects */
+ break;
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyIelementToIelement
+ *
+ * PARAMETERS: ACPI_PKG_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy one package element to another package element
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopyIelementToIelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 ThisIndex;
+ ACPI_OPERAND_OBJECT **ThisTargetPtr;
+ ACPI_OPERAND_OBJECT *TargetObject;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ ThisIndex = State->Pkg.Index;
+ ThisTargetPtr = (ACPI_OPERAND_OBJECT **)
+ &State->Pkg.DestObject->Package.Elements[ThisIndex];
+
+ switch (ObjectType)
+ {
+ case ACPI_COPY_TYPE_SIMPLE:
+
+ /* A null source object indicates a (legal) null package element */
+
+ if (SourceObject)
+ {
+ /*
+ * This is a simple object, just copy it
+ */
+ TargetObject = AcpiUtCreateInternalObject (
+ SourceObject->Common.Type);
+ if (!TargetObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ Status = AcpiUtCopySimpleObject (SourceObject, TargetObject);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ *ThisTargetPtr = TargetObject;
+ }
+ else
+ {
+ /* Pass through a null element */
+
+ *ThisTargetPtr = NULL;
+ }
+ break;
+
+
+ case ACPI_COPY_TYPE_PACKAGE:
+
+ /*
+ * This object is a package - go down another nesting level
+ * Create and build the package object
+ */
+ TargetObject = AcpiUtCreatePackageObject (SourceObject->Package.Count);
+ if (!TargetObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ TargetObject->Common.Flags = SourceObject->Common.Flags;
+
+ /* Pass the new package object back to the package walk routine */
+
+ State->Pkg.ThisTargetObj = TargetObject;
+
+ /* Store the object pointer in the parent package object */
+
+ *ThisTargetPtr = TargetObject;
+ break;
+
+
+ default:
+ return (AE_BAD_PARAMETER);
+ }
+
+ return (Status);
+
+ErrorExit:
+ AcpiUtRemoveReference (TargetObject);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyIpackageToIpackage
+ *
+ * PARAMETERS: SourceObj - Pointer to the source package object
+ * DestObj - Where the internal object is returned
+ * WalkState - Current Walk state descriptor
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to copy an internal package object
+ * into another internal package object.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCopyIpackageToIpackage (
+ ACPI_OPERAND_OBJECT *SourceObj,
+ ACPI_OPERAND_OBJECT *DestObj,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage);
+
+
+ DestObj->Common.Type = SourceObj->Common.Type;
+ DestObj->Common.Flags = SourceObj->Common.Flags;
+ DestObj->Package.Count = SourceObj->Package.Count;
+
+ /*
+ * Create the object array and walk the source package tree
+ */
+ DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED (
+ ((ACPI_SIZE) SourceObj->Package.Count + 1) *
+ sizeof (void *));
+ if (!DestObj->Package.Elements)
+ {
+ ACPI_ERROR ((AE_INFO, "Package allocation failure"));
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Copy the package element-by-element by walking the package "tree".
+ * This handles nested packages of arbitrary depth.
+ */
+ Status = AcpiUtWalkPackageTree (SourceObj, DestObj,
+ AcpiUtCopyIelementToIelement, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* On failure, delete the destination package object */
+
+ AcpiUtRemoveReference (DestObj);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCopyIobjectToIobject
+ *
+ * PARAMETERS: SourceDesc - The internal object to be copied
+ * DestDesc - Where the copied object is returned
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy an internal object to a new internal object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCopyIobjectToIobject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT **DestDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject);
+
+
+ /* Create the top level object */
+
+ *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type);
+ if (!*DestDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the object and possible subobjects */
+
+ if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE)
+ {
+ Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc,
+ WalkState);
+ }
+ else
+ {
+ Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utdebug.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utdebug.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,741 @@
+/******************************************************************************
+ *
+ * Module Name: utdebug - Debug print 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 __UTDEBUG_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utdebug")
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF;
+static char *AcpiGbl_FnEntryStr = "----Entry";
+static char *AcpiGbl_FnExitStr = "----Exit-";
+
+/* Local prototypes */
+
+static const char *
+AcpiUtTrimFunctionName (
+ const char *FunctionName);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtInitStackPtrTrace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
+ *
+ ******************************************************************************/
+
+void
+AcpiUtInitStackPtrTrace (
+ void)
+{
+ ACPI_SIZE CurrentSp;
+
+
+ AcpiGbl_EntryStackPointer = &CurrentSp;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTrackStackPtr
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Save the current CPU stack pointer
+ *
+ ******************************************************************************/
+
+void
+AcpiUtTrackStackPtr (
+ void)
+{
+ ACPI_SIZE CurrentSp;
+
+
+ if (&CurrentSp < AcpiGbl_LowestStackPointer)
+ {
+ AcpiGbl_LowestStackPointer = &CurrentSp;
+ }
+
+ if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
+ {
+ AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTrimFunctionName
+ *
+ * PARAMETERS: FunctionName - Ascii string containing a procedure name
+ *
+ * RETURN: Updated pointer to the function name
+ *
+ * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
+ * This allows compiler macros such as __FUNCTION__ to be used
+ * with no change to the debug output.
+ *
+ ******************************************************************************/
+
+static const char *
+AcpiUtTrimFunctionName (
+ const char *FunctionName)
+{
+
+ /* All Function names are longer than 4 chars, check is safe */
+
+ if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED)
+ {
+ /* This is the case where the original source has not been modified */
+
+ return (FunctionName + 4);
+ }
+
+ if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER)
+ {
+ /* This is the case where the source has been 'linuxized' */
+
+ return (FunctionName + 5);
+ }
+
+ return (FunctionName);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDebugPrint
+ *
+ * PARAMETERS: RequestedDebugLevel - Requested debug print level
+ * LineNumber - Caller's line number (for error output)
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Format - Printf format field
+ * ... - Optional printf arguments
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print error message with prefix consisting of the module name,
+ * line number, and component ID.
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiDebugPrint (
+ UINT32 RequestedDebugLevel,
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ const char *Format,
+ ...)
+{
+ ACPI_THREAD_ID ThreadId;
+ va_list args;
+
+
+ /*
+ * Stay silent if the debug level or component ID is disabled
+ */
+ if (!(RequestedDebugLevel & AcpiDbgLevel) ||
+ !(ComponentId & AcpiDbgLayer))
+ {
+ return;
+ }
+
+ /*
+ * Thread tracking and context switch notification
+ */
+ ThreadId = AcpiOsGetThreadId ();
+ if (ThreadId != AcpiGbl_PrevThreadId)
+ {
+ if (ACPI_LV_THREADS & AcpiDbgLevel)
+ {
+ AcpiOsPrintf (
+ "\n**** Context Switch from TID %u to TID %u ****\n\n",
+ (UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId);
+ }
+
+ AcpiGbl_PrevThreadId = ThreadId;
+ }
+
+ /*
+ * Display the module name, current line number, thread ID (if requested),
+ * current procedure nesting level, and the current procedure name
+ */
+ AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber);
+
+ if (ACPI_LV_THREADS & AcpiDbgLevel)
+ {
+ AcpiOsPrintf ("[%u] ", (UINT32) ThreadId);
+ }
+
+ AcpiOsPrintf ("[%02ld] %-22.22s: ",
+ AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName));
+
+ va_start (args, Format);
+ AcpiOsVprintf (Format, args);
+ va_end (args);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiDebugPrint)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDebugPrintRaw
+ *
+ * PARAMETERS: RequestedDebugLevel - Requested debug print level
+ * LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Format - Printf format field
+ * ... - Optional printf arguments
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print message with no headers. Has same interface as
+ * DebugPrint so that the same macros can be used.
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiDebugPrintRaw (
+ UINT32 RequestedDebugLevel,
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ const char *Format,
+ ...)
+{
+ va_list args;
+
+
+ if (!(RequestedDebugLevel & AcpiDbgLevel) ||
+ !(ComponentId & AcpiDbgLayer))
+ {
+ return;
+ }
+
+ va_start (args, Format);
+ AcpiOsVprintf (Format, args);
+ va_end (args);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTrace
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ******************************************************************************/
+
+void
+AcpiUtTrace (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId)
+{
+
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s\n", AcpiGbl_FnEntryStr);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiUtTrace)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTracePtr
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Pointer - Pointer to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ******************************************************************************/
+
+void
+AcpiUtTracePtr (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ void *Pointer)
+{
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s %p\n", AcpiGbl_FnEntryStr, Pointer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTraceStr
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * String - Additional string to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ******************************************************************************/
+
+void
+AcpiUtTraceStr (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ char *String)
+{
+
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s %s\n", AcpiGbl_FnEntryStr, String);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTraceU32
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Integer - Integer to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ******************************************************************************/
+
+void
+AcpiUtTraceU32 (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ UINT32 Integer)
+{
+
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s %08X\n", AcpiGbl_FnEntryStr, Integer);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ******************************************************************************/
+
+void
+AcpiUtExit (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId)
+{
+
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s\n", AcpiGbl_FnExitStr);
+
+ AcpiGbl_NestingLevel--;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiUtExit)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtStatusExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Status - Exit status code
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel. Prints exit status also.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtStatusExit (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ ACPI_STATUS Status)
+{
+
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s %s\n", AcpiGbl_FnExitStr,
+ AcpiFormatException (Status));
+ }
+ else
+ {
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s ****Exception****: %s\n", AcpiGbl_FnExitStr,
+ AcpiFormatException (Status));
+ }
+
+ AcpiGbl_NestingLevel--;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiUtStatusExit)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValueExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Value - Value to be printed with exit msg
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel. Prints exit value also.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtValueExit (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ UINT64 Value)
+{
+
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr,
+ ACPI_FORMAT_UINT64 (Value));
+
+ AcpiGbl_NestingLevel--;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiUtValueExit)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtPtrExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * FunctionName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Ptr - Pointer to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel. Prints exit value also.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtPtrExit (
+ UINT32 LineNumber,
+ const char *FunctionName,
+ const char *ModuleName,
+ UINT32 ComponentId,
+ UINT8 *Ptr)
+{
+
+ AcpiDebugPrint (ACPI_LV_FUNCTIONS,
+ LineNumber, FunctionName, ModuleName, ComponentId,
+ "%s %p\n", AcpiGbl_FnExitStr, Ptr);
+
+ AcpiGbl_NestingLevel--;
+}
+
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDumpBuffer
+ *
+ * PARAMETERS: Buffer - Buffer to dump
+ * Count - Amount to dump, in bytes
+ * Display - BYTE, WORD, DWORD, or QWORD display
+ * ComponentID - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generic dump buffer in both hex and ascii.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDumpBuffer2 (
+ UINT8 *Buffer,
+ UINT32 Count,
+ UINT32 Display)
+{
+ UINT32 i = 0;
+ UINT32 j;
+ UINT32 Temp32;
+ UINT8 BufChar;
+
+
+ if (!Buffer)
+ {
+ AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
+ return;
+ }
+
+ if ((Count < 4) || (Count & 0x01))
+ {
+ Display = DB_BYTE_DISPLAY;
+ }
+
+ /* Nasty little dump buffer routine! */
+
+ while (i < Count)
+ {
+ /* Print current offset */
+
+ AcpiOsPrintf ("%6.4X: ", i);
+
+ /* Print 16 hex chars */
+
+ for (j = 0; j < 16;)
+ {
+ if (i + j >= Count)
+ {
+ /* Dump fill spaces */
+
+ AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
+ j += Display;
+ continue;
+ }
+
+ switch (Display)
+ {
+ case DB_BYTE_DISPLAY:
+ default: /* Default is BYTE display */
+
+ AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]);
+ break;
+
+
+ case DB_WORD_DISPLAY:
+
+ ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
+ AcpiOsPrintf ("%04X ", Temp32);
+ break;
+
+
+ case DB_DWORD_DISPLAY:
+
+ ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
+ AcpiOsPrintf ("%08X ", Temp32);
+ break;
+
+
+ case DB_QWORD_DISPLAY:
+
+ ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
+ AcpiOsPrintf ("%08X", Temp32);
+
+ ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
+ AcpiOsPrintf ("%08X ", Temp32);
+ break;
+ }
+
+ j += Display;
+ }
+
+ /*
+ * Print the ASCII equivalent characters but watch out for the bad
+ * unprintable ones (printable chars are 0x20 through 0x7E)
+ */
+ AcpiOsPrintf (" ");
+ for (j = 0; j < 16; j++)
+ {
+ if (i + j >= Count)
+ {
+ AcpiOsPrintf ("\n");
+ return;
+ }
+
+ BufChar = Buffer[(ACPI_SIZE) i + j];
+ if (ACPI_IS_PRINT (BufChar))
+ {
+ AcpiOsPrintf ("%c", BufChar);
+ }
+ else
+ {
+ AcpiOsPrintf (".");
+ }
+ }
+
+ /* Done with that line. */
+
+ AcpiOsPrintf ("\n");
+ i += 16;
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDumpBuffer
+ *
+ * PARAMETERS: Buffer - Buffer to dump
+ * Count - Amount to dump, in bytes
+ * Display - BYTE, WORD, DWORD, or QWORD display
+ * ComponentID - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generic dump buffer in both hex and ascii.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDumpBuffer (
+ UINT8 *Buffer,
+ UINT32 Count,
+ UINT32 Display,
+ UINT32 ComponentId)
+{
+
+ /* Only dump the buffer if tracing is enabled */
+
+ if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
+ (ComponentId & AcpiDbgLayer)))
+ {
+ return;
+ }
+
+ AcpiUtDumpBuffer2 (Buffer, Count, Display);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utdecode.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utdecode.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,637 @@
+/******************************************************************************
+ *
+ * Module Name: utdecode - Utility decoding routines (value-to-string)
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __UTDECODE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utdecode")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiFormatException
+ *
+ * PARAMETERS: Status - The ACPI_STATUS code to be formatted
+ *
+ * RETURN: A string containing the exception text. A valid pointer is
+ * always returned.
+ *
+ * DESCRIPTION: This function translates an ACPI exception into an ASCII string
+ * It is here instead of utxface.c so it is always present.
+ *
+ ******************************************************************************/
+
+const char *
+AcpiFormatException (
+ ACPI_STATUS Status)
+{
+ const char *Exception = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Exception = AcpiUtValidateException (Status);
+ if (!Exception)
+ {
+ /* Exception code was not recognized */
+
+ ACPI_ERROR ((AE_INFO,
+ "Unknown exception code: 0x%8.8X", Status));
+
+ Exception = "UNKNOWN_STATUS_CODE";
+ }
+
+ return (ACPI_CAST_PTR (const char, Exception));
+}
+
+ACPI_EXPORT_SYMBOL (AcpiFormatException)
+
+
+/*
+ * Properties of the ACPI Object Types, both internal and external.
+ * The table is indexed by values of ACPI_OBJECT_TYPE
+ */
+const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
+{
+ ACPI_NS_NORMAL, /* 00 Any */
+ ACPI_NS_NORMAL, /* 01 Number */
+ ACPI_NS_NORMAL, /* 02 String */
+ ACPI_NS_NORMAL, /* 03 Buffer */
+ ACPI_NS_NORMAL, /* 04 Package */
+ ACPI_NS_NORMAL, /* 05 FieldUnit */
+ ACPI_NS_NEWSCOPE, /* 06 Device */
+ ACPI_NS_NORMAL, /* 07 Event */
+ ACPI_NS_NEWSCOPE, /* 08 Method */
+ ACPI_NS_NORMAL, /* 09 Mutex */
+ ACPI_NS_NORMAL, /* 10 Region */
+ ACPI_NS_NEWSCOPE, /* 11 Power */
+ ACPI_NS_NEWSCOPE, /* 12 Processor */
+ ACPI_NS_NEWSCOPE, /* 13 Thermal */
+ ACPI_NS_NORMAL, /* 14 BufferField */
+ ACPI_NS_NORMAL, /* 15 DdbHandle */
+ ACPI_NS_NORMAL, /* 16 Debug Object */
+ ACPI_NS_NORMAL, /* 17 DefField */
+ ACPI_NS_NORMAL, /* 18 BankField */
+ ACPI_NS_NORMAL, /* 19 IndexField */
+ ACPI_NS_NORMAL, /* 20 Reference */
+ ACPI_NS_NORMAL, /* 21 Alias */
+ ACPI_NS_NORMAL, /* 22 MethodAlias */
+ ACPI_NS_NORMAL, /* 23 Notify */
+ ACPI_NS_NORMAL, /* 24 Address Handler */
+ ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
+ ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
+ ACPI_NS_NEWSCOPE, /* 27 Scope */
+ ACPI_NS_NORMAL, /* 28 Extra */
+ ACPI_NS_NORMAL, /* 29 Data */
+ ACPI_NS_NORMAL /* 30 Invalid */
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtHexToAsciiChar
+ *
+ * PARAMETERS: Integer - Contains the hex digit
+ * Position - bit position of the digit within the
+ * integer (multiple of 4)
+ *
+ * RETURN: The converted Ascii character
+ *
+ * DESCRIPTION: Convert a hex digit to an Ascii character
+ *
+ ******************************************************************************/
+
+/* Hex to ASCII conversion table */
+
+static const char AcpiGbl_HexToAscii[] =
+{
+ '0','1','2','3','4','5','6','7',
+ '8','9','A','B','C','D','E','F'
+};
+
+char
+AcpiUtHexToAsciiChar (
+ UINT64 Integer,
+ UINT32 Position)
+{
+
+ return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetRegionName
+ *
+ * PARAMETERS: Space ID - ID for the region
+ *
+ * RETURN: Decoded region SpaceId name
+ *
+ * DESCRIPTION: Translate a Space ID into a name string (Debug only)
+ *
+ ******************************************************************************/
+
+/* Region type decoding */
+
+const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
+{
+ "SystemMemory",
+ "SystemIO",
+ "PCI_Config",
+ "EmbeddedControl",
+ "SMBus",
+ "SystemCMOS",
+ "PCIBARTarget",
+ "IPMI",
+ "GeneralPurposeIo",
+ "GenericSerialBus"
+};
+
+
+char *
+AcpiUtGetRegionName (
+ UINT8 SpaceId)
+{
+
+ if (SpaceId >= ACPI_USER_REGION_BEGIN)
+ {
+ return ("UserDefinedRegion");
+ }
+ else if (SpaceId == ACPI_ADR_SPACE_DATA_TABLE)
+ {
+ return ("DataTable");
+ }
+ else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
+ {
+ return ("FunctionalFixedHW");
+ }
+ else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
+ {
+ return ("InvalidSpaceId");
+ }
+
+ return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetEventName
+ *
+ * PARAMETERS: EventId - Fixed event ID
+ *
+ * RETURN: Decoded event ID name
+ *
+ * DESCRIPTION: Translate a Event ID into a name string (Debug only)
+ *
+ ******************************************************************************/
+
+/* Event type decoding */
+
+static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
+{
+ "PM_Timer",
+ "GlobalLock",
+ "PowerButton",
+ "SleepButton",
+ "RealTimeClock",
+};
+
+
+char *
+AcpiUtGetEventName (
+ UINT32 EventId)
+{
+
+ if (EventId > ACPI_EVENT_MAX)
+ {
+ return ("InvalidEventID");
+ }
+
+ return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetTypeName
+ *
+ * PARAMETERS: Type - An ACPI object type
+ *
+ * RETURN: Decoded ACPI object type name
+ *
+ * DESCRIPTION: Translate a Type ID into a name string (Debug only)
+ *
+ ******************************************************************************/
+
+/*
+ * Elements of AcpiGbl_NsTypeNames below must match
+ * one-to-one with values of ACPI_OBJECT_TYPE
+ *
+ * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
+ * when stored in a table it really means that we have thus far seen no
+ * evidence to indicate what type is actually going to be stored for this entry.
+ */
+static const char AcpiGbl_BadType[] = "UNDEFINED";
+
+/* Printable names of the ACPI object types */
+
+static const char *AcpiGbl_NsTypeNames[] =
+{
+ /* 00 */ "Untyped",
+ /* 01 */ "Integer",
+ /* 02 */ "String",
+ /* 03 */ "Buffer",
+ /* 04 */ "Package",
+ /* 05 */ "FieldUnit",
+ /* 06 */ "Device",
+ /* 07 */ "Event",
+ /* 08 */ "Method",
+ /* 09 */ "Mutex",
+ /* 10 */ "Region",
+ /* 11 */ "Power",
+ /* 12 */ "Processor",
+ /* 13 */ "Thermal",
+ /* 14 */ "BufferField",
+ /* 15 */ "DdbHandle",
+ /* 16 */ "DebugObject",
+ /* 17 */ "RegionField",
+ /* 18 */ "BankField",
+ /* 19 */ "IndexField",
+ /* 20 */ "Reference",
+ /* 21 */ "Alias",
+ /* 22 */ "MethodAlias",
+ /* 23 */ "Notify",
+ /* 24 */ "AddrHandler",
+ /* 25 */ "ResourceDesc",
+ /* 26 */ "ResourceFld",
+ /* 27 */ "Scope",
+ /* 28 */ "Extra",
+ /* 29 */ "Data",
+ /* 30 */ "Invalid"
+};
+
+
+char *
+AcpiUtGetTypeName (
+ ACPI_OBJECT_TYPE Type)
+{
+
+ if (Type > ACPI_TYPE_INVALID)
+ {
+ return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
+ }
+
+ return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
+}
+
+
+char *
+AcpiUtGetObjectTypeName (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+
+ if (!ObjDesc)
+ {
+ return ("[NULL Object Descriptor]");
+ }
+
+ return (AcpiUtGetTypeName (ObjDesc->Common.Type));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetNodeName
+ *
+ * PARAMETERS: Object - A namespace node
+ *
+ * RETURN: ASCII name of the node
+ *
+ * DESCRIPTION: Validate the node and return the node's ACPI name.
+ *
+ ******************************************************************************/
+
+char *
+AcpiUtGetNodeName (
+ void *Object)
+{
+ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
+
+
+ /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
+
+ if (!Object)
+ {
+ return ("NULL");
+ }
+
+ /* Check for Root node */
+
+ if ((Object == ACPI_ROOT_OBJECT) ||
+ (Object == AcpiGbl_RootNode))
+ {
+ return ("\"\\\" ");
+ }
+
+ /* Descriptor must be a namespace node */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
+ {
+ return ("####");
+ }
+
+ /*
+ * Ensure name is valid. The name was validated/repaired when the node
+ * was created, but make sure it has not been corrupted.
+ */
+ AcpiUtRepairName (Node->Name.Ascii);
+
+ /* Return the name */
+
+ return (Node->Name.Ascii);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetDescriptorName
+ *
+ * PARAMETERS: Object - An ACPI object
+ *
+ * RETURN: Decoded name of the descriptor type
+ *
+ * DESCRIPTION: Validate object and return the descriptor type
+ *
+ ******************************************************************************/
+
+/* Printable names of object descriptor types */
+
+static const char *AcpiGbl_DescTypeNames[] =
+{
+ /* 00 */ "Not a Descriptor",
+ /* 01 */ "Cached",
+ /* 02 */ "State-Generic",
+ /* 03 */ "State-Update",
+ /* 04 */ "State-Package",
+ /* 05 */ "State-Control",
+ /* 06 */ "State-RootParseScope",
+ /* 07 */ "State-ParseScope",
+ /* 08 */ "State-WalkScope",
+ /* 09 */ "State-Result",
+ /* 10 */ "State-Notify",
+ /* 11 */ "State-Thread",
+ /* 12 */ "Walk",
+ /* 13 */ "Parser",
+ /* 14 */ "Operand",
+ /* 15 */ "Node"
+};
+
+
+char *
+AcpiUtGetDescriptorName (
+ void *Object)
+{
+
+ if (!Object)
+ {
+ return ("NULL OBJECT");
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
+ {
+ return ("Not a Descriptor");
+ }
+
+ return (ACPI_CAST_PTR (char,
+ AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetReferenceName
+ *
+ * PARAMETERS: Object - An ACPI reference object
+ *
+ * RETURN: Decoded name of the type of reference
+ *
+ * DESCRIPTION: Decode a reference object sub-type to a string.
+ *
+ ******************************************************************************/
+
+/* Printable names of reference object sub-types */
+
+static const char *AcpiGbl_RefClassNames[] =
+{
+ /* 00 */ "Local",
+ /* 01 */ "Argument",
+ /* 02 */ "RefOf",
+ /* 03 */ "Index",
+ /* 04 */ "DdbHandle",
+ /* 05 */ "Named Object",
+ /* 06 */ "Debug"
+};
+
+const char *
+AcpiUtGetReferenceName (
+ ACPI_OPERAND_OBJECT *Object)
+{
+
+ if (!Object)
+ {
+ return ("NULL Object");
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
+ {
+ return ("Not an Operand object");
+ }
+
+ if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
+ {
+ return ("Not a Reference object");
+ }
+
+ if (Object->Reference.Class > ACPI_REFCLASS_MAX)
+ {
+ return ("Unknown Reference class");
+ }
+
+ return (AcpiGbl_RefClassNames[Object->Reference.Class]);
+}
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+/*
+ * Strings and procedures used for debug only
+ */
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetMutexName
+ *
+ * PARAMETERS: MutexId - The predefined ID for this mutex.
+ *
+ * RETURN: Decoded name of the internal mutex
+ *
+ * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
+ *
+ ******************************************************************************/
+
+/* Names for internal mutex objects, used for debug output */
+
+static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
+{
+ "ACPI_MTX_Interpreter",
+ "ACPI_MTX_Namespace",
+ "ACPI_MTX_Tables",
+ "ACPI_MTX_Events",
+ "ACPI_MTX_Caches",
+ "ACPI_MTX_Memory",
+ "ACPI_MTX_CommandComplete",
+ "ACPI_MTX_CommandReady"
+};
+
+char *
+AcpiUtGetMutexName (
+ UINT32 MutexId)
+{
+
+ if (MutexId > ACPI_MAX_MUTEX)
+ {
+ return ("Invalid Mutex ID");
+ }
+
+ return (AcpiGbl_MutexNames[MutexId]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetNotifyName
+ *
+ * PARAMETERS: NotifyValue - Value from the Notify() request
+ *
+ * RETURN: Decoded name for the notify value
+ *
+ * DESCRIPTION: Translate a Notify Value to a notify namestring.
+ *
+ ******************************************************************************/
+
+/* Names for Notify() values, used for debug output */
+
+static const char *AcpiGbl_NotifyValueNames[ACPI_NOTIFY_MAX + 1] =
+{
+ /* 00 */ "Bus Check",
+ /* 01 */ "Device Check",
+ /* 02 */ "Device Wake",
+ /* 03 */ "Eject Request",
+ /* 04 */ "Device Check Light",
+ /* 05 */ "Frequency Mismatch",
+ /* 06 */ "Bus Mode Mismatch",
+ /* 07 */ "Power Fault",
+ /* 08 */ "Capabilities Check",
+ /* 09 */ "Device PLD Check",
+ /* 10 */ "Reserved",
+ /* 11 */ "System Locality Update",
+ /* 12 */ "Shutdown Request"
+};
+
+const char *
+AcpiUtGetNotifyName (
+ UINT32 NotifyValue)
+{
+
+ if (NotifyValue <= ACPI_NOTIFY_MAX)
+ {
+ return (AcpiGbl_NotifyValueNames[NotifyValue]);
+ }
+ else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
+ {
+ return ("Reserved");
+ }
+ else if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY)
+ {
+ return ("Device Specific");
+ }
+ else
+ {
+ return ("Hardware Specific");
+ }
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidObjectType
+ *
+ * PARAMETERS: Type - Object type to be validated
+ *
+ * RETURN: TRUE if valid object type, FALSE otherwise
+ *
+ * DESCRIPTION: Validate an object type
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiUtValidObjectType (
+ ACPI_OBJECT_TYPE Type)
+{
+
+ if (Type > ACPI_TYPE_LOCAL_MAX)
+ {
+ /* Note: Assumes all TYPEs are contiguous (external/local) */
+
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utdelete.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utdelete.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,766 @@
+/*******************************************************************************
+ *
+ * Module Name: utdelete - object deletion and reference count 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 __UTDELETE_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/acevents.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utdelete")
+
+/* Local prototypes */
+
+static void
+AcpiUtDeleteInternalObj (
+ ACPI_OPERAND_OBJECT *Object);
+
+static void
+AcpiUtUpdateRefCount (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT32 Action);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteInternalObj
+ *
+ * PARAMETERS: Object - Object to be deleted
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Low level object deletion, after reference counts have been
+ * updated (All reference counts, including sub-objects!)
+ *
+ ******************************************************************************/
+
+static void
+AcpiUtDeleteInternalObj (
+ ACPI_OPERAND_OBJECT *Object)
+{
+ void *ObjPointer = NULL;
+ ACPI_OPERAND_OBJECT *HandlerDesc;
+ ACPI_OPERAND_OBJECT *SecondDesc;
+ ACPI_OPERAND_OBJECT *NextDesc;
+ ACPI_OPERAND_OBJECT **LastObjPtr;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object);
+
+
+ if (!Object)
+ {
+ return_VOID;
+ }
+
+ /*
+ * Must delete or free any pointers within the object that are not
+ * actual ACPI objects (for example, a raw buffer pointer).
+ */
+ switch (Object->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n",
+ Object, Object->String.Pointer));
+
+ /* Free the actual string buffer */
+
+ if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
+ {
+ /* But only if it is NOT a pointer into an ACPI table */
+
+ ObjPointer = Object->String.Pointer;
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
+ Object, Object->Buffer.Pointer));
+
+ /* Free the actual buffer */
+
+ if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
+ {
+ /* But only if it is NOT a pointer into an ACPI table */
+
+ ObjPointer = Object->Buffer.Pointer;
+ }
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
+ Object->Package.Count));
+
+ /*
+ * Elements of the package are not handled here, they are deleted
+ * separately
+ */
+
+ /* Free the (variable length) element pointer array */
+
+ ObjPointer = Object->Package.Elements;
+ break;
+
+
+ /*
+ * These objects have a possible list of notify handlers.
+ * Device object also may have a GPE block.
+ */
+ case ACPI_TYPE_DEVICE:
+
+ if (Object->Device.GpeBlock)
+ {
+ (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock);
+ }
+
+ /*lint -fallthrough */
+
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_THERMAL:
+
+ /* Walk the notify handler list for this object */
+
+ HandlerDesc = Object->CommonNotify.Handler;
+ while (HandlerDesc)
+ {
+ NextDesc = HandlerDesc->AddressSpace.Next;
+ AcpiUtRemoveReference (HandlerDesc);
+ HandlerDesc = NextDesc;
+ }
+ break;
+
+
+ case ACPI_TYPE_MUTEX:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Mutex %p, OS Mutex %p\n",
+ Object, Object->Mutex.OsMutex));
+
+ if (Object == AcpiGbl_GlobalLockMutex)
+ {
+ /* Global Lock has extra semaphore */
+
+ (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore);
+ AcpiGbl_GlobalLockSemaphore = NULL;
+
+ AcpiOsDeleteMutex (Object->Mutex.OsMutex);
+ AcpiGbl_GlobalLockMutex = NULL;
+ }
+ else
+ {
+ AcpiExUnlinkMutex (Object);
+ AcpiOsDeleteMutex (Object->Mutex.OsMutex);
+ }
+ break;
+
+
+ case ACPI_TYPE_EVENT:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Event %p, OS Semaphore %p\n",
+ Object, Object->Event.OsSemaphore));
+
+ (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore);
+ Object->Event.OsSemaphore = NULL;
+ break;
+
+
+ case ACPI_TYPE_METHOD:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Method %p\n", Object));
+
+ /* Delete the method mutex if it exists */
+
+ if (Object->Method.Mutex)
+ {
+ AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex);
+ AcpiUtDeleteObjectDesc (Object->Method.Mutex);
+ Object->Method.Mutex = NULL;
+ }
+ break;
+
+
+ case ACPI_TYPE_REGION:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Region %p\n", Object));
+
+ /*
+ * Update AddressRange list. However, only permanent regions
+ * are installed in this list. (Not created within a method)
+ */
+ if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY))
+ {
+ AcpiUtRemoveAddressRange (Object->Region.SpaceId,
+ Object->Region.Node);
+ }
+
+ SecondDesc = AcpiNsGetSecondaryObject (Object);
+ if (SecondDesc)
+ {
+ /*
+ * Free the RegionContext if and only if the handler is one of the
+ * default handlers -- and therefore, we created the context object
+ * locally, it was not created by an external caller.
+ */
+ HandlerDesc = Object->Region.Handler;
+ if (HandlerDesc)
+ {
+ NextDesc = HandlerDesc->AddressSpace.RegionList;
+ LastObjPtr = &HandlerDesc->AddressSpace.RegionList;
+
+ /* Remove the region object from the handler's list */
+
+ while (NextDesc)
+ {
+ if (NextDesc == Object)
+ {
+ *LastObjPtr = NextDesc->Region.Next;
+ break;
+ }
+
+ /* Walk the linked list of handler */
+
+ LastObjPtr = &NextDesc->Region.Next;
+ NextDesc = NextDesc->Region.Next;
+ }
+
+ if (HandlerDesc->AddressSpace.HandlerFlags &
+ ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
+ {
+ /* Deactivate region and free region context */
+
+ if (HandlerDesc->AddressSpace.Setup)
+ {
+ (void) HandlerDesc->AddressSpace.Setup (Object,
+ ACPI_REGION_DEACTIVATE,
+ HandlerDesc->AddressSpace.Context,
+ &SecondDesc->Extra.RegionContext);
+ }
+ }
+
+ AcpiUtRemoveReference (HandlerDesc);
+ }
+
+ /* Now we can free the Extra object */
+
+ AcpiUtDeleteObjectDesc (SecondDesc);
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Buffer Field %p\n", Object));
+
+ SecondDesc = AcpiNsGetSecondaryObject (Object);
+ if (SecondDesc)
+ {
+ AcpiUtDeleteObjectDesc (SecondDesc);
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Bank Field %p\n", Object));
+
+ SecondDesc = AcpiNsGetSecondaryObject (Object);
+ if (SecondDesc)
+ {
+ AcpiUtDeleteObjectDesc (SecondDesc);
+ }
+ break;
+
+
+ default:
+ break;
+ }
+
+ /* Free any allocated memory (pointer within the object) found above */
+
+ if (ObjPointer)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n",
+ ObjPointer));
+ ACPI_FREE (ObjPointer);
+ }
+
+ /* Now the object can be safely deleted */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
+ Object, AcpiUtGetObjectTypeName (Object)));
+
+ AcpiUtDeleteObjectDesc (Object);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteInternalObjectList
+ *
+ * PARAMETERS: ObjList - Pointer to the list to be deleted
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: This function deletes an internal object list, including both
+ * simple objects and package objects
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDeleteInternalObjectList (
+ ACPI_OPERAND_OBJECT **ObjList)
+{
+ ACPI_OPERAND_OBJECT **InternalObj;
+
+
+ ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList);
+
+
+ /* Walk the null-terminated internal list */
+
+ for (InternalObj = ObjList; *InternalObj; InternalObj++)
+ {
+ AcpiUtRemoveReference (*InternalObj);
+ }
+
+ /* Free the combined parameter pointer list and object array */
+
+ ACPI_FREE (ObjList);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtUpdateRefCount
+ *
+ * PARAMETERS: Object - Object whose ref count is to be updated
+ * Action - What to do
+ *
+ * RETURN: New ref count
+ *
+ * DESCRIPTION: Modify the ref count and return it.
+ *
+ ******************************************************************************/
+
+static void
+AcpiUtUpdateRefCount (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT32 Action)
+{
+ UINT16 Count;
+ UINT16 NewCount;
+
+
+ ACPI_FUNCTION_NAME (UtUpdateRefCount);
+
+
+ if (!Object)
+ {
+ return;
+ }
+
+ Count = Object->Common.ReferenceCount;
+ NewCount = Count;
+
+ /*
+ * Perform the reference count action (increment, decrement, force delete)
+ */
+ switch (Action)
+ {
+ case REF_INCREMENT:
+
+ NewCount++;
+ Object->Common.ReferenceCount = NewCount;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, [Incremented]\n",
+ Object, NewCount));
+ break;
+
+ case REF_DECREMENT:
+
+ if (Count < 1)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
+ Object, NewCount));
+
+ NewCount = 0;
+ }
+ else
+ {
+ NewCount--;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, [Decremented]\n",
+ Object, NewCount));
+ }
+
+ if (Object->Common.Type == ACPI_TYPE_METHOD)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount));
+ }
+
+ Object->Common.ReferenceCount = NewCount;
+ if (NewCount == 0)
+ {
+ AcpiUtDeleteInternalObj (Object);
+ }
+ break;
+
+ case REF_FORCE_DELETE:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count));
+
+ NewCount = 0;
+ Object->Common.ReferenceCount = NewCount;
+ AcpiUtDeleteInternalObj (Object);
+ break;
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Unknown action (0x%X)", Action));
+ break;
+ }
+
+ /*
+ * Sanity check the reference count, for debug purposes only.
+ * (A deleted object will have a huge reference count)
+ */
+ if (Count > ACPI_MAX_REFERENCE_COUNT)
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Large Reference Count (0x%X) in object %p", Count, Object));
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtUpdateObjectReference
+ *
+ * PARAMETERS: Object - Increment ref count for this object
+ * and all sub-objects
+ * Action - Either REF_INCREMENT or REF_DECREMENT or
+ * REF_FORCE_DELETE
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Increment the object reference count
+ *
+ * Object references are incremented when:
+ * 1) An object is attached to a Node (namespace object)
+ * 2) An object is copied (all subobjects must be incremented)
+ *
+ * Object references are decremented when:
+ * 1) An object is detached from an Node
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtUpdateObjectReference (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT16 Action)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_GENERIC_STATE *StateList = NULL;
+ ACPI_OPERAND_OBJECT *NextObject = NULL;
+ ACPI_GENERIC_STATE *State;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object);
+
+
+ while (Object)
+ {
+ /* Make sure that this isn't a namespace handle */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Object %p is NS handle\n", Object));
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * All sub-objects must have their reference count incremented also.
+ * Different object types have different subobjects.
+ */
+ switch (Object->Common.Type)
+ {
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_POWER:
+ case ACPI_TYPE_THERMAL:
+
+ /* Update the notify objects for these types (if present) */
+
+ AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action);
+ AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action);
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ /*
+ * We must update all the sub-objects of the package,
+ * each of whom may have their own sub-objects.
+ */
+ for (i = 0; i < Object->Package.Count; i++)
+ {
+ /*
+ * Push each element onto the stack for later processing.
+ * Note: There can be null elements within the package,
+ * these are simply ignored
+ */
+ Status = AcpiUtCreateUpdateStateAndPush (
+ Object->Package.Elements[i], Action, &StateList);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER_FIELD:
+
+ NextObject = Object->BufferField.BufferObj;
+ break;
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ NextObject = Object->Field.RegionObj;
+ break;
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ NextObject = Object->BankField.BankObj;
+ Status = AcpiUtCreateUpdateStateAndPush (
+ Object->BankField.RegionObj, Action, &StateList);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+ break;
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ NextObject = Object->IndexField.IndexObj;
+ Status = AcpiUtCreateUpdateStateAndPush (
+ Object->IndexField.DataObj, Action, &StateList);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+ break;
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+ /*
+ * The target of an Index (a package, string, or buffer) or a named
+ * reference must track changes to the ref count of the index or
+ * target object.
+ */
+ if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) ||
+ (Object->Reference.Class== ACPI_REFCLASS_NAME))
+ {
+ NextObject = Object->Reference.Object;
+ }
+ break;
+
+ case ACPI_TYPE_REGION:
+ default:
+ break; /* No subobjects for all other types */
+ }
+
+ /*
+ * Now we can update the count in the main object. This can only
+ * happen after we update the sub-objects in case this causes the
+ * main object to be deleted.
+ */
+ AcpiUtUpdateRefCount (Object, Action);
+ Object = NULL;
+
+ /* Move on to the next object to be updated */
+
+ if (NextObject)
+ {
+ Object = NextObject;
+ NextObject = NULL;
+ }
+ else if (StateList)
+ {
+ State = AcpiUtPopGenericState (&StateList);
+ Object = State->Update.Object;
+ AcpiUtDeleteGenericState (State);
+ }
+ }
+
+ return_ACPI_STATUS (AE_OK);
+
+
+ErrorExit:
+
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Could not update object reference count"));
+
+ /* Free any stacked Update State objects */
+
+ while (StateList)
+ {
+ State = AcpiUtPopGenericState (&StateList);
+ AcpiUtDeleteGenericState (State);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAddReference
+ *
+ * PARAMETERS: Object - Object whose reference count is to be
+ * incremented
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Add one reference to an ACPI object
+ *
+ ******************************************************************************/
+
+void
+AcpiUtAddReference (
+ ACPI_OPERAND_OBJECT *Object)
+{
+
+ ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object);
+
+
+ /* Ensure that we have a valid object */
+
+ if (!AcpiUtValidInternalObject (Object))
+ {
+ return_VOID;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Current Refs=%X [To Be Incremented]\n",
+ Object, Object->Common.ReferenceCount));
+
+ /* Increment the reference count */
+
+ (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtRemoveReference
+ *
+ * PARAMETERS: Object - Object whose ref count will be decremented
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decrement the reference count of an ACPI internal object
+ *
+ ******************************************************************************/
+
+void
+AcpiUtRemoveReference (
+ ACPI_OPERAND_OBJECT *Object)
+{
+
+ ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object);
+
+
+ /*
+ * Allow a NULL pointer to be passed in, just ignore it. This saves
+ * each caller from having to check. Also, ignore NS nodes.
+ *
+ */
+ if (!Object ||
+ (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED))
+
+ {
+ return_VOID;
+ }
+
+ /* Ensure that we have a valid object */
+
+ if (!AcpiUtValidInternalObject (Object))
+ {
+ return_VOID;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Current Refs=%X [To Be Decremented]\n",
+ Object, Object->Common.ReferenceCount));
+
+ /*
+ * Decrement the reference count, and only actually delete the object
+ * if the reference count becomes 0. (Must also decrement the ref count
+ * of all subobjects!)
+ */
+ (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT);
+ return_VOID;
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/uteval.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/uteval.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,370 @@
+/******************************************************************************
+ *
+ * Module Name: uteval - Object evaluation
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __UTEVAL_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("uteval")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtEvaluateObject
+ *
+ * PARAMETERS: PrefixNode - Starting node
+ * Path - Path to object from starting node
+ * ExpectedReturnTypes - Bitmap of allowed return types
+ * ReturnDesc - Where a return value is stored
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Evaluates a namespace object and verifies the type of the
+ * return object. Common code that simplifies accessing objects
+ * that have required return objects of fixed types.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtEvaluateObject (
+ ACPI_NAMESPACE_NODE *PrefixNode,
+ char *Path,
+ UINT32 ExpectedReturnBtypes,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_EVALUATE_INFO *Info;
+ ACPI_STATUS Status;
+ UINT32 ReturnBtype;
+
+
+ ACPI_FUNCTION_TRACE (UtEvaluateObject);
+
+
+ /* Allocate the evaluation information block */
+
+ Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
+ if (!Info)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Info->PrefixNode = PrefixNode;
+ Info->Pathname = Path;
+
+ /* Evaluate the object/method */
+
+ Status = AcpiNsEvaluate (Info);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_FOUND)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
+ AcpiUtGetNodeName (PrefixNode), Path));
+ }
+ else
+ {
+ ACPI_ERROR_METHOD ("Method execution failed",
+ PrefixNode, Path, Status);
+ }
+
+ goto Cleanup;
+ }
+
+ /* Did we get a return object? */
+
+ if (!Info->ReturnObject)
+ {
+ if (ExpectedReturnBtypes)
+ {
+ ACPI_ERROR_METHOD ("No object was returned from",
+ PrefixNode, Path, AE_NOT_EXIST);
+
+ Status = AE_NOT_EXIST;
+ }
+
+ goto Cleanup;
+ }
+
+ /* Map the return object type to the bitmapped type */
+
+ switch ((Info->ReturnObject)->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ ReturnBtype = ACPI_BTYPE_INTEGER;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ ReturnBtype = ACPI_BTYPE_BUFFER;
+ break;
+
+ case ACPI_TYPE_STRING:
+ ReturnBtype = ACPI_BTYPE_STRING;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ ReturnBtype = ACPI_BTYPE_PACKAGE;
+ break;
+
+ default:
+ ReturnBtype = 0;
+ break;
+ }
+
+ if ((AcpiGbl_EnableInterpreterSlack) &&
+ (!ExpectedReturnBtypes))
+ {
+ /*
+ * We received a return object, but one was not expected. This can
+ * happen frequently if the "implicit return" feature is enabled.
+ * Just delete the return object and return AE_OK.
+ */
+ AcpiUtRemoveReference (Info->ReturnObject);
+ goto Cleanup;
+ }
+
+ /* Is the return object one of the expected types? */
+
+ if (!(ExpectedReturnBtypes & ReturnBtype))
+ {
+ ACPI_ERROR_METHOD ("Return object type is incorrect",
+ PrefixNode, Path, AE_TYPE);
+
+ ACPI_ERROR ((AE_INFO,
+ "Type returned from %s was incorrect: %s, expected Btypes: 0x%X",
+ Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
+ ExpectedReturnBtypes));
+
+ /* On error exit, we must delete the return object */
+
+ AcpiUtRemoveReference (Info->ReturnObject);
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+
+ /* Object type is OK, return it */
+
+ *ReturnDesc = Info->ReturnObject;
+
+Cleanup:
+ ACPI_FREE (Info);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtEvaluateNumericObject
+ *
+ * PARAMETERS: ObjectName - Object name to be evaluated
+ * DeviceNode - Node for the device
+ * Value - Where the value is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Evaluates a numeric namespace object for a selected device
+ * and stores result in *Value.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtEvaluateNumericObject (
+ char *ObjectName,
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ UINT64 *Value)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
+ ACPI_BTYPE_INTEGER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the returned Integer */
+
+ *Value = ObjDesc->Integer.Value;
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_STA
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * Flags - Where the status flags are returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes _STA for selected device and stores results in
+ * *Flags.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_STA (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ UINT32 *Flags)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtExecute_STA);
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
+ ACPI_BTYPE_INTEGER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ if (AE_NOT_FOUND == Status)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "_STA on %4.4s was not found, assuming device is present\n",
+ AcpiUtGetNodeName (DeviceNode)));
+
+ *Flags = ACPI_UINT32_MAX;
+ Status = AE_OK;
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Extract the status flags */
+
+ *Flags = (UINT32) ObjDesc->Integer.Value;
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecutePowerMethods
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * MethodNames - Array of power method names
+ * MethodCount - Number of methods to execute
+ * OutValues - Where the power method values are returned
+ *
+ * RETURN: Status, OutValues
+ *
+ * DESCRIPTION: Executes the specified power methods for the device and returns
+ * the result(s).
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecutePowerMethods (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ const char **MethodNames,
+ UINT8 MethodCount,
+ UINT8 *OutValues)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+ ACPI_STATUS FinalStatus = AE_NOT_FOUND;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (UtExecutePowerMethods);
+
+
+ for (i = 0; i < MethodCount; i++)
+ {
+ /*
+ * Execute the power method (_SxD or _SxW). The only allowable
+ * return type is an Integer.
+ */
+ Status = AcpiUtEvaluateObject (DeviceNode,
+ ACPI_CAST_PTR (char, MethodNames[i]),
+ ACPI_BTYPE_INTEGER, &ObjDesc);
+ if (ACPI_SUCCESS (Status))
+ {
+ OutValues[i] = (UINT8) ObjDesc->Integer.Value;
+
+ /* Delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ FinalStatus = AE_OK; /* At least one value is valid */
+ continue;
+ }
+
+ OutValues[i] = ACPI_UINT8_MAX;
+ if (Status == AE_NOT_FOUND)
+ {
+ continue; /* Ignore if not found */
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n",
+ ACPI_CAST_PTR (char, MethodNames[i]),
+ AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status)));
+ }
+
+ return_ACPI_STATUS (FinalStatus);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utglobal.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utglobal.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,365 @@
+/******************************************************************************
+ *
+ * Module Name: utglobal - Global variables for the ACPI subsystem
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __UTGLOBAL_C__
+#define DEFINE_ACPI_GLOBALS
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utglobal")
+
+
+/*******************************************************************************
+ *
+ * Static global variable initialization.
+ *
+ ******************************************************************************/
+
+/*
+ * We want the debug switches statically initialized so they
+ * are already set when the debugger is entered.
+ */
+
+/* Debug switch - level and trace mask */
+
+#ifdef ACPI_DEBUG_OUTPUT
+UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
+#else
+UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
+#endif
+
+/* Debug switch - layer (component) mask */
+
+UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
+UINT32 AcpiGbl_NestingLevel = 0;
+
+/* Debugger globals */
+
+BOOLEAN AcpiGbl_DbTerminateThreads = FALSE;
+BOOLEAN AcpiGbl_AbortMethod = FALSE;
+BOOLEAN AcpiGbl_MethodExecuting = FALSE;
+
+/* System flags */
+
+UINT32 AcpiGbl_StartupFlags = 0;
+
+/* System starts uninitialized */
+
+BOOLEAN AcpiGbl_Shutdown = TRUE;
+
+const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] =
+{
+ "\\_S0_",
+ "\\_S1_",
+ "\\_S2_",
+ "\\_S3_",
+ "\\_S4_",
+ "\\_S5_"
+};
+
+const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] =
+{
+ "_S0W",
+ "_S1W",
+ "_S2W",
+ "_S3W",
+ "_S4W"
+};
+
+const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] =
+{
+ "_S1D",
+ "_S2D",
+ "_S3D",
+ "_S4D"
+};
+
+
+/*******************************************************************************
+ *
+ * Namespace globals
+ *
+ ******************************************************************************/
+
+/*
+ * Predefined ACPI Names (Built-in to the Interpreter)
+ *
+ * NOTES:
+ * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
+ * during the initialization sequence.
+ * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
+ * perform a Notify() operation on it. 09/2010: Changed to type Device.
+ * This still allows notifies, but does not confuse host code that
+ * searches for valid ThermalZone objects.
+ */
+const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] =
+{
+ {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
+ {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
+ {"_SB_", ACPI_TYPE_DEVICE, NULL},
+ {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
+ {"_TZ_", ACPI_TYPE_DEVICE, NULL},
+ {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL},
+ {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
+ {"_GL_", ACPI_TYPE_MUTEX, (char *) 1},
+
+#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+ {"_OSI", ACPI_TYPE_METHOD, (char *) 1},
+#endif
+
+ /* Table terminator */
+
+ {NULL, ACPI_TYPE_ANY, NULL}
+};
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/******************************************************************************
+ *
+ * Event and Hardware globals
+ *
+ ******************************************************************************/
+
+ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] =
+{
+ /* Name Parent Register Register Bit Position Register Bit Mask */
+
+ /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS},
+ /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS},
+ /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS},
+ /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS},
+ /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS},
+ /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS},
+ /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS},
+ /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS},
+
+ /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE},
+ /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+ /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE},
+ /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+ /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE},
+ /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
+
+ /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE},
+ /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD},
+ /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
+ /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE},
+ /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE},
+
+ /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE}
+};
+
+
+ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
+{
+ /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE},
+ /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+ /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE},
+ /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+ /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
+};
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtInitGlobals
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Init ACPICA globals. All globals that require specific
+ * initialization should be initialized here!
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtInitGlobals (
+ void)
+{
+ ACPI_STATUS Status;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (UtInitGlobals);
+
+
+ /* Create all memory caches */
+
+ Status = AcpiUtCreateCaches ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Address Range lists */
+
+ for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
+ {
+ AcpiGbl_AddressRangeList[i] = NULL;
+ }
+
+ /* Mutex locked flags */
+
+ for (i = 0; i < ACPI_NUM_MUTEX; i++)
+ {
+ AcpiGbl_MutexInfo[i].Mutex = NULL;
+ AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
+ AcpiGbl_MutexInfo[i].UseCount = 0;
+ }
+
+ for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++)
+ {
+ AcpiGbl_OwnerIdMask[i] = 0;
+ }
+
+ /* Last OwnerID is never valid */
+
+ AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
+
+ /* Event counters */
+
+ AcpiMethodCount = 0;
+ AcpiSciCount = 0;
+ AcpiGpeCount = 0;
+
+ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
+ {
+ AcpiFixedEventCount[i] = 0;
+ }
+
+#if (!ACPI_REDUCED_HARDWARE)
+
+ /* GPE support */
+
+ AcpiGbl_AllGpesInitialized = FALSE;
+ AcpiGbl_GpeXruptListHead = NULL;
+ AcpiGbl_GpeFadtBlocks[0] = NULL;
+ AcpiGbl_GpeFadtBlocks[1] = NULL;
+ AcpiCurrentGpeCount = 0;
+
+ AcpiGbl_GlobalEventHandler = NULL;
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+ /* Global handlers */
+
+ AcpiGbl_SystemNotify.Handler = NULL;
+ AcpiGbl_DeviceNotify.Handler = NULL;
+ AcpiGbl_ExceptionHandler = NULL;
+ AcpiGbl_InitHandler = NULL;
+ AcpiGbl_TableHandler = NULL;
+ AcpiGbl_InterfaceHandler = NULL;
+
+ /* Global Lock support */
+
+ AcpiGbl_GlobalLockSemaphore = NULL;
+ AcpiGbl_GlobalLockMutex = NULL;
+ AcpiGbl_GlobalLockAcquired = FALSE;
+ AcpiGbl_GlobalLockHandle = 0;
+ AcpiGbl_GlobalLockPresent = FALSE;
+
+ /* Miscellaneous variables */
+
+ AcpiGbl_DSDT = NULL;
+ AcpiGbl_CmSingleStep = FALSE;
+ AcpiGbl_DbTerminateThreads = FALSE;
+ AcpiGbl_Shutdown = FALSE;
+ AcpiGbl_NsLookupCount = 0;
+ AcpiGbl_PsFindCount = 0;
+ AcpiGbl_AcpiHardwarePresent = TRUE;
+ AcpiGbl_LastOwnerIdIndex = 0;
+ AcpiGbl_NextOwnerIdOffset = 0;
+ AcpiGbl_TraceMethodName = 0;
+ AcpiGbl_TraceDbgLevel = 0;
+ AcpiGbl_TraceDbgLayer = 0;
+ AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
+ AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
+ AcpiGbl_OsiData = 0;
+ AcpiGbl_OsiMutex = NULL;
+ AcpiGbl_RegMethodsExecuted = FALSE;
+
+ /* Hardware oriented */
+
+ AcpiGbl_EventsInitialized = FALSE;
+ AcpiGbl_SystemAwakeAndRunning = TRUE;
+
+ /* Namespace */
+
+ AcpiGbl_ModuleCodeList = NULL;
+ AcpiGbl_RootNode = NULL;
+ AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
+ AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
+ AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
+ AcpiGbl_RootNodeStruct.Parent = NULL;
+ AcpiGbl_RootNodeStruct.Child = NULL;
+ AcpiGbl_RootNodeStruct.Peer = NULL;
+ AcpiGbl_RootNodeStruct.Object = NULL;
+
+
+#ifdef ACPI_DISASSEMBLER
+ AcpiGbl_ExternalList = NULL;
+#endif
+
+#ifdef ACPI_DEBUG_OUTPUT
+ AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX);
+#endif
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ AcpiGbl_DisplayFinalMemStats = FALSE;
+ AcpiGbl_DisableMemTracking = FALSE;
+#endif
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+/* Public globals */
+
+ACPI_EXPORT_SYMBOL (AcpiGbl_FADT)
+ACPI_EXPORT_SYMBOL (AcpiDbgLevel)
+ACPI_EXPORT_SYMBOL (AcpiDbgLayer)
+ACPI_EXPORT_SYMBOL (AcpiGpeCount)
+ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utids.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utids.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,380 @@
+/******************************************************************************
+ *
+ * Module Name: utids - support for device IDs - HID, UID, CID
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __UTIDS_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utids")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_HID
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * ReturnId - Where the string HID is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes the _HID control method that returns the hardware
+ * ID of the device. The HID is either an 32-bit encoded EISAID
+ * Integer or a String. A string is always returned. An EISAID
+ * is converted to a string.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_HID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID **ReturnId)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_DEVICE_ID *Hid;
+ UINT32 Length;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtExecute_HID);
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
+ ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the size of the String to be returned, includes null terminator */
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ Length = ACPI_EISAID_STRING_SIZE;
+ }
+ else
+ {
+ Length = ObjDesc->String.Length + 1;
+ }
+
+ /* Allocate a buffer for the HID */
+
+ Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length);
+ if (!Hid)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Area for the string starts after DEVICE_ID struct */
+
+ Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_DEVICE_ID));
+
+ /* Convert EISAID to a string or simply copy existing string */
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value);
+ }
+ else
+ {
+ ACPI_STRCPY (Hid->String, ObjDesc->String.Pointer);
+ }
+
+ Hid->Length = Length;
+ *ReturnId = Hid;
+
+
+Cleanup:
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_UID
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * ReturnId - Where the string UID is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes the _UID control method that returns the unique
+ * ID of the device. The UID is either a 64-bit Integer (NOT an
+ * EISAID) or a string. Always returns a string. A 64-bit integer
+ * is converted to a decimal string.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_UID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID **ReturnId)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_DEVICE_ID *Uid;
+ UINT32 Length;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtExecute_UID);
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
+ ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the size of the String to be returned, includes null terminator */
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ Length = ACPI_MAX64_DECIMAL_DIGITS + 1;
+ }
+ else
+ {
+ Length = ObjDesc->String.Length + 1;
+ }
+
+ /* Allocate a buffer for the UID */
+
+ Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length);
+ if (!Uid)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Area for the string starts after DEVICE_ID struct */
+
+ Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_DEVICE_ID));
+
+ /* Convert an Integer to string, or just copy an existing string */
+
+ if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value);
+ }
+ else
+ {
+ ACPI_STRCPY (Uid->String, ObjDesc->String.Pointer);
+ }
+
+ Uid->Length = Length;
+ *ReturnId = Uid;
+
+
+Cleanup:
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_CID
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * ReturnCidList - Where the CID list is returned
+ *
+ * RETURN: Status, list of CID strings
+ *
+ * DESCRIPTION: Executes the _CID control method that returns one or more
+ * compatible hardware IDs for the device.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ * A _CID method can return either a single compatible ID or a package of
+ * compatible IDs. Each compatible ID can be one of the following:
+ * 1) Integer (32 bit compressed EISA ID) or
+ * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
+ *
+ * The Integer CIDs are converted to string format by this function.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_CID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID_LIST **ReturnCidList)
+{
+ ACPI_OPERAND_OBJECT **CidObjects;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_DEVICE_ID_LIST *CidList;
+ char *NextIdString;
+ UINT32 StringAreaSize;
+ UINT32 Length;
+ UINT32 CidListSize;
+ ACPI_STATUS Status;
+ UINT32 Count;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (UtExecute_CID);
+
+
+ /* Evaluate the _CID method for this device */
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
+ ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
+ &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Get the count and size of the returned _CIDs. _CID can return either
+ * a Package of Integers/Strings or a single Integer or String.
+ * Note: This section also validates that all CID elements are of the
+ * correct type (Integer or String).
+ */
+ if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
+ {
+ Count = ObjDesc->Package.Count;
+ CidObjects = ObjDesc->Package.Elements;
+ }
+ else /* Single Integer or String CID */
+ {
+ Count = 1;
+ CidObjects = &ObjDesc;
+ }
+
+ StringAreaSize = 0;
+ for (i = 0; i < Count; i++)
+ {
+ /* String lengths include null terminator */
+
+ switch (CidObjects[i]->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ StringAreaSize += ACPI_EISAID_STRING_SIZE;
+ break;
+
+ case ACPI_TYPE_STRING:
+ StringAreaSize += CidObjects[i]->String.Length + 1;
+ break;
+
+ default:
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+ }
+
+ /*
+ * Now that we know the length of the CIDs, allocate return buffer:
+ * 1) Size of the base structure +
+ * 2) Size of the CID DEVICE_ID array +
+ * 3) Size of the actual CID strings
+ */
+ CidListSize = sizeof (ACPI_DEVICE_ID_LIST) +
+ ((Count - 1) * sizeof (ACPI_DEVICE_ID)) +
+ StringAreaSize;
+
+ CidList = ACPI_ALLOCATE_ZEROED (CidListSize);
+ if (!CidList)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Area for CID strings starts after the CID DEVICE_ID array */
+
+ NextIdString = ACPI_CAST_PTR (char, CidList->Ids) +
+ ((ACPI_SIZE) Count * sizeof (ACPI_DEVICE_ID));
+
+ /* Copy/convert the CIDs to the return buffer */
+
+ for (i = 0; i < Count; i++)
+ {
+ if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER)
+ {
+ /* Convert the Integer (EISAID) CID to a string */
+
+ AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value);
+ Length = ACPI_EISAID_STRING_SIZE;
+ }
+ else /* ACPI_TYPE_STRING */
+ {
+ /* Copy the String CID from the returned object */
+
+ ACPI_STRCPY (NextIdString, CidObjects[i]->String.Pointer);
+ Length = CidObjects[i]->String.Length + 1;
+ }
+
+ CidList->Ids[i].String = NextIdString;
+ CidList->Ids[i].Length = Length;
+ NextIdString += Length;
+ }
+
+ /* Finish the CID list */
+
+ CidList->Count = Count;
+ CidList->ListSize = CidListSize;
+ *ReturnCidList = CidList;
+
+
+Cleanup:
+
+ /* On exit, we must delete the _CID return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utinit.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utinit.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,192 @@
+/******************************************************************************
+ *
+ * Module Name: utinit - Common ACPI subsystem 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.
+ */
+
+
+#define __UTINIT_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/actables.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utinit")
+
+/* Local prototypes */
+
+static void AcpiUtTerminate (
+ void);
+
+#if (!ACPI_REDUCED_HARDWARE)
+
+static void
+AcpiUtFreeGpeLists (
+ void);
+
+#else
+
+#define AcpiUtFreeGpeLists()
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtFreeGpeLists
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Free global GPE lists
+ *
+ ******************************************************************************/
+
+static void
+AcpiUtFreeGpeLists (
+ void)
+{
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+ ACPI_GPE_BLOCK_INFO *NextGpeBlock;
+ ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
+ ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo;
+
+
+ /* Free global GPE blocks and related info structures */
+
+ GpeXruptInfo = AcpiGbl_GpeXruptListHead;
+ while (GpeXruptInfo)
+ {
+ GpeBlock = GpeXruptInfo->GpeBlockListHead;
+ while (GpeBlock)
+ {
+ NextGpeBlock = GpeBlock->Next;
+ ACPI_FREE (GpeBlock->EventInfo);
+ ACPI_FREE (GpeBlock->RegisterInfo);
+ ACPI_FREE (GpeBlock);
+
+ GpeBlock = NextGpeBlock;
+ }
+ NextGpeXruptInfo = GpeXruptInfo->Next;
+ ACPI_FREE (GpeXruptInfo);
+ GpeXruptInfo = NextGpeXruptInfo;
+ }
+}
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtTerminate
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Free global memory
+ *
+ ******************************************************************************/
+
+static void
+AcpiUtTerminate (
+ void)
+{
+ ACPI_FUNCTION_TRACE (UtTerminate);
+
+ AcpiUtFreeGpeLists ();
+ AcpiUtDeleteAddressLists ();
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtSubsystemShutdown
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Shutdown the various components. Do not delete the mutex
+ * objects here, because the AML debugger may be still running.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtSubsystemShutdown (
+ void)
+{
+ ACPI_FUNCTION_TRACE (UtSubsystemShutdown);
+
+
+#ifndef ACPI_ASL_COMPILER
+
+ /* Close the AcpiEvent Handling */
+
+ AcpiEvTerminate ();
+
+ /* Delete any dynamic _OSI interfaces */
+
+ AcpiUtInterfaceTerminate ();
+#endif
+
+ /* Close the Namespace */
+
+ AcpiNsTerminate ();
+
+ /* Delete the ACPI tables */
+
+ AcpiTbTerminate ();
+
+ /* Close the globals */
+
+ AcpiUtTerminate ();
+
+ /* Purge the local caches */
+
+ (void) AcpiUtDeleteCaches ();
+ return_VOID;
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utlock.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utlock.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,205 @@
+/******************************************************************************
+ *
+ * Module Name: utlock - Reader/Writer lock 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.
+ */
+
+#define __UTLOCK_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utlock")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateRwLock
+ * AcpiUtDeleteRwLock
+ *
+ * PARAMETERS: Lock - Pointer to a valid RW lock
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reader/writer lock creation and deletion interfaces.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCreateRwLock (
+ ACPI_RW_LOCK *Lock)
+{
+ ACPI_STATUS Status;
+
+
+ Lock->NumReaders = 0;
+ Status = AcpiOsCreateMutex (&Lock->ReaderMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiOsCreateMutex (&Lock->WriterMutex);
+ return (Status);
+}
+
+
+void
+AcpiUtDeleteRwLock (
+ ACPI_RW_LOCK *Lock)
+{
+
+ AcpiOsDeleteMutex (Lock->ReaderMutex);
+ AcpiOsDeleteMutex (Lock->WriterMutex);
+
+ Lock->NumReaders = 0;
+ Lock->ReaderMutex = NULL;
+ Lock->WriterMutex = NULL;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAcquireReadLock
+ * AcpiUtReleaseReadLock
+ *
+ * PARAMETERS: Lock - Pointer to a valid RW lock
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition,
+ * only the first reader acquires the write mutex. On release,
+ * only the last reader releases the write mutex. Although this
+ * algorithm can in theory starve writers, this should not be a
+ * problem with ACPICA since the subsystem is infrequently used
+ * in comparison to (for example) an I/O system.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtAcquireReadLock (
+ ACPI_RW_LOCK *Lock)
+{
+ ACPI_STATUS Status;
+
+
+ Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Acquire the write lock only for the first reader */
+
+ Lock->NumReaders++;
+ if (Lock->NumReaders == 1)
+ {
+ Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER);
+ }
+
+ AcpiOsReleaseMutex (Lock->ReaderMutex);
+ return (Status);
+}
+
+
+ACPI_STATUS
+AcpiUtReleaseReadLock (
+ ACPI_RW_LOCK *Lock)
+{
+ ACPI_STATUS Status;
+
+
+ Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Release the write lock only for the very last reader */
+
+ Lock->NumReaders--;
+ if (Lock->NumReaders == 0)
+ {
+ AcpiOsReleaseMutex (Lock->WriterMutex);
+ }
+
+ AcpiOsReleaseMutex (Lock->ReaderMutex);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAcquireWriteLock
+ * AcpiUtReleaseWriteLock
+ *
+ * PARAMETERS: Lock - Pointer to a valid RW lock
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or
+ * release the writer mutex associated with the lock. Acquisition
+ * of the lock is fully exclusive and will block all readers and
+ * writers until it is released.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtAcquireWriteLock (
+ ACPI_RW_LOCK *Lock)
+{
+ ACPI_STATUS Status;
+
+
+ Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER);
+ return (Status);
+}
+
+
+void
+AcpiUtReleaseWriteLock (
+ ACPI_RW_LOCK *Lock)
+{
+
+ AcpiOsReleaseMutex (Lock->WriterMutex);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utmath.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utmath.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,379 @@
+/*******************************************************************************
+ *
+ * Module Name: utmath - Integer math support 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 __UTMATH_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utmath")
+
+/*
+ * Optional support for 64-bit double-precision integer divide. This code
+ * is configurable and is implemented in order to support 32-bit kernel
+ * environments where a 64-bit double-precision math library is not available.
+ *
+ * Support for a more normal 64-bit divide/modulo (with check for a divide-
+ * by-zero) appears after this optional section of code.
+ */
+#ifndef ACPI_USE_NATIVE_DIVIDE
+
+/* Structures used only for 64-bit divide */
+
+typedef struct uint64_struct
+{
+ UINT32 Lo;
+ UINT32 Hi;
+
+} UINT64_STRUCT;
+
+typedef union uint64_overlay
+{
+ UINT64 Full;
+ UINT64_STRUCT Part;
+
+} UINT64_OVERLAY;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortDivide
+ *
+ * PARAMETERS: Dividend - 64-bit dividend
+ * Divisor - 32-bit divisor
+ * OutQuotient - Pointer to where the quotient is returned
+ * OutRemainder - Pointer to where the remainder is returned
+ *
+ * RETURN: Status (Checks for divide-by-zero)
+ *
+ * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
+ * divide and modulo. The result is a 64-bit quotient and a
+ * 32-bit remainder.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortDivide (
+ UINT64 Dividend,
+ UINT32 Divisor,
+ UINT64 *OutQuotient,
+ UINT32 *OutRemainder)
+{
+ UINT64_OVERLAY DividendOvl;
+ UINT64_OVERLAY Quotient;
+ UINT32 Remainder32;
+
+
+ ACPI_FUNCTION_TRACE (UtShortDivide);
+
+
+ /* Always check for a zero divisor */
+
+ if (Divisor == 0)
+ {
+ ACPI_ERROR ((AE_INFO, "Divide by zero"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+ DividendOvl.Full = Dividend;
+
+ /*
+ * The quotient is 64 bits, the remainder is always 32 bits,
+ * and is generated by the second divide.
+ */
+ ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor,
+ Quotient.Part.Hi, Remainder32);
+ ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor,
+ Quotient.Part.Lo, Remainder32);
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = Quotient.Full;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = Remainder32;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDivide
+ *
+ * PARAMETERS: InDividend - Dividend
+ * InDivisor - Divisor
+ * OutQuotient - Pointer to where the quotient is returned
+ * OutRemainder - Pointer to where the remainder is returned
+ *
+ * RETURN: Status (Checks for divide-by-zero)
+ *
+ * DESCRIPTION: Perform a divide and modulo.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtDivide (
+ UINT64 InDividend,
+ UINT64 InDivisor,
+ UINT64 *OutQuotient,
+ UINT64 *OutRemainder)
+{
+ UINT64_OVERLAY Dividend;
+ UINT64_OVERLAY Divisor;
+ UINT64_OVERLAY Quotient;
+ UINT64_OVERLAY Remainder;
+ UINT64_OVERLAY NormalizedDividend;
+ UINT64_OVERLAY NormalizedDivisor;
+ UINT32 Partial1;
+ UINT64_OVERLAY Partial2;
+ UINT64_OVERLAY Partial3;
+
+
+ ACPI_FUNCTION_TRACE (UtDivide);
+
+
+ /* Always check for a zero divisor */
+
+ if (InDivisor == 0)
+ {
+ ACPI_ERROR ((AE_INFO, "Divide by zero"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+ Divisor.Full = InDivisor;
+ Dividend.Full = InDividend;
+ if (Divisor.Part.Hi == 0)
+ {
+ /*
+ * 1) Simplest case is where the divisor is 32 bits, we can
+ * just do two divides
+ */
+ Remainder.Part.Hi = 0;
+
+ /*
+ * The quotient is 64 bits, the remainder is always 32 bits,
+ * and is generated by the second divide.
+ */
+ ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo,
+ Quotient.Part.Hi, Partial1);
+ ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo,
+ Quotient.Part.Lo, Remainder.Part.Lo);
+ }
+
+ else
+ {
+ /*
+ * 2) The general case where the divisor is a full 64 bits
+ * is more difficult
+ */
+ Quotient.Part.Hi = 0;
+ NormalizedDividend = Dividend;
+ NormalizedDivisor = Divisor;
+
+ /* Normalize the operands (shift until the divisor is < 32 bits) */
+
+ do
+ {
+ ACPI_SHIFT_RIGHT_64 (NormalizedDivisor.Part.Hi,
+ NormalizedDivisor.Part.Lo);
+ ACPI_SHIFT_RIGHT_64 (NormalizedDividend.Part.Hi,
+ NormalizedDividend.Part.Lo);
+
+ } while (NormalizedDivisor.Part.Hi != 0);
+
+ /* Partial divide */
+
+ ACPI_DIV_64_BY_32 (NormalizedDividend.Part.Hi,
+ NormalizedDividend.Part.Lo,
+ NormalizedDivisor.Part.Lo,
+ Quotient.Part.Lo, Partial1);
+
+ /*
+ * The quotient is always 32 bits, and simply requires adjustment.
+ * The 64-bit remainder must be generated.
+ */
+ Partial1 = Quotient.Part.Lo * Divisor.Part.Hi;
+ Partial2.Full = (UINT64) Quotient.Part.Lo * Divisor.Part.Lo;
+ Partial3.Full = (UINT64) Partial2.Part.Hi + Partial1;
+
+ Remainder.Part.Hi = Partial3.Part.Lo;
+ Remainder.Part.Lo = Partial2.Part.Lo;
+
+ if (Partial3.Part.Hi == 0)
+ {
+ if (Partial3.Part.Lo >= Dividend.Part.Hi)
+ {
+ if (Partial3.Part.Lo == Dividend.Part.Hi)
+ {
+ if (Partial2.Part.Lo > Dividend.Part.Lo)
+ {
+ Quotient.Part.Lo--;
+ Remainder.Full -= Divisor.Full;
+ }
+ }
+ else
+ {
+ Quotient.Part.Lo--;
+ Remainder.Full -= Divisor.Full;
+ }
+ }
+
+ Remainder.Full = Remainder.Full - Dividend.Full;
+ Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi);
+ Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo);
+
+ if (Remainder.Part.Lo)
+ {
+ Remainder.Part.Hi--;
+ }
+ }
+ }
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = Quotient.Full;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = Remainder.Full;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+#else
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortDivide, AcpiUtDivide
+ *
+ * PARAMETERS: See function headers above
+ *
+ * DESCRIPTION: Native versions of the UtDivide functions. Use these if either
+ * 1) The target is a 64-bit platform and therefore 64-bit
+ * integer math is supported directly by the machine.
+ * 2) The target is a 32-bit or 16-bit platform, and the
+ * double-precision integer math library is available to
+ * perform the divide.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortDivide (
+ UINT64 InDividend,
+ UINT32 Divisor,
+ UINT64 *OutQuotient,
+ UINT32 *OutRemainder)
+{
+
+ ACPI_FUNCTION_TRACE (UtShortDivide);
+
+
+ /* Always check for a zero divisor */
+
+ if (Divisor == 0)
+ {
+ ACPI_ERROR ((AE_INFO, "Divide by zero"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = InDividend / Divisor;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = (UINT32) (InDividend % Divisor);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_STATUS
+AcpiUtDivide (
+ UINT64 InDividend,
+ UINT64 InDivisor,
+ UINT64 *OutQuotient,
+ UINT64 *OutRemainder)
+{
+ ACPI_FUNCTION_TRACE (UtDivide);
+
+
+ /* Always check for a zero divisor */
+
+ if (InDivisor == 0)
+ {
+ ACPI_ERROR ((AE_INFO, "Divide by zero"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = InDividend / InDivisor;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = InDividend % InDivisor;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utmisc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utmisc.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1299 @@
+/*******************************************************************************
+ *
+ * Module Name: utmisc - common utility procedures
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __UTMISC_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utmisc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidateException
+ *
+ * PARAMETERS: Status - The ACPI_STATUS code to be formatted
+ *
+ * RETURN: A string containing the exception text. NULL if exception is
+ * not valid.
+ *
+ * DESCRIPTION: This function validates and translates an ACPI exception into
+ * an ASCII string.
+ *
+ ******************************************************************************/
+
+const char *
+AcpiUtValidateException (
+ ACPI_STATUS Status)
+{
+ UINT32 SubStatus;
+ const char *Exception = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Status is composed of two parts, a "type" and an actual code
+ */
+ SubStatus = (Status & ~AE_CODE_MASK);
+
+ switch (Status & AE_CODE_MASK)
+ {
+ case AE_CODE_ENVIRONMENTAL:
+
+ if (SubStatus <= AE_CODE_ENV_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
+ }
+ break;
+
+ case AE_CODE_PROGRAMMER:
+
+ if (SubStatus <= AE_CODE_PGM_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus];
+ }
+ break;
+
+ case AE_CODE_ACPI_TABLES:
+
+ if (SubStatus <= AE_CODE_TBL_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus];
+ }
+ break;
+
+ case AE_CODE_AML:
+
+ if (SubStatus <= AE_CODE_AML_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Aml [SubStatus];
+ }
+ break;
+
+ case AE_CODE_CONTROL:
+
+ if (SubStatus <= AE_CODE_CTRL_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus];
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return (ACPI_CAST_PTR (const char, Exception));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtIsPciRootBridge
+ *
+ * PARAMETERS: Id - The HID/CID in string format
+ *
+ * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
+ *
+ * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiUtIsPciRootBridge (
+ char *Id)
+{
+
+ /*
+ * Check if this is a PCI root bridge.
+ * ACPI 3.0+: check for a PCI Express root also.
+ */
+ if (!(ACPI_STRCMP (Id,
+ PCI_ROOT_HID_STRING)) ||
+
+ !(ACPI_STRCMP (Id,
+ PCI_EXPRESS_ROOT_HID_STRING)))
+ {
+ return (TRUE);
+ }
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtIsAmlTable
+ *
+ * PARAMETERS: Table - An ACPI table
+ *
+ * RETURN: TRUE if table contains executable AML; FALSE otherwise
+ *
+ * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
+ * Currently, these are DSDT,SSDT,PSDT. All other table types are
+ * data tables that do not contain AML code.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiUtIsAmlTable (
+ ACPI_TABLE_HEADER *Table)
+{
+
+ /* These are the only tables that contain executable AML */
+
+ if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
+ ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
+ ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
+ {
+ return (TRUE);
+ }
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocateOwnerId
+ *
+ * PARAMETERS: OwnerId - Where the new owner ID is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
+ * track objects created by the table or method, to be deleted
+ * when the method exits or the table is unloaded.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtAllocateOwnerId (
+ ACPI_OWNER_ID *OwnerId)
+{
+ UINT32 i;
+ UINT32 j;
+ UINT32 k;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
+
+
+ /* Guard against multiple allocations of ID to the same location */
+
+ if (*OwnerId)
+ {
+ ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId));
+ return_ACPI_STATUS (AE_ALREADY_EXISTS);
+ }
+
+ /* Mutex for the global ID mask */
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Find a free owner ID, cycle through all possible IDs on repeated
+ * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
+ * to be scanned twice.
+ */
+ for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
+ i < (ACPI_NUM_OWNERID_MASKS + 1);
+ i++, j++)
+ {
+ if (j >= ACPI_NUM_OWNERID_MASKS)
+ {
+ j = 0; /* Wraparound to start of mask array */
+ }
+
+ for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
+ {
+ if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
+ {
+ /* There are no free IDs in this mask */
+
+ break;
+ }
+
+ if (!(AcpiGbl_OwnerIdMask[j] & (1 << k)))
+ {
+ /*
+ * Found a free ID. The actual ID is the bit index plus one,
+ * making zero an invalid Owner ID. Save this as the last ID
+ * allocated and update the global ID mask.
+ */
+ AcpiGbl_OwnerIdMask[j] |= (1 << k);
+
+ AcpiGbl_LastOwnerIdIndex = (UINT8) j;
+ AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
+
+ /*
+ * Construct encoded ID from the index and bit position
+ *
+ * Note: Last [j].k (bit 255) is never used and is marked
+ * permanently allocated (prevents +1 overflow)
+ */
+ *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
+ "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId));
+ goto Exit;
+ }
+ }
+
+ AcpiGbl_NextOwnerIdOffset = 0;
+ }
+
+ /*
+ * All OwnerIds have been allocated. This typically should
+ * not happen since the IDs are reused after deallocation. The IDs are
+ * allocated upon table load (one per table) and method execution, and
+ * they are released when a table is unloaded or a method completes
+ * execution.
+ *
+ * If this error happens, there may be very deep nesting of invoked control
+ * methods, or there may be a bug where the IDs are not released.
+ */
+ Status = AE_OWNER_ID_LIMIT;
+ ACPI_ERROR ((AE_INFO,
+ "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
+
+Exit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtReleaseOwnerId
+ *
+ * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID
+ *
+ * RETURN: None. No error is returned because we are either exiting a
+ * control method or unloading a table. Either way, we would
+ * ignore any error anyway.
+ *
+ * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
+ *
+ ******************************************************************************/
+
+void
+AcpiUtReleaseOwnerId (
+ ACPI_OWNER_ID *OwnerIdPtr)
+{
+ ACPI_OWNER_ID OwnerId = *OwnerIdPtr;
+ ACPI_STATUS Status;
+ UINT32 Index;
+ UINT32 Bit;
+
+
+ ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
+
+
+ /* Always clear the input OwnerId (zero is an invalid ID) */
+
+ *OwnerIdPtr = 0;
+
+ /* Zero is not a valid OwnerID */
+
+ if (OwnerId == 0)
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%2.2X", OwnerId));
+ return_VOID;
+ }
+
+ /* Mutex for the global ID mask */
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VOID;
+ }
+
+ /* Normalize the ID to zero */
+
+ OwnerId--;
+
+ /* Decode ID to index/offset pair */
+
+ Index = ACPI_DIV_32 (OwnerId);
+ Bit = 1 << ACPI_MOD_32 (OwnerId);
+
+ /* Free the owner ID only if it is valid */
+
+ if (AcpiGbl_OwnerIdMask[Index] & Bit)
+ {
+ AcpiGbl_OwnerIdMask[Index] ^= Bit;
+ }
+ else
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Release of non-allocated OwnerId: 0x%2.2X", OwnerId + 1));
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtStrupr (strupr)
+ *
+ * PARAMETERS: SrcString - The source string to convert
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Convert string to uppercase
+ *
+ * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
+ *
+ ******************************************************************************/
+
+void
+AcpiUtStrupr (
+ char *SrcString)
+{
+ char *String;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!SrcString)
+ {
+ return;
+ }
+
+ /* Walk entire string, uppercasing the letters */
+
+ for (String = SrcString; *String; String++)
+ {
+ *String = (char) ACPI_TOUPPER (*String);
+ }
+
+ return;
+}
+
+
+#ifdef ACPI_ASL_COMPILER
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtStrlwr (strlwr)
+ *
+ * PARAMETERS: SrcString - The source string to convert
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Convert string to lowercase
+ *
+ * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
+ *
+ ******************************************************************************/
+
+void
+AcpiUtStrlwr (
+ char *SrcString)
+{
+ char *String;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!SrcString)
+ {
+ return;
+ }
+
+ /* Walk entire string, lowercasing the letters */
+
+ for (String = SrcString; *String; String++)
+ {
+ *String = (char) ACPI_TOLOWER (*String);
+ }
+
+ return;
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtStricmp
+ *
+ * PARAMETERS: String1 - first string to compare
+ * String2 - second string to compare
+ *
+ * RETURN: int that signifies string relationship. Zero means strings
+ * are equal.
+ *
+ * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
+ * strings with no case sensitivity)
+ *
+ ******************************************************************************/
+
+int
+AcpiUtStricmp (
+ char *String1,
+ char *String2)
+{
+ int c1;
+ int c2;
+
+
+ do
+ {
+ c1 = tolower ((int) *String1);
+ c2 = tolower ((int) *String2);
+
+ String1++;
+ String2++;
+ }
+ while ((c1 == c2) && (c1));
+
+ return (c1 - c2);
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtPrintString
+ *
+ * PARAMETERS: String - Null terminated ASCII string
+ * MaxLength - Maximum output length
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
+ * sequences.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtPrintString (
+ char *String,
+ UINT8 MaxLength)
+{
+ UINT32 i;
+
+
+ if (!String)
+ {
+ AcpiOsPrintf ("<\"NULL STRING PTR\">");
+ return;
+ }
+
+ AcpiOsPrintf ("\"");
+ for (i = 0; String[i] && (i < MaxLength); i++)
+ {
+ /* Escape sequences */
+
+ switch (String[i])
+ {
+ case 0x07:
+ AcpiOsPrintf ("\\a"); /* BELL */
+ break;
+
+ case 0x08:
+ AcpiOsPrintf ("\\b"); /* BACKSPACE */
+ break;
+
+ case 0x0C:
+ AcpiOsPrintf ("\\f"); /* FORMFEED */
+ break;
+
+ case 0x0A:
+ AcpiOsPrintf ("\\n"); /* LINEFEED */
+ break;
+
+ case 0x0D:
+ AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/
+ break;
+
+ case 0x09:
+ AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */
+ break;
+
+ case 0x0B:
+ AcpiOsPrintf ("\\v"); /* VERTICAL TAB */
+ break;
+
+ case '\'': /* Single Quote */
+ case '\"': /* Double Quote */
+ case '\\': /* Backslash */
+ AcpiOsPrintf ("\\%c", (int) String[i]);
+ break;
+
+ default:
+
+ /* Check for printable character or hex escape */
+
+ if (ACPI_IS_PRINT (String[i]))
+ {
+ /* This is a normal character */
+
+ AcpiOsPrintf ("%c", (int) String[i]);
+ }
+ else
+ {
+ /* All others will be Hex escapes */
+
+ AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
+ }
+ break;
+ }
+ }
+ AcpiOsPrintf ("\"");
+
+ if (i == MaxLength && String[i])
+ {
+ AcpiOsPrintf ("...");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDwordByteSwap
+ *
+ * PARAMETERS: Value - Value to be converted
+ *
+ * RETURN: UINT32 integer with bytes swapped
+ *
+ * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiUtDwordByteSwap (
+ UINT32 Value)
+{
+ union
+ {
+ UINT32 Value;
+ UINT8 Bytes[4];
+ } Out;
+ union
+ {
+ UINT32 Value;
+ UINT8 Bytes[4];
+ } In;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ In.Value = Value;
+
+ Out.Bytes[0] = In.Bytes[3];
+ Out.Bytes[1] = In.Bytes[2];
+ Out.Bytes[2] = In.Bytes[1];
+ Out.Bytes[3] = In.Bytes[0];
+
+ return (Out.Value);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtSetIntegerWidth
+ *
+ * PARAMETERS: Revision From DSDT header
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Set the global integer bit width based upon the revision
+ * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
+ * For Revision 2 and above, Integers are 64 bits. Yes, this
+ * makes a difference.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtSetIntegerWidth (
+ UINT8 Revision)
+{
+
+ if (Revision < 2)
+ {
+ /* 32-bit case */
+
+ AcpiGbl_IntegerBitWidth = 32;
+ AcpiGbl_IntegerNybbleWidth = 8;
+ AcpiGbl_IntegerByteWidth = 4;
+ }
+ else
+ {
+ /* 64-bit case (ACPI 2.0+) */
+
+ AcpiGbl_IntegerBitWidth = 64;
+ AcpiGbl_IntegerNybbleWidth = 16;
+ AcpiGbl_IntegerByteWidth = 8;
+ }
+}
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDisplayInitPathname
+ *
+ * PARAMETERS: Type - Object type of the node
+ * ObjHandle - Handle whose pathname will be displayed
+ * Path - Additional path string to be appended.
+ * (NULL if no extra path)
+ *
+ * RETURN: ACPI_STATUS
+ *
+ * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDisplayInitPathname (
+ UINT8 Type,
+ ACPI_NAMESPACE_NODE *ObjHandle,
+ char *Path)
+{
+ ACPI_STATUS Status;
+ ACPI_BUFFER Buffer;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Only print the path if the appropriate debug level is enabled */
+
+ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
+ {
+ return;
+ }
+
+ /* Get the full pathname to the node */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ /* Print what we're doing */
+
+ switch (Type)
+ {
+ case ACPI_TYPE_METHOD:
+ AcpiOsPrintf ("Executing ");
+ break;
+
+ default:
+ AcpiOsPrintf ("Initializing ");
+ break;
+ }
+
+ /* Print the object type and pathname */
+
+ AcpiOsPrintf ("%-12s %s",
+ AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
+
+ /* Extra path is used to append names like _STA, _INI, etc. */
+
+ if (Path)
+ {
+ AcpiOsPrintf (".%s", Path);
+ }
+ AcpiOsPrintf ("\n");
+
+ ACPI_FREE (Buffer.Pointer);
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidAcpiChar
+ *
+ * PARAMETERS: Char - The character to be examined
+ * Position - Byte position (0-3)
+ *
+ * RETURN: TRUE if the character is valid, FALSE otherwise
+ *
+ * DESCRIPTION: Check for a valid ACPI character. Must be one of:
+ * 1) Upper case alpha
+ * 2) numeric
+ * 3) underscore
+ *
+ * We allow a '!' as the last character because of the ASF! table
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiUtValidAcpiChar (
+ char Character,
+ UINT32 Position)
+{
+
+ if (!((Character >= 'A' && Character <= 'Z') ||
+ (Character >= '0' && Character <= '9') ||
+ (Character == '_')))
+ {
+ /* Allow a '!' in the last position */
+
+ if (Character == '!' && Position == 3)
+ {
+ return (TRUE);
+ }
+
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidAcpiName
+ *
+ * PARAMETERS: Name - The name to be examined
+ *
+ * RETURN: TRUE if the name is valid, FALSE otherwise
+ *
+ * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
+ * 1) Upper case alpha
+ * 2) numeric
+ * 3) underscore
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiUtValidAcpiName (
+ UINT32 Name)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ for (i = 0; i < ACPI_NAME_SIZE; i++)
+ {
+ if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i))
+ {
+ return (FALSE);
+ }
+ }
+
+ return (TRUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtRepairName
+ *
+ * PARAMETERS: Name - The ACPI name to be repaired
+ *
+ * RETURN: Repaired version of the name
+ *
+ * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
+ * return the new name. NOTE: the Name parameter must reside in
+ * read/write memory, cannot be a const.
+ *
+ * An ACPI Name must consist of valid ACPI characters. We will repair the name
+ * if necessary because we don't want to abort because of this, but we want
+ * all namespace names to be printable. A warning message is appropriate.
+ *
+ * This issue came up because there are in fact machines that exhibit
+ * this problem, and we want to be able to enable ACPI support for them,
+ * even though there are a few bad names.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtRepairName (
+ char *Name)
+{
+ UINT32 i;
+ BOOLEAN FoundBadChar = FALSE;
+
+
+ ACPI_FUNCTION_NAME (UtRepairName);
+
+
+ /* Check each character in the name */
+
+ for (i = 0; i < ACPI_NAME_SIZE; i++)
+ {
+ if (AcpiUtValidAcpiChar (Name[i], i))
+ {
+ continue;
+ }
+
+ /*
+ * Replace a bad character with something printable, yet technically
+ * still invalid. This prevents any collisions with existing "good"
+ * names in the namespace.
+ */
+ Name[i] = '*';
+ FoundBadChar = TRUE;
+ }
+
+ if (FoundBadChar)
+ {
+ /* Report warning only if in strict mode or debug mode */
+
+ if (!AcpiGbl_EnableInterpreterSlack)
+ {
+ ACPI_WARNING ((AE_INFO,
+ "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtStrtoul64
+ *
+ * PARAMETERS: String - Null terminated string
+ * Base - Radix of the string: 16 or ACPI_ANY_BASE;
+ * ACPI_ANY_BASE means 'in behalf of ToInteger'
+ * RetInteger - Where the converted integer is returned
+ *
+ * RETURN: Status and Converted value
+ *
+ * DESCRIPTION: Convert a string into an unsigned value. Performs either a
+ * 32-bit or 64-bit conversion, depending on the current mode
+ * of the interpreter.
+ * NOTE: Does not support Octal strings, not needed.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtStrtoul64 (
+ char *String,
+ UINT32 Base,
+ UINT64 *RetInteger)
+{
+ UINT32 ThisDigit = 0;
+ UINT64 ReturnValue = 0;
+ UINT64 Quotient;
+ UINT64 Dividend;
+ UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE);
+ UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4);
+ UINT8 ValidDigits = 0;
+ UINT8 SignOf0x = 0;
+ UINT8 Term = 0;
+
+
+ ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
+
+
+ switch (Base)
+ {
+ case ACPI_ANY_BASE:
+ case 16:
+ break;
+
+ default:
+ /* Invalid Base */
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (!String)
+ {
+ goto ErrorExit;
+ }
+
+ /* Skip over any white space in the buffer */
+
+ while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
+ {
+ String++;
+ }
+
+ if (ToIntegerOp)
+ {
+ /*
+ * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
+ * We need to determine if it is decimal or hexadecimal.
+ */
+ if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
+ {
+ SignOf0x = 1;
+ Base = 16;
+
+ /* Skip over the leading '0x' */
+ String += 2;
+ }
+ else
+ {
+ Base = 10;
+ }
+ }
+
+ /* Any string left? Check that '0x' is not followed by white space. */
+
+ if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
+ {
+ if (ToIntegerOp)
+ {
+ goto ErrorExit;
+ }
+ else
+ {
+ goto AllDone;
+ }
+ }
+
+ /*
+ * Perform a 32-bit or 64-bit conversion, depending upon the current
+ * execution mode of the interpreter
+ */
+ Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
+
+ /* Main loop: convert the string to a 32- or 64-bit integer */
+
+ while (*String)
+ {
+ if (ACPI_IS_DIGIT (*String))
+ {
+ /* Convert ASCII 0-9 to Decimal value */
+
+ ThisDigit = ((UINT8) *String) - '0';
+ }
+ else if (Base == 10)
+ {
+ /* Digit is out of range; possible in ToInteger case only */
+
+ Term = 1;
+ }
+ else
+ {
+ ThisDigit = (UINT8) ACPI_TOUPPER (*String);
+ if (ACPI_IS_XDIGIT ((char) ThisDigit))
+ {
+ /* Convert ASCII Hex char to value */
+
+ ThisDigit = ThisDigit - 'A' + 10;
+ }
+ else
+ {
+ Term = 1;
+ }
+ }
+
+ if (Term)
+ {
+ if (ToIntegerOp)
+ {
+ goto ErrorExit;
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x)
+ {
+ /* Skip zeros */
+ String++;
+ continue;
+ }
+
+ ValidDigits++;
+
+ if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32)))
+ {
+ /*
+ * This is ToInteger operation case.
+ * No any restrictions for string-to-integer conversion,
+ * see ACPI spec.
+ */
+ goto ErrorExit;
+ }
+
+ /* Divide the digit into the correct position */
+
+ (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit),
+ Base, &Quotient, NULL);
+
+ if (ReturnValue > Quotient)
+ {
+ if (ToIntegerOp)
+ {
+ goto ErrorExit;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ ReturnValue *= Base;
+ ReturnValue += ThisDigit;
+ String++;
+ }
+
+ /* All done, normal exit */
+
+AllDone:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (ReturnValue)));
+
+ *RetInteger = ReturnValue;
+ return_ACPI_STATUS (AE_OK);
+
+
+ErrorExit:
+ /* Base was set/validated above */
+
+ if (Base == 10)
+ {
+ return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
+ }
+ else
+ {
+ return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateUpdateStateAndPush
+ *
+ * PARAMETERS: Object - Object to be added to the new state
+ * Action - Increment/Decrement
+ * StateList - List the state will be added to
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new state and push it
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCreateUpdateStateAndPush (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT16 Action,
+ ACPI_GENERIC_STATE **StateList)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Ignore null objects; these are expected */
+
+ if (!Object)
+ {
+ return (AE_OK);
+ }
+
+ State = AcpiUtCreateUpdateState (Object, Action);
+ if (!State)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ AcpiUtPushGenericState (StateList, State);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtWalkPackageTree
+ *
+ * PARAMETERS: SourceObject - The package to walk
+ * TargetObject - Target object (if package is being copied)
+ * WalkCallback - Called once for each package element
+ * Context - Passed to the callback function
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk through a package
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtWalkPackageTree (
+ ACPI_OPERAND_OBJECT *SourceObject,
+ void *TargetObject,
+ ACPI_PKG_CALLBACK WalkCallback,
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_GENERIC_STATE *StateList = NULL;
+ ACPI_GENERIC_STATE *State;
+ UINT32 ThisIndex;
+ ACPI_OPERAND_OBJECT *ThisSourceObj;
+
+
+ ACPI_FUNCTION_TRACE (UtWalkPackageTree);
+
+
+ State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
+ if (!State)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ while (State)
+ {
+ /* Get one element of the package */
+
+ ThisIndex = State->Pkg.Index;
+ ThisSourceObj = (ACPI_OPERAND_OBJECT *)
+ State->Pkg.SourceObject->Package.Elements[ThisIndex];
+
+ /*
+ * Check for:
+ * 1) An uninitialized package element. It is completely
+ * legal to declare a package and leave it uninitialized
+ * 2) Not an internal object - can be a namespace node instead
+ * 3) Any type other than a package. Packages are handled in else
+ * case below.
+ */
+ if ((!ThisSourceObj) ||
+ (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
+ (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
+ {
+ Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
+ State, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ State->Pkg.Index++;
+ while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
+ {
+ /*
+ * We've handled all of the objects at this level, This means
+ * that we have just completed a package. That package may
+ * have contained one or more packages itself.
+ *
+ * Delete this state and pop the previous state (package).
+ */
+ AcpiUtDeleteGenericState (State);
+ State = AcpiUtPopGenericState (&StateList);
+
+ /* Finished when there are no more states */
+
+ if (!State)
+ {
+ /*
+ * We have handled all of the objects in the top level
+ * package just add the length of the package objects
+ * and exit
+ */
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Go back up a level and move the index past the just
+ * completed package object.
+ */
+ State->Pkg.Index++;
+ }
+ }
+ else
+ {
+ /* This is a subobject of type package */
+
+ Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
+ State, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Push the current state and create a new one
+ * The callback above returned a new target package object.
+ */
+ AcpiUtPushGenericState (&StateList, State);
+ State = AcpiUtCreatePkgState (ThisSourceObj,
+ State->Pkg.ThisTargetObj, 0);
+ if (!State)
+ {
+ /* Free any stacked Update State objects */
+
+ while (StateList)
+ {
+ State = AcpiUtPopGenericState (&StateList);
+ AcpiUtDeleteGenericState (State);
+ }
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ }
+ }
+
+ /* We should never get here */
+
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utmutex.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utmutex.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ *
+ * Module Name: utmutex - local mutex 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.
+ */
+
+
+#define __UTMUTEX_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utmutex")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiUtCreateMutex (
+ ACPI_MUTEX_HANDLE MutexId);
+
+static void
+AcpiUtDeleteMutex (
+ ACPI_MUTEX_HANDLE MutexId);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtMutexInitialize
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create the system mutex objects. This includes mutexes,
+ * spin locks, and reader/writer locks.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtMutexInitialize (
+ void)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtMutexInitialize);
+
+
+ /* Create each of the predefined mutex objects */
+
+ for (i = 0; i < ACPI_NUM_MUTEX; i++)
+ {
+ Status = AcpiUtCreateMutex (i);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Create the spinlocks for use at interrupt level */
+
+ Status = AcpiOsCreateLock (&AcpiGbl_GpeLock);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Mutex for _OSI support */
+ Status = AcpiOsCreateMutex (&AcpiGbl_OsiMutex);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Create the reader/writer lock for namespace access */
+
+ Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtMutexTerminate
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes,
+ * spin locks, and reader/writer locks.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtMutexTerminate (
+ void)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE (UtMutexTerminate);
+
+
+ /* Delete each predefined mutex object */
+
+ for (i = 0; i < ACPI_NUM_MUTEX; i++)
+ {
+ AcpiUtDeleteMutex (i);
+ }
+
+ AcpiOsDeleteMutex (AcpiGbl_OsiMutex);
+
+ /* Delete the spinlocks */
+
+ AcpiOsDeleteLock (AcpiGbl_GpeLock);
+ AcpiOsDeleteLock (AcpiGbl_HardwareLock);
+
+ /* Delete the reader/writer lock */
+
+ AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateMutex
+ *
+ * PARAMETERS: MutexID - ID of the mutex to be created
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a mutex object.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtCreateMutex (
+ ACPI_MUTEX_HANDLE MutexId)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId);
+
+
+ if (!AcpiGbl_MutexInfo[MutexId].Mutex)
+ {
+ Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex);
+ AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
+ AcpiGbl_MutexInfo[MutexId].UseCount = 0;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteMutex
+ *
+ * PARAMETERS: MutexID - ID of the mutex to be deleted
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Delete a mutex object.
+ *
+ ******************************************************************************/
+
+static void
+AcpiUtDeleteMutex (
+ ACPI_MUTEX_HANDLE MutexId)
+{
+
+ ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId);
+
+
+ AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
+
+ AcpiGbl_MutexInfo[MutexId].Mutex = NULL;
+ AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAcquireMutex
+ *
+ * PARAMETERS: MutexID - ID of the mutex to be acquired
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Acquire a mutex object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtAcquireMutex (
+ ACPI_MUTEX_HANDLE MutexId)
+{
+ ACPI_STATUS Status;
+ ACPI_THREAD_ID ThisThreadId;
+
+
+ ACPI_FUNCTION_NAME (UtAcquireMutex);
+
+
+ if (MutexId > ACPI_MAX_MUTEX)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ ThisThreadId = AcpiOsGetThreadId ();
+
+#ifdef ACPI_MUTEX_DEBUG
+ {
+ UINT32 i;
+ /*
+ * Mutex debug code, for internal debugging only.
+ *
+ * Deadlock prevention. Check if this thread owns any mutexes of value
+ * greater than or equal to this one. If so, the thread has violated
+ * the mutex ordering rule. This indicates a coding error somewhere in
+ * the ACPI subsystem code.
+ */
+ for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
+ {
+ if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId)
+ {
+ if (i == MutexId)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Mutex [%s] already acquired by this thread [%u]",
+ AcpiUtGetMutexName (MutexId),
+ (UINT32) ThisThreadId));
+
+ return (AE_ALREADY_ACQUIRED);
+ }
+
+ ACPI_ERROR ((AE_INFO,
+ "Invalid acquire order: Thread %u owns [%s], wants [%s]",
+ (UINT32) ThisThreadId, AcpiUtGetMutexName (i),
+ AcpiUtGetMutexName (MutexId)));
+
+ return (AE_ACQUIRE_DEADLOCK);
+ }
+ }
+ }
+#endif
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
+ "Thread %u attempting to acquire Mutex [%s]\n",
+ (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
+
+ Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex,
+ ACPI_WAIT_FOREVER);
+ if (ACPI_SUCCESS (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u acquired Mutex [%s]\n",
+ (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
+
+ AcpiGbl_MutexInfo[MutexId].UseCount++;
+ AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId;
+ }
+ else
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status,
+ "Thread %u could not acquire Mutex [0x%X]",
+ (UINT32) ThisThreadId, MutexId));
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtReleaseMutex
+ *
+ * PARAMETERS: MutexID - ID of the mutex to be released
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release a mutex object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtReleaseMutex (
+ ACPI_MUTEX_HANDLE MutexId)
+{
+ ACPI_FUNCTION_NAME (UtReleaseMutex);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n",
+ (UINT32) AcpiOsGetThreadId (), AcpiUtGetMutexName (MutexId)));
+
+ if (MutexId > ACPI_MAX_MUTEX)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Mutex must be acquired in order to release it!
+ */
+ if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "Mutex [0x%X] is not acquired, cannot release", MutexId));
+
+ return (AE_NOT_ACQUIRED);
+ }
+
+#ifdef ACPI_MUTEX_DEBUG
+ {
+ UINT32 i;
+ /*
+ * Mutex debug code, for internal debugging only.
+ *
+ * Deadlock prevention. Check if this thread owns any mutexes of value
+ * greater than this one. If so, the thread has violated the mutex
+ * ordering rule. This indicates a coding error somewhere in
+ * the ACPI subsystem code.
+ */
+ for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
+ {
+ if (AcpiGbl_MutexInfo[i].ThreadId == AcpiOsGetThreadId ())
+ {
+ if (i == MutexId)
+ {
+ continue;
+ }
+
+ ACPI_ERROR ((AE_INFO,
+ "Invalid release order: owns [%s], releasing [%s]",
+ AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId)));
+
+ return (AE_RELEASE_DEADLOCK);
+ }
+ }
+ }
+#endif
+
+ /* Mark unlocked FIRST */
+
+ AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
+
+ AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
+ return (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utobject.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utobject.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,787 @@
+/******************************************************************************
+ *
+ * Module Name: utobject - ACPI object create/delete/size/cache 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 __UTOBJECT_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utobject")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiUtGetSimpleObjectSize (
+ ACPI_OPERAND_OBJECT *Obj,
+ ACPI_SIZE *ObjLength);
+
+static ACPI_STATUS
+AcpiUtGetPackageObjectSize (
+ ACPI_OPERAND_OBJECT *Obj,
+ ACPI_SIZE *ObjLength);
+
+static ACPI_STATUS
+AcpiUtGetElementLength (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateInternalObjectDbg
+ *
+ * PARAMETERS: ModuleName - Source file name of caller
+ * LineNumber - Line number of caller
+ * ComponentId - Component type of caller
+ * Type - ACPI Type of the new object
+ *
+ * RETURN: A new internal object, null on failure
+ *
+ * DESCRIPTION: Create and initialize a new internal object.
+ *
+ * NOTE: We always allocate the worst-case object descriptor because
+ * these objects are cached, and we want them to be
+ * one-size-satisifies-any-request. This in itself may not be
+ * the most memory efficient, but the efficiency of the object
+ * cache should more than make up for this!
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiUtCreateInternalObjectDbg (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId,
+ ACPI_OBJECT_TYPE Type)
+{
+ ACPI_OPERAND_OBJECT *Object;
+ ACPI_OPERAND_OBJECT *SecondObject;
+
+
+ ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg,
+ AcpiUtGetTypeName (Type));
+
+
+ /* Allocate the raw object descriptor */
+
+ Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId);
+ if (!Object)
+ {
+ return_PTR (NULL);
+ }
+
+ switch (Type)
+ {
+ case ACPI_TYPE_REGION:
+ case ACPI_TYPE_BUFFER_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ /* These types require a secondary object */
+
+ SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName,
+ LineNumber, ComponentId);
+ if (!SecondObject)
+ {
+ AcpiUtDeleteObjectDesc (Object);
+ return_PTR (NULL);
+ }
+
+ SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;
+ SecondObject->Common.ReferenceCount = 1;
+
+ /* Link the second object to the first */
+
+ Object->Common.NextObject = SecondObject;
+ break;
+
+ default:
+ /* All others have no secondary object */
+ break;
+ }
+
+ /* Save the object type in the object descriptor */
+
+ Object->Common.Type = (UINT8) Type;
+
+ /* Init the reference count */
+
+ Object->Common.ReferenceCount = 1;
+
+ /* Any per-type initialization should go here */
+
+ return_PTR (Object);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreatePackageObject
+ *
+ * PARAMETERS: Count - Number of package elements
+ *
+ * RETURN: Pointer to a new Package object, null on failure
+ *
+ * DESCRIPTION: Create a fully initialized package object
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiUtCreatePackageObject (
+ UINT32 Count)
+{
+ ACPI_OPERAND_OBJECT *PackageDesc;
+ ACPI_OPERAND_OBJECT **PackageElements;
+
+
+ ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count);
+
+
+ /* Create a new Package object */
+
+ PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
+ if (!PackageDesc)
+ {
+ return_PTR (NULL);
+ }
+
+ /*
+ * Create the element array. Count+1 allows the array to be null
+ * terminated.
+ */
+ PackageElements = ACPI_ALLOCATE_ZEROED (
+ ((ACPI_SIZE) Count + 1) * sizeof (void *));
+ if (!PackageElements)
+ {
+ ACPI_FREE (PackageDesc);
+ return_PTR (NULL);
+ }
+
+ PackageDesc->Package.Count = Count;
+ PackageDesc->Package.Elements = PackageElements;
+ return_PTR (PackageDesc);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateIntegerObject
+ *
+ * PARAMETERS: InitialValue - Initial value for the integer
+ *
+ * RETURN: Pointer to a new Integer object, null on failure
+ *
+ * DESCRIPTION: Create an initialized integer object
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiUtCreateIntegerObject (
+ UINT64 InitialValue)
+{
+ ACPI_OPERAND_OBJECT *IntegerDesc;
+
+
+ ACPI_FUNCTION_TRACE (UtCreateIntegerObject);
+
+
+ /* Create and initialize a new integer object */
+
+ IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!IntegerDesc)
+ {
+ return_PTR (NULL);
+ }
+
+ IntegerDesc->Integer.Value = InitialValue;
+ return_PTR (IntegerDesc);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateBufferObject
+ *
+ * PARAMETERS: BufferSize - Size of buffer to be created
+ *
+ * RETURN: Pointer to a new Buffer object, null on failure
+ *
+ * DESCRIPTION: Create a fully initialized buffer object
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiUtCreateBufferObject (
+ ACPI_SIZE BufferSize)
+{
+ ACPI_OPERAND_OBJECT *BufferDesc;
+ UINT8 *Buffer = NULL;
+
+
+ ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize);
+
+
+ /* Create a new Buffer object */
+
+ BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
+ if (!BufferDesc)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Create an actual buffer only if size > 0 */
+
+ if (BufferSize > 0)
+ {
+ /* Allocate the actual buffer */
+
+ Buffer = ACPI_ALLOCATE_ZEROED (BufferSize);
+ if (!Buffer)
+ {
+ ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
+ (UINT32) BufferSize));
+ AcpiUtRemoveReference (BufferDesc);
+ return_PTR (NULL);
+ }
+ }
+
+ /* Complete buffer object initialization */
+
+ BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
+ BufferDesc->Buffer.Pointer = Buffer;
+ BufferDesc->Buffer.Length = (UINT32) BufferSize;
+
+ /* Return the new buffer descriptor */
+
+ return_PTR (BufferDesc);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateStringObject
+ *
+ * PARAMETERS: StringSize - Size of string to be created. Does not
+ * include NULL terminator, this is added
+ * automatically.
+ *
+ * RETURN: Pointer to a new String object
+ *
+ * DESCRIPTION: Create a fully initialized string object
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiUtCreateStringObject (
+ ACPI_SIZE StringSize)
+{
+ ACPI_OPERAND_OBJECT *StringDesc;
+ char *String;
+
+
+ ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize);
+
+
+ /* Create a new String object */
+
+ StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
+ if (!StringDesc)
+ {
+ return_PTR (NULL);
+ }
+
+ /*
+ * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
+ * NOTE: Zero-length strings are NULL terminated
+ */
+ String = ACPI_ALLOCATE_ZEROED (StringSize + 1);
+ if (!String)
+ {
+ ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
+ (UINT32) StringSize));
+ AcpiUtRemoveReference (StringDesc);
+ return_PTR (NULL);
+ }
+
+ /* Complete string object initialization */
+
+ StringDesc->String.Pointer = String;
+ StringDesc->String.Length = (UINT32) StringSize;
+
+ /* Return the new string descriptor */
+
+ return_PTR (StringDesc);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidInternalObject
+ *
+ * PARAMETERS: Object - Object to be validated
+ *
+ * RETURN: TRUE if object is valid, FALSE otherwise
+ *
+ * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiUtValidInternalObject (
+ void *Object)
+{
+
+ ACPI_FUNCTION_NAME (UtValidInternalObject);
+
+
+ /* Check for a null pointer */
+
+ if (!Object)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
+ return (FALSE);
+ }
+
+ /* Check the descriptor type field */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (Object))
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+
+ /* The object appears to be a valid ACPI_OPERAND_OBJECT */
+
+ return (TRUE);
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "%p is not not an ACPI operand obj [%s]\n",
+ Object, AcpiUtGetDescriptorName (Object)));
+ break;
+ }
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocateObjectDescDbg
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * ComponentId - Caller's component ID (for error output)
+ *
+ * RETURN: Pointer to newly allocated object descriptor. Null on error
+ *
+ * DESCRIPTION: Allocate a new object descriptor. Gracefully handle
+ * error conditions.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAllocateObjectDescDbg (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId)
+{
+ ACPI_OPERAND_OBJECT *Object;
+
+
+ ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg);
+
+
+ Object = AcpiOsAcquireObject (AcpiGbl_OperandCache);
+ if (!Object)
+ {
+ ACPI_ERROR ((ModuleName, LineNumber,
+ "Could not allocate an object descriptor"));
+
+ return_PTR (NULL);
+ }
+
+ /* Mark the descriptor type */
+
+ ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
+ Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT)));
+
+ return_PTR (Object);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteObjectDesc
+ *
+ * PARAMETERS: Object - An Acpi internal object to be deleted
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDeleteObjectDesc (
+ ACPI_OPERAND_OBJECT *Object)
+{
+ ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);
+
+
+ /* Object must be an ACPI_OPERAND_OBJECT */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "%p is not an ACPI Operand object [%s]", Object,
+ AcpiUtGetDescriptorName (Object)));
+ return_VOID;
+ }
+
+ (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetSimpleObjectSize
+ *
+ * PARAMETERS: InternalObject - An ACPI operand object
+ * ObjLength - Where the length is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to determine the space required to
+ * contain a simple object for return to an external user.
+ *
+ * The length includes the object structure plus any additional
+ * needed space.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtGetSimpleObjectSize (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ ACPI_SIZE *ObjLength)
+{
+ ACPI_SIZE Length;
+ ACPI_SIZE Size;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject);
+
+
+ /* Start with the length of the (external) Acpi object */
+
+ Length = sizeof (ACPI_OBJECT);
+
+ /* A NULL object is allowed, can be a legal uninitialized package element */
+
+ if (!InternalObject)
+ {
+ /*
+ * Object is NULL, just return the length of ACPI_OBJECT
+ * (A NULL ACPI_OBJECT is an object of all zeroes.)
+ */
+ *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* A Namespace Node should never appear here */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)
+ {
+ /* A namespace node should never get here */
+
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ /*
+ * The final length depends on the object type
+ * Strings and Buffers are packed right up against the parent object and
+ * must be accessed bytewise or there may be alignment problems on
+ * certain processors
+ */
+ switch (InternalObject->Common.Type)
+ {
+ case ACPI_TYPE_STRING:
+
+ Length += (ACPI_SIZE) InternalObject->String.Length + 1;
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ Length += (ACPI_SIZE) InternalObject->Buffer.Length;
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_PROCESSOR:
+ case ACPI_TYPE_POWER:
+
+ /* No extra data for these types */
+
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ switch (InternalObject->Reference.Class)
+ {
+ case ACPI_REFCLASS_NAME:
+
+ /*
+ * Get the actual length of the full pathname to this object.
+ * The reference will be converted to the pathname to the object
+ */
+ Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);
+ if (!Size)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);
+ break;
+
+ default:
+
+ /*
+ * No other reference opcodes are supported.
+ * Notably, Locals and Args are not supported, but this may be
+ * required eventually.
+ */
+ ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
+ "unsupported Reference Class [%s] 0x%X in object %p",
+ AcpiUtGetReferenceName (InternalObject),
+ InternalObject->Reference.Class, InternalObject));
+ Status = AE_TYPE;
+ break;
+ }
+ break;
+
+
+ default:
+
+ ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
+ "unsupported type [%s] 0x%X in object %p",
+ AcpiUtGetObjectTypeName (InternalObject),
+ InternalObject->Common.Type, InternalObject));
+ Status = AE_TYPE;
+ break;
+ }
+
+ /*
+ * Account for the space required by the object rounded up to the next
+ * multiple of the machine word size. This keeps each object aligned
+ * on a machine word boundary. (preventing alignment faults on some
+ * machines.)
+ */
+ *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetElementLength
+ *
+ * PARAMETERS: ACPI_PKG_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get the length of one package element.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtGetElementLength (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
+ ACPI_SIZE ObjectSpace;
+
+
+ switch (ObjectType)
+ {
+ case ACPI_COPY_TYPE_SIMPLE:
+
+ /*
+ * Simple object - just get the size (Null object/entry is handled
+ * here also) and sum it into the running package length
+ */
+ Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Info->Length += ObjectSpace;
+ break;
+
+
+ case ACPI_COPY_TYPE_PACKAGE:
+
+ /* Package object - nothing much to do here, let the walk handle it */
+
+ Info->NumPackages++;
+ State->Pkg.ThisTargetObj = NULL;
+ break;
+
+
+ default:
+
+ /* No other types allowed */
+
+ return (AE_BAD_PARAMETER);
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetPackageObjectSize
+ *
+ * PARAMETERS: InternalObject - An ACPI internal object
+ * ObjLength - Where the length is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to determine the space required to
+ * contain a package object for return to an external user.
+ *
+ * This is moderately complex since a package contains other
+ * objects including packages.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtGetPackageObjectSize (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ ACPI_SIZE *ObjLength)
+{
+ ACPI_STATUS Status;
+ ACPI_PKG_INFO Info;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject);
+
+
+ Info.Length = 0;
+ Info.ObjectSpace = 0;
+ Info.NumPackages = 1;
+
+ Status = AcpiUtWalkPackageTree (InternalObject, NULL,
+ AcpiUtGetElementLength, &Info);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * We have handled all of the objects in all levels of the package.
+ * just add the length of the package objects themselves.
+ * Round up to the next machine word.
+ */
+ Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) *
+ (ACPI_SIZE) Info.NumPackages;
+
+ /* Return the total package length */
+
+ *ObjLength = Info.Length;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetObjectSize
+ *
+ * PARAMETERS: InternalObject - An ACPI internal object
+ * ObjLength - Where the length will be returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to determine the space required to
+ * contain an object for return to an API user.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtGetObjectSize (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ ACPI_SIZE *ObjLength)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) &&
+ (InternalObject->Common.Type == ACPI_TYPE_PACKAGE))
+ {
+ Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);
+ }
+ else
+ {
+ Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);
+ }
+
+ return (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utosi.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utosi.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,422 @@
+/******************************************************************************
+ *
+ * Module Name: utosi - Support for the _OSI predefined control method
+ *
+ *****************************************************************************/
+
+/*
+ * 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 __UTOSI_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utosi")
+
+/*
+ * Strings supported by the _OSI predefined control method (which is
+ * implemented internally within this module.)
+ *
+ * March 2009: Removed "Linux" as this host no longer wants to respond true
+ * for this string. Basically, the only safe OS strings are windows-related
+ * and in many or most cases represent the only test path within the
+ * BIOS-provided ASL code.
+ *
+ * The last element of each entry is used to track the newest version of
+ * Windows that the BIOS has requested.
+ */
+static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] =
+{
+ /* Operating System Vendor Strings */
+
+ {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */
+ {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */
+ {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
+ {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
+ {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
+ {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
+ {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
+ {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
+ {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
+ {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
+ {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
+
+ /* Feature Group Strings */
+
+ {"Extended Address Space Descriptor", NULL, 0, 0}
+
+ /*
+ * All "optional" feature group strings (features that are implemented
+ * by the host) should be dynamically added by the host via
+ * AcpiInstallInterface and should not be manually added here.
+ *
+ * Examples of optional feature group strings:
+ *
+ * "Module Device"
+ * "Processor Device"
+ * "3.0 Thermal Model"
+ * "3.0 _SCP Extensions"
+ * "Processor Aggregator Device"
+ */
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtInitializeInterfaces
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize the global _OSI supported interfaces list
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtInitializeInterfaces (
+ void)
+{
+ UINT32 i;
+
+
+ (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
+ AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
+
+ /* Link the static list of supported interfaces */
+
+ for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++)
+ {
+ AcpiDefaultSupportedInterfaces[i].Next =
+ &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
+ }
+
+ AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtInterfaceTerminate
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Delete all interfaces in the global list. Sets
+ * AcpiGbl_SupportedInterfaces to NULL.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtInterfaceTerminate (
+ void)
+{
+ ACPI_INTERFACE_INFO *NextInterface;
+
+
+ (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
+ NextInterface = AcpiGbl_SupportedInterfaces;
+
+ while (NextInterface)
+ {
+ AcpiGbl_SupportedInterfaces = NextInterface->Next;
+
+ /* Only interfaces added at runtime can be freed */
+
+ if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
+ {
+ ACPI_FREE (NextInterface->Name);
+ ACPI_FREE (NextInterface);
+ }
+
+ NextInterface = AcpiGbl_SupportedInterfaces;
+ }
+
+ AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtInstallInterface
+ *
+ * PARAMETERS: InterfaceName - The interface to install
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install the interface into the global interface list.
+ * Caller MUST hold AcpiGbl_OsiMutex
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtInstallInterface (
+ ACPI_STRING InterfaceName)
+{
+ ACPI_INTERFACE_INFO *InterfaceInfo;
+
+
+ /* Allocate info block and space for the name string */
+
+ InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
+ if (!InterfaceInfo)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1);
+ if (!InterfaceInfo->Name)
+ {
+ ACPI_FREE (InterfaceInfo);
+ return (AE_NO_MEMORY);
+ }
+
+ /* Initialize new info and insert at the head of the global list */
+
+ ACPI_STRCPY (InterfaceInfo->Name, InterfaceName);
+ InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
+ InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
+
+ AcpiGbl_SupportedInterfaces = InterfaceInfo;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtRemoveInterface
+ *
+ * PARAMETERS: InterfaceName - The interface to remove
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Remove the interface from the global interface list.
+ * Caller MUST hold AcpiGbl_OsiMutex
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtRemoveInterface (
+ ACPI_STRING InterfaceName)
+{
+ ACPI_INTERFACE_INFO *PreviousInterface;
+ ACPI_INTERFACE_INFO *NextInterface;
+
+
+ PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
+ while (NextInterface)
+ {
+ if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
+ {
+ /* Found: name is in either the static list or was added at runtime */
+
+ if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
+ {
+ /* Interface was added dynamically, remove and free it */
+
+ if (PreviousInterface == NextInterface)
+ {
+ AcpiGbl_SupportedInterfaces = NextInterface->Next;
+ }
+ else
+ {
+ PreviousInterface->Next = NextInterface->Next;
+ }
+
+ ACPI_FREE (NextInterface->Name);
+ ACPI_FREE (NextInterface);
+ }
+ else
+ {
+ /*
+ * Interface is in static list. If marked invalid, then it
+ * does not actually exist. Else, mark it invalid.
+ */
+ if (NextInterface->Flags & ACPI_OSI_INVALID)
+ {
+ return (AE_NOT_EXIST);
+ }
+
+ NextInterface->Flags |= ACPI_OSI_INVALID;
+ }
+
+ return (AE_OK);
+ }
+
+ PreviousInterface = NextInterface;
+ NextInterface = NextInterface->Next;
+ }
+
+ /* Interface was not found */
+
+ return (AE_NOT_EXIST);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetInterface
+ *
+ * PARAMETERS: InterfaceName - The interface to find
+ *
+ * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found.
+ *
+ * DESCRIPTION: Search for the specified interface name in the global list.
+ * Caller MUST hold AcpiGbl_OsiMutex
+ *
+ ******************************************************************************/
+
+ACPI_INTERFACE_INFO *
+AcpiUtGetInterface (
+ ACPI_STRING InterfaceName)
+{
+ ACPI_INTERFACE_INFO *NextInterface;
+
+
+ NextInterface = AcpiGbl_SupportedInterfaces;
+ while (NextInterface)
+ {
+ if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
+ {
+ return (NextInterface);
+ }
+
+ NextInterface = NextInterface->Next;
+ }
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtOsiImplementation
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implementation of the _OSI predefined control method. When
+ * an invocation of _OSI is encountered in the system AML,
+ * control is transferred to this function.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtOsiImplementation (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT *StringDesc;
+ ACPI_OPERAND_OBJECT *ReturnDesc;
+ ACPI_INTERFACE_INFO *InterfaceInfo;
+ ACPI_INTERFACE_HANDLER InterfaceHandler;
+ UINT32 ReturnValue;
+
+
+ ACPI_FUNCTION_TRACE (UtOsiImplementation);
+
+
+ /* Validate the string input argument (from the AML caller) */
+
+ StringDesc = WalkState->Arguments[0].Object;
+ if (!StringDesc ||
+ (StringDesc->Common.Type != ACPI_TYPE_STRING))
+ {
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /* Create a return object */
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Default return value is 0, NOT SUPPORTED */
+
+ ReturnValue = 0;
+ (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
+
+ /* Lookup the interface in the global _OSI list */
+
+ InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
+ if (InterfaceInfo &&
+ !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
+ {
+ /*
+ * The interface is supported.
+ * Update the OsiData if necessary. We keep track of the latest
+ * version of Windows that has been requested by the BIOS.
+ */
+ if (InterfaceInfo->Value > AcpiGbl_OsiData)
+ {
+ AcpiGbl_OsiData = InterfaceInfo->Value;
+ }
+
+ ReturnValue = ACPI_UINT32_MAX;
+ }
+
+ AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
+
+ /*
+ * Invoke an optional _OSI interface handler. The host OS may wish
+ * to do some interface-specific handling. For example, warn about
+ * certain interfaces or override the true/false support value.
+ */
+ InterfaceHandler = AcpiGbl_InterfaceHandler;
+ if (InterfaceHandler)
+ {
+ ReturnValue = InterfaceHandler (
+ StringDesc->String.Pointer, ReturnValue);
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
+ "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
+ StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
+
+ /* Complete the return object */
+
+ ReturnDesc->Integer.Value = ReturnValue;
+ WalkState->ReturnDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utresrc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utresrc.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,923 @@
+/*******************************************************************************
+ *
+ * Module Name: utresrc - Resource managment 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 __UTRESRC_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utresrc")
+
+
+#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
+
+/*
+ * Strings used to decode resource descriptors.
+ * Used by both the disasssembler and the debugger resource dump routines
+ */
+const char *AcpiGbl_BmDecode[] =
+{
+ "NotBusMaster",
+ "BusMaster"
+};
+
+const char *AcpiGbl_ConfigDecode[] =
+{
+ "0 - Good Configuration",
+ "1 - Acceptable Configuration",
+ "2 - Suboptimal Configuration",
+ "3 - ***Invalid Configuration***",
+};
+
+const char *AcpiGbl_ConsumeDecode[] =
+{
+ "ResourceProducer",
+ "ResourceConsumer"
+};
+
+const char *AcpiGbl_DecDecode[] =
+{
+ "PosDecode",
+ "SubDecode"
+};
+
+const char *AcpiGbl_HeDecode[] =
+{
+ "Level",
+ "Edge"
+};
+
+const char *AcpiGbl_IoDecode[] =
+{
+ "Decode10",
+ "Decode16"
+};
+
+const char *AcpiGbl_LlDecode[] =
+{
+ "ActiveHigh",
+ "ActiveLow"
+};
+
+const char *AcpiGbl_MaxDecode[] =
+{
+ "MaxNotFixed",
+ "MaxFixed"
+};
+
+const char *AcpiGbl_MemDecode[] =
+{
+ "NonCacheable",
+ "Cacheable",
+ "WriteCombining",
+ "Prefetchable"
+};
+
+const char *AcpiGbl_MinDecode[] =
+{
+ "MinNotFixed",
+ "MinFixed"
+};
+
+const char *AcpiGbl_MtpDecode[] =
+{
+ "AddressRangeMemory",
+ "AddressRangeReserved",
+ "AddressRangeACPI",
+ "AddressRangeNVS"
+};
+
+const char *AcpiGbl_RngDecode[] =
+{
+ "InvalidRanges",
+ "NonISAOnlyRanges",
+ "ISAOnlyRanges",
+ "EntireRange"
+};
+
+const char *AcpiGbl_RwDecode[] =
+{
+ "ReadOnly",
+ "ReadWrite"
+};
+
+const char *AcpiGbl_ShrDecode[] =
+{
+ "Exclusive",
+ "Shared"
+};
+
+const char *AcpiGbl_SizDecode[] =
+{
+ "Transfer8",
+ "Transfer8_16",
+ "Transfer16",
+ "InvalidSize"
+};
+
+const char *AcpiGbl_TrsDecode[] =
+{
+ "DenseTranslation",
+ "SparseTranslation"
+};
+
+const char *AcpiGbl_TtpDecode[] =
+{
+ "TypeStatic",
+ "TypeTranslation"
+};
+
+const char *AcpiGbl_TypDecode[] =
+{
+ "Compatibility",
+ "TypeA",
+ "TypeB",
+ "TypeF"
+};
+
+const char *AcpiGbl_PpcDecode[] =
+{
+ "PullDefault",
+ "PullUp",
+ "PullDown",
+ "PullNone"
+};
+
+const char *AcpiGbl_IorDecode[] =
+{
+ "IoRestrictionNone",
+ "IoRestrictionInputOnly",
+ "IoRestrictionOutputOnly",
+ "IoRestrictionNoneAndPreserve"
+};
+
+const char *AcpiGbl_DtsDecode[] =
+{
+ "Width8bit",
+ "Width16bit",
+ "Width32bit",
+ "Width64bit",
+ "Width128bit",
+ "Width256bit",
+};
+
+/* GPIO connection type */
+
+const char *AcpiGbl_CtDecode[] =
+{
+ "Interrupt",
+ "I/O"
+};
+
+/* Serial bus type */
+
+const char *AcpiGbl_SbtDecode[] =
+{
+ "/* UNKNOWN serial bus type */",
+ "I2C",
+ "SPI",
+ "UART"
+};
+
+/* I2C serial bus access mode */
+
+const char *AcpiGbl_AmDecode[] =
+{
+ "AddressingMode7Bit",
+ "AddressingMode10Bit"
+};
+
+/* I2C serial bus slave mode */
+
+const char *AcpiGbl_SmDecode[] =
+{
+ "ControllerInitiated",
+ "DeviceInitiated"
+};
+
+/* SPI serial bus wire mode */
+
+const char *AcpiGbl_WmDecode[] =
+{
+ "FourWireMode",
+ "ThreeWireMode"
+};
+
+/* SPI serial clock phase */
+
+const char *AcpiGbl_CphDecode[] =
+{
+ "ClockPhaseFirst",
+ "ClockPhaseSecond"
+};
+
+/* SPI serial bus clock polarity */
+
+const char *AcpiGbl_CpoDecode[] =
+{
+ "ClockPolarityLow",
+ "ClockPolarityHigh"
+};
+
+/* SPI serial bus device polarity */
+
+const char *AcpiGbl_DpDecode[] =
+{
+ "PolarityLow",
+ "PolarityHigh"
+};
+
+/* UART serial bus endian */
+
+const char *AcpiGbl_EdDecode[] =
+{
+ "LittleEndian",
+ "BigEndian"
+};
+
+/* UART serial bus bits per byte */
+
+const char *AcpiGbl_BpbDecode[] =
+{
+ "DataBitsFive",
+ "DataBitsSix",
+ "DataBitsSeven",
+ "DataBitsEight",
+ "DataBitsNine",
+ "/* UNKNOWN Bits per byte */",
+ "/* UNKNOWN Bits per byte */",
+ "/* UNKNOWN Bits per byte */"
+};
+
+/* UART serial bus stop bits */
+
+const char *AcpiGbl_SbDecode[] =
+{
+ "StopBitsNone",
+ "StopBitsOne",
+ "StopBitsOnePlusHalf",
+ "StopBitsTwo"
+};
+
+/* UART serial bus flow control */
+
+const char *AcpiGbl_FcDecode[] =
+{
+ "FlowControlNone",
+ "FlowControlHardware",
+ "FlowControlXON",
+ "/* UNKNOWN flow control keyword */"
+};
+
+/* UART serial bus parity type */
+
+const char *AcpiGbl_PtDecode[] =
+{
+ "ParityTypeNone",
+ "ParityTypeEven",
+ "ParityTypeOdd",
+ "ParityTypeMark",
+ "ParityTypeSpace",
+ "/* UNKNOWN parity keyword */",
+ "/* UNKNOWN parity keyword */",
+ "/* UNKNOWN parity keyword */"
+};
+
+#endif
+
+
+/*
+ * Base sizes of the raw AML resource descriptors, indexed by resource type.
+ * Zero indicates a reserved (and therefore invalid) resource type.
+ */
+const UINT8 AcpiGbl_ResourceAmlSizes[] =
+{
+ /* Small descriptors */
+
+ 0,
+ 0,
+ 0,
+ 0,
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ),
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA),
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT),
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT),
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO),
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO),
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_DMA),
+ 0,
+ 0,
+ 0,
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL),
+ ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG),
+
+ /* Large descriptors */
+
+ 0,
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER),
+ 0,
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO),
+ 0,
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_COMMON_SERIALBUS),
+};
+
+const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[] =
+{
+ 0,
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS),
+ ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS),
+};
+
+
+/*
+ * Resource types, used to validate the resource length field.
+ * The length of fixed-length types must match exactly, variable
+ * lengths must meet the minimum required length, etc.
+ * Zero indicates a reserved (and therefore invalid) resource type.
+ */
+static const UINT8 AcpiGbl_ResourceTypes[] =
+{
+ /* Small descriptors */
+
+ 0,
+ 0,
+ 0,
+ 0,
+ ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */
+ ACPI_FIXED_LENGTH, /* 05 DMA */
+ ACPI_SMALL_VARIABLE_LENGTH, /* 06 StartDependentFunctions */
+ ACPI_FIXED_LENGTH, /* 07 EndDependentFunctions */
+ ACPI_FIXED_LENGTH, /* 08 IO */
+ ACPI_FIXED_LENGTH, /* 09 FixedIO */
+ ACPI_FIXED_LENGTH, /* 0A FixedDMA */
+ 0,
+ 0,
+ 0,
+ ACPI_VARIABLE_LENGTH, /* 0E VendorShort */
+ ACPI_FIXED_LENGTH, /* 0F EndTag */
+
+ /* Large descriptors */
+
+ 0,
+ ACPI_FIXED_LENGTH, /* 01 Memory24 */
+ ACPI_FIXED_LENGTH, /* 02 GenericRegister */
+ 0,
+ ACPI_VARIABLE_LENGTH, /* 04 VendorLong */
+ ACPI_FIXED_LENGTH, /* 05 Memory32 */
+ ACPI_FIXED_LENGTH, /* 06 Memory32Fixed */
+ ACPI_VARIABLE_LENGTH, /* 07 Dword* address */
+ ACPI_VARIABLE_LENGTH, /* 08 Word* address */
+ ACPI_VARIABLE_LENGTH, /* 09 ExtendedIRQ */
+ ACPI_VARIABLE_LENGTH, /* 0A Qword* address */
+ ACPI_FIXED_LENGTH, /* 0B Extended* address */
+ ACPI_VARIABLE_LENGTH, /* 0C Gpio* */
+ 0,
+ ACPI_VARIABLE_LENGTH /* 0E *SerialBus */
+};
+
+/*
+ * For the iASL compiler/disassembler, we don't want any error messages
+ * because the disassembler uses the resource validation code to determine
+ * if Buffer objects are actually Resource Templates.
+ */
+#ifdef ACPI_ASL_COMPILER
+#define ACPI_RESOURCE_ERROR(plist)
+#else
+#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtWalkAmlResources
+ *
+ * PARAMETERS: Aml - Pointer to the raw AML resource template
+ * AmlLength - Length of the entire template
+ * UserFunction - Called once for each descriptor found. If
+ * NULL, a pointer to the EndTag is returned
+ * Context - Passed to UserFunction
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
+ * once for each resource found.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtWalkAmlResources (
+ UINT8 *Aml,
+ ACPI_SIZE AmlLength,
+ ACPI_WALK_AML_CALLBACK UserFunction,
+ void *Context)
+{
+ ACPI_STATUS Status;
+ UINT8 *EndAml;
+ UINT8 ResourceIndex;
+ UINT32 Length;
+ UINT32 Offset = 0;
+ UINT8 EndTag[2] = {0x79, 0x00};
+
+
+ ACPI_FUNCTION_TRACE (UtWalkAmlResources);
+
+
+ /* The absolute minimum resource template is one EndTag descriptor */
+
+ if (AmlLength < sizeof (AML_RESOURCE_END_TAG))
+ {
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+ }
+
+ /* Point to the end of the resource template buffer */
+
+ EndAml = Aml + AmlLength;
+
+ /* Walk the byte list, abort on any invalid descriptor type or length */
+
+ while (Aml < EndAml)
+ {
+ /* Validate the Resource Type and Resource Length */
+
+ Status = AcpiUtValidateResource (Aml, &ResourceIndex);
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * Exit on failure. Cannot continue because the descriptor length
+ * may be bogus also.
+ */
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the length of this descriptor */
+
+ Length = AcpiUtGetDescriptorLength (Aml);
+
+ /* Invoke the user function */
+
+ if (UserFunction)
+ {
+ Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* An EndTag descriptor terminates this resource template */
+
+ if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG)
+ {
+ /*
+ * There must be at least one more byte in the buffer for
+ * the 2nd byte of the EndTag
+ */
+ if ((Aml + 1) >= EndAml)
+ {
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+ }
+
+ /* Return the pointer to the EndTag if requested */
+
+ if (!UserFunction)
+ {
+ *(void **) Context = Aml;
+ }
+
+ /* Normal exit */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ Aml += Length;
+ Offset += Length;
+ }
+
+ /* Did not find an EndTag descriptor */
+
+ if (UserFunction)
+ {
+ /* Insert an EndTag anyway. AcpiRsGetListLength always leaves room */
+
+ (void) AcpiUtValidateResource (EndTag, &ResourceIndex);
+ Status = UserFunction (EndTag, 2, Offset, ResourceIndex, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidateResource
+ *
+ * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
+ * ReturnIndex - Where the resource index is returned. NULL
+ * if the index is not required.
+ *
+ * RETURN: Status, and optionally the Index into the global resource tables
+ *
+ * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
+ * Type and Resource Length. Returns an index into the global
+ * resource information/dispatch tables for later use.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtValidateResource (
+ void *Aml,
+ UINT8 *ReturnIndex)
+{
+ AML_RESOURCE *AmlResource;
+ UINT8 ResourceType;
+ UINT8 ResourceIndex;
+ ACPI_RS_LENGTH ResourceLength;
+ ACPI_RS_LENGTH MinimumResourceLength;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * 1) Validate the ResourceType field (Byte 0)
+ */
+ ResourceType = ACPI_GET8 (Aml);
+
+ /*
+ * Byte 0 contains the descriptor name (Resource Type)
+ * Examine the large/small bit in the resource header
+ */
+ if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
+ {
+ /* Verify the large resource type (name) against the max */
+
+ if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
+ {
+ goto InvalidResource;
+ }
+
+ /*
+ * Large Resource Type -- bits 6:0 contain the name
+ * Translate range 0x80-0x8B to index range 0x10-0x1B
+ */
+ ResourceIndex = (UINT8) (ResourceType - 0x70);
+ }
+ else
+ {
+ /*
+ * Small Resource Type -- bits 6:3 contain the name
+ * Shift range to index range 0x00-0x0F
+ */
+ ResourceIndex = (UINT8)
+ ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
+ }
+
+ /*
+ * Check validity of the resource type, via AcpiGbl_ResourceTypes. Zero
+ * indicates an invalid resource.
+ */
+ if (!AcpiGbl_ResourceTypes[ResourceIndex])
+ {
+ goto InvalidResource;
+ }
+
+ /*
+ * Validate the ResourceLength field. This ensures that the length
+ * is at least reasonable, and guarantees that it is non-zero.
+ */
+ ResourceLength = AcpiUtGetResourceLength (Aml);
+ MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
+
+ /* Validate based upon the type of resource - fixed length or variable */
+
+ switch (AcpiGbl_ResourceTypes[ResourceIndex])
+ {
+ case ACPI_FIXED_LENGTH:
+
+ /* Fixed length resource, length must match exactly */
+
+ if (ResourceLength != MinimumResourceLength)
+ {
+ goto BadResourceLength;
+ }
+ break;
+
+ case ACPI_VARIABLE_LENGTH:
+
+ /* Variable length resource, length must be at least the minimum */
+
+ if (ResourceLength < MinimumResourceLength)
+ {
+ goto BadResourceLength;
+ }
+ break;
+
+ case ACPI_SMALL_VARIABLE_LENGTH:
+
+ /* Small variable length resource, length can be (Min) or (Min-1) */
+
+ if ((ResourceLength > MinimumResourceLength) ||
+ (ResourceLength < (MinimumResourceLength - 1)))
+ {
+ goto BadResourceLength;
+ }
+ break;
+
+ default:
+
+ /* Shouldn't happen (because of validation earlier), but be sure */
+
+ goto InvalidResource;
+ }
+
+ AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
+ if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS)
+ {
+ /* Validate the BusType field */
+
+ if ((AmlResource->CommonSerialBus.Type == 0) ||
+ (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
+ {
+ ACPI_RESOURCE_ERROR ((AE_INFO,
+ "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
+ AmlResource->CommonSerialBus.Type));
+ return (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+ }
+
+ /* Optionally return the resource table index */
+
+ if (ReturnIndex)
+ {
+ *ReturnIndex = ResourceIndex;
+ }
+
+ return (AE_OK);
+
+
+InvalidResource:
+
+ ACPI_RESOURCE_ERROR ((AE_INFO,
+ "Invalid/unsupported resource descriptor: Type 0x%2.2X",
+ ResourceType));
+ return (AE_AML_INVALID_RESOURCE_TYPE);
+
+BadResourceLength:
+
+ ACPI_RESOURCE_ERROR ((AE_INFO,
+ "Invalid resource descriptor length: Type "
+ "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
+ ResourceType, ResourceLength, MinimumResourceLength));
+ return (AE_AML_BAD_RESOURCE_LENGTH);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetResourceType
+ *
+ * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
+ *
+ * RETURN: The Resource Type with no extraneous bits (except the
+ * Large/Small descriptor bit -- this is left alone)
+ *
+ * DESCRIPTION: Extract the Resource Type/Name from the first byte of
+ * a resource descriptor.
+ *
+ ******************************************************************************/
+
+UINT8
+AcpiUtGetResourceType (
+ void *Aml)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Byte 0 contains the descriptor name (Resource Type)
+ * Examine the large/small bit in the resource header
+ */
+ if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
+ {
+ /* Large Resource Type -- bits 6:0 contain the name */
+
+ return (ACPI_GET8 (Aml));
+ }
+ else
+ {
+ /* Small Resource Type -- bits 6:3 contain the name */
+
+ return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetResourceLength
+ *
+ * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
+ *
+ * RETURN: Byte Length
+ *
+ * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
+ * definition, this does not include the size of the descriptor
+ * header or the length field itself.
+ *
+ ******************************************************************************/
+
+UINT16
+AcpiUtGetResourceLength (
+ void *Aml)
+{
+ ACPI_RS_LENGTH ResourceLength;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Byte 0 contains the descriptor name (Resource Type)
+ * Examine the large/small bit in the resource header
+ */
+ if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
+ {
+ /* Large Resource type -- bytes 1-2 contain the 16-bit length */
+
+ ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
+
+ }
+ else
+ {
+ /* Small Resource type -- bits 2:0 of byte 0 contain the length */
+
+ ResourceLength = (UINT16) (ACPI_GET8 (Aml) &
+ ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
+ }
+
+ return (ResourceLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetResourceHeaderLength
+ *
+ * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
+ *
+ * RETURN: Length of the AML header (depends on large/small descriptor)
+ *
+ * DESCRIPTION: Get the length of the header for this resource.
+ *
+ ******************************************************************************/
+
+UINT8
+AcpiUtGetResourceHeaderLength (
+ void *Aml)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Examine the large/small bit in the resource header */
+
+ if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
+ {
+ return (sizeof (AML_RESOURCE_LARGE_HEADER));
+ }
+ else
+ {
+ return (sizeof (AML_RESOURCE_SMALL_HEADER));
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetDescriptorLength
+ *
+ * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
+ *
+ * RETURN: Byte length
+ *
+ * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
+ * length of the descriptor header and the length field itself.
+ * Used to walk descriptor lists.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiUtGetDescriptorLength (
+ void *Aml)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Get the Resource Length (does not include header length) and add
+ * the header length (depends on if this is a small or large resource)
+ */
+ return (AcpiUtGetResourceLength (Aml) +
+ AcpiUtGetResourceHeaderLength (Aml));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetResourceEndTag
+ *
+ * PARAMETERS: ObjDesc - The resource template buffer object
+ * EndTag - Where the pointer to the EndTag is returned
+ *
+ * RETURN: Status, pointer to the end tag
+ *
+ * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template
+ * Note: allows a buffer length of zero.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtGetResourceEndTag (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT8 **EndTag)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtGetResourceEndTag);
+
+
+ /* Allow a buffer length of zero */
+
+ if (!ObjDesc->Buffer.Length)
+ {
+ *EndTag = ObjDesc->Buffer.Pointer;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Validate the template and get a pointer to the EndTag */
+
+ Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer,
+ ObjDesc->Buffer.Length, NULL, EndTag);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utstate.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utstate.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,398 @@
+/*******************************************************************************
+ *
+ * Module Name: utstate - state object support procedures
+ *
+ ******************************************************************************/
+
+/*
+ * 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 __UTSTATE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utstate")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreatePkgStateAndPush
+ *
+ * PARAMETERS: Object - Object to be added to the new state
+ * Action - Increment/Decrement
+ * StateList - List the state will be added to
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a new state and push it
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCreatePkgStateAndPush (
+ void *InternalObject,
+ void *ExternalObject,
+ UINT16 Index,
+ ACPI_GENERIC_STATE **StateList)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index);
+ if (!State)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ AcpiUtPushGenericState (StateList, State);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtPushGenericState
+ *
+ * PARAMETERS: ListHead - Head of the state stack
+ * State - State object to push
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Push a state object onto a state stack
+ *
+ ******************************************************************************/
+
+void
+AcpiUtPushGenericState (
+ ACPI_GENERIC_STATE **ListHead,
+ ACPI_GENERIC_STATE *State)
+{
+ ACPI_FUNCTION_TRACE (UtPushGenericState);
+
+
+ /* Push the state object onto the front of the list (stack) */
+
+ State->Common.Next = *ListHead;
+ *ListHead = State;
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtPopGenericState
+ *
+ * PARAMETERS: ListHead - Head of the state stack
+ *
+ * RETURN: The popped state object
+ *
+ * DESCRIPTION: Pop a state object from a state stack
+ *
+ ******************************************************************************/
+
+ACPI_GENERIC_STATE *
+AcpiUtPopGenericState (
+ ACPI_GENERIC_STATE **ListHead)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_TRACE (UtPopGenericState);
+
+
+ /* Remove the state object at the head of the list (stack) */
+
+ State = *ListHead;
+ if (State)
+ {
+ /* Update the list head */
+
+ *ListHead = State->Common.Next;
+ }
+
+ return_PTR (State);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateGenericState
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: The new state object. NULL on failure.
+ *
+ * DESCRIPTION: Create a generic state object. Attempt to obtain one from
+ * the global state cache; If none available, create a new one.
+ *
+ ******************************************************************************/
+
+ACPI_GENERIC_STATE *
+AcpiUtCreateGenericState (
+ void)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ State = AcpiOsAcquireObject (AcpiGbl_StateCache);
+ if (State)
+ {
+ /* Initialize */
+ State->Common.DescriptorType = ACPI_DESC_TYPE_STATE;
+ }
+
+ return (State);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateThreadState
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: New Thread State. NULL on failure
+ *
+ * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
+ * to track per-thread info during method execution
+ *
+ ******************************************************************************/
+
+ACPI_THREAD_STATE *
+AcpiUtCreateThreadState (
+ void)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_TRACE (UtCreateThreadState);
+
+
+ /* Create the generic state object */
+
+ State = AcpiUtCreateGenericState ();
+ if (!State)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Init fields specific to the update struct */
+
+ State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_THREAD;
+ State->Thread.ThreadId = AcpiOsGetThreadId ();
+
+ /* Check for invalid thread ID - zero is very bad, it will break things */
+
+ if (!State->Thread.ThreadId)
+ {
+ ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId"));
+ State->Thread.ThreadId = (ACPI_THREAD_ID) 1;
+ }
+
+ return_PTR ((ACPI_THREAD_STATE *) State);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateUpdateState
+ *
+ * PARAMETERS: Object - Initial Object to be installed in the state
+ * Action - Update action to be performed
+ *
+ * RETURN: New state object, null on failure
+ *
+ * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
+ * to update reference counts and delete complex objects such
+ * as packages.
+ *
+ ******************************************************************************/
+
+ACPI_GENERIC_STATE *
+AcpiUtCreateUpdateState (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT16 Action)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtCreateUpdateState, Object);
+
+
+ /* Create the generic state object */
+
+ State = AcpiUtCreateGenericState ();
+ if (!State)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Init fields specific to the update struct */
+
+ State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_UPDATE;
+ State->Update.Object = Object;
+ State->Update.Value = Action;
+
+ return_PTR (State);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreatePkgState
+ *
+ * PARAMETERS: Object - Initial Object to be installed in the state
+ * Action - Update action to be performed
+ *
+ * RETURN: New state object, null on failure
+ *
+ * DESCRIPTION: Create a "Package State"
+ *
+ ******************************************************************************/
+
+ACPI_GENERIC_STATE *
+AcpiUtCreatePkgState (
+ void *InternalObject,
+ void *ExternalObject,
+ UINT16 Index)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtCreatePkgState, InternalObject);
+
+
+ /* Create the generic state object */
+
+ State = AcpiUtCreateGenericState ();
+ if (!State)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Init fields specific to the update struct */
+
+ State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PACKAGE;
+ State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject;
+ State->Pkg.DestObject = ExternalObject;
+ State->Pkg.Index= Index;
+ State->Pkg.NumPackages = 1;
+
+ return_PTR (State);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateControlState
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: New state object, null on failure
+ *
+ * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
+ * to support nested IF/WHILE constructs in the AML.
+ *
+ ******************************************************************************/
+
+ACPI_GENERIC_STATE *
+AcpiUtCreateControlState (
+ void)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ ACPI_FUNCTION_TRACE (UtCreateControlState);
+
+
+ /* Create the generic state object */
+
+ State = AcpiUtCreateGenericState ();
+ if (!State)
+ {
+ return_PTR (NULL);
+ }
+
+ /* Init fields specific to the control struct */
+
+ State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL;
+ State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING;
+
+ return_PTR (State);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteGenericState
+ *
+ * PARAMETERS: State - The state object to be deleted
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Release a state object to the state cache. NULL state objects
+ * are ignored.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDeleteGenericState (
+ ACPI_GENERIC_STATE *State)
+{
+ ACPI_FUNCTION_TRACE (UtDeleteGenericState);
+
+
+ /* Ignore null state */
+
+ if (State)
+ {
+ (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State);
+ }
+ return_VOID;
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/uttrack.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/uttrack.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,711 @@
+/******************************************************************************
+ *
+ * Module Name: uttrack - Memory allocation tracking routines (debug only)
+ *
+ *****************************************************************************/
+
+/*
+ * 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.
+ */
+
+/*
+ * These procedures are used for tracking memory leaks in the subsystem, and
+ * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
+ *
+ * Each memory allocation is tracked via a doubly linked list. Each
+ * element contains the caller's component, module name, function name, and
+ * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call
+ * AcpiUtTrackAllocation to add an element to the list; deletion
+ * occurs in the body of AcpiUtFree.
+ */
+
+#define __UTTRACK_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("uttrack")
+
+/* Local prototypes */
+
+static ACPI_DEBUG_MEM_BLOCK *
+AcpiUtFindAllocation (
+ void *Allocation);
+
+static ACPI_STATUS
+AcpiUtTrackAllocation (
+ ACPI_DEBUG_MEM_BLOCK *Address,
+ ACPI_SIZE Size,
+ UINT8 AllocType,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line);
+
+static ACPI_STATUS
+AcpiUtRemoveAllocation (
+ ACPI_DEBUG_MEM_BLOCK *Address,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCreateList
+ *
+ * PARAMETERS: CacheName - Ascii name for the cache
+ * ObjectSize - Size of each cached object
+ * ReturnCache - Where the new cache object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create a local memory list for tracking purposed
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtCreateList (
+ char *ListName,
+ UINT16 ObjectSize,
+ ACPI_MEMORY_LIST **ReturnCache)
+{
+ ACPI_MEMORY_LIST *Cache;
+
+
+ Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
+ if (!Cache)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
+
+ Cache->ListName = ListName;
+ Cache->ObjectSize = ObjectSize;
+
+ *ReturnCache = Cache;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocateAndTrack
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: The subsystem's equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAllocateAndTrack (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line)
+{
+ ACPI_DEBUG_MEM_BLOCK *Allocation;
+ ACPI_STATUS Status;
+
+
+ Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
+ Component, Module, Line);
+ if (!Allocation)
+ {
+ return (NULL);
+ }
+
+ Status = AcpiUtTrackAllocation (Allocation, Size,
+ ACPI_MEM_MALLOC, Component, Module, Line);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsFree (Allocation);
+ return (NULL);
+ }
+
+ AcpiGbl_GlobalList->TotalAllocated++;
+ AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
+ AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
+ if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
+ {
+ AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
+ }
+
+ return ((void *) &Allocation->UserSpace);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocateZeroedAndTrack
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAllocateZeroedAndTrack (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line)
+{
+ ACPI_DEBUG_MEM_BLOCK *Allocation;
+ ACPI_STATUS Status;
+
+
+ Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
+ Component, Module, Line);
+ if (!Allocation)
+ {
+ /* Report allocation error */
+
+ ACPI_ERROR ((Module, Line,
+ "Could not allocate size %u", (UINT32) Size));
+ return (NULL);
+ }
+
+ Status = AcpiUtTrackAllocation (Allocation, Size,
+ ACPI_MEM_CALLOC, Component, Module, Line);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsFree (Allocation);
+ return (NULL);
+ }
+
+ AcpiGbl_GlobalList->TotalAllocated++;
+ AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
+ AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
+ if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
+ {
+ AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
+ }
+
+ return ((void *) &Allocation->UserSpace);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtFreeAndTrack
+ *
+ * PARAMETERS: Allocation - Address of the memory to deallocate
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Frees the memory at Allocation
+ *
+ ******************************************************************************/
+
+void
+AcpiUtFreeAndTrack (
+ void *Allocation,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line)
+{
+ ACPI_DEBUG_MEM_BLOCK *DebugBlock;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation);
+
+
+ if (NULL == Allocation)
+ {
+ ACPI_ERROR ((Module, Line,
+ "Attempt to delete a NULL address"));
+
+ return_VOID;
+ }
+
+ DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
+ (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
+
+ AcpiGbl_GlobalList->TotalFreed++;
+ AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size;
+
+ Status = AcpiUtRemoveAllocation (DebugBlock,
+ Component, Module, Line);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory"));
+ }
+
+ AcpiOsFree (DebugBlock);
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtFindAllocation
+ *
+ * PARAMETERS: Allocation - Address of allocated memory
+ *
+ * RETURN: A list element if found; NULL otherwise.
+ *
+ * DESCRIPTION: Searches for an element in the global allocation tracking list.
+ *
+ ******************************************************************************/
+
+static ACPI_DEBUG_MEM_BLOCK *
+AcpiUtFindAllocation (
+ void *Allocation)
+{
+ ACPI_DEBUG_MEM_BLOCK *Element;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Element = AcpiGbl_GlobalList->ListHead;
+
+ /* Search for the address. */
+
+ while (Element)
+ {
+ if (Element == Allocation)
+ {
+ return (Element);
+ }
+
+ Element = Element->Next;
+ }
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTrackAllocation
+ *
+ * PARAMETERS: Allocation - Address of allocated memory
+ * Size - Size of the allocation
+ * AllocType - MEM_MALLOC or MEM_CALLOC
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Inserts an element into the global allocation tracking list.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtTrackAllocation (
+ ACPI_DEBUG_MEM_BLOCK *Allocation,
+ ACPI_SIZE Size,
+ UINT8 AllocType,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line)
+{
+ ACPI_MEMORY_LIST *MemList;
+ ACPI_DEBUG_MEM_BLOCK *Element;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation);
+
+
+ if (AcpiGbl_DisableMemTracking)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ MemList = AcpiGbl_GlobalList;
+ Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Search list for this address to make sure it is not already on the list.
+ * This will catch several kinds of problems.
+ */
+ Element = AcpiUtFindAllocation (Allocation);
+ if (Element)
+ {
+ ACPI_ERROR ((AE_INFO,
+ "UtTrackAllocation: Allocation already present in list! (%p)",
+ Allocation));
+
+ ACPI_ERROR ((AE_INFO, "Element %p Address %p",
+ Element, Allocation));
+
+ goto UnlockAndExit;
+ }
+
+ /* Fill in the instance data. */
+
+ Allocation->Size = (UINT32) Size;
+ Allocation->AllocType = AllocType;
+ Allocation->Component = Component;
+ Allocation->Line = Line;
+
+ ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
+ Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0;
+
+ /* Insert at list head */
+
+ if (MemList->ListHead)
+ {
+ ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
+ }
+
+ Allocation->Next = MemList->ListHead;
+ Allocation->Previous = NULL;
+
+ MemList->ListHead = Allocation;
+
+
+UnlockAndExit:
+ Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtRemoveAllocation
+ *
+ * PARAMETERS: Allocation - Address of allocated memory
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Deletes an element from the global allocation tracking list.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtRemoveAllocation (
+ ACPI_DEBUG_MEM_BLOCK *Allocation,
+ UINT32 Component,
+ const char *Module,
+ UINT32 Line)
+{
+ ACPI_MEMORY_LIST *MemList;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (UtRemoveAllocation);
+
+
+ if (AcpiGbl_DisableMemTracking)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ MemList = AcpiGbl_GlobalList;
+ if (NULL == MemList->ListHead)
+ {
+ /* No allocations! */
+
+ ACPI_ERROR ((Module, Line,
+ "Empty allocation list, nothing to free!"));
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Unlink */
+
+ if (Allocation->Previous)
+ {
+ (Allocation->Previous)->Next = Allocation->Next;
+ }
+ else
+ {
+ MemList->ListHead = Allocation->Next;
+ }
+
+ if (Allocation->Next)
+ {
+ (Allocation->Next)->Previous = Allocation->Previous;
+ }
+
+ /* Mark the segment as deleted */
+
+ ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
+ Allocation->Size));
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDumpAllocationInfo
+ *
+ * PARAMETERS:
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print some info about the outstanding allocations.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDumpAllocationInfo (
+ void)
+{
+/*
+ ACPI_MEMORY_LIST *MemList;
+*/
+
+ ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);
+
+/*
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Current allocations",
+ MemList->CurrentCount,
+ ROUND_UP_TO_1K (MemList->CurrentSize)));
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
+ MemList->MaxConcurrentCount,
+ ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
+
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
+ RunningObjectCount,
+ ROUND_UP_TO_1K (RunningObjectSize)));
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
+ RunningAllocCount,
+ ROUND_UP_TO_1K (RunningAllocSize)));
+
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Current Nodes",
+ AcpiGbl_CurrentNodeCount,
+ ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Max Nodes",
+ AcpiGbl_MaxConcurrentNodeCount,
+ ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount *
+ sizeof (ACPI_NAMESPACE_NODE)))));
+*/
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDumpAllocations
+ *
+ * PARAMETERS: Component - Component(s) to dump info for.
+ * Module - Module to dump info for. NULL means all.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print a list of all outstanding allocations.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDumpAllocations (
+ UINT32 Component,
+ const char *Module)
+{
+ ACPI_DEBUG_MEM_BLOCK *Element;
+ ACPI_DESCRIPTOR *Descriptor;
+ UINT32 NumOutstanding = 0;
+ UINT8 DescriptorType;
+
+
+ ACPI_FUNCTION_TRACE (UtDumpAllocations);
+
+
+ if (AcpiGbl_DisableMemTracking)
+ {
+ return;
+ }
+
+ /*
+ * Walk the allocation list.
+ */
+ if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
+ {
+ return;
+ }
+
+ Element = AcpiGbl_GlobalList->ListHead;
+ while (Element)
+ {
+ if ((Element->Component & Component) &&
+ ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
+ {
+ Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
+
+ if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))
+ {
+ AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u "
+ "[Not a Descriptor - too small]\n",
+ Descriptor, Element->Size, Element->Module,
+ Element->Line);
+ }
+ else
+ {
+ /* Ignore allocated objects that are in a cache */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED)
+ {
+ AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ",
+ Descriptor, Element->Size, Element->Module,
+ Element->Line, AcpiUtGetDescriptorName (Descriptor));
+
+ /* Validate the descriptor type using Type field and length */
+
+ DescriptorType = 0; /* Not a valid descriptor type */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+ if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND))
+ {
+ DescriptorType = ACPI_DESC_TYPE_OPERAND;
+ }
+ break;
+
+ case ACPI_DESC_TYPE_PARSER:
+ if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER))
+ {
+ DescriptorType = ACPI_DESC_TYPE_PARSER;
+ }
+ break;
+
+ case ACPI_DESC_TYPE_NAMED:
+ if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED))
+ {
+ DescriptorType = ACPI_DESC_TYPE_NAMED;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ /* Display additional info for the major descriptor types */
+
+ switch (DescriptorType)
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+ AcpiOsPrintf ("%12.12s RefCount 0x%04X\n",
+ AcpiUtGetTypeName (Descriptor->Object.Common.Type),
+ Descriptor->Object.Common.ReferenceCount);
+ break;
+
+ case ACPI_DESC_TYPE_PARSER:
+ AcpiOsPrintf ("AmlOpcode 0x%04hX\n",
+ Descriptor->Op.Asl.AmlOpcode);
+ break;
+
+ case ACPI_DESC_TYPE_NAMED:
+ AcpiOsPrintf ("%4.4s\n",
+ AcpiUtGetNodeName (&Descriptor->Node));
+ break;
+
+ default:
+ AcpiOsPrintf ( "\n");
+ break;
+ }
+ }
+ }
+
+ NumOutstanding++;
+ }
+
+ Element = Element->Next;
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
+
+ /* Print summary */
+
+ if (!NumOutstanding)
+ {
+ ACPI_INFO ((AE_INFO, "No outstanding allocations"));
+ }
+ else
+ {
+ ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations",
+ NumOutstanding, NumOutstanding));
+ }
+
+ return_VOID;
+}
+
+#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utxface.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utxface.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,837 @@
+/******************************************************************************
+ *
+ * Module Name: utxface - External interfaces for "global" ACPI 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.
+ */
+
+
+#define __UTXFACE_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/acdebug.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utxface")
+
+
+#ifndef ACPI_ASL_COMPILER
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiInitializeSubsystem
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initializes all global variables. This is the first function
+ * called, so any early initialization belongs here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInitializeSubsystem (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
+
+
+ AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
+ ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
+
+ /* Initialize the OS-Dependent layer */
+
+ Status = AcpiOsInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Initialize all globals used by the subsystem */
+
+ Status = AcpiUtInitGlobals ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Create the default mutex objects */
+
+ Status = AcpiUtMutexInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Initialize the namespace manager and
+ * the root of the namespace tree
+ */
+ Status = AcpiNsRootInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Initialize the global OSI interfaces list with the static names */
+
+ Status = AcpiUtInitializeInterfaces ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* If configured, initialize the AML debugger */
+
+ ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ());
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEnableSubsystem
+ *
+ * PARAMETERS: Flags - Init/enable Options
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Completes the subsystem initialization including hardware.
+ * Puts system into ACPI mode if it isn't already.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnableSubsystem (
+ UINT32 Flags)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+
+ /* Enable ACPI mode */
+
+ if (!(Flags & ACPI_NO_ACPI_ENABLE))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
+
+ AcpiGbl_OriginalMode = AcpiHwGetMode();
+
+ Status = AcpiEnable ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Obtain a permanent mapping for the FACS. This is required for the
+ * Global Lock and the Firmware Waking Vector
+ */
+ Status = AcpiTbInitializeFacs ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
+ return_ACPI_STATUS (Status);
+ }
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+ /*
+ * Install the default OpRegion handlers. These are installed unless
+ * other handlers have already been installed via the
+ * InstallAddressSpaceHandler interface.
+ */
+ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Installing default address space handlers\n"));
+
+ Status = AcpiEvInstallRegionHandlers ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+#if (!ACPI_REDUCED_HARDWARE)
+ /*
+ * Initialize ACPI Event handling (Fixed and General Purpose)
+ *
+ * Note1: We must have the hardware and events initialized before we can
+ * execute any control methods safely. Any control method can require
+ * ACPI hardware support, so the hardware must be fully initialized before
+ * any method execution!
+ *
+ * Note2: Fixed events are initialized and enabled here. GPEs are
+ * initialized, but cannot be enabled until after the hardware is
+ * completely initialized (SCI and GlobalLock activated) and the various
+ * initialization control methods are run (_REG, _STA, _INI) on the
+ * entire namespace.
+ */
+ if (!(Flags & ACPI_NO_EVENT_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Initializing ACPI events\n"));
+
+ Status = AcpiEvInitializeEvents ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Install the SCI handler and Global Lock handler. This completes the
+ * hardware initialization.
+ */
+ if (!(Flags & ACPI_NO_HANDLER_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Installing SCI/GL handlers\n"));
+
+ Status = AcpiEvInstallXruptHandlers ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiInitializeObjects
+ *
+ * PARAMETERS: Flags - Init/enable Options
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Completes namespace initialization by initializing device
+ * objects and executing AML code for Regions, buffers, etc.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInitializeObjects (
+ UINT32 Flags)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
+
+
+ /*
+ * Run all _REG methods
+ *
+ * Note: Any objects accessed by the _REG methods will be automatically
+ * initialized, even if they contain executable AML (see the call to
+ * AcpiNsInitializeObjects below).
+ */
+ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Executing _REG OpRegion methods\n"));
+
+ Status = AcpiEvInitializeOpRegions ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Execute any module-level code that was detected during the table load
+ * phase. Although illegal since ACPI 2.0, there are many machines that
+ * contain this type of code. Each block of detected executable AML code
+ * outside of any control method is wrapped with a temporary control
+ * method object and placed on a global list. The methods on this list
+ * are executed below.
+ */
+ AcpiNsExecModuleCodeList ();
+
+ /*
+ * Initialize the objects that remain uninitialized. This runs the
+ * executable AML that may be part of the declaration of these objects:
+ * OperationRegions, BufferFields, Buffers, and Packages.
+ */
+ if (!(Flags & ACPI_NO_OBJECT_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Completing Initialization of ACPI Objects\n"));
+
+ Status = AcpiNsInitializeObjects ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Initialize all device objects in the namespace. This runs the device
+ * _STA and _INI methods.
+ */
+ if (!(Flags & ACPI_NO_DEVICE_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Initializing ACPI Devices\n"));
+
+ Status = AcpiNsInitializeDevices ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Empty the caches (delete the cached objects) on the assumption that
+ * the table load filled them up more than they will be at runtime --
+ * thus wasting non-paged memory.
+ */
+ Status = AcpiPurgeCachedObjects ();
+
+ AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInitializeObjects)
+
+
+#endif
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTerminate
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTerminate (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiTerminate);
+
+
+ /* Just exit if subsystem is already shutdown */
+
+ if (AcpiGbl_Shutdown)
+ {
+ ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated"));
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Subsystem appears active, go ahead and shut it down */
+
+ AcpiGbl_Shutdown = TRUE;
+ AcpiGbl_StartupFlags = 0;
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
+
+ /* Terminate the AML Debugger if present */
+
+ ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE);
+
+ /* Shutdown and free all resources */
+
+ AcpiUtSubsystemShutdown ();
+
+ /* Free the mutex objects */
+
+ AcpiUtMutexTerminate ();
+
+
+#ifdef ACPI_DEBUGGER
+
+ /* Shut down the debugger */
+
+ AcpiDbTerminate ();
+#endif
+
+ /* Now we can shutdown the OS-dependent layer */
+
+ Status = AcpiOsTerminate ();
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiTerminate)
+
+
+#ifndef ACPI_ASL_COMPILER
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSubsystemStatus
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status of the ACPI subsystem
+ *
+ * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
+ * before making any other calls, to ensure the subsystem
+ * initialized successfully.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSubsystemStatus (
+ void)
+{
+
+ if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK)
+ {
+ return (AE_OK);
+ }
+ else
+ {
+ return (AE_ERROR);
+ }
+}
+
+ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetSystemInfo
+ *
+ * PARAMETERS: OutBuffer - A buffer to receive the resources for the
+ * device
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get information about the current
+ * state of the ACPI subsystem. It will return system information
+ * in the OutBuffer.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of OutBuffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetSystemInfo (
+ ACPI_BUFFER *OutBuffer)
+{
+ ACPI_SYSTEM_INFO *InfoPtr;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (AcpiGetSystemInfo);
+
+
+ /* Parameter validation */
+
+ Status = AcpiUtValidateBuffer (OutBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Populate the return buffer
+ */
+ InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
+
+ InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
+
+ /* System flags (ACPI capabilities) */
+
+ InfoPtr->Flags = ACPI_SYS_MODE_ACPI;
+
+ /* Timer resolution - 24 or 32 bits */
+
+ if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
+ {
+ InfoPtr->TimerResolution = 24;
+ }
+ else
+ {
+ InfoPtr->TimerResolution = 32;
+ }
+
+ /* Clear the reserved fields */
+
+ InfoPtr->Reserved1 = 0;
+ InfoPtr->Reserved2 = 0;
+
+ /* Current debug levels */
+
+ InfoPtr->DebugLayer = AcpiDbgLayer;
+ InfoPtr->DebugLevel = AcpiDbgLevel;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetStatistics
+ *
+ * PARAMETERS: Stats - Where the statistics are returned
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: Get the contents of the various system counters
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetStatistics (
+ ACPI_STATISTICS *Stats)
+{
+ ACPI_FUNCTION_TRACE (AcpiGetStatistics);
+
+
+ /* Parameter validation */
+
+ if (!Stats)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Various interrupt-based event counters */
+
+ Stats->SciCount = AcpiSciCount;
+ Stats->GpeCount = AcpiGpeCount;
+
+ ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount,
+ sizeof (AcpiFixedEventCount));
+
+
+ /* Other counters */
+
+ Stats->MethodCount = AcpiMethodCount;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetStatistics)
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiInstallInitializationHandler
+ *
+ * PARAMETERS: Handler - Callback procedure
+ * Function - Not (currently) used, see below
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install an initialization handler
+ *
+ * TBD: When a second function is added, must save the Function also.
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiInstallInitializationHandler (
+ ACPI_INIT_HANDLER Handler,
+ UINT32 Function)
+{
+
+ if (!Handler)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ if (AcpiGbl_InitHandler)
+ {
+ return (AE_ALREADY_EXISTS);
+ }
+
+ AcpiGbl_InitHandler = Handler;
+ return AE_OK;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler)
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiPurgeCachedObjects
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Empty all caches (delete the cached objects)
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiPurgeCachedObjects (
+ void)
+{
+ ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects);
+
+ (void) AcpiOsPurgeCache (AcpiGbl_StateCache);
+ (void) AcpiOsPurgeCache (AcpiGbl_OperandCache);
+ (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache);
+ (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache);
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects)
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiInstallInterface
+ *
+ * PARAMETERS: InterfaceName - The interface to install
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install an _OSI interface to the global list
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiInstallInterface (
+ ACPI_STRING InterfaceName)
+{
+ ACPI_STATUS Status;
+ ACPI_INTERFACE_INFO *InterfaceInfo;
+
+
+ /* Parameter validation */
+
+ if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
+
+ /* Check if the interface name is already in the global list */
+
+ InterfaceInfo = AcpiUtGetInterface (InterfaceName);
+ if (InterfaceInfo)
+ {
+ /*
+ * The interface already exists in the list. This is OK if the
+ * interface has been marked invalid -- just clear the bit.
+ */
+ if (InterfaceInfo->Flags & ACPI_OSI_INVALID)
+ {
+ InterfaceInfo->Flags &= ~ACPI_OSI_INVALID;
+ Status = AE_OK;
+ }
+ else
+ {
+ Status = AE_ALREADY_EXISTS;
+ }
+ }
+ else
+ {
+ /* New interface name, install into the global list */
+
+ Status = AcpiUtInstallInterface (InterfaceName);
+ }
+
+ AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallInterface)
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiRemoveInterface
+ *
+ * PARAMETERS: InterfaceName - The interface to remove
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Remove an _OSI interface from the global list
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiRemoveInterface (
+ ACPI_STRING InterfaceName)
+{
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
+
+ Status = AcpiUtRemoveInterface (InterfaceName);
+
+ AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRemoveInterface)
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiInstallInterfaceHandler
+ *
+ * PARAMETERS: Handler - The _OSI interface handler to install
+ * NULL means "remove existing handler"
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install a handler for the predefined _OSI ACPI method.
+ * invoked during execution of the internal implementation of
+ * _OSI. A NULL handler simply removes any existing handler.
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiInstallInterfaceHandler (
+ ACPI_INTERFACE_HANDLER Handler)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
+
+ if (Handler && AcpiGbl_InterfaceHandler)
+ {
+ Status = AE_ALREADY_EXISTS;
+ }
+ else
+ {
+ AcpiGbl_InterfaceHandler = Handler;
+ }
+
+ AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
+ return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallInterfaceHandler)
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiCheckAddressRange
+ *
+ * PARAMETERS: SpaceId - Address space ID
+ * Address - Start address
+ * Length - Length
+ * Warn - TRUE if warning on overlap desired
+ *
+ * RETURN: Count of the number of conflicts detected.
+ *
+ * DESCRIPTION: Check if the input address range overlaps any of the
+ * ASL operation region address ranges.
+ *
+ ****************************************************************************/
+
+UINT32
+AcpiCheckAddressRange (
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ ACPI_PHYSICAL_ADDRESS Address,
+ ACPI_SIZE Length,
+ BOOLEAN Warn)
+{
+ UINT32 Overlaps;
+ ACPI_STATUS Status;
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (0);
+ }
+
+ Overlaps = AcpiUtCheckAddressRange (SpaceId, Address,
+ (UINT32) Length, Warn);
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Overlaps);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiCheckAddressRange)
+
+#endif /* !ACPI_ASL_COMPILER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utxferror.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utxferror.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,483 @@
+/*******************************************************************************
+ *
+ * Module Name: utxferror - Various error/warning output 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.
+ */
+
+#define __UTXFERROR_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utxferror")
+
+/*
+ * This module is used for the in-kernel ACPICA as well as the ACPICA
+ * tools/applications.
+ *
+ * For the iASL compiler case, the output is redirected to stderr so that
+ * any of the various ACPI errors and warnings do not appear in the output
+ * files, for either the compiler or disassembler portions of the tool.
+ */
+#ifdef ACPI_ASL_COMPILER
+#include <stdio.h>
+
+extern FILE *AcpiGbl_OutputFile;
+
+#define ACPI_MSG_REDIRECT_BEGIN \
+ FILE *OutputFile = AcpiGbl_OutputFile; \
+ AcpiOsRedirectOutput (stderr);
+
+#define ACPI_MSG_REDIRECT_END \
+ AcpiOsRedirectOutput (OutputFile);
+
+#else
+/*
+ * non-iASL case - no redirection, nothing to do
+ */
+#define ACPI_MSG_REDIRECT_BEGIN
+#define ACPI_MSG_REDIRECT_END
+#endif
+
+/*
+ * Common message prefixes
+ */
+#define ACPI_MSG_ERROR "ACPI Error: "
+#define ACPI_MSG_EXCEPTION "ACPI Exception: "
+#define ACPI_MSG_WARNING "ACPI Warning: "
+#define ACPI_MSG_INFO "ACPI: "
+
+/*
+ * Common message suffix
+ */
+#define ACPI_MSG_SUFFIX \
+ AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiError
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * Format - Printf format string + additional args
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print "ACPI Error" message with module/line/version info
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiError (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ const char *Format,
+ ...)
+{
+ va_list ArgList;
+
+
+ ACPI_MSG_REDIRECT_BEGIN;
+ AcpiOsPrintf (ACPI_MSG_ERROR);
+
+ va_start (ArgList, Format);
+ AcpiOsVprintf (Format, ArgList);
+ ACPI_MSG_SUFFIX;
+ va_end (ArgList);
+
+ ACPI_MSG_REDIRECT_END;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiError)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiException
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * Status - Status to be formatted
+ * Format - Printf format string + additional args
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
+ * and decoded ACPI_STATUS.
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiException (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ ACPI_STATUS Status,
+ const char *Format,
+ ...)
+{
+ va_list ArgList;
+
+
+ ACPI_MSG_REDIRECT_BEGIN;
+ AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
+
+ va_start (ArgList, Format);
+ AcpiOsVprintf (Format, ArgList);
+ ACPI_MSG_SUFFIX;
+ va_end (ArgList);
+
+ ACPI_MSG_REDIRECT_END;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiException)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiWarning
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * Format - Printf format string + additional args
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiWarning (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ const char *Format,
+ ...)
+{
+ va_list ArgList;
+
+
+ ACPI_MSG_REDIRECT_BEGIN;
+ AcpiOsPrintf (ACPI_MSG_WARNING);
+
+ va_start (ArgList, Format);
+ AcpiOsVprintf (Format, ArgList);
+ ACPI_MSG_SUFFIX;
+ va_end (ArgList);
+
+ ACPI_MSG_REDIRECT_END;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiWarning)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiInfo
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * Format - Printf format string + additional args
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print generic "ACPI:" information message. There is no
+ * module/line/version info in order to keep the message simple.
+ *
+ * TBD: ModuleName and LineNumber args are not needed, should be removed.
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiInfo (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ const char *Format,
+ ...)
+{
+ va_list ArgList;
+
+#ifdef _KERNEL
+ /* Temporarily hide too verbose printfs. */
+ if (!bootverbose)
+ return;
+#endif
+
+ ACPI_MSG_REDIRECT_BEGIN;
+ AcpiOsPrintf (ACPI_MSG_INFO);
+
+ va_start (ArgList, Format);
+ AcpiOsVprintf (Format, ArgList);
+ AcpiOsPrintf ("\n");
+ va_end (ArgList);
+
+ ACPI_MSG_REDIRECT_END;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInfo)
+
+
+/*
+ * The remainder of this module contains internal error functions that may
+ * be configured out.
+ */
+#if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtPredefinedWarning
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * Pathname - Full pathname to the node
+ * NodeFlags - From Namespace node for the method/object
+ * Format - Printf format string + additional args
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Warnings for the predefined validation module. Messages are
+ * only emitted the first time a problem with a particular
+ * method/object is detected. This prevents a flood of error
+ * messages for methods that are repeatedly evaluated.
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiUtPredefinedWarning (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ char *Pathname,
+ UINT8 NodeFlags,
+ const char *Format,
+ ...)
+{
+ va_list ArgList;
+
+
+ /*
+ * Warning messages for this method/object will be disabled after the
+ * first time a validation fails or an object is successfully repaired.
+ */
+ if (NodeFlags & ANOBJ_EVALUATED)
+ {
+ return;
+ }
+
+ AcpiOsPrintf (ACPI_MSG_WARNING "For %s: ", Pathname);
+
+ va_start (ArgList, Format);
+ AcpiOsVprintf (Format, ArgList);
+ ACPI_MSG_SUFFIX;
+ va_end (ArgList);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtPredefinedInfo
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * Pathname - Full pathname to the node
+ * NodeFlags - From Namespace node for the method/object
+ * Format - Printf format string + additional args
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Info messages for the predefined validation module. Messages
+ * are only emitted the first time a problem with a particular
+ * method/object is detected. This prevents a flood of
+ * messages for methods that are repeatedly evaluated.
+ *
+ ******************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiUtPredefinedInfo (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ char *Pathname,
+ UINT8 NodeFlags,
+ const char *Format,
+ ...)
+{
+ va_list ArgList;
+
+
+ /*
+ * Warning messages for this method/object will be disabled after the
+ * first time a validation fails or an object is successfully repaired.
+ */
+ if (NodeFlags & ANOBJ_EVALUATED)
+ {
+ return;
+ }
+
+ AcpiOsPrintf (ACPI_MSG_INFO "For %s: ", Pathname);
+
+ va_start (ArgList, Format);
+ AcpiOsVprintf (Format, ArgList);
+ ACPI_MSG_SUFFIX;
+ va_end (ArgList);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtNamespaceError
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * InternalName - Name or path of the namespace node
+ * LookupStatus - Exception code from NS lookup
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print error message with the full pathname for the NS node.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtNamespaceError (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ const char *InternalName,
+ ACPI_STATUS LookupStatus)
+{
+ ACPI_STATUS Status;
+ UINT32 BadName;
+ char *Name = NULL;
+
+
+ ACPI_MSG_REDIRECT_BEGIN;
+ AcpiOsPrintf (ACPI_MSG_ERROR);
+
+ if (LookupStatus == AE_BAD_CHARACTER)
+ {
+ /* There is a non-ascii character in the name */
+
+ ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
+ AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName);
+ }
+ else
+ {
+ /* Convert path to external format */
+
+ Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
+ InternalName, NULL, &Name);
+
+ /* Print target name */
+
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiOsPrintf ("[%s]", Name);
+ }
+ else
+ {
+ AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
+ }
+
+ if (Name)
+ {
+ ACPI_FREE (Name);
+ }
+ }
+
+ AcpiOsPrintf (" Namespace lookup failure, %s",
+ AcpiFormatException (LookupStatus));
+
+ ACPI_MSG_SUFFIX;
+ ACPI_MSG_REDIRECT_END;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtMethodError
+ *
+ * PARAMETERS: ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * Message - Error message to use on failure
+ * PrefixNode - Prefix relative to the path
+ * Path - Path to the node (optional)
+ * MethodStatus - Execution status
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print error message with the full pathname for the method.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtMethodError (
+ const char *ModuleName,
+ UINT32 LineNumber,
+ const char *Message,
+ ACPI_NAMESPACE_NODE *PrefixNode,
+ const char *Path,
+ ACPI_STATUS MethodStatus)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node = PrefixNode;
+
+
+ ACPI_MSG_REDIRECT_BEGIN;
+ AcpiOsPrintf (ACPI_MSG_ERROR);
+
+ if (Path)
+ {
+ Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
+ &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("[Could not get node by pathname]");
+ }
+ }
+
+ AcpiNsPrintNodePathname (Node, Message);
+ AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
+
+ ACPI_MSG_SUFFIX;
+ ACPI_MSG_REDIRECT_END;
+}
+
+#endif /* ACPI_NO_ERROR_MESSAGES */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/utilities/utxfmutex.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/utilities/utxfmutex.c Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ *
+ * Module Name: utxfmutex - external AML mutex access 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.
+ */
+
+#define __UTXFMUTEX_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utxfmutex")
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiUtGetMutexObject (
+ ACPI_HANDLE Handle,
+ ACPI_STRING Pathname,
+ ACPI_OPERAND_OBJECT **RetObj);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtGetMutexObject
+ *
+ * PARAMETERS: Handle - Mutex or prefix handle (optional)
+ * Pathname - Mutex pathname (optional)
+ * RetObj - Where the mutex object is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get an AML mutex object. The mutex node is pointed to by
+ * Handle:Pathname. Either Handle or Pathname can be NULL, but
+ * not both.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiUtGetMutexObject (
+ ACPI_HANDLE Handle,
+ ACPI_STRING Pathname,
+ ACPI_OPERAND_OBJECT **RetObj)
+{
+ ACPI_NAMESPACE_NODE *MutexNode;
+ ACPI_OPERAND_OBJECT *MutexObj;
+ ACPI_STATUS Status;
+
+
+ /* Parameter validation */
+
+ if (!RetObj || (!Handle && !Pathname))
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Get a the namespace node for the mutex */
+
+ MutexNode = Handle;
+ if (Pathname != NULL)
+ {
+ Status = AcpiGetHandle (Handle, Pathname,
+ ACPI_CAST_PTR (ACPI_HANDLE, &MutexNode));
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ /* Ensure that we actually have a Mutex object */
+
+ if (!MutexNode ||
+ (MutexNode->Type != ACPI_TYPE_MUTEX))
+ {
+ return (AE_TYPE);
+ }
+
+ /* Get the low-level mutex object */
+
+ MutexObj = AcpiNsGetAttachedObject (MutexNode);
+ if (!MutexObj)
+ {
+ return (AE_NULL_OBJECT);
+ }
+
+ *RetObj = MutexObj;
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAcquireMutex
+ *
+ * PARAMETERS: Handle - Mutex or prefix handle (optional)
+ * Pathname - Mutex pathname (optional)
+ * Timeout - Max time to wait for the lock (millisec)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Acquire an AML mutex. This is a device driver interface to
+ * AML mutex objects, and allows for transaction locking between
+ * drivers and AML code. The mutex node is pointed to by
+ * Handle:Pathname. Either Handle or Pathname can be NULL, but
+ * not both.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAcquireMutex (
+ ACPI_HANDLE Handle,
+ ACPI_STRING Pathname,
+ UINT16 Timeout)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *MutexObj;
+
+
+ /* Get the low-level mutex associated with Handle:Pathname */
+
+ Status = AcpiUtGetMutexObject (Handle, Pathname, &MutexObj);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Acquire the OS mutex */
+
+ Status = AcpiOsAcquireMutex (MutexObj->Mutex.OsMutex, Timeout);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiReleaseMutex
+ *
+ * PARAMETERS: Handle - Mutex or prefix handle (optional)
+ * Pathname - Mutex pathname (optional)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Release an AML mutex. This is a device driver interface to
+ * AML mutex objects, and allows for transaction locking between
+ * drivers and AML code. The mutex node is pointed to by
+ * Handle:Pathname. Either Handle or Pathname can be NULL, but
+ * not both.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiReleaseMutex (
+ ACPI_HANDLE Handle,
+ ACPI_STRING Pathname)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *MutexObj;
+
+
+ /* Get the low-level mutex associated with Handle:Pathname */
+
+ Status = AcpiUtGetMutexObject (Handle, Pathname, &MutexObj);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Release the OS mutex */
+
+ AcpiOsReleaseMutex (MutexObj->Mutex.OsMutex);
+ return (AE_OK);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/debugger/dbcmds.c
--- a/head/sys/contrib/dev/acpica/debugger/dbcmds.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1061 +0,0 @@
-/*******************************************************************************
- *
- * 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;
-
-
- SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
-
- AcpiOsPrintf ("**** Prepare to sleep ****\n");
- Status = AcpiEnterSleepStatePrep (SleepState);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- AcpiOsPrintf ("**** Going to sleep ****\n");
- Status = AcpiEnterSleepState (SleepState);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- AcpiOsPrintf ("**** returning from sleep ****\n");
- Status = AcpiLeaveSleepState (SleepState);
-
- 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);
-}
-
-
-/*******************************************************************************
- *
- * 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_DEBUGGER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/debugger/dbdisply.c
--- a/head/sys/contrib/dev/acpica/debugger/dbdisply.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1051 +0,0 @@
-/*******************************************************************************
- *
- * 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);
-}
-
-
-/*******************************************************************************
- *
- * 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;
- }
-}
-
-
-/*******************************************************************************
- *
- * 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;
- }
- }
-
- /* 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");
- }
- }
-
- /* 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/debugger/dbexec.c
--- a/head/sys/contrib/dev/acpica/debugger/dbexec.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1105 +0,0 @@
-/*******************************************************************************
- *
- * 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/debugger/dbfileio.c
--- a/head/sys/contrib/dev/acpica/debugger/dbfileio.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,578 +0,0 @@
-/*******************************************************************************
- *
- * 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/debugger/dbhistry.c
--- a/head/sys/contrib/dev/acpica/debugger/dbhistry.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/******************************************************************************
- *
- * 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/debugger/dbinput.c
--- a/head/sys/contrib/dev/acpica/debugger/dbinput.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1088 +0,0 @@
-/*******************************************************************************
- *
- * 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:
- Status = AcpiEnable();
- if (ACPI_FAILURE(Status))
- {
- AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
- return (Status);
- }
- break;
-
- case CMD_EVENT:
- AcpiOsPrintf ("Event command not implemented\n");
- break;
-
- case CMD_EXECUTE:
- AcpiDbExecute (AcpiGbl_DbArgs[1],
- &AcpiGbl_DbArgs[2], &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/debugger/dbmethod.c
--- a/head/sys/contrib/dev/acpica/debugger/dbmethod.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,529 +0,0 @@
-/*******************************************************************************
- *
- * 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/debugger/dbnames.c
--- a/head/sys/contrib/dev/acpica/debugger/dbnames.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,934 +0,0 @@
-/*******************************************************************************
- *
- * 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/debugger/dbstats.c
--- a/head/sys/contrib/dev/acpica/debugger/dbstats.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,549 +0,0 @@
-/*******************************************************************************
- *
- * 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/debugger/dbutils.c
--- a/head/sys/contrib/dev/acpica/debugger/dbutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,526 +0,0 @@
-/*******************************************************************************
- *
- * 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/debugger/dbxface.c
--- a/head/sys/contrib/dev/acpica/debugger/dbxface.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,542 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmbuffer.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmbuffer.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,542 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmnames.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmnames.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,453 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmobject.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmobject.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,589 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmopcode.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmopcode.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,607 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmresrc.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmresrc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,434 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmresrcl.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmresrcl.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1052 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmresrcl2.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmresrcl2.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,700 +0,0 @@
-/*******************************************************************************
- *
- * 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)]);
-
- /* 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)]);
-
- /* 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)]);
-
- /* 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/disassembler/dmresrcs.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmresrcs.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,358 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmutils.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,321 +0,0 @@
-/*******************************************************************************
- *
- * 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/disassembler/dmwalk.c
--- a/head/sys/contrib/dev/acpica/disassembler/dmwalk.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,935 +0,0 @@
-/*******************************************************************************
- *
- * 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/dispatcher/dsargs.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsargs.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,438 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dscontrol.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dscontrol.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,424 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dsfield.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsfield.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,748 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dsinit.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsinit.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dsmethod.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsmethod.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,726 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dsmthdat.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsmthdat.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,772 +0,0 @@
-/*******************************************************************************
- *
- * 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/dispatcher/dsobject.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsobject.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,867 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dsopcode.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsopcode.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,809 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dsutils.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dsutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,937 +0,0 @@
-/*******************************************************************************
- *
- * 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/dispatcher/dswexec.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dswexec.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,797 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dswload.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dswload.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,551 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dswload2.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dswload2.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,747 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dswscope.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dswscope.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-/******************************************************************************
- *
- * 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/dispatcher/dswstate.c
--- a/head/sys/contrib/dev/acpica/dispatcher/dswstate.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,846 +0,0 @@
-/******************************************************************************
- *
- * 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/events/evevent.c
--- a/head/sys/contrib/dev/acpica/events/evevent.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,332 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-/* 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));
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evglock.c
--- a/head/sys/contrib/dev/acpica/events/evglock.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,374 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-
-/* 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);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evgpe.c
--- a/head/sys/contrib/dev/acpica/events/evgpe.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,828 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-/* 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);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evgpeblk.c
--- a/head/sys/contrib/dev/acpica/events/evgpeblk.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,547 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-/* 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);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evgpeinit.c
--- a/head/sys/contrib/dev/acpica/events/evgpeinit.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,459 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-
-/*
- * 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);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evgpeutil.c
--- a/head/sys/contrib/dev/acpica/events/evgpeutil.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,424 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-
-/*******************************************************************************
- *
- * 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);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evmisc.c
--- a/head/sys/contrib/dev/acpica/events/evmisc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,372 +0,0 @@
-/******************************************************************************
- *
- * 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 3 (Ejection Request), some device method may need to be run.
- * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need
- * to be run.
- * For value 0x80 (Status Change) on the power button or sleep button,
- * initiate soft-off or sleep operation?
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n",
- AcpiUtGetNodeName (Node), Node, NotifyValue,
- AcpiUtGetNotifyName (NotifyValue)));
-
- /* Get the notify object attached to the NS Node */
-
- ObjDesc = AcpiNsGetAttachedObject (Node);
- if (ObjDesc)
- {
- /* We have the notify object, Get the right handler */
-
- switch (Node->Type)
- {
- /* Notify 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 any 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);
-}
-
-
-/******************************************************************************
- *
- * 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;
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evregion.c
--- a/head/sys/contrib/dev/acpica/events/evregion.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1366 +0,0 @@
-/******************************************************************************
- *
- * 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/events/evrgnini.c
--- a/head/sys/contrib/dev/acpica/events/evrgnini.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,732 +0,0 @@
-/******************************************************************************
- *
- * 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/events/evsci.c
--- a/head/sys/contrib/dev/acpica/events/evsci.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/*******************************************************************************
- *
- * 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")
-
-/* 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);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evxface.c
--- a/head/sys/contrib/dev/acpica/events/evxface.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,977 +0,0 @@
-/******************************************************************************
- *
- * 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: 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)
-
-
-/*******************************************************************************
- *
- * 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: 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: 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)
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evxfevnt.c
--- a/head/sys/contrib/dev/acpica/events/evxfevnt.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,380 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-
-/*******************************************************************************
- *
- * 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)
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evxfgpe.c
--- a/head/sys/contrib/dev/acpica/events/evxfgpe.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,900 +0,0 @@
-/******************************************************************************
- *
- * 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")
-
-
-/*******************************************************************************
- *
- * 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)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/events/evxfregn.c
--- a/head/sys/contrib/dev/acpica/events/evxfregn.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-/******************************************************************************
- *
- * 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/executer/exconfig.c
--- a/head/sys/contrib/dev/acpica/executer/exconfig.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,688 +0,0 @@
-/******************************************************************************
- *
- * 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/executer/exconvrt.c
--- a/head/sys/contrib/dev/acpica/executer/exconvrt.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,754 +0,0 @@
-/******************************************************************************
- *
- * 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 */
- break;
- }
-
- /* Create a new integer */
-
- ReturnDesc = AcpiUtCreateIntegerObject (Result);
- if (!ReturnDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (Result)));
-
- /* Save the Result */
-
- AcpiExTruncateFor32bitTable (ReturnDesc);
- *ResultDesc = ReturnDesc;
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExConvertToBuffer
- *
- * PARAMETERS: ObjDesc - Object to be converted. Must be an
- * Integer, Buffer, or String
- * ResultDesc - Where the new buffer object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert an ACPI Object to a Buffer
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExConvertToBuffer (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_OPERAND_OBJECT **ResultDesc)
-{
- ACPI_OPERAND_OBJECT *ReturnDesc;
- UINT8 *NewBuf;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);
-
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_BUFFER:
-
- /* No conversion necessary */
-
- *ResultDesc = ObjDesc;
- return_ACPI_STATUS (AE_OK);
-
-
- case ACPI_TYPE_INTEGER:
-
- /*
- * Create a new Buffer object.
- * Need enough space for one integer
- */
- ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
- if (!ReturnDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Copy the integer to the buffer, LSB first */
-
- NewBuf = ReturnDesc->Buffer.Pointer;
- ACPI_MEMCPY (NewBuf,
- &ObjDesc->Integer.Value,
- AcpiGbl_IntegerByteWidth);
- break;
-
-
- case ACPI_TYPE_STRING:
-
- /*
- * Create a new Buffer object
- * Size will be the string length
- *
- * NOTE: Add one to the string length to include the null terminator.
- * The ACPI spec is unclear on this subject, but there is existing
- * ASL/AML code that depends on the null being transferred to the new
- * buffer.
- */
- ReturnDesc = AcpiUtCreateBufferObject (
- (ACPI_SIZE) ObjDesc->String.Length + 1);
- if (!ReturnDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Copy the string to the buffer */
-
- NewBuf = ReturnDesc->Buffer.Pointer;
- ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
- ObjDesc->String.Length);
- break;
-
-
- default:
- return_ACPI_STATUS (AE_TYPE);
- }
-
- /* Mark buffer initialized */
-
- ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
- *ResultDesc = ReturnDesc;
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExConvertToAscii
- *
- * PARAMETERS: Integer - Value to be converted
- * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
- * String - Where the string is returned
- * DataWidth - Size of data item to be converted, in bytes
- *
- * RETURN: Actual string length
- *
- * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
- *
- ******************************************************************************/
-
-static UINT32
-AcpiExConvertToAscii (
- UINT64 Integer,
- UINT16 Base,
- UINT8 *String,
- UINT8 DataWidth)
-{
- UINT64 Digit;
- UINT32 i;
- UINT32 j;
- UINT32 k = 0;
- UINT32 HexLength;
- UINT32 DecimalLength;
- UINT32 Remainder;
- BOOLEAN SupressZeros;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- switch (Base)
- {
- case 10:
-
- /* Setup max length for the decimal number */
-
- switch (DataWidth)
- {
- case 1:
- DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
- break;
-
- case 4:
- DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
- break;
-
- case 8:
- default:
- DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
- break;
- }
-
- SupressZeros = TRUE; /* No leading zeros */
- Remainder = 0;
-
- for (i = DecimalLength; i > 0; i--)
- {
- /* Divide by nth factor of 10 */
-
- Digit = Integer;
- for (j = 0; j < i; j++)
- {
- (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
- }
-
- /* Handle leading zeros */
-
- if (Remainder != 0)
- {
- SupressZeros = FALSE;
- }
-
- if (!SupressZeros)
- {
- String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
- k++;
- }
- }
- break;
-
- case 16:
-
- /* HexLength: 2 ascii hex chars per data byte */
-
- HexLength = ACPI_MUL_2 (DataWidth);
- for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
- {
- /* Get one hex digit, most significant digits first */
-
- String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
- k++;
- }
- break;
-
- default:
- return (0);
- }
-
- /*
- * Since leading zeros are suppressed, we must check for the case where
- * the integer equals 0
- *
- * Finally, null terminate the string and return the length
- */
- if (!k)
- {
- String [0] = ACPI_ASCII_ZERO;
- k = 1;
- }
-
- String [k] = 0;
- return ((UINT32) k);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExConvertToString
- *
- * PARAMETERS: ObjDesc - Object to be converted. Must be an
- * Integer, Buffer, or String
- * ResultDesc - Where the string object is returned
- * Type - String flags (base and conversion type)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert an ACPI Object to a string
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExConvertToString (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_OPERAND_OBJECT **ResultDesc,
- UINT32 Type)
-{
- ACPI_OPERAND_OBJECT *ReturnDesc;
- UINT8 *NewBuf;
- UINT32 i;
- UINT32 StringLength = 0;
- UINT16 Base = 16;
- UINT8 Separator = ',';
-
-
- ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);
-
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_STRING:
-
- /* No conversion necessary */
-
- *ResultDesc = ObjDesc;
- return_ACPI_STATUS (AE_OK);
-
-
- case ACPI_TYPE_INTEGER:
-
- switch (Type)
- {
- case ACPI_EXPLICIT_CONVERT_DECIMAL:
-
- /* Make room for maximum decimal number */
-
- StringLength = ACPI_MAX_DECIMAL_DIGITS;
- Base = 10;
- break;
-
- default:
-
- /* Two hex string characters for each integer byte */
-
- StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
- break;
- }
-
- /*
- * Create a new String
- * Need enough space for one ASCII integer (plus null terminator)
- */
- ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
- if (!ReturnDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- NewBuf = ReturnDesc->Buffer.Pointer;
-
- /* Convert integer to string */
-
- StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base,
- NewBuf, AcpiGbl_IntegerByteWidth);
-
- /* Null terminate at the correct place */
-
- ReturnDesc->String.Length = StringLength;
- NewBuf [StringLength] = 0;
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- /* Setup string length, base, and separator */
-
- switch (Type)
- {
- case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
- /*
- * From ACPI: "If Data is a buffer, it is converted to a string of
- * decimal values separated by commas."
- */
- Base = 10;
-
- /*
- * Calculate the final string length. Individual string values
- * are variable length (include separator for each)
- */
- for (i = 0; i < ObjDesc->Buffer.Length; i++)
- {
- if (ObjDesc->Buffer.Pointer[i] >= 100)
- {
- StringLength += 4;
- }
- else if (ObjDesc->Buffer.Pointer[i] >= 10)
- {
- StringLength += 3;
- }
- else
- {
- StringLength += 2;
- }
- }
- break;
-
- case ACPI_IMPLICIT_CONVERT_HEX:
- /*
- * From the ACPI spec:
- *"The entire contents of the buffer are converted to a string of
- * two-character hexadecimal numbers, each separated by a space."
- */
- Separator = ' ';
- StringLength = (ObjDesc->Buffer.Length * 3);
- break;
-
- case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */
- /*
- * From ACPI: "If Data is a buffer, it is converted to a string of
- * hexadecimal values separated by commas."
- */
- StringLength = (ObjDesc->Buffer.Length * 3);
- break;
-
- default:
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /*
- * Create a new string object and string buffer
- * (-1 because of extra separator included in StringLength from above)
- * Allow creation of zero-length strings from zero-length buffers.
- */
- if (StringLength)
- {
- StringLength--;
- }
-
- ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
- if (!ReturnDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- NewBuf = ReturnDesc->Buffer.Pointer;
-
- /*
- * Convert buffer bytes to hex or decimal values
- * (separated by commas or spaces)
- */
- for (i = 0; i < ObjDesc->Buffer.Length; i++)
- {
- NewBuf += AcpiExConvertToAscii (
- (UINT64) ObjDesc->Buffer.Pointer[i], Base,
- NewBuf, 1);
- *NewBuf++ = Separator; /* each separated by a comma or space */
- }
-
- /*
- * Null terminate the string
- * (overwrites final comma/space from above)
- */
- if (ObjDesc->Buffer.Length)
- {
- NewBuf--;
- }
- *NewBuf = 0;
- break;
-
- default:
- return_ACPI_STATUS (AE_TYPE);
- }
-
- *ResultDesc = ReturnDesc;
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExConvertToTargetType
- *
- * PARAMETERS: DestinationType - Current type of the destination
- * SourceDesc - Source object to be converted.
- * ResultDesc - Where the converted object is returned
- * WalkState - Current method state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExConvertToTargetType (
- ACPI_OBJECT_TYPE DestinationType,
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT **ResultDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExConvertToTargetType);
-
-
- /* Default behavior */
-
- *ResultDesc = SourceDesc;
-
- /*
- * If required by the target,
- * perform implicit conversion on the source before we store it.
- */
- switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
- {
- case ARGI_SIMPLE_TARGET:
- case ARGI_FIXED_TARGET:
- case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */
-
- switch (DestinationType)
- {
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- /*
- * Named field can always handle conversions
- */
- break;
-
- default:
- /* No conversion allowed for these types */
-
- if (DestinationType != SourceDesc->Common.Type)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Explicit operator, will store (%s) over existing type (%s)\n",
- AcpiUtGetObjectTypeName (SourceDesc),
- AcpiUtGetTypeName (DestinationType)));
- Status = AE_TYPE;
- }
- }
- break;
-
-
- case ARGI_TARGETREF:
-
- switch (DestinationType)
- {
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
- /*
- * These types require an Integer operand. We can convert
- * a Buffer or a String to an Integer if necessary.
- */
- Status = AcpiExConvertToInteger (SourceDesc, ResultDesc,
- 16);
- break;
-
-
- case ACPI_TYPE_STRING:
- /*
- * The operand must be a String. We can convert an
- * Integer or Buffer if necessary
- */
- Status = AcpiExConvertToString (SourceDesc, ResultDesc,
- ACPI_IMPLICIT_CONVERT_HEX);
- break;
-
-
- case ACPI_TYPE_BUFFER:
- /*
- * The operand must be a Buffer. We can convert an
- * Integer or String if necessary
- */
- Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
- break;
-
-
- default:
- ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: 0x%X",
- DestinationType));
- Status = AE_AML_INTERNAL;
- break;
- }
- break;
-
-
- case ARGI_REFERENCE:
- /*
- * CreateXxxxField cases - we are storing the field object into the name
- */
- break;
-
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
- GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
- WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
- Status = AE_AML_INTERNAL;
- }
-
- /*
- * Source-to-Target conversion semantics:
- *
- * If conversion to the target type cannot be performed, then simply
- * overwrite the target with the new object and type.
- */
- if (Status == AE_TYPE)
- {
- Status = AE_OK;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/excreate.c
--- a/head/sys/contrib/dev/acpica/executer/excreate.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,574 +0,0 @@
-/******************************************************************************
- *
- * Module Name: excreate - Named object creation
- *
- *****************************************************************************/
-
-/*
- * 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 __EXCREATE_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>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("excreate")
-
-
-#ifndef ACPI_NO_METHOD_EXECUTION
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCreateAlias
- *
- * PARAMETERS: WalkState - Current state, contains operands
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new named alias
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCreateAlias (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_NAMESPACE_NODE *TargetNode;
- ACPI_NAMESPACE_NODE *AliasNode;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExCreateAlias);
-
-
- /* Get the source/alias operands (both namespace nodes) */
-
- AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
- TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
-
- if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
- (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
- {
- /*
- * Dereference an existing alias so that we don't create a chain
- * of aliases. With this code, we guarantee that an alias is
- * always exactly one level of indirection away from the
- * actual aliased name.
- */
- TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
- }
-
- /*
- * For objects that can never change (i.e., the NS node will
- * permanently point to the same object), we can simply attach
- * the object to the new NS node. For other objects (such as
- * Integers, buffers, etc.), we have to point the Alias node
- * to the original Node.
- */
- switch (TargetNode->Type)
- {
-
- /* For these types, the sub-object can change dynamically via a Store */
-
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_PACKAGE:
- case ACPI_TYPE_BUFFER_FIELD:
-
- /*
- * These types open a new scope, so we need the NS node in order to access
- * any children.
- */
- case ACPI_TYPE_DEVICE:
- case ACPI_TYPE_POWER:
- case ACPI_TYPE_PROCESSOR:
- case ACPI_TYPE_THERMAL:
- case ACPI_TYPE_LOCAL_SCOPE:
-
- /*
- * The new alias has the type ALIAS and points to the original
- * NS node, not the object itself.
- */
- AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
- AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
- break;
-
- case ACPI_TYPE_METHOD:
-
- /*
- * Control method aliases need to be differentiated
- */
- AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
- AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
- break;
-
- default:
-
- /* Attach the original source object to the new Alias Node */
-
- /*
- * The new alias assumes the type of the target, and it points
- * to the same object. The reference count of the object has an
- * additional reference to prevent deletion out from under either the
- * target node or the alias Node
- */
- Status = AcpiNsAttachObject (AliasNode,
- AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
- break;
- }
-
- /* Since both operands are Nodes, we don't need to delete them */
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCreateEvent
- *
- * PARAMETERS: WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new event object
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCreateEvent (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_TRACE (ExCreateEvent);
-
-
- ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
- if (!ObjDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /*
- * Create the actual OS semaphore, with zero initial units -- meaning
- * that the event is created in an unsignalled state
- */
- Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
- &ObjDesc->Event.OsSemaphore);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /* Attach object to the Node */
-
- Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
- ObjDesc, ACPI_TYPE_EVENT);
-
-Cleanup:
- /*
- * Remove local reference to the object (on error, will cause deletion
- * of both object and semaphore if present.)
- */
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCreateMutex
- *
- * PARAMETERS: WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new mutex object
- *
- * Mutex (Name[0], SyncLevel[1])
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCreateMutex (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
-
-
- /* Create the new mutex object */
-
- ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
- if (!ObjDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Create the actual OS Mutex */
-
- Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /* Init object and attach to NS node */
-
- ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
- ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
-
- Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
-
-
-Cleanup:
- /*
- * Remove local reference to the object (on error, will cause deletion
- * of both object and semaphore if present.)
- */
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCreateRegion
- *
- * PARAMETERS: AmlStart - Pointer to the region declaration AML
- * AmlLength - Max length of the declaration AML
- * SpaceId - Address space ID for the region
- * WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new operation region object
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCreateRegion (
- UINT8 *AmlStart,
- UINT32 AmlLength,
- UINT8 SpaceId,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_OPERAND_OBJECT *RegionObj2;
-
-
- ACPI_FUNCTION_TRACE (ExCreateRegion);
-
-
- /* Get the Namespace Node */
-
- Node = WalkState->Op->Common.Node;
-
- /*
- * If the region object is already attached to this node,
- * just return
- */
- if (AcpiNsGetAttachedObject (Node))
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Space ID must be one of the predefined IDs, or in the user-defined
- * range
- */
- if (!AcpiIsValidSpaceId (SpaceId))
- {
- /*
- * Print an error message, but continue. We don't want to abort
- * a table load for this exception. Instead, if the region is
- * actually used at runtime, abort the executing method.
- */
- ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
- AcpiUtGetRegionName (SpaceId), SpaceId));
-
- /* Create the region descriptor */
-
- ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
- if (!ObjDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /*
- * Remember location in AML stream of address & length
- * operands since they need to be evaluated at run time.
- */
- RegionObj2 = ObjDesc->Common.NextObject;
- RegionObj2->Extra.AmlStart = AmlStart;
- RegionObj2->Extra.AmlLength = AmlLength;
- if (WalkState->ScopeInfo)
- {
- RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
- }
- else
- {
- RegionObj2->Extra.ScopeNode = Node;
- }
-
- /* Init the region from the operands */
-
- ObjDesc->Region.SpaceId = SpaceId;
- ObjDesc->Region.Address = 0;
- ObjDesc->Region.Length = 0;
- ObjDesc->Region.Node = Node;
-
- /* Install the new region object in the parent Node */
-
- Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
-
-
-Cleanup:
-
- /* Remove local reference to the object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCreateProcessor
- *
- * PARAMETERS: WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new processor object and populate the fields
- *
- * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCreateProcessor (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
-
-
- /* Create the processor object */
-
- ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
- if (!ObjDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Initialize the processor object from the operands */
-
- ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
- ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
- ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
-
- /* Install the processor object in the parent Node */
-
- Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
- ObjDesc, ACPI_TYPE_PROCESSOR);
-
- /* Remove local reference to the object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCreatePowerResource
- *
- * PARAMETERS: WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new PowerResource object and populate the fields
- *
- * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCreatePowerResource (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
-
-
- /* Create the power resource object */
-
- ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
- if (!ObjDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Initialize the power object from the operands */
-
- ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
- ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
-
- /* Install the power resource object in the parent Node */
-
- Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
- ObjDesc, ACPI_TYPE_POWER);
-
- /* Remove local reference to the object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCreateMethod
- *
- * PARAMETERS: AmlStart - First byte of the method's AML
- * AmlLength - AML byte count for this method
- * WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new method object
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCreateMethod (
- UINT8 *AmlStart,
- UINT32 AmlLength,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
- UINT8 MethodFlags;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
-
-
- /* Create a new method object */
-
- ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
- if (!ObjDesc)
- {
- Status = AE_NO_MEMORY;
- goto Exit;
- }
-
- /* Save the method's AML pointer and length */
-
- ObjDesc->Method.AmlStart = AmlStart;
- ObjDesc->Method.AmlLength = AmlLength;
-
- /*
- * Disassemble the method flags. Split off the ArgCount, Serialized
- * flag, and SyncLevel for efficiency.
- */
- MethodFlags = (UINT8) Operand[1]->Integer.Value;
- ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
-
- /*
- * Get the SyncLevel. If method is serialized, a mutex will be
- * created for this method when it is parsed.
- */
- if (MethodFlags & AML_METHOD_SERIALIZED)
- {
- ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
-
- /*
- * ACPI 1.0: SyncLevel = 0
- * ACPI 2.0: SyncLevel = SyncLevel in method declaration
- */
- ObjDesc->Method.SyncLevel = (UINT8)
- ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
- }
-
- /* Attach the new object to the method Node */
-
- Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
- ObjDesc, ACPI_TYPE_METHOD);
-
- /* Remove local reference to the object */
-
- AcpiUtRemoveReference (ObjDesc);
-
-Exit:
- /* Remove a reference to the operand */
-
- AcpiUtRemoveReference (Operand[1]);
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exdebug.c
--- a/head/sys/contrib/dev/acpica/executer/exdebug.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,278 +0,0 @@
-/******************************************************************************
- *
- * Module Name: exdebug - Support for stores to the AML Debug Object
- *
- *****************************************************************************/
-
-/*
- * 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 __EXDEBUG_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exdebug")
-
-
-#ifndef ACPI_NO_ERROR_MESSAGES
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDoDebugObject
- *
- * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
- * Level - Indentation level (used for packages)
- * Index - Current package element, zero if not pkg
- *
- * RETURN: None
- *
- * DESCRIPTION: Handles stores to the AML Debug Object. For example:
- * Store(INT1, Debug)
- *
- * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
- *
- * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or
- * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
- * operational case, stores to the debug object are ignored but can be easily
- * enabled if necessary.
- *
- ******************************************************************************/
-
-void
-AcpiExDoDebugObject (
- ACPI_OPERAND_OBJECT *SourceDesc,
- UINT32 Level,
- UINT32 Index)
-{
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
-
-
- /* Output must be enabled via the DebugObject global or the DbgLevel */
-
- if (!AcpiGbl_EnableAmlDebugObject &&
- !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
- {
- return_VOID;
- }
-
- /*
- * Print line header as long as we are not in the middle of an
- * object display
- */
- if (!((Level > 0) && Index == 0))
- {
- AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
- }
-
- /* Display the index for package output only */
-
- if (Index > 0)
- {
- AcpiOsPrintf ("(%.2u) ", Index-1);
- }
-
- if (!SourceDesc)
- {
- AcpiOsPrintf ("[Null Object]\n");
- return_VOID;
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
- {
- AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
-
- if (!AcpiUtValidInternalObject (SourceDesc))
- {
- AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
- return_VOID;
- }
- }
- else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
- {
- AcpiOsPrintf ("%s: %p\n",
- AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
- SourceDesc);
- return_VOID;
- }
- else
- {
- return_VOID;
- }
-
- /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
-
- switch (SourceDesc->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
-
- /* Output correct integer width */
-
- if (AcpiGbl_IntegerByteWidth == 4)
- {
- AcpiOsPrintf ("0x%8.8X\n",
- (UINT32) SourceDesc->Integer.Value);
- }
- else
- {
- AcpiOsPrintf ("0x%8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
- }
- break;
-
- case ACPI_TYPE_BUFFER:
-
- AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
- AcpiUtDumpBuffer2 (SourceDesc->Buffer.Pointer,
- (SourceDesc->Buffer.Length < 256) ?
- SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY);
- break;
-
- case ACPI_TYPE_STRING:
-
- AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
- SourceDesc->String.Length, SourceDesc->String.Pointer);
- break;
-
- case ACPI_TYPE_PACKAGE:
-
- AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
- SourceDesc->Package.Count);
-
- /* Output the entire contents of the package */
-
- for (i = 0; i < SourceDesc->Package.Count; i++)
- {
- AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
- Level+4, i+1);
- }
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
-
- /* Decode the reference */
-
- switch (SourceDesc->Reference.Class)
- {
- case ACPI_REFCLASS_INDEX:
-
- AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
- break;
-
- case ACPI_REFCLASS_TABLE:
-
- /* Case for DdbHandle */
-
- AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
- return;
-
- default:
- break;
- }
-
- AcpiOsPrintf (" ");
-
- /* Check for valid node first, then valid object */
-
- if (SourceDesc->Reference.Node)
- {
- if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
- ACPI_DESC_TYPE_NAMED)
- {
- AcpiOsPrintf (" %p - Not a valid namespace node\n",
- SourceDesc->Reference.Node);
- }
- else
- {
- AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
- (SourceDesc->Reference.Node)->Name.Ascii);
-
- switch ((SourceDesc->Reference.Node)->Type)
- {
- /* These types have no attached object */
-
- case ACPI_TYPE_DEVICE:
- AcpiOsPrintf ("Device\n");
- break;
-
- case ACPI_TYPE_THERMAL:
- AcpiOsPrintf ("Thermal Zone\n");
- break;
-
- default:
- AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
- Level+4, 0);
- break;
- }
- }
- }
- else if (SourceDesc->Reference.Object)
- {
- if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
- ACPI_DESC_TYPE_NAMED)
- {
- AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
- SourceDesc->Reference.Object)->Object,
- Level+4, 0);
- }
- else
- {
- AcpiExDoDebugObject (SourceDesc->Reference.Object,
- Level+4, 0);
- }
- }
- break;
-
- default:
-
- AcpiOsPrintf ("%p\n", SourceDesc);
- break;
- }
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
- return_VOID;
-}
-#endif
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exdump.c
--- a/head/sys/contrib/dev/acpica/executer/exdump.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1124 +0,0 @@
-/******************************************************************************
- *
- * Module Name: exdump - Interpreter debug 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.
- */
-
-#define __EXDUMP_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>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exdump")
-
-/*
- * The following routines are used for debug output only
- */
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-
-/* Local prototypes */
-
-static void
-AcpiExOutString (
- char *Title,
- char *Value);
-
-static void
-AcpiExOutPointer (
- char *Title,
- void *Value);
-
-static void
-AcpiExDumpObject (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_EXDUMP_INFO *Info);
-
-static void
-AcpiExDumpReferenceObj (
- ACPI_OPERAND_OBJECT *ObjDesc);
-
-static void
-AcpiExDumpPackageObj (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 Level,
- UINT32 Index);
-
-
-/*******************************************************************************
- *
- * Object Descriptor info tables
- *
- * Note: The first table entry must be an INIT opcode and must contain
- * the table length (number of table entries)
- *
- ******************************************************************************/
-
-static ACPI_EXDUMP_INFO AcpiExDumpInteger[2] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger), NULL},
- {ACPI_EXD_UINT64, ACPI_EXD_OFFSET (Integer.Value), "Value"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpString[4] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpString), NULL},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (String.Length), "Length"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (String.Pointer), "Pointer"},
- {ACPI_EXD_STRING, 0, NULL}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"},
- {ACPI_EXD_BUFFER, 0, NULL}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Elements"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"},
- {ACPI_EXD_PACKAGE, 0, NULL}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.Handler), "Handler"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.SystemNotify), "System Notify"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.DeviceNotify), "Device Notify"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.InfoFlags), "Info Flags"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"},
- {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"},
- {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Handler), "Handler"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpPower[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.SystemNotify), "System Notify"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.DeviceNotify), "Device Notify"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"},
- {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"},
- {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.SystemNotify), "System Notify"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.DeviceNotify), "Device Notify"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.Handler), "Handler"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpThermal[4] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal), NULL},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.SystemNotify), "System Notify"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.DeviceNotify), "Device Notify"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.Handler), "Handler"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpBufferField[3] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField), NULL},
- {ACPI_EXD_FIELD, 0, NULL},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BufferField.BufferObj), "Buffer Object"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpRegionField[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField), NULL},
- {ACPI_EXD_FIELD, 0, NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Field.AccessLength), "AccessLength"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.RegionObj), "Region Object"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.ResourceBuffer), "ResourceBuffer"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpBankField[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL},
- {ACPI_EXD_FIELD, 0, NULL},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (BankField.Value), "Value"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.RegionObj), "Region Object"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.BankObj), "Bank Object"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL},
- {ACPI_EXD_FIELD, 0, NULL},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (IndexField.Value), "Value"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.IndexObj), "Index Object"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpReference[8] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"},
- {ACPI_EXD_REFERENCE,0, NULL}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Next), "Next"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpNotify[3] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Node), "Node"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"}
-};
-
-
-/* Miscellaneous tables */
-
-static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL},
- {ACPI_EXD_TYPE , 0, NULL},
- {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.FieldFlags), "Field Flags"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.AccessByteWidth), "Access Byte Width"},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"},
- {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"},
- {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"},
- {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"}
-};
-
-static ACPI_EXDUMP_INFO AcpiExDumpNode[5] =
-{
- {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL},
- {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"},
- {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"},
- {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"},
- {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"}
-};
-
-
-/* Dispatch table, indexed by object type */
-
-static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] =
-{
- NULL,
- AcpiExDumpInteger,
- AcpiExDumpString,
- AcpiExDumpBuffer,
- AcpiExDumpPackage,
- NULL,
- AcpiExDumpDevice,
- AcpiExDumpEvent,
- AcpiExDumpMethod,
- AcpiExDumpMutex,
- AcpiExDumpRegion,
- AcpiExDumpPower,
- AcpiExDumpProcessor,
- AcpiExDumpThermal,
- AcpiExDumpBufferField,
- NULL,
- NULL,
- AcpiExDumpRegionField,
- AcpiExDumpBankField,
- AcpiExDumpIndexField,
- AcpiExDumpReference,
- NULL,
- NULL,
- AcpiExDumpNotify,
- AcpiExDumpAddressHandler,
- NULL,
- NULL,
- NULL
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDumpObject
- *
- * PARAMETERS: ObjDesc - Descriptor to dump
- * Info - Info table corresponding to this object
- * type
- *
- * RETURN: None
- *
- * DESCRIPTION: Walk the info table for this object
- *
- ******************************************************************************/
-
-static void
-AcpiExDumpObject (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_EXDUMP_INFO *Info)
-{
- UINT8 *Target;
- char *Name;
- UINT8 Count;
-
-
- if (!Info)
- {
- AcpiOsPrintf (
- "ExDumpObject: Display not implemented for object type %s\n",
- AcpiUtGetObjectTypeName (ObjDesc));
- return;
- }
-
- /* First table entry must contain the table length (# of table entries) */
-
- Count = Info->Offset;
-
- while (Count)
- {
- Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset);
- Name = Info->Name;
-
- switch (Info->Opcode)
- {
- case ACPI_EXD_INIT:
- break;
-
- case ACPI_EXD_TYPE:
-
- AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc));
- break;
-
- case ACPI_EXD_UINT8:
-
- AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target);
- break;
-
- case ACPI_EXD_UINT16:
-
- AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target));
- break;
-
- case ACPI_EXD_UINT32:
-
- AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target));
- break;
-
- case ACPI_EXD_UINT64:
-
- AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value",
- ACPI_FORMAT_UINT64 (ACPI_GET64 (Target)));
- break;
-
- case ACPI_EXD_POINTER:
- case ACPI_EXD_ADDRESS:
-
- AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target));
- break;
-
- case ACPI_EXD_STRING:
-
- AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
- AcpiOsPrintf ("\n");
- break;
-
- case ACPI_EXD_BUFFER:
-
- ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length);
- break;
-
- case ACPI_EXD_PACKAGE:
-
- /* Dump the package contents */
-
- AcpiOsPrintf ("\nPackage Contents:\n");
- AcpiExDumpPackageObj (ObjDesc, 0, 0);
- break;
-
- case ACPI_EXD_FIELD:
-
- AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon);
- break;
-
- case ACPI_EXD_REFERENCE:
-
- AcpiExOutString ("Class Name",
- ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc)));
- AcpiExDumpReferenceObj (ObjDesc);
- break;
-
- default:
-
- AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
- Info->Opcode);
- return;
- }
-
- Info++;
- Count--;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDumpOperand
- *
- * PARAMETERS: *ObjDesc - Pointer to entry to be dumped
- * Depth - Current nesting depth
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump an operand object
- *
- ******************************************************************************/
-
-void
-AcpiExDumpOperand (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 Depth)
-{
- UINT32 Length;
- UINT32 Index;
-
-
- ACPI_FUNCTION_NAME (ExDumpOperand)
-
-
- if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
- {
- return;
- }
-
- if (!ObjDesc)
- {
- /* This could be a null element of a package */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
- return;
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc));
- ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC);
- return;
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "%p is not a node or operand object: [%s]\n",
- ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
- ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT));
- return;
- }
-
- /* ObjDesc is a valid object */
-
- if (Depth > 0)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ",
- Depth, " ", Depth, ObjDesc));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc));
- }
-
- /* Decode object type */
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc));
-
- switch (ObjDesc->Reference.Class)
- {
- case ACPI_REFCLASS_DEBUG:
-
- AcpiOsPrintf ("\n");
- break;
-
-
- case ACPI_REFCLASS_INDEX:
-
- AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object);
- break;
-
-
- case ACPI_REFCLASS_TABLE:
-
- AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value);
- break;
-
-
- case ACPI_REFCLASS_REFOF:
-
- AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object,
- AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
- ObjDesc->Reference.Object)->Common.Type));
- break;
-
-
- case ACPI_REFCLASS_NAME:
-
- AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii);
- break;
-
-
- case ACPI_REFCLASS_ARG:
- case ACPI_REFCLASS_LOCAL:
-
- AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value);
- break;
-
-
- default: /* Unknown reference class */
-
- AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
- break;
- }
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- AcpiOsPrintf ("Buffer length %.2X @ %p\n",
- ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer);
-
- /* Debug only -- dump the buffer contents */
-
- if (ObjDesc->Buffer.Pointer)
- {
- Length = ObjDesc->Buffer.Length;
- if (Length > 128)
- {
- Length = 128;
- }
-
- AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n",
- Length);
- ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length);
- }
- break;
-
-
- case ACPI_TYPE_INTEGER:
-
- AcpiOsPrintf ("Integer %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
- break;
-
-
- case ACPI_TYPE_PACKAGE:
-
- AcpiOsPrintf ("Package [Len %X] ElementArray %p\n",
- ObjDesc->Package.Count, ObjDesc->Package.Elements);
-
- /*
- * If elements exist, package element pointer is valid,
- * and debug_level exceeds 1, dump package's elements.
- */
- if (ObjDesc->Package.Count &&
- ObjDesc->Package.Elements &&
- AcpiDbgLevel > 1)
- {
- for (Index = 0; Index < ObjDesc->Package.Count; Index++)
- {
- AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1);
- }
- }
- break;
-
-
- case ACPI_TYPE_REGION:
-
- AcpiOsPrintf ("Region %s (%X)",
- AcpiUtGetRegionName (ObjDesc->Region.SpaceId),
- ObjDesc->Region.SpaceId);
-
- /*
- * If the address and length have not been evaluated,
- * don't print them.
- */
- if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID))
- {
- AcpiOsPrintf ("\n");
- }
- else
- {
- AcpiOsPrintf (" base %8.8X%8.8X Length %X\n",
- ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
- ObjDesc->Region.Length);
- }
- break;
-
-
- case ACPI_TYPE_STRING:
-
- AcpiOsPrintf ("String length %X @ %p ",
- ObjDesc->String.Length,
- ObjDesc->String.Pointer);
-
- AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
- AcpiOsPrintf ("\n");
- break;
-
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- AcpiOsPrintf ("BankField\n");
- break;
-
-
- case ACPI_TYPE_LOCAL_REGION_FIELD:
-
- AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
- "byte=%X bit=%X of below:\n",
- ObjDesc->Field.BitLength,
- ObjDesc->Field.AccessByteWidth,
- ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK,
- ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK,
- ObjDesc->Field.BaseByteOffset,
- ObjDesc->Field.StartFieldBitOffset);
-
- AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1);
- break;
-
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- AcpiOsPrintf ("IndexField\n");
- break;
-
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n",
- ObjDesc->BufferField.BitLength,
- ObjDesc->BufferField.BaseByteOffset,
- ObjDesc->BufferField.StartFieldBitOffset);
-
- if (!ObjDesc->BufferField.BufferObj)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n"));
- }
- else if ((ObjDesc->BufferField.BufferObj)->Common.Type !=
- ACPI_TYPE_BUFFER)
- {
- AcpiOsPrintf ("*not a Buffer*\n");
- }
- else
- {
- AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1);
- }
- break;
-
-
- case ACPI_TYPE_EVENT:
-
- AcpiOsPrintf ("Event\n");
- break;
-
-
- case ACPI_TYPE_METHOD:
-
- AcpiOsPrintf ("Method(%X) @ %p:%X\n",
- ObjDesc->Method.ParamCount,
- ObjDesc->Method.AmlStart,
- ObjDesc->Method.AmlLength);
- break;
-
-
- case ACPI_TYPE_MUTEX:
-
- AcpiOsPrintf ("Mutex\n");
- break;
-
-
- case ACPI_TYPE_DEVICE:
-
- AcpiOsPrintf ("Device\n");
- break;
-
-
- case ACPI_TYPE_POWER:
-
- AcpiOsPrintf ("Power\n");
- break;
-
-
- case ACPI_TYPE_PROCESSOR:
-
- AcpiOsPrintf ("Processor\n");
- break;
-
-
- case ACPI_TYPE_THERMAL:
-
- AcpiOsPrintf ("Thermal\n");
- break;
-
-
- default:
- /* Unknown Type */
-
- AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type);
- break;
- }
-
- return;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDumpOperands
- *
- * PARAMETERS: Operands - A list of Operand objects
- * OpcodeName - AML opcode name
- * NumOperands - Operand count for this opcode
- *
- * DESCRIPTION: Dump the operands associated with the opcode
- *
- ******************************************************************************/
-
-void
-AcpiExDumpOperands (
- ACPI_OPERAND_OBJECT **Operands,
- const char *OpcodeName,
- UINT32 NumOperands)
-{
- ACPI_FUNCTION_NAME (ExDumpOperands);
-
-
- if (!OpcodeName)
- {
- OpcodeName = "UNKNOWN";
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "**** Start operand dump for opcode [%s], %u operands\n",
- OpcodeName, NumOperands));
-
- if (NumOperands == 0)
- {
- NumOperands = 1;
- }
-
- /* Dump the individual operands */
-
- while (NumOperands)
- {
- AcpiExDumpOperand (*Operands, 0);
- Operands++;
- NumOperands--;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "**** End operand dump for [%s]\n", OpcodeName));
- return;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOut* functions
- *
- * PARAMETERS: Title - Descriptive text
- * Value - Value to be displayed
- *
- * DESCRIPTION: Object dump output formatting functions. These functions
- * reduce the number of format strings required and keeps them
- * all in one place for easy modification.
- *
- ******************************************************************************/
-
-static void
-AcpiExOutString (
- char *Title,
- char *Value)
-{
- AcpiOsPrintf ("%20s : %s\n", Title, Value);
-}
-
-static void
-AcpiExOutPointer (
- char *Title,
- void *Value)
-{
- AcpiOsPrintf ("%20s : %p\n", Title, Value);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDumpNamespaceNode
- *
- * PARAMETERS: Node - Descriptor to dump
- * Flags - Force display if TRUE
- *
- * DESCRIPTION: Dumps the members of the given.Node
- *
- ******************************************************************************/
-
-void
-AcpiExDumpNamespaceNode (
- ACPI_NAMESPACE_NODE *Node,
- UINT32 Flags)
-{
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!Flags)
- {
- if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
- {
- return;
- }
- }
-
- AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node));
- AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type));
- AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node));
- AcpiExOutPointer ("Parent", Node->Parent);
-
- AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node),
- AcpiExDumpNode);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDumpReferenceObj
- *
- * PARAMETERS: Object - Descriptor to dump
- *
- * DESCRIPTION: Dumps a reference object
- *
- ******************************************************************************/
-
-static void
-AcpiExDumpReferenceObj (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_BUFFER RetBuf;
- ACPI_STATUS Status;
-
-
- RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
-
- if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME)
- {
- AcpiOsPrintf (" %p ", ObjDesc->Reference.Node);
-
- Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsPrintf (" Could not convert name to pathname\n");
- }
- else
- {
- AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer);
- ACPI_FREE (RetBuf.Pointer);
- }
- }
- else if (ObjDesc->Reference.Object)
- {
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
- {
- AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object);
- if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE)
- {
- AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value);
- }
- else
- {
- AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object,
- AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)
- ObjDesc->Reference.Object)->Common.Type));
- }
- }
- else
- {
- AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object);
- }
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDumpPackageObj
- *
- * PARAMETERS: ObjDesc - Descriptor to dump
- * Level - Indentation Level
- * Index - Package index for this object
- *
- * DESCRIPTION: Dumps the elements of the package
- *
- ******************************************************************************/
-
-static void
-AcpiExDumpPackageObj (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 Level,
- UINT32 Index)
-{
- UINT32 i;
-
-
- /* Indentation and index output */
-
- if (Level > 0)
- {
- for (i = 0; i < Level; i++)
- {
- AcpiOsPrintf (" ");
- }
-
- AcpiOsPrintf ("[%.2d] ", Index);
- }
-
- AcpiOsPrintf ("%p ", ObjDesc);
-
- /* Null package elements are allowed */
-
- if (!ObjDesc)
- {
- AcpiOsPrintf ("[Null Object]\n");
- return;
- }
-
- /* Packages may only contain a few object types */
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
-
- AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
- break;
-
-
- case ACPI_TYPE_STRING:
-
- AcpiOsPrintf ("[String] Value: ");
- for (i = 0; i < ObjDesc->String.Length; i++)
- {
- AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
- }
- AcpiOsPrintf ("\n");
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
- if (ObjDesc->Buffer.Length)
- {
- AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
- ObjDesc->Buffer.Length, DB_DWORD_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++)
- {
- AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i);
- }
- break;
-
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X",
- AcpiUtGetReferenceName (ObjDesc),
- ObjDesc->Reference.Class);
- AcpiExDumpReferenceObj (ObjDesc);
- break;
-
-
- default:
-
- AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type);
- break;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDumpObjectDescriptor
- *
- * PARAMETERS: ObjDesc - Descriptor to dump
- * Flags - Force display if TRUE
- *
- * DESCRIPTION: Dumps the members of the object descriptor given.
- *
- ******************************************************************************/
-
-void
-AcpiExDumpObjectDescriptor (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 Flags)
-{
- ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor);
-
-
- if (!ObjDesc)
- {
- return_VOID;
- }
-
- if (!Flags)
- {
- if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)))
- {
- return_VOID;
- }
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
- {
- AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags);
-
- AcpiOsPrintf ("\nAttached Object (%p):\n",
- ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object);
-
- AcpiExDumpObjectDescriptor (
- ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags);
- return_VOID;
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
- {
- AcpiOsPrintf (
- "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n",
- ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
- return_VOID;
- }
-
- if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX)
- {
- return_VOID;
- }
-
- /* Common Fields */
-
- AcpiExDumpObject (ObjDesc, AcpiExDumpCommon);
-
- /* Object-specific fields */
-
- AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]);
- return_VOID;
-}
-
-#endif
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exfield.c
--- a/head/sys/contrib/dev/acpica/executer/exfield.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,406 +0,0 @@
-/******************************************************************************
- *
- * Module Name: exfield - ACPI AML (p-code) execution - field 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 __EXFIELD_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>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exfield")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExReadDataFromField
- *
- * PARAMETERS: WalkState - Current execution state
- * ObjDesc - The named field
- * RetBufferDesc - Where the return data object is stored
- *
- * RETURN: Status
- *
- * DESCRIPTION: Read from a named field. Returns either an Integer or a
- * Buffer, depending on the size of the field.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExReadDataFromField (
- ACPI_WALK_STATE *WalkState,
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_OPERAND_OBJECT **RetBufferDesc)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *BufferDesc;
- ACPI_SIZE Length;
- void *Buffer;
- UINT32 Function;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc);
-
-
- /* Parameter validation */
-
- if (!ObjDesc)
- {
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
- if (!RetBufferDesc)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
- {
- /*
- * If the BufferField arguments have not been previously evaluated,
- * evaluate them now and save the results.
- */
- if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
- {
- Status = AcpiDsGetBufferFieldArguments (ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
- }
- else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
- (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
- ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
- ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
- {
- /*
- * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold
- * the data and then directly access the region handler.
- *
- * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function
- */
- if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
- {
- Length = ACPI_SMBUS_BUFFER_SIZE;
- Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
- }
- else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
- {
- Length = ACPI_GSBUS_BUFFER_SIZE;
- Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
- }
- else /* IPMI */
- {
- Length = ACPI_IPMI_BUFFER_SIZE;
- Function = ACPI_READ;
- }
-
- BufferDesc = AcpiUtCreateBufferObject (Length);
- if (!BufferDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Lock entire transaction if requested */
-
- AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
-
- /* Call the region handler for the read */
-
- Status = AcpiExAccessRegion (ObjDesc, 0,
- ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer),
- Function);
- AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
- goto Exit;
- }
-
- /*
- * Allocate a buffer for the contents of the field.
- *
- * If the field is larger than the current integer width, create
- * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
- * the use of arithmetic operators on the returned value if the
- * field size is equal or smaller than an Integer.
- *
- * Note: Field.length is in bits.
- */
- Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
- if (Length > AcpiGbl_IntegerByteWidth)
- {
- /* Field is too large for an Integer, create a Buffer instead */
-
- BufferDesc = AcpiUtCreateBufferObject (Length);
- if (!BufferDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
- Buffer = BufferDesc->Buffer.Pointer;
- }
- else
- {
- /* Field will fit within an Integer (normal case) */
-
- BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
- if (!BufferDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Length = AcpiGbl_IntegerByteWidth;
- Buffer = &BufferDesc->Integer.Value;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
- ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length));
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
- ObjDesc->CommonField.BitLength,
- ObjDesc->CommonField.StartFieldBitOffset,
- ObjDesc->CommonField.BaseByteOffset));
-
- /* Lock entire transaction if requested */
-
- AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
-
- /* Read from the field */
-
- Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length);
- AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
-
-
-Exit:
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (BufferDesc);
- }
- else
- {
- *RetBufferDesc = BufferDesc;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExWriteDataToField
- *
- * PARAMETERS: SourceDesc - Contains data to write
- * ObjDesc - The named field
- * ResultDesc - Where the return value is returned, if any
- *
- * RETURN: Status
- *
- * DESCRIPTION: Write to a named field
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExWriteDataToField (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_OPERAND_OBJECT **ResultDesc)
-{
- ACPI_STATUS Status;
- UINT32 Length;
- void *Buffer;
- ACPI_OPERAND_OBJECT *BufferDesc;
- UINT32 Function;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc);
-
-
- /* Parameter validation */
-
- if (!SourceDesc || !ObjDesc)
- {
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
-
- if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
- {
- /*
- * If the BufferField arguments have not been previously evaluated,
- * evaluate them now and save the results.
- */
- if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
- {
- Status = AcpiDsGetBufferFieldArguments (ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
- }
- else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
- (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
- ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
- ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
- {
- /*
- * This is an SMBus, GSBus or IPMI write. We will bypass the entire field
- * mechanism and handoff the buffer directly to the handler. For
- * these address spaces, the buffer is bi-directional; on a write,
- * return data is returned in the same buffer.
- *
- * Source must be a buffer of sufficient size:
- * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE.
- *
- * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function
- */
- if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
- {
- ACPI_ERROR ((AE_INFO,
- "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s",
- AcpiUtGetObjectTypeName (SourceDesc)));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
- {
- Length = ACPI_SMBUS_BUFFER_SIZE;
- Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
- }
- else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
- {
- Length = ACPI_GSBUS_BUFFER_SIZE;
- Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
- }
- else /* IPMI */
- {
- Length = ACPI_IPMI_BUFFER_SIZE;
- Function = ACPI_WRITE;
- }
-
- if (SourceDesc->Buffer.Length < Length)
- {
- ACPI_ERROR ((AE_INFO,
- "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u",
- Length, SourceDesc->Buffer.Length));
-
- return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
- }
-
- /* Create the bi-directional buffer */
-
- BufferDesc = AcpiUtCreateBufferObject (Length);
- if (!BufferDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Buffer = BufferDesc->Buffer.Pointer;
- ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length);
-
- /* Lock entire transaction if requested */
-
- AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
-
- /*
- * Perform the write (returns status and perhaps data in the
- * same buffer)
- */
- Status = AcpiExAccessRegion (ObjDesc, 0,
- (UINT64 *) Buffer, Function);
- AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
-
- *ResultDesc = BufferDesc;
- return_ACPI_STATUS (Status);
- }
-
- /* Get a pointer to the data to be written */
-
- switch (SourceDesc->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- Buffer = &SourceDesc->Integer.Value;
- Length = sizeof (SourceDesc->Integer.Value);
- break;
-
- case ACPI_TYPE_BUFFER:
- Buffer = SourceDesc->Buffer.Pointer;
- Length = SourceDesc->Buffer.Length;
- break;
-
- case ACPI_TYPE_STRING:
- Buffer = SourceDesc->String.Pointer;
- Length = SourceDesc->String.Length;
- break;
-
- default:
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
- SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type),
- SourceDesc->Common.Type, Buffer, Length));
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
- ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type),
- ObjDesc->Common.Type,
- ObjDesc->CommonField.BitLength,
- ObjDesc->CommonField.StartFieldBitOffset,
- ObjDesc->CommonField.BaseByteOffset));
-
- /* Lock entire transaction if requested */
-
- AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
-
- /* Write to the field */
-
- Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length);
- AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exfldio.c
--- a/head/sys/contrib/dev/acpica/executer/exfldio.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1057 +0,0 @@
-/******************************************************************************
- *
- * Module Name: exfldio - Aml Field I/O
- *
- *****************************************************************************/
-
-/*
- * 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 __EXFLDIO_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>
-#include <contrib/dev/acpica/include/acevents.h>
-#include <contrib/dev/acpica/include/acdispat.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exfldio")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiExFieldDatumIo (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 FieldDatumByteOffset,
- UINT64 *Value,
- UINT32 ReadWrite);
-
-static BOOLEAN
-AcpiExRegisterOverflow (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT64 Value);
-
-static ACPI_STATUS
-AcpiExSetupRegion (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 FieldDatumByteOffset);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSetupRegion
- *
- * PARAMETERS: ObjDesc - Field to be read or written
- * FieldDatumByteOffset - Byte offset of this datum within the
- * parent field
- *
- * RETURN: Status
- *
- * DESCRIPTION: Common processing for AcpiExExtractFromField and
- * AcpiExInsertIntoField. Initialize the Region if necessary and
- * validate the request.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExSetupRegion (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 FieldDatumByteOffset)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *RgnDesc;
- UINT8 SpaceId;
-
-
- ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset);
-
-
- RgnDesc = ObjDesc->CommonField.RegionObj;
-
- /* We must have a valid region */
-
- if (RgnDesc->Common.Type != ACPI_TYPE_REGION)
- {
- ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
- RgnDesc->Common.Type,
- AcpiUtGetObjectTypeName (RgnDesc)));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- SpaceId = RgnDesc->Region.SpaceId;
-
- /* Validate the Space ID */
-
- if (!AcpiIsValidSpaceId (SpaceId))
- {
- ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
- return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
- }
-
- /*
- * If the Region Address and Length have not been previously evaluated,
- * evaluate them now and save the results.
- */
- if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID))
- {
- Status = AcpiDsGetRegionArguments (RgnDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Exit now for SMBus, GSBus or IPMI address space, it has a non-linear
- * address space and the request cannot be directly validated
- */
- if (SpaceId == ACPI_ADR_SPACE_SMBUS ||
- SpaceId == ACPI_ADR_SPACE_GSBUS ||
- SpaceId == ACPI_ADR_SPACE_IPMI)
- {
- /* SMBus or IPMI has a non-linear address space */
-
- return_ACPI_STATUS (AE_OK);
- }
-
-#ifdef ACPI_UNDER_DEVELOPMENT
- /*
- * If the Field access is AnyAcc, we can now compute the optimal
- * access (because we know know the length of the parent region)
- */
- if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
- {
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-#endif
-
- /*
- * Validate the request. The entire request from the byte offset for a
- * length of one field datum (access width) must fit within the region.
- * (Region length is specified in bytes)
- */
- if (RgnDesc->Region.Length <
- (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset +
- ObjDesc->CommonField.AccessByteWidth))
- {
- if (AcpiGbl_EnableInterpreterSlack)
- {
- /*
- * Slack mode only: We will go ahead and allow access to this
- * field if it is within the region length rounded up to the next
- * access width boundary. ACPI_SIZE cast for 64-bit compile.
- */
- if (ACPI_ROUND_UP (RgnDesc->Region.Length,
- ObjDesc->CommonField.AccessByteWidth) >=
- ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset +
- ObjDesc->CommonField.AccessByteWidth +
- FieldDatumByteOffset))
- {
- return_ACPI_STATUS (AE_OK);
- }
- }
-
- if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth)
- {
- /*
- * This is the case where the AccessType (AccWord, etc.) is wider
- * than the region itself. For example, a region of length one
- * byte, and a field with Dword access specified.
- */
- ACPI_ERROR ((AE_INFO,
- "Field [%4.4s] access width (%u bytes) too large for region [%4.4s] (length %u)",
- AcpiUtGetNodeName (ObjDesc->CommonField.Node),
- ObjDesc->CommonField.AccessByteWidth,
- AcpiUtGetNodeName (RgnDesc->Region.Node),
- RgnDesc->Region.Length));
- }
-
- /*
- * Offset rounded up to next multiple of field width
- * exceeds region length, indicate an error
- */
- ACPI_ERROR ((AE_INFO,
- "Field [%4.4s] Base+Offset+Width %u+%u+%u is beyond end of region [%4.4s] (length %u)",
- AcpiUtGetNodeName (ObjDesc->CommonField.Node),
- ObjDesc->CommonField.BaseByteOffset,
- FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth,
- AcpiUtGetNodeName (RgnDesc->Region.Node),
- RgnDesc->Region.Length));
-
- return_ACPI_STATUS (AE_AML_REGION_LIMIT);
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExAccessRegion
- *
- * PARAMETERS: ObjDesc - Field to be read
- * FieldDatumByteOffset - Byte offset of this datum within the
- * parent field
- * Value - Where to store value (must at least
- * 64 bits)
- * Function - Read or Write flag plus other region-
- * dependent flags
- *
- * RETURN: Status
- *
- * DESCRIPTION: Read or Write a single field datum to an Operation Region.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExAccessRegion (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 FieldDatumByteOffset,
- UINT64 *Value,
- UINT32 Function)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *RgnDesc;
- UINT32 RegionOffset;
-
-
- ACPI_FUNCTION_TRACE (ExAccessRegion);
-
-
- /*
- * Ensure that the region operands are fully evaluated and verify
- * the validity of the request
- */
- Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * The physical address of this field datum is:
- *
- * 1) The base of the region, plus
- * 2) The base offset of the field, plus
- * 3) The current offset into the field
- */
- RgnDesc = ObjDesc->CommonField.RegionObj;
- RegionOffset =
- ObjDesc->CommonField.BaseByteOffset +
- FieldDatumByteOffset;
-
- if ((Function & ACPI_IO_MASK) == ACPI_READ)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
- }
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
- " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId,
- ObjDesc->CommonField.AccessByteWidth,
- ObjDesc->CommonField.BaseByteOffset,
- FieldDatumByteOffset,
- ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset))));
-
- /* Invoke the appropriate AddressSpace/OpRegion handler */
-
- Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc,
- Function, RegionOffset,
- ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value);
-
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_NOT_IMPLEMENTED)
- {
- ACPI_ERROR ((AE_INFO,
- "Region %s (ID=%u) not implemented",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId));
- }
- else if (Status == AE_NOT_EXIST)
- {
- ACPI_ERROR ((AE_INFO,
- "Region %s (ID=%u) has no handler",
- AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
- RgnDesc->Region.SpaceId));
- }
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExRegisterOverflow
- *
- * PARAMETERS: ObjDesc - Register(Field) to be written
- * Value - Value to be stored
- *
- * RETURN: TRUE if value overflows the field, FALSE otherwise
- *
- * DESCRIPTION: Check if a value is out of range of the field being written.
- * Used to check if the values written to Index and Bank registers
- * are out of range. Normally, the value is simply truncated
- * to fit the field, but this case is most likely a serious
- * coding error in the ASL.
- *
- ******************************************************************************/
-
-static BOOLEAN
-AcpiExRegisterOverflow (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT64 Value)
-{
- ACPI_FUNCTION_NAME (ExRegisterOverflow);
-
-
- if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE)
- {
- /*
- * The field is large enough to hold the maximum integer, so we can
- * never overflow it.
- */
- return (FALSE);
- }
-
- if (Value >= ((UINT64) 1 << ObjDesc->CommonField.BitLength))
- {
- /*
- * The Value is larger than the maximum value that can fit into
- * the register.
- */
- ACPI_ERROR ((AE_INFO,
- "Index value 0x%8.8X%8.8X overflows field width 0x%X",
- ACPI_FORMAT_UINT64 (Value),
- ObjDesc->CommonField.BitLength));
-
- return (TRUE);
- }
-
- /* The Value will fit into the field with no truncation */
-
- return (FALSE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExFieldDatumIo
- *
- * PARAMETERS: ObjDesc - Field to be read
- * FieldDatumByteOffset - Byte offset of this datum within the
- * parent field
- * Value - Where to store value (must be 64 bits)
- * ReadWrite - Read or Write flag
- *
- * RETURN: Status
- *
- * DESCRIPTION: Read or Write a single datum of a field. The FieldType is
- * demultiplexed here to handle the different types of fields
- * (BufferField, RegionField, IndexField, BankField)
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExFieldDatumIo (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT32 FieldDatumByteOffset,
- UINT64 *Value,
- UINT32 ReadWrite)
-{
- ACPI_STATUS Status;
- UINT64 LocalValue;
-
-
- ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset);
-
-
- if (ReadWrite == ACPI_READ)
- {
- if (!Value)
- {
- LocalValue = 0;
-
- /* To support reads without saving return value */
- Value = &LocalValue;
- }
-
- /* Clear the entire return buffer first, [Very Important!] */
-
- *Value = 0;
- }
-
- /*
- * The four types of fields are:
- *
- * BufferField - Read/write from/to a Buffer
- * RegionField - Read/write from/to a Operation Region.
- * BankField - Write to a Bank Register, then read/write from/to an
- * OperationRegion
- * IndexField - Write to an Index Register, then read/write from/to a
- * Data Register
- */
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_BUFFER_FIELD:
- /*
- * If the BufferField arguments have not been previously evaluated,
- * evaluate them now and save the results.
- */
- if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
- {
- Status = AcpiDsGetBufferFieldArguments (ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- if (ReadWrite == ACPI_READ)
- {
- /*
- * Copy the data from the source buffer.
- * Length is the field width in bytes.
- */
- ACPI_MEMCPY (Value,
- (ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
- ObjDesc->BufferField.BaseByteOffset +
- FieldDatumByteOffset,
- ObjDesc->CommonField.AccessByteWidth);
- }
- else
- {
- /*
- * Copy the data to the target buffer.
- * Length is the field width in bytes.
- */
- ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
- ObjDesc->BufferField.BaseByteOffset +
- FieldDatumByteOffset,
- Value, ObjDesc->CommonField.AccessByteWidth);
- }
-
- Status = AE_OK;
- break;
-
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- /*
- * Ensure that the BankValue is not beyond the capacity of
- * the register
- */
- if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj,
- (UINT64) ObjDesc->BankField.Value))
- {
- return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
- }
-
- /*
- * For BankFields, we must write the BankValue to the BankRegister
- * (itself a RegionField) before we can access the data.
- */
- Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj,
- &ObjDesc->BankField.Value,
- sizeof (ObjDesc->BankField.Value));
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Now that the Bank has been selected, fall through to the
- * RegionField case and write the datum to the Operation Region
- */
-
- /*lint -fallthrough */
-
-
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- /*
- * For simple RegionFields, we just directly access the owning
- * Operation Region.
- */
- Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value,
- ReadWrite);
- break;
-
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
-
- /*
- * Ensure that the IndexValue is not beyond the capacity of
- * the register
- */
- if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj,
- (UINT64) ObjDesc->IndexField.Value))
- {
- return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
- }
-
- /* Write the index value to the IndexRegister (itself a RegionField) */
-
- FieldDatumByteOffset += ObjDesc->IndexField.Value;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Write to Index Register: Value %8.8X\n",
- FieldDatumByteOffset));
-
- Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj,
- &FieldDatumByteOffset,
- sizeof (FieldDatumByteOffset));
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (ReadWrite == ACPI_READ)
- {
- /* Read the datum from the DataRegister */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Read from Data Register\n"));
-
- Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj,
- Value, sizeof (UINT64));
- }
- else
- {
- /* Write the datum to the DataRegister */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Write to Data Register: Value %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (*Value)));
-
- Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj,
- Value, sizeof (UINT64));
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %u",
- ObjDesc->Common.Type));
- Status = AE_AML_INTERNAL;
- break;
- }
-
- if (ACPI_SUCCESS (Status))
- {
- if (ReadWrite == ACPI_READ)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Value Read %8.8X%8.8X, Width %u\n",
- ACPI_FORMAT_UINT64 (*Value),
- ObjDesc->CommonField.AccessByteWidth));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Value Written %8.8X%8.8X, Width %u\n",
- ACPI_FORMAT_UINT64 (*Value),
- ObjDesc->CommonField.AccessByteWidth));
- }
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExWriteWithUpdateRule
- *
- * PARAMETERS: ObjDesc - Field to be written
- * Mask - bitmask within field datum
- * FieldValue - Value to write
- * FieldDatumByteOffset - Offset of datum within field
- *
- * RETURN: Status
- *
- * DESCRIPTION: Apply the field update rule to a field write
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExWriteWithUpdateRule (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT64 Mask,
- UINT64 FieldValue,
- UINT32 FieldDatumByteOffset)
-{
- ACPI_STATUS Status = AE_OK;
- UINT64 MergedValue;
- UINT64 CurrentValue;
-
-
- ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask);
-
-
- /* Start with the new bits */
-
- MergedValue = FieldValue;
-
- /* If the mask is all ones, we don't need to worry about the update rule */
-
- if (Mask != ACPI_UINT64_MAX)
- {
- /* Decode the update rule */
-
- switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
- {
- case AML_FIELD_UPDATE_PRESERVE:
- /*
- * Check if update rule needs to be applied (not if mask is all
- * ones) The left shift drops the bits we want to ignore.
- */
- if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) -
- ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0)
- {
- /*
- * Read the current contents of the byte/word/dword containing
- * the field, and merge with the new field value.
- */
- Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
- &CurrentValue, ACPI_READ);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- MergedValue |= (CurrentValue & ~Mask);
- }
- break;
-
- case AML_FIELD_UPDATE_WRITE_AS_ONES:
-
- /* Set positions outside the field to all ones */
-
- MergedValue |= ~Mask;
- break;
-
- case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
-
- /* Set positions outside the field to all zeros */
-
- MergedValue &= Mask;
- break;
-
- default:
-
- ACPI_ERROR ((AE_INFO,
- "Unknown UpdateRule value: 0x%X",
- (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)));
- return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
- }
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (Mask),
- FieldDatumByteOffset,
- ObjDesc->CommonField.AccessByteWidth,
- ACPI_FORMAT_UINT64 (FieldValue),
- ACPI_FORMAT_UINT64 (MergedValue)));
-
- /* Write the merged value */
-
- Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
- &MergedValue, ACPI_WRITE);
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExExtractFromField
- *
- * PARAMETERS: ObjDesc - Field to be read
- * Buffer - Where to store the field data
- * BufferLength - Length of Buffer
- *
- * RETURN: Status
- *
- * DESCRIPTION: Retrieve the current value of the given field
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExExtractFromField (
- ACPI_OPERAND_OBJECT *ObjDesc,
- void *Buffer,
- UINT32 BufferLength)
-{
- ACPI_STATUS Status;
- UINT64 RawDatum;
- UINT64 MergedDatum;
- UINT32 FieldOffset = 0;
- UINT32 BufferOffset = 0;
- UINT32 BufferTailBits;
- UINT32 DatumCount;
- UINT32 FieldDatumCount;
- UINT32 AccessBitWidth;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (ExExtractFromField);
-
-
- /* Validate target buffer and clear it */
-
- if (BufferLength <
- ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength))
- {
- ACPI_ERROR ((AE_INFO,
- "Field size %u (bits) is too large for buffer (%u)",
- ObjDesc->CommonField.BitLength, BufferLength));
-
- return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
- }
-
- ACPI_MEMSET (Buffer, 0, BufferLength);
- AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
-
- /* Handle the simple case here */
-
- if ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
- (ObjDesc->CommonField.BitLength == AccessBitWidth))
- {
- Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ);
- return_ACPI_STATUS (Status);
- }
-
-/* TBD: Move to common setup code */
-
- /* Field algorithm is limited to sizeof(UINT64), truncate if needed */
-
- if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
- {
- ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
- AccessBitWidth = sizeof (UINT64) * 8;
- }
-
- /* Compute the number of datums (access width data items) */
-
- DatumCount = ACPI_ROUND_UP_TO (
- ObjDesc->CommonField.BitLength, AccessBitWidth);
-
- FieldDatumCount = ACPI_ROUND_UP_TO (
- ObjDesc->CommonField.BitLength +
- ObjDesc->CommonField.StartFieldBitOffset, AccessBitWidth);
-
- /* Priming read from the field */
-
- Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
-
- /* Read the rest of the field */
-
- for (i = 1; i < FieldDatumCount; i++)
- {
- /* Get next input datum from the field */
-
- FieldOffset += ObjDesc->CommonField.AccessByteWidth;
- Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset,
- &RawDatum, ACPI_READ);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Merge with previous datum if necessary.
- *
- * Note: Before the shift, check if the shift value will be larger than
- * the integer size. If so, there is no need to perform the operation.
- * This avoids the differences in behavior between different compilers
- * concerning shift values larger than the target data width.
- */
- if (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset <
- ACPI_INTEGER_BIT_SIZE)
- {
- MergedDatum |= RawDatum <<
- (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
- }
-
- if (i == DatumCount)
- {
- break;
- }
-
- /* Write merged datum to target buffer */
-
- ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
- ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
- BufferLength - BufferOffset));
-
- BufferOffset += ObjDesc->CommonField.AccessByteWidth;
- MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
- }
-
- /* Mask off any extra bits in the last datum */
-
- BufferTailBits = ObjDesc->CommonField.BitLength % AccessBitWidth;
- if (BufferTailBits)
- {
- MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
- }
-
- /* Write the last datum to the buffer */
-
- ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
- ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
- BufferLength - BufferOffset));
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExInsertIntoField
- *
- * PARAMETERS: ObjDesc - Field to be written
- * Buffer - Data to be written
- * BufferLength - Length of Buffer
- *
- * RETURN: Status
- *
- * DESCRIPTION: Store the Buffer contents into the given field
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExInsertIntoField (
- ACPI_OPERAND_OBJECT *ObjDesc,
- void *Buffer,
- UINT32 BufferLength)
-{
- void *NewBuffer;
- ACPI_STATUS Status;
- UINT64 Mask;
- UINT64 WidthMask;
- UINT64 MergedDatum;
- UINT64 RawDatum = 0;
- UINT32 FieldOffset = 0;
- UINT32 BufferOffset = 0;
- UINT32 BufferTailBits;
- UINT32 DatumCount;
- UINT32 FieldDatumCount;
- UINT32 AccessBitWidth;
- UINT32 RequiredLength;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (ExInsertIntoField);
-
-
- /* Validate input buffer */
-
- NewBuffer = NULL;
- RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (
- ObjDesc->CommonField.BitLength);
- /*
- * We must have a buffer that is at least as long as the field
- * we are writing to. This is because individual fields are
- * indivisible and partial writes are not supported -- as per
- * the ACPI specification.
- */
- if (BufferLength < RequiredLength)
- {
- /* We need to create a new buffer */
-
- NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength);
- if (!NewBuffer)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /*
- * Copy the original data to the new buffer, starting
- * at Byte zero. All unused (upper) bytes of the
- * buffer will be 0.
- */
- ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength);
- Buffer = NewBuffer;
- BufferLength = RequiredLength;
- }
-
-/* TBD: Move to common setup code */
-
- /* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */
- if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
- {
- ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
- }
-
- AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
-
- /*
- * Create the bitmasks used for bit insertion.
- * Note: This if/else is used to bypass compiler differences with the
- * shift operator
- */
- if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
- {
- WidthMask = ACPI_UINT64_MAX;
- }
- else
- {
- WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
- }
-
- Mask = WidthMask &
- ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
-
- /* Compute the number of datums (access width data items) */
-
- DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength,
- AccessBitWidth);
-
- FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength +
- ObjDesc->CommonField.StartFieldBitOffset,
- AccessBitWidth);
-
- /* Get initial Datum from the input buffer */
-
- ACPI_MEMCPY (&RawDatum, Buffer,
- ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
- BufferLength - BufferOffset));
-
- MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
-
- /* Write the entire field */
-
- for (i = 1; i < FieldDatumCount; i++)
- {
- /* Write merged datum to the target field */
-
- MergedDatum &= Mask;
- Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask,
- MergedDatum, FieldOffset);
- if (ACPI_FAILURE (Status))
- {
- goto Exit;
- }
-
- FieldOffset += ObjDesc->CommonField.AccessByteWidth;
-
- /*
- * Start new output datum by merging with previous input datum
- * if necessary.
- *
- * Note: Before the shift, check if the shift value will be larger than
- * the integer size. If so, there is no need to perform the operation.
- * This avoids the differences in behavior between different compilers
- * concerning shift values larger than the target data width.
- */
- if ((AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset) <
- ACPI_INTEGER_BIT_SIZE)
- {
- MergedDatum = RawDatum >>
- (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
- }
- else
- {
- MergedDatum = 0;
- }
-
- Mask = WidthMask;
-
- if (i == DatumCount)
- {
- break;
- }
-
- /* Get the next input datum from the buffer */
-
- BufferOffset += ObjDesc->CommonField.AccessByteWidth;
- ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset,
- ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
- BufferLength - BufferOffset));
-
- MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
- }
-
- /* Mask off any extra bits in the last datum */
-
- BufferTailBits = (ObjDesc->CommonField.BitLength +
- ObjDesc->CommonField.StartFieldBitOffset) % AccessBitWidth;
- if (BufferTailBits)
- {
- Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
- }
-
- /* Write the last datum to the field */
-
- MergedDatum &= Mask;
- Status = AcpiExWriteWithUpdateRule (ObjDesc,
- Mask, MergedDatum, FieldOffset);
-
-Exit:
- /* Free temporary buffer if we used one */
-
- if (NewBuffer)
- {
- ACPI_FREE (NewBuffer);
- }
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exmisc.c
--- a/head/sys/contrib/dev/acpica/executer/exmisc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,800 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exmisc - ACPI AML (p-code) execution - specific 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 __EXMISC_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>
-#include <contrib/dev/acpica/include/amlresrc.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exmisc")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExGetObjectReference
- *
- * PARAMETERS: ObjDesc - Create a reference to this object
- * ReturnDesc - Where to store the reference
- * WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Obtain and return a "reference" to the target object
- * Common code for the RefOfOp and the CondRefOfOp.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExGetObjectReference (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_OPERAND_OBJECT **ReturnDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT *ReferenceObj;
- ACPI_OPERAND_OBJECT *ReferencedObj;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
-
-
- *ReturnDesc = NULL;
-
- switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
- {
- case ACPI_DESC_TYPE_OPERAND:
-
- if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
- {
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * Must be a reference to a Local or Arg
- */
- switch (ObjDesc->Reference.Class)
- {
- case ACPI_REFCLASS_LOCAL:
- case ACPI_REFCLASS_ARG:
- case ACPI_REFCLASS_DEBUG:
-
- /* The referenced object is the pseudo-node for the local/arg */
-
- ReferencedObj = ObjDesc->Reference.Object;
- break;
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
- ObjDesc->Reference.Class));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
- break;
-
-
- case ACPI_DESC_TYPE_NAMED:
-
- /*
- * A named reference that has already been resolved to a Node
- */
- ReferencedObj = ObjDesc;
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X",
- ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
- return_ACPI_STATUS (AE_TYPE);
- }
-
-
- /* Create a new reference object */
-
- ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
- if (!ReferenceObj)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF;
- ReferenceObj->Reference.Object = ReferencedObj;
- *ReturnDesc = ReferenceObj;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Object %p Type [%s], returning Reference %p\n",
- ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExConcatTemplate
- *
- * PARAMETERS: Operand0 - First source object
- * Operand1 - Second source object
- * ActualReturnDesc - Where to place the return object
- * WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Concatenate two resource templates
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExConcatTemplate (
- ACPI_OPERAND_OBJECT *Operand0,
- ACPI_OPERAND_OBJECT *Operand1,
- ACPI_OPERAND_OBJECT **ActualReturnDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *ReturnDesc;
- UINT8 *NewBuf;
- UINT8 *EndTag;
- ACPI_SIZE Length0;
- ACPI_SIZE Length1;
- ACPI_SIZE NewLength;
-
-
- ACPI_FUNCTION_TRACE (ExConcatTemplate);
-
-
- /*
- * Find the EndTag descriptor in each resource template.
- * Note1: returned pointers point TO the EndTag, not past it.
- * Note2: zero-length buffers are allowed; treated like one EndTag
- */
-
- /* Get the length of the first resource template */
-
- Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
-
- /* Get the length of the second resource template */
-
- Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
-
- /* Combine both lengths, minimum size will be 2 for EndTag */
-
- NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
-
- /* Create a new buffer object for the result (with one EndTag) */
-
- ReturnDesc = AcpiUtCreateBufferObject (NewLength);
- if (!ReturnDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /*
- * Copy the templates to the new buffer, 0 first, then 1 follows. One
- * EndTag descriptor is copied from Operand1.
- */
- NewBuf = ReturnDesc->Buffer.Pointer;
- ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0);
- ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
-
- /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
-
- NewBuf[NewLength - 1] = 0;
- NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
-
- /* Return the completed resource template */
-
- *ActualReturnDesc = ReturnDesc;
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDoConcatenate
- *
- * PARAMETERS: Operand0 - First source object
- * Operand1 - Second source object
- * ActualReturnDesc - Where to place the return object
- * WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExDoConcatenate (
- ACPI_OPERAND_OBJECT *Operand0,
- ACPI_OPERAND_OBJECT *Operand1,
- ACPI_OPERAND_OBJECT **ActualReturnDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
- ACPI_OPERAND_OBJECT *ReturnDesc;
- char *NewBuf;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (ExDoConcatenate);
-
-
- /*
- * Convert the second operand if necessary. The first operand
- * determines the type of the second operand, (See the Data Types
- * section of the ACPI specification.) Both object types are
- * guaranteed to be either Integer/String/Buffer by the operand
- * resolution mechanism.
- */
- switch (Operand0->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
- break;
-
- case ACPI_TYPE_STRING:
- Status = AcpiExConvertToString (Operand1, &LocalOperand1,
- ACPI_IMPLICIT_CONVERT_HEX);
- break;
-
- case ACPI_TYPE_BUFFER:
- Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
- break;
-
- default:
- ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
- Operand0->Common.Type));
- Status = AE_AML_INTERNAL;
- }
-
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /*
- * Both operands are now known to be the same object type
- * (Both are Integer, String, or Buffer), and we can now perform the
- * concatenation.
- */
-
- /*
- * There are three cases to handle:
- *
- * 1) Two Integers concatenated to produce a new Buffer
- * 2) Two Strings concatenated to produce a new String
- * 3) Two Buffers concatenated to produce a new Buffer
- */
- switch (Operand0->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
-
- /* Result of two Integers is a Buffer */
- /* Need enough buffer space for two integers */
-
- ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
- ACPI_MUL_2 (AcpiGbl_IntegerByteWidth));
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- NewBuf = (char *) ReturnDesc->Buffer.Pointer;
-
- /* Copy the first integer, LSB first */
-
- ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value,
- AcpiGbl_IntegerByteWidth);
-
- /* Copy the second integer (LSB first) after the first */
-
- ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
- &LocalOperand1->Integer.Value,
- AcpiGbl_IntegerByteWidth);
- break;
-
- case ACPI_TYPE_STRING:
-
- /* Result of two Strings is a String */
-
- ReturnDesc = AcpiUtCreateStringObject (
- ((ACPI_SIZE) Operand0->String.Length +
- LocalOperand1->String.Length));
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- NewBuf = ReturnDesc->String.Pointer;
-
- /* Concatenate the strings */
-
- ACPI_STRCPY (NewBuf, Operand0->String.Pointer);
- ACPI_STRCPY (NewBuf + Operand0->String.Length,
- LocalOperand1->String.Pointer);
- break;
-
- case ACPI_TYPE_BUFFER:
-
- /* Result of two Buffers is a Buffer */
-
- ReturnDesc = AcpiUtCreateBufferObject (
- ((ACPI_SIZE) Operand0->Buffer.Length +
- LocalOperand1->Buffer.Length));
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- NewBuf = (char *) ReturnDesc->Buffer.Pointer;
-
- /* Concatenate the buffers */
-
- ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer,
- Operand0->Buffer.Length);
- ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
- LocalOperand1->Buffer.Pointer,
- LocalOperand1->Buffer.Length);
- break;
-
- default:
-
- /* Invalid object type, should not happen here */
-
- ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
- Operand0->Common.Type));
- Status =AE_AML_INTERNAL;
- goto Cleanup;
- }
-
- *ActualReturnDesc = ReturnDesc;
-
-Cleanup:
- if (LocalOperand1 != Operand1)
- {
- AcpiUtRemoveReference (LocalOperand1);
- }
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDoMathOp
- *
- * PARAMETERS: Opcode - AML opcode
- * Integer0 - Integer operand #0
- * Integer1 - Integer operand #1
- *
- * RETURN: Integer result of the operation
- *
- * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
- * math functions here is to prevent a lot of pointer dereferencing
- * to obtain the operands.
- *
- ******************************************************************************/
-
-UINT64
-AcpiExDoMathOp (
- UINT16 Opcode,
- UINT64 Integer0,
- UINT64 Integer1)
-{
-
- ACPI_FUNCTION_ENTRY ();
-
-
- switch (Opcode)
- {
- case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
-
- return (Integer0 + Integer1);
-
-
- case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
-
- return (Integer0 & Integer1);
-
-
- case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
-
- return (~(Integer0 & Integer1));
-
-
- case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
-
- return (Integer0 | Integer1);
-
-
- case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
-
- return (~(Integer0 | Integer1));
-
-
- case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
-
- return (Integer0 ^ Integer1);
-
-
- case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
-
- return (Integer0 * Integer1);
-
-
- case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
-
- /*
- * We need to check if the shiftcount is larger than the integer bit
- * width since the behavior of this is not well-defined in the C language.
- */
- if (Integer1 >= AcpiGbl_IntegerBitWidth)
- {
- return (0);
- }
- return (Integer0 << Integer1);
-
-
- case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
-
- /*
- * We need to check if the shiftcount is larger than the integer bit
- * width since the behavior of this is not well-defined in the C language.
- */
- if (Integer1 >= AcpiGbl_IntegerBitWidth)
- {
- return (0);
- }
- return (Integer0 >> Integer1);
-
-
- case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
-
- return (Integer0 - Integer1);
-
- default:
-
- return (0);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDoLogicalNumericOp
- *
- * PARAMETERS: Opcode - AML opcode
- * Integer0 - Integer operand #0
- * Integer1 - Integer operand #1
- * LogicalResult - TRUE/FALSE result of the operation
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
- * operators (LAnd and LOr), both operands must be integers.
- *
- * Note: cleanest machine code seems to be produced by the code
- * below, rather than using statements of the form:
- * Result = (Integer0 && Integer1);
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExDoLogicalNumericOp (
- UINT16 Opcode,
- UINT64 Integer0,
- UINT64 Integer1,
- BOOLEAN *LogicalResult)
-{
- ACPI_STATUS Status = AE_OK;
- BOOLEAN LocalResult = FALSE;
-
-
- ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
-
-
- switch (Opcode)
- {
- case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
-
- if (Integer0 && Integer1)
- {
- LocalResult = TRUE;
- }
- break;
-
- case AML_LOR_OP: /* LOr (Integer0, Integer1) */
-
- if (Integer0 || Integer1)
- {
- LocalResult = TRUE;
- }
- break;
-
- default:
- Status = AE_AML_INTERNAL;
- break;
- }
-
- /* Return the logical result and status */
-
- *LogicalResult = LocalResult;
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDoLogicalOp
- *
- * PARAMETERS: Opcode - AML opcode
- * Operand0 - operand #0
- * Operand1 - operand #1
- * LogicalResult - TRUE/FALSE result of the operation
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
- * functions here is to prevent a lot of pointer dereferencing
- * to obtain the operands and to simplify the generation of the
- * logical value. For the Numeric operators (LAnd and LOr), both
- * operands must be integers. For the other logical operators,
- * operands can be any combination of Integer/String/Buffer. The
- * first operand determines the type to which the second operand
- * will be converted.
- *
- * Note: cleanest machine code seems to be produced by the code
- * below, rather than using statements of the form:
- * Result = (Operand0 == Operand1);
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExDoLogicalOp (
- UINT16 Opcode,
- ACPI_OPERAND_OBJECT *Operand0,
- ACPI_OPERAND_OBJECT *Operand1,
- BOOLEAN *LogicalResult)
-{
- ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
- UINT64 Integer0;
- UINT64 Integer1;
- UINT32 Length0;
- UINT32 Length1;
- ACPI_STATUS Status = AE_OK;
- BOOLEAN LocalResult = FALSE;
- int Compare;
-
-
- ACPI_FUNCTION_TRACE (ExDoLogicalOp);
-
-
- /*
- * Convert the second operand if necessary. The first operand
- * determines the type of the second operand, (See the Data Types
- * section of the ACPI 3.0+ specification.) Both object types are
- * guaranteed to be either Integer/String/Buffer by the operand
- * resolution mechanism.
- */
- switch (Operand0->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
- break;
-
- case ACPI_TYPE_STRING:
- Status = AcpiExConvertToString (Operand1, &LocalOperand1,
- ACPI_IMPLICIT_CONVERT_HEX);
- break;
-
- case ACPI_TYPE_BUFFER:
- Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
- break;
-
- default:
- Status = AE_AML_INTERNAL;
- break;
- }
-
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /*
- * Two cases: 1) Both Integers, 2) Both Strings or Buffers
- */
- if (Operand0->Common.Type == ACPI_TYPE_INTEGER)
- {
- /*
- * 1) Both operands are of type integer
- * Note: LocalOperand1 may have changed above
- */
- Integer0 = Operand0->Integer.Value;
- Integer1 = LocalOperand1->Integer.Value;
-
- switch (Opcode)
- {
- case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
-
- if (Integer0 == Integer1)
- {
- LocalResult = TRUE;
- }
- break;
-
- case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
-
- if (Integer0 > Integer1)
- {
- LocalResult = TRUE;
- }
- break;
-
- case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
-
- if (Integer0 < Integer1)
- {
- LocalResult = TRUE;
- }
- break;
-
- default:
- Status = AE_AML_INTERNAL;
- break;
- }
- }
- else
- {
- /*
- * 2) Both operands are Strings or both are Buffers
- * Note: Code below takes advantage of common Buffer/String
- * object fields. LocalOperand1 may have changed above. Use
- * memcmp to handle nulls in buffers.
- */
- Length0 = Operand0->Buffer.Length;
- Length1 = LocalOperand1->Buffer.Length;
-
- /* Lexicographic compare: compare the data bytes */
-
- Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer,
- LocalOperand1->Buffer.Pointer,
- (Length0 > Length1) ? Length1 : Length0);
-
- switch (Opcode)
- {
- case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
-
- /* Length and all bytes must be equal */
-
- if ((Length0 == Length1) &&
- (Compare == 0))
- {
- /* Length and all bytes match ==> TRUE */
-
- LocalResult = TRUE;
- }
- break;
-
- case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
-
- if (Compare > 0)
- {
- LocalResult = TRUE;
- goto Cleanup; /* TRUE */
- }
- if (Compare < 0)
- {
- goto Cleanup; /* FALSE */
- }
-
- /* Bytes match (to shortest length), compare lengths */
-
- if (Length0 > Length1)
- {
- LocalResult = TRUE;
- }
- break;
-
- case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
-
- if (Compare > 0)
- {
- goto Cleanup; /* FALSE */
- }
- if (Compare < 0)
- {
- LocalResult = TRUE;
- goto Cleanup; /* TRUE */
- }
-
- /* Bytes match (to shortest length), compare lengths */
-
- if (Length0 < Length1)
- {
- LocalResult = TRUE;
- }
- break;
-
- default:
- Status = AE_AML_INTERNAL;
- break;
- }
- }
-
-Cleanup:
-
- /* New object was created if implicit conversion performed - delete */
-
- if (LocalOperand1 != Operand1)
- {
- AcpiUtRemoveReference (LocalOperand1);
- }
-
- /* Return the logical result and status */
-
- *LogicalResult = LocalResult;
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exmutex.c
--- a/head/sys/contrib/dev/acpica/executer/exmutex.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,554 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exmutex - ASL Mutex Acquire/Release 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.
- */
-
-#define __EXMUTEX_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/acevents.h>
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exmutex")
-
-/* Local prototypes */
-
-static void
-AcpiExLinkMutex (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_THREAD_STATE *Thread);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExUnlinkMutex
- *
- * PARAMETERS: ObjDesc - The mutex to be unlinked
- *
- * RETURN: None
- *
- * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list
- *
- ******************************************************************************/
-
-void
-AcpiExUnlinkMutex (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread;
-
-
- if (!Thread)
- {
- return;
- }
-
- /* Doubly linked list */
-
- if (ObjDesc->Mutex.Next)
- {
- (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev;
- }
-
- if (ObjDesc->Mutex.Prev)
- {
- (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next;
-
- /*
- * Migrate the previous sync level associated with this mutex to
- * the previous mutex on the list so that it may be preserved.
- * This handles the case where several mutexes have been acquired
- * at the same level, but are not released in opposite order.
- */
- (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel =
- ObjDesc->Mutex.OriginalSyncLevel;
- }
- else
- {
- Thread->AcquiredMutexList = ObjDesc->Mutex.Next;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExLinkMutex
- *
- * PARAMETERS: ObjDesc - The mutex to be linked
- * Thread - Current executing thread object
- *
- * RETURN: None
- *
- * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk
- *
- ******************************************************************************/
-
-static void
-AcpiExLinkMutex (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_THREAD_STATE *Thread)
-{
- ACPI_OPERAND_OBJECT *ListHead;
-
-
- ListHead = Thread->AcquiredMutexList;
-
- /* This object will be the first object in the list */
-
- ObjDesc->Mutex.Prev = NULL;
- ObjDesc->Mutex.Next = ListHead;
-
- /* Update old first object to point back to this object */
-
- if (ListHead)
- {
- ListHead->Mutex.Prev = ObjDesc;
- }
-
- /* Update list head */
-
- Thread->AcquiredMutexList = ObjDesc;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExAcquireMutexObject
- *
- * PARAMETERS: Timeout - Timeout in milliseconds
- * ObjDesc - Mutex object
- * ThreadId - Current thread state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common
- * path that supports multiple acquires by the same thread.
- *
- * MUTEX: Interpreter must be locked
- *
- * NOTE: This interface is called from three places:
- * 1) From AcpiExAcquireMutex, via an AML Acquire() operator
- * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the
- * global lock
- * 3) From the external interface, AcpiAcquireGlobalLock
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExAcquireMutexObject (
- UINT16 Timeout,
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_THREAD_ID ThreadId)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc);
-
-
- if (!ObjDesc)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Support for multiple acquires by the owning thread */
-
- if (ObjDesc->Mutex.ThreadId == ThreadId)
- {
- /*
- * The mutex is already owned by this thread, just increment the
- * acquisition depth
- */
- ObjDesc->Mutex.AcquisitionDepth++;
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Acquire the mutex, wait if necessary. Special case for Global Lock */
-
- if (ObjDesc == AcpiGbl_GlobalLockMutex)
- {
- Status = AcpiEvAcquireGlobalLock (Timeout);
- }
- else
- {
- Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex,
- Timeout);
- }
-
- if (ACPI_FAILURE (Status))
- {
- /* Includes failure from a timeout on TimeDesc */
-
- return_ACPI_STATUS (Status);
- }
-
- /* Acquired the mutex: update mutex object */
-
- ObjDesc->Mutex.ThreadId = ThreadId;
- ObjDesc->Mutex.AcquisitionDepth = 1;
- ObjDesc->Mutex.OriginalSyncLevel = 0;
- ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExAcquireMutex
- *
- * PARAMETERS: TimeDesc - Timeout integer
- * ObjDesc - Mutex object
- * WalkState - Current method execution state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Acquire an AML mutex
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExAcquireMutex (
- ACPI_OPERAND_OBJECT *TimeDesc,
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc);
-
-
- if (!ObjDesc)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Must have a valid thread state struct */
-
- if (!WalkState->Thread)
- {
- ACPI_ERROR ((AE_INFO,
- "Cannot acquire Mutex [%4.4s], null thread info",
- AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- /*
- * Current sync level must be less than or equal to the sync level of the
- * mutex. This mechanism provides some deadlock prevention
- */
- if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel)
- {
- ACPI_ERROR ((AE_INFO,
- "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%u)",
- AcpiUtGetNodeName (ObjDesc->Mutex.Node),
- WalkState->Thread->CurrentSyncLevel));
- return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
- }
-
- Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value,
- ObjDesc, WalkState->Thread->ThreadId);
- if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1)
- {
- /* Save Thread object, original/current sync levels */
-
- ObjDesc->Mutex.OwnerThread = WalkState->Thread;
- ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel;
- WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel;
-
- /* Link the mutex to the current thread for force-unlock at method exit */
-
- AcpiExLinkMutex (ObjDesc, WalkState->Thread);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExReleaseMutexObject
- *
- * PARAMETERS: ObjDesc - The object descriptor for this op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Release a previously acquired Mutex, low level interface.
- * Provides a common path that supports multiple releases (after
- * previous multiple acquires) by the same thread.
- *
- * MUTEX: Interpreter must be locked
- *
- * NOTE: This interface is called from three places:
- * 1) From AcpiExReleaseMutex, via an AML Acquire() operator
- * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the
- * global lock
- * 3) From the external interface, AcpiReleaseGlobalLock
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExReleaseMutexObject (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExReleaseMutexObject);
-
-
- if (ObjDesc->Mutex.AcquisitionDepth == 0)
- {
- return (AE_NOT_ACQUIRED);
- }
-
- /* Match multiple Acquires with multiple Releases */
-
- ObjDesc->Mutex.AcquisitionDepth--;
- if (ObjDesc->Mutex.AcquisitionDepth != 0)
- {
- /* Just decrement the depth and return */
-
- return_ACPI_STATUS (AE_OK);
- }
-
- if (ObjDesc->Mutex.OwnerThread)
- {
- /* Unlink the mutex from the owner's list */
-
- AcpiExUnlinkMutex (ObjDesc);
- ObjDesc->Mutex.OwnerThread = NULL;
- }
-
- /* Release the mutex, special case for Global Lock */
-
- if (ObjDesc == AcpiGbl_GlobalLockMutex)
- {
- Status = AcpiEvReleaseGlobalLock ();
- }
- else
- {
- AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
- }
-
- /* Clear mutex info */
-
- ObjDesc->Mutex.ThreadId = 0;
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExReleaseMutex
- *
- * PARAMETERS: ObjDesc - The object descriptor for this op
- * WalkState - Current method execution state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Release a previously acquired Mutex.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExReleaseMutex (
- ACPI_OPERAND_OBJECT *ObjDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- UINT8 PreviousSyncLevel;
- ACPI_THREAD_STATE *OwnerThread;
-
-
- ACPI_FUNCTION_TRACE (ExReleaseMutex);
-
-
- if (!ObjDesc)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- OwnerThread = ObjDesc->Mutex.OwnerThread;
-
- /* The mutex must have been previously acquired in order to release it */
-
- if (!OwnerThread)
- {
- ACPI_ERROR ((AE_INFO,
- "Cannot release Mutex [%4.4s], not acquired",
- AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
- return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
- }
-
- /* Must have a valid thread ID */
-
- if (!WalkState->Thread)
- {
- ACPI_ERROR ((AE_INFO,
- "Cannot release Mutex [%4.4s], null thread info",
- AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- /*
- * The Mutex is owned, but this thread must be the owner.
- * Special case for Global Lock, any thread can release
- */
- if ((OwnerThread->ThreadId != WalkState->Thread->ThreadId) &&
- (ObjDesc != AcpiGbl_GlobalLockMutex))
- {
- ACPI_ERROR ((AE_INFO,
- "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
- (UINT32) WalkState->Thread->ThreadId,
- AcpiUtGetNodeName (ObjDesc->Mutex.Node),
- (UINT32) OwnerThread->ThreadId));
- return_ACPI_STATUS (AE_AML_NOT_OWNER);
- }
-
- /*
- * The sync level of the mutex must be equal to the current sync level. In
- * other words, the current level means that at least one mutex at that
- * level is currently being held. Attempting to release a mutex of a
- * different level can only mean that the mutex ordering rule is being
- * violated. This behavior is clarified in ACPI 4.0 specification.
- */
- if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel)
- {
- ACPI_ERROR ((AE_INFO,
- "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %u current %u",
- AcpiUtGetNodeName (ObjDesc->Mutex.Node),
- ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel));
- return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
- }
-
- /*
- * Get the previous SyncLevel from the head of the acquired mutex list.
- * This handles the case where several mutexes at the same level have been
- * acquired, but are not released in reverse order.
- */
- PreviousSyncLevel =
- OwnerThread->AcquiredMutexList->Mutex.OriginalSyncLevel;
-
- Status = AcpiExReleaseMutexObject (ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (ObjDesc->Mutex.AcquisitionDepth == 0)
- {
- /* Restore the previous SyncLevel */
-
- OwnerThread->CurrentSyncLevel = PreviousSyncLevel;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExReleaseAllMutexes
- *
- * PARAMETERS: Thread - Current executing thread object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Release all mutexes held by this thread
- *
- * NOTE: This function is called as the thread is exiting the interpreter.
- * Mutexes are not released when an individual control method is exited, but
- * only when the parent thread actually exits the interpreter. This allows one
- * method to acquire a mutex, and a different method to release it, as long as
- * this is performed underneath a single parent control method.
- *
- ******************************************************************************/
-
-void
-AcpiExReleaseAllMutexes (
- ACPI_THREAD_STATE *Thread)
-{
- ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList;
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Traverse the list of owned mutexes, releasing each one */
-
- while (Next)
- {
- ObjDesc = Next;
- Next = ObjDesc->Mutex.Next;
-
- ObjDesc->Mutex.Prev = NULL;
- ObjDesc->Mutex.Next = NULL;
- ObjDesc->Mutex.AcquisitionDepth = 0;
-
- /* Release the mutex, special case for Global Lock */
-
- if (ObjDesc == AcpiGbl_GlobalLockMutex)
- {
- /* Ignore errors */
-
- (void) AcpiEvReleaseGlobalLock ();
- }
- else
- {
- AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
- }
-
- /* Mark mutex unowned */
-
- ObjDesc->Mutex.OwnerThread = NULL;
- ObjDesc->Mutex.ThreadId = 0;
-
- /* Update Thread SyncLevel (Last mutex is the important one) */
-
- Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel;
- }
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exnames.c
--- a/head/sys/contrib/dev/acpica/executer/exnames.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,488 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exnames - interpreter/scanner name load/execute
- *
- *****************************************************************************/
-
-/*
- * 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 __EXNAMES_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 ("exnames")
-
-/* Local prototypes */
-
-static char *
-AcpiExAllocateNameString (
- UINT32 PrefixCount,
- UINT32 NumNameSegs);
-
-static ACPI_STATUS
-AcpiExNameSegment (
- UINT8 **InAmlAddress,
- char *NameString);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExAllocateNameString
- *
- * PARAMETERS: PrefixCount - Count of parent levels. Special cases:
- * (-1)==root, 0==none
- * NumNameSegs - count of 4-character name segments
- *
- * RETURN: A pointer to the allocated string segment. This segment must
- * be deleted by the caller.
- *
- * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name
- * string is long enough, and set up prefix if any.
- *
- ******************************************************************************/
-
-static char *
-AcpiExAllocateNameString (
- UINT32 PrefixCount,
- UINT32 NumNameSegs)
-{
- char *TempPtr;
- char *NameString;
- UINT32 SizeNeeded;
-
- ACPI_FUNCTION_TRACE (ExAllocateNameString);
-
-
- /*
- * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix.
- * Also, one byte for the null terminator.
- * This may actually be somewhat longer than needed.
- */
- if (PrefixCount == ACPI_UINT32_MAX)
- {
- /* Special case for root */
-
- SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
- }
- else
- {
- SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
- }
-
- /*
- * Allocate a buffer for the name.
- * This buffer must be deleted by the caller!
- */
- NameString = ACPI_ALLOCATE (SizeNeeded);
- if (!NameString)
- {
- ACPI_ERROR ((AE_INFO,
- "Could not allocate size %u", SizeNeeded));
- return_PTR (NULL);
- }
-
- TempPtr = NameString;
-
- /* Set up Root or Parent prefixes if needed */
-
- if (PrefixCount == ACPI_UINT32_MAX)
- {
- *TempPtr++ = AML_ROOT_PREFIX;
- }
- else
- {
- while (PrefixCount--)
- {
- *TempPtr++ = AML_PARENT_PREFIX;
- }
- }
-
-
- /* Set up Dual or Multi prefixes if needed */
-
- if (NumNameSegs > 2)
- {
- /* Set up multi prefixes */
-
- *TempPtr++ = AML_MULTI_NAME_PREFIX_OP;
- *TempPtr++ = (char) NumNameSegs;
- }
- else if (2 == NumNameSegs)
- {
- /* Set up dual prefixes */
-
- *TempPtr++ = AML_DUAL_NAME_PREFIX;
- }
-
- /*
- * Terminate string following prefixes. AcpiExNameSegment() will
- * append the segment(s)
- */
- *TempPtr = 0;
-
- return_PTR (NameString);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExNameSegment
- *
- * PARAMETERS: InAmlAddress - Pointer to the name in the AML code
- * NameString - Where to return the name. The name is appended
- * to any existing string to form a namepath
- *
- * RETURN: Status
- *
- * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExNameSegment (
- UINT8 **InAmlAddress,
- char *NameString)
-{
- char *AmlAddress = (void *) *InAmlAddress;
- ACPI_STATUS Status = AE_OK;
- UINT32 Index;
- char CharBuf[5];
-
-
- ACPI_FUNCTION_TRACE (ExNameSegment);
-
-
- /*
- * If first character is a digit, then we know that we aren't looking at a
- * valid name segment
- */
- CharBuf[0] = *AmlAddress;
-
- if ('0' <= CharBuf[0] && CharBuf[0] <= '9')
- {
- ACPI_ERROR ((AE_INFO, "Invalid leading digit: %c", CharBuf[0]));
- return_ACPI_STATUS (AE_CTRL_PENDING);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n"));
-
- for (Index = 0;
- (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0));
- Index++)
- {
- CharBuf[Index] = *AmlAddress++;
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[Index]));
- }
-
-
- /* Valid name segment */
-
- if (Index == 4)
- {
- /* Found 4 valid characters */
-
- CharBuf[4] = '\0';
-
- if (NameString)
- {
- ACPI_STRCAT (NameString, CharBuf);
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Appended to - %s\n", NameString));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "No Name string - %s\n", CharBuf));
- }
- }
- else if (Index == 0)
- {
- /*
- * First character was not a valid name character,
- * so we are looking at something other than a name.
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Leading character is not alpha: %02Xh (not a name)\n",
- CharBuf[0]));
- Status = AE_CTRL_PENDING;
- }
- else
- {
- /*
- * Segment started with one or more valid characters, but fewer than
- * the required 4
- */
- Status = AE_AML_BAD_NAME;
- ACPI_ERROR ((AE_INFO,
- "Bad character 0x%02x in name, at %p",
- *AmlAddress, AmlAddress));
- }
-
- *InAmlAddress = ACPI_CAST_PTR (UINT8, AmlAddress);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExGetNameString
- *
- * PARAMETERS: DataType - Object type to be associated with this
- * name
- * InAmlAddress - Pointer to the namestring in the AML code
- * OutNameString - Where the namestring is returned
- * OutNameLength - Length of the returned string
- *
- * RETURN: Status, namestring and length
- *
- * DESCRIPTION: Extract a full namepath from the AML byte stream,
- * including any prefixes.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExGetNameString (
- ACPI_OBJECT_TYPE DataType,
- UINT8 *InAmlAddress,
- char **OutNameString,
- UINT32 *OutNameLength)
-{
- ACPI_STATUS Status = AE_OK;
- UINT8 *AmlAddress = InAmlAddress;
- char *NameString = NULL;
- UINT32 NumSegments;
- UINT32 PrefixCount = 0;
- BOOLEAN HasPrefix = FALSE;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress);
-
-
- if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType ||
- ACPI_TYPE_LOCAL_BANK_FIELD == DataType ||
- ACPI_TYPE_LOCAL_INDEX_FIELD == DataType)
- {
- /* Disallow prefixes for types associated with FieldUnit names */
-
- NameString = AcpiExAllocateNameString (0, 1);
- if (!NameString)
- {
- Status = AE_NO_MEMORY;
- }
- else
- {
- Status = AcpiExNameSegment (&AmlAddress, NameString);
- }
- }
- else
- {
- /*
- * DataType is not a field name.
- * Examine first character of name for root or parent prefix operators
- */
- switch (*AmlAddress)
- {
- case AML_ROOT_PREFIX:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n",
- AmlAddress));
-
- /*
- * Remember that we have a RootPrefix --
- * see comment in AcpiExAllocateNameString()
- */
- AmlAddress++;
- PrefixCount = ACPI_UINT32_MAX;
- HasPrefix = TRUE;
- break;
-
-
- case AML_PARENT_PREFIX:
-
- /* Increment past possibly multiple parent prefixes */
-
- do
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n",
- AmlAddress));
-
- AmlAddress++;
- PrefixCount++;
-
- } while (*AmlAddress == AML_PARENT_PREFIX);
-
- HasPrefix = TRUE;
- break;
-
-
- default:
-
- /* Not a prefix character */
-
- break;
- }
-
- /* Examine first character of name for name segment prefix operator */
-
- switch (*AmlAddress)
- {
- case AML_DUAL_NAME_PREFIX:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n",
- AmlAddress));
-
- AmlAddress++;
- NameString = AcpiExAllocateNameString (PrefixCount, 2);
- if (!NameString)
- {
- Status = AE_NO_MEMORY;
- break;
- }
-
- /* Indicate that we processed a prefix */
-
- HasPrefix = TRUE;
-
- Status = AcpiExNameSegment (&AmlAddress, NameString);
- if (ACPI_SUCCESS (Status))
- {
- Status = AcpiExNameSegment (&AmlAddress, NameString);
- }
- break;
-
-
- case AML_MULTI_NAME_PREFIX_OP:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
- AmlAddress));
-
- /* Fetch count of segments remaining in name path */
-
- AmlAddress++;
- NumSegments = *AmlAddress;
-
- NameString = AcpiExAllocateNameString (PrefixCount, NumSegments);
- if (!NameString)
- {
- Status = AE_NO_MEMORY;
- break;
- }
-
- /* Indicate that we processed a prefix */
-
- AmlAddress++;
- HasPrefix = TRUE;
-
- while (NumSegments &&
- (Status = AcpiExNameSegment (&AmlAddress, NameString)) ==
- AE_OK)
- {
- NumSegments--;
- }
-
- break;
-
-
- case 0:
-
- /* NullName valid as of 8-12-98 ASL/AML Grammar Update */
-
- if (PrefixCount == ACPI_UINT32_MAX)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "NameSeg is \"\\\" followed by NULL\n"));
- }
-
- /* Consume the NULL byte */
-
- AmlAddress++;
- NameString = AcpiExAllocateNameString (PrefixCount, 0);
- if (!NameString)
- {
- Status = AE_NO_MEMORY;
- break;
- }
-
- break;
-
-
- default:
-
- /* Name segment string */
-
- NameString = AcpiExAllocateNameString (PrefixCount, 1);
- if (!NameString)
- {
- Status = AE_NO_MEMORY;
- break;
- }
-
- Status = AcpiExNameSegment (&AmlAddress, NameString);
- break;
- }
- }
-
- if (AE_CTRL_PENDING == Status && HasPrefix)
- {
- /* Ran out of segments after processing a prefix */
-
- ACPI_ERROR ((AE_INFO,
- "Malformed Name at %p", NameString));
- Status = AE_AML_BAD_NAME;
- }
-
- if (ACPI_FAILURE (Status))
- {
- if (NameString)
- {
- ACPI_FREE (NameString);
- }
- return_ACPI_STATUS (Status);
- }
-
- *OutNameString = NameString;
- *OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exoparg1.c
--- a/head/sys/contrib/dev/acpica/executer/exoparg1.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1111 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exoparg1 - AML execution - opcodes with 1 argument
- *
- *****************************************************************************/
-
-/*
- * 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 __EXOPARG1_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/acinterp.h>
-#include <contrib/dev/acpica/include/amlcode.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exoparg1")
-
-
-/*!
- * Naming convention for AML interpreter execution routines.
- *
- * The routines that begin execution of AML opcodes are named with a common
- * convention based upon the number of arguments, the number of target operands,
- * and whether or not a value is returned:
- *
- * AcpiExOpcode_xA_yT_zR
- *
- * Where:
- *
- * xA - ARGUMENTS: The number of arguments (input operands) that are
- * required for this opcode type (0 through 6 args).
- * yT - TARGETS: The number of targets (output operands) that are required
- * for this opcode type (0, 1, or 2 targets).
- * zR - RETURN VALUE: Indicates whether this opcode type returns a value
- * as the function return (0 or 1).
- *
- * The AcpiExOpcode* functions are called via the Dispatcher component with
- * fully resolved operands.
-!*/
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_0A_0T_1R
- *
- * PARAMETERS: WalkState - Current state (contains AML opcode)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute operator with no operands, one return value
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_0A_0T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Examine the AML opcode */
-
- switch (WalkState->Opcode)
- {
- case AML_TIMER_OP: /* Timer () */
-
- /* Create a return object of type Integer */
-
- ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
- break;
-
- default: /* Unknown opcode */
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- break;
- }
-
-Cleanup:
-
- /* Delete return object on error */
-
- if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
- {
- AcpiUtRemoveReference (ReturnDesc);
- WalkState->ResultObj = NULL;
- }
- else
- {
- /* Save the return value */
-
- WalkState->ResultObj = ReturnDesc;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_1A_0T_0R
- *
- * PARAMETERS: WalkState - Current state (contains AML opcode)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
- * object stack
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_1A_0T_0R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Examine the AML opcode */
-
- switch (WalkState->Opcode)
- {
- case AML_RELEASE_OP: /* Release (MutexObject) */
-
- Status = AcpiExReleaseMutex (Operand[0], WalkState);
- break;
-
-
- case AML_RESET_OP: /* Reset (EventObject) */
-
- Status = AcpiExSystemResetEvent (Operand[0]);
- break;
-
-
- case AML_SIGNAL_OP: /* Signal (EventObject) */
-
- Status = AcpiExSystemSignalEvent (Operand[0]);
- break;
-
-
- case AML_SLEEP_OP: /* Sleep (MsecTime) */
-
- Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
- break;
-
-
- case AML_STALL_OP: /* Stall (UsecTime) */
-
- Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
- break;
-
-
- case AML_UNLOAD_OP: /* Unload (Handle) */
-
- Status = AcpiExUnloadTable (Operand[0]);
- break;
-
-
- default: /* Unknown opcode */
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_1A_1T_0R
- *
- * PARAMETERS: WalkState - Current state (contains AML opcode)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute opcode with one argument, one target, and no
- * return value.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_1A_1T_0R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Examine the AML opcode */
-
- switch (WalkState->Opcode)
- {
- case AML_LOAD_OP:
-
- Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
- break;
-
- default: /* Unknown opcode */
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
-
-Cleanup:
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_1A_1T_1R
- *
- * PARAMETERS: WalkState - Current state (contains AML opcode)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute opcode with one argument, one target, and a
- * return value.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_1A_1T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
- ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
- UINT32 Temp32;
- UINT32 i;
- UINT64 PowerOfTen;
- UINT64 Digit;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Examine the AML opcode */
-
- switch (WalkState->Opcode)
- {
- case AML_BIT_NOT_OP:
- case AML_FIND_SET_LEFT_BIT_OP:
- case AML_FIND_SET_RIGHT_BIT_OP:
- case AML_FROM_BCD_OP:
- case AML_TO_BCD_OP:
- case AML_COND_REF_OF_OP:
-
- /* Create a return object of type Integer for these opcodes */
-
- ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- switch (WalkState->Opcode)
- {
- case AML_BIT_NOT_OP: /* Not (Operand, Result) */
-
- ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
- break;
-
-
- case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
-
- ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
-
- /*
- * Acpi specification describes Integer type as a little
- * endian unsigned value, so this boundary condition is valid.
- */
- for (Temp32 = 0; ReturnDesc->Integer.Value &&
- Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
- {
- ReturnDesc->Integer.Value >>= 1;
- }
-
- ReturnDesc->Integer.Value = Temp32;
- break;
-
-
- case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
-
- ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
-
- /*
- * The Acpi specification describes Integer type as a little
- * endian unsigned value, so this boundary condition is valid.
- */
- for (Temp32 = 0; ReturnDesc->Integer.Value &&
- Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
- {
- ReturnDesc->Integer.Value <<= 1;
- }
-
- /* Since the bit position is one-based, subtract from 33 (65) */
-
- ReturnDesc->Integer.Value =
- Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
- break;
-
-
- case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */
-
- /*
- * The 64-bit ACPI integer can hold 16 4-bit BCD characters
- * (if table is 32-bit, integer can hold 8 BCD characters)
- * Convert each 4-bit BCD value
- */
- PowerOfTen = 1;
- ReturnDesc->Integer.Value = 0;
- Digit = Operand[0]->Integer.Value;
-
- /* Convert each BCD digit (each is one nybble wide) */
-
- for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
- {
- /* Get the least significant 4-bit BCD digit */
-
- Temp32 = ((UINT32) Digit) & 0xF;
-
- /* Check the range of the digit */
-
- if (Temp32 > 9)
- {
- ACPI_ERROR ((AE_INFO,
- "BCD digit too large (not decimal): 0x%X",
- Temp32));
-
- Status = AE_AML_NUMERIC_OVERFLOW;
- goto Cleanup;
- }
-
- /* Sum the digit into the result with the current power of 10 */
-
- ReturnDesc->Integer.Value +=
- (((UINT64) Temp32) * PowerOfTen);
-
- /* Shift to next BCD digit */
-
- Digit >>= 4;
-
- /* Next power of 10 */
-
- PowerOfTen *= 10;
- }
- break;
-
-
- case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
-
- ReturnDesc->Integer.Value = 0;
- Digit = Operand[0]->Integer.Value;
-
- /* Each BCD digit is one nybble wide */
-
- for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
- {
- (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
-
- /*
- * Insert the BCD digit that resides in the
- * remainder from above
- */
- ReturnDesc->Integer.Value |=
- (((UINT64) Temp32) << ACPI_MUL_4 (i));
- }
-
- /* Overflow if there is any data left in Digit */
-
- if (Digit > 0)
- {
- ACPI_ERROR ((AE_INFO,
- "Integer too large to convert to BCD: 0x%8.8X%8.8X",
- ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
- Status = AE_AML_NUMERIC_OVERFLOW;
- goto Cleanup;
- }
- break;
-
-
- case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */
-
- /*
- * This op is a little strange because the internal return value is
- * different than the return value stored in the result descriptor
- * (There are really two return values)
- */
- if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
- {
- /*
- * This means that the object does not exist in the namespace,
- * return FALSE
- */
- ReturnDesc->Integer.Value = 0;
- goto Cleanup;
- }
-
- /* Get the object reference, store it, and remove our reference */
-
- Status = AcpiExGetObjectReference (Operand[0],
- &ReturnDesc2, WalkState);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
- AcpiUtRemoveReference (ReturnDesc2);
-
- /* The object exists in the namespace, return TRUE */
-
- ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
- goto Cleanup;
-
-
- default:
- /* No other opcodes get here */
- break;
- }
- break;
-
-
- case AML_STORE_OP: /* Store (Source, Target) */
-
- /*
- * A store operand is typically a number, string, buffer or lvalue
- * Be careful about deleting the source object,
- * since the object itself may have been stored.
- */
- Status = AcpiExStore (Operand[0], Operand[1], WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* It is possible that the Store already produced a return object */
-
- if (!WalkState->ResultObj)
- {
- /*
- * Normally, we would remove a reference on the Operand[0]
- * parameter; But since it is being used as the internal return
- * object (meaning we would normally increment it), the two
- * cancel out, and we simply don't do anything.
- */
- WalkState->ResultObj = Operand[0];
- WalkState->Operands[0] = NULL; /* Prevent deletion */
- }
- return_ACPI_STATUS (Status);
-
-
- /*
- * ACPI 2.0 Opcodes
- */
- case AML_COPY_OP: /* Copy (Source, Target) */
-
- Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
- WalkState);
- break;
-
-
- case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
-
- Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
- ACPI_EXPLICIT_CONVERT_DECIMAL);
- if (ReturnDesc == Operand[0])
- {
- /* No conversion performed, add ref to handle return value */
- AcpiUtAddReference (ReturnDesc);
- }
- break;
-
-
- case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
-
- Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
- ACPI_EXPLICIT_CONVERT_HEX);
- if (ReturnDesc == Operand[0])
- {
- /* No conversion performed, add ref to handle return value */
- AcpiUtAddReference (ReturnDesc);
- }
- break;
-
-
- case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
-
- Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
- if (ReturnDesc == Operand[0])
- {
- /* No conversion performed, add ref to handle return value */
- AcpiUtAddReference (ReturnDesc);
- }
- break;
-
-
- case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
-
- Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
- ACPI_ANY_BASE);
- if (ReturnDesc == Operand[0])
- {
- /* No conversion performed, add ref to handle return value */
- AcpiUtAddReference (ReturnDesc);
- }
- break;
-
-
- case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
- case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
-
- /* These are two obsolete opcodes */
-
- ACPI_ERROR ((AE_INFO,
- "%s is obsolete and not implemented",
- AcpiPsGetOpcodeName (WalkState->Opcode)));
- Status = AE_SUPPORT;
- goto Cleanup;
-
-
- default: /* Unknown opcode */
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
- if (ACPI_SUCCESS (Status))
- {
- /* Store the return value computed above into the target object */
-
- Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
- }
-
-
-Cleanup:
-
- /* Delete return object on error */
-
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (ReturnDesc);
- }
-
- /* Save return object on success */
-
- else if (!WalkState->ResultObj)
- {
- WalkState->ResultObj = ReturnDesc;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_1A_0T_1R
- *
- * PARAMETERS: WalkState - Current state (contains AML opcode)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute opcode with one argument, no target, and a return value
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_1A_0T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *TempDesc;
- ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
- ACPI_STATUS Status = AE_OK;
- UINT32 Type;
- UINT64 Value;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Examine the AML opcode */
-
- switch (WalkState->Opcode)
- {
- case AML_LNOT_OP: /* LNot (Operand) */
-
- ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /*
- * Set result to ONES (TRUE) if Value == 0. Note:
- * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
- */
- if (!Operand[0]->Integer.Value)
- {
- ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
- }
- break;
-
-
- case AML_DECREMENT_OP: /* Decrement (Operand) */
- case AML_INCREMENT_OP: /* Increment (Operand) */
-
- /*
- * Create a new integer. Can't just get the base integer and
- * increment it because it may be an Arg or Field.
- */
- ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /*
- * Since we are expecting a Reference operand, it can be either a
- * NS Node or an internal object.
- */
- TempDesc = Operand[0];
- if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
- {
- /* Internal reference object - prevent deletion */
-
- AcpiUtAddReference (TempDesc);
- }
-
- /*
- * Convert the Reference operand to an Integer (This removes a
- * reference on the Operand[0] object)
- *
- * NOTE: We use LNOT_OP here in order to force resolution of the
- * reference operand to an actual integer.
- */
- Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "While resolving operands for [%s]",
- AcpiPsGetOpcodeName (WalkState->Opcode)));
-
- goto Cleanup;
- }
-
- /*
- * TempDesc is now guaranteed to be an Integer object --
- * Perform the actual increment or decrement
- */
- if (WalkState->Opcode == AML_INCREMENT_OP)
- {
- ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
- }
- else
- {
- ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
- }
-
- /* Finished with this Integer object */
-
- AcpiUtRemoveReference (TempDesc);
-
- /*
- * Store the result back (indirectly) through the original
- * Reference object
- */
- Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
- break;
-
-
- case AML_TYPE_OP: /* ObjectType (SourceObject) */
-
- /*
- * Note: The operand is not resolved at this point because we want to
- * get the associated object, not its value. For example, we don't
- * want to resolve a FieldUnit to its value, we want the actual
- * FieldUnit object.
- */
-
- /* Get the type of the base object */
-
- Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /* Allocate a descriptor to hold the type. */
-
- ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
- break;
-
-
- case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
-
- /*
- * Note: The operand is not resolved at this point because we want to
- * get the associated object, not its value.
- */
-
- /* Get the base object */
-
- Status = AcpiExResolveMultiple (WalkState,
- Operand[0], &Type, &TempDesc);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /*
- * The type of the base object must be integer, buffer, string, or
- * package. All others are not supported.
- *
- * NOTE: Integer is not specifically supported by the ACPI spec,
- * but is supported implicitly via implicit operand conversion.
- * rather than bother with conversion, we just use the byte width
- * global (4 or 8 bytes).
- */
- switch (Type)
- {
- case ACPI_TYPE_INTEGER:
- Value = AcpiGbl_IntegerByteWidth;
- break;
-
- case ACPI_TYPE_STRING:
- Value = TempDesc->String.Length;
- break;
-
- case ACPI_TYPE_BUFFER:
-
- /* Buffer arguments may not be evaluated at this point */
-
- Status = AcpiDsGetBufferArguments (TempDesc);
- Value = TempDesc->Buffer.Length;
- break;
-
- case ACPI_TYPE_PACKAGE:
-
- /* Package arguments may not be evaluated at this point */
-
- Status = AcpiDsGetPackageArguments (TempDesc);
- Value = TempDesc->Package.Count;
- break;
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Operand must be Buffer/Integer/String/Package - found type %s",
- AcpiUtGetTypeName (Type)));
- Status = AE_AML_OPERAND_TYPE;
- goto Cleanup;
- }
-
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /*
- * Now that we have the size of the object, create a result
- * object to hold the value
- */
- ReturnDesc = AcpiUtCreateIntegerObject (Value);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
- break;
-
-
- case AML_REF_OF_OP: /* RefOf (SourceObject) */
-
- Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
- break;
-
-
- case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */
-
- /* Check for a method local or argument, or standalone String */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
- {
- TempDesc = AcpiNsGetAttachedObject (
- (ACPI_NAMESPACE_NODE *) Operand[0]);
- if (TempDesc &&
- ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
- (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
- {
- Operand[0] = TempDesc;
- AcpiUtAddReference (TempDesc);
- }
- else
- {
- Status = AE_AML_OPERAND_TYPE;
- goto Cleanup;
- }
- }
- else
- {
- switch ((Operand[0])->Common.Type)
- {
- case ACPI_TYPE_LOCAL_REFERENCE:
- /*
- * This is a DerefOf (LocalX | ArgX)
- *
- * Must resolve/dereference the local/arg reference first
- */
- switch (Operand[0]->Reference.Class)
- {
- case ACPI_REFCLASS_LOCAL:
- case ACPI_REFCLASS_ARG:
-
- /* Set Operand[0] to the value of the local/arg */
-
- Status = AcpiDsMethodDataGetValue (
- Operand[0]->Reference.Class,
- Operand[0]->Reference.Value,
- WalkState, &TempDesc);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /*
- * Delete our reference to the input object and
- * point to the object just retrieved
- */
- AcpiUtRemoveReference (Operand[0]);
- Operand[0] = TempDesc;
- break;
-
- case ACPI_REFCLASS_REFOF:
-
- /* Get the object to which the reference refers */
-
- TempDesc = Operand[0]->Reference.Object;
- AcpiUtRemoveReference (Operand[0]);
- Operand[0] = TempDesc;
- break;
-
- default:
-
- /* Must be an Index op - handled below */
- break;
- }
- break;
-
- case ACPI_TYPE_STRING:
- break;
-
- default:
- Status = AE_AML_OPERAND_TYPE;
- goto Cleanup;
- }
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
- {
- if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
- {
- /*
- * This is a DerefOf (String). The string is a reference
- * to a named ACPI object.
- *
- * 1) Find the owning Node
- * 2) Dereference the node to an actual object. Could be a
- * Field, so we need to resolve the node to a value.
- */
- Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
- Operand[0]->String.Pointer,
- ACPI_NS_SEARCH_PARENT,
- ACPI_CAST_INDIRECT_PTR (
- ACPI_NAMESPACE_NODE, &ReturnDesc));
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- Status = AcpiExResolveNodeToValue (
- ACPI_CAST_INDIRECT_PTR (
- ACPI_NAMESPACE_NODE, &ReturnDesc),
- WalkState);
- goto Cleanup;
- }
- }
-
- /* Operand[0] may have changed from the code above */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
- {
- /*
- * This is a DerefOf (ObjectReference)
- * Get the actual object from the Node (This is the dereference).
- * This case may only happen when a LocalX or ArgX is
- * dereferenced above.
- */
- ReturnDesc = AcpiNsGetAttachedObject (
- (ACPI_NAMESPACE_NODE *) Operand[0]);
- AcpiUtAddReference (ReturnDesc);
- }
- else
- {
- /*
- * This must be a reference object produced by either the
- * Index() or RefOf() operator
- */
- switch (Operand[0]->Reference.Class)
- {
- case ACPI_REFCLASS_INDEX:
-
- /*
- * The target type for the Index operator must be
- * either a Buffer or a Package
- */
- switch (Operand[0]->Reference.TargetType)
- {
- case ACPI_TYPE_BUFFER_FIELD:
-
- TempDesc = Operand[0]->Reference.Object;
-
- /*
- * Create a new object that contains one element of the
- * buffer -- the element pointed to by the index.
- *
- * NOTE: index into a buffer is NOT a pointer to a
- * sub-buffer of the main buffer, it is only a pointer to a
- * single element (byte) of the buffer!
- *
- * Since we are returning the value of the buffer at the
- * indexed location, we don't need to add an additional
- * reference to the buffer itself.
- */
- ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
- TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
- break;
-
-
- case ACPI_TYPE_PACKAGE:
-
- /*
- * Return the referenced element of the package. We must
- * add another reference to the referenced object, however.
- */
- ReturnDesc = *(Operand[0]->Reference.Where);
- if (ReturnDesc)
- {
- AcpiUtAddReference (ReturnDesc);
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO,
- "Unknown Index TargetType 0x%X in reference object %p",
- Operand[0]->Reference.TargetType, Operand[0]));
- Status = AE_AML_OPERAND_TYPE;
- goto Cleanup;
- }
- break;
-
-
- case ACPI_REFCLASS_REFOF:
-
- ReturnDesc = Operand[0]->Reference.Object;
-
- if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
- ACPI_DESC_TYPE_NAMED)
- {
- ReturnDesc = AcpiNsGetAttachedObject (
- (ACPI_NAMESPACE_NODE *) ReturnDesc);
- }
-
- /* Add another reference to the object! */
-
- AcpiUtAddReference (ReturnDesc);
- break;
-
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Unknown class in reference(%p) - 0x%2.2X",
- Operand[0], Operand[0]->Reference.Class));
-
- Status = AE_TYPE;
- goto Cleanup;
- }
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
-
-Cleanup:
-
- /* Delete return object on error */
-
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (ReturnDesc);
- }
-
- /* Save return object on success */
-
- else
- {
- WalkState->ResultObj = ReturnDesc;
- }
-
- return_ACPI_STATUS (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exoparg2.c
--- a/head/sys/contrib/dev/acpica/executer/exoparg2.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-/******************************************************************************
- *
- * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
- *
- *****************************************************************************/
-
-/*
- * 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 __EXOPARG2_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/acinterp.h>
-#include <contrib/dev/acpica/include/acevents.h>
-#include <contrib/dev/acpica/include/amlcode.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exoparg2")
-
-
-/*!
- * Naming convention for AML interpreter execution routines.
- *
- * The routines that begin execution of AML opcodes are named with a common
- * convention based upon the number of arguments, the number of target operands,
- * and whether or not a value is returned:
- *
- * AcpiExOpcode_xA_yT_zR
- *
- * Where:
- *
- * xA - ARGUMENTS: The number of arguments (input operands) that are
- * required for this opcode type (1 through 6 args).
- * yT - TARGETS: The number of targets (output operands) that are required
- * for this opcode type (0, 1, or 2 targets).
- * zR - RETURN VALUE: Indicates whether this opcode type returns a value
- * as the function return (0 or 1).
- *
- * The AcpiExOpcode* functions are called via the Dispatcher component with
- * fully resolved operands.
-!*/
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_2A_0T_0R
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute opcode with two arguments, no target, and no return
- * value.
- *
- * ALLOCATION: Deletes both operands
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_2A_0T_0R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_NAMESPACE_NODE *Node;
- UINT32 Value;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Examine the opcode */
-
- switch (WalkState->Opcode)
- {
- case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */
-
- /* The first operand is a namespace node */
-
- Node = (ACPI_NAMESPACE_NODE *) Operand[0];
-
- /* Second value is the notify value */
-
- Value = (UINT32) Operand[1]->Integer.Value;
-
- /* Are notifies allowed on this object? */
-
- if (!AcpiEvIsNotifyObject (Node))
- {
- ACPI_ERROR ((AE_INFO,
- "Unexpected notify object type [%s]",
- AcpiUtGetTypeName (Node->Type)));
-
- Status = AE_AML_OPERAND_TYPE;
- break;
- }
-
- /*
- * Dispatch the notify to the appropriate handler
- * NOTE: the request is queued for execution after this method
- * completes. The notify handlers are NOT invoked synchronously
- * from this thread -- because handlers may in turn run other
- * control methods.
- */
- Status = AcpiEvQueueNotifyRequest (Node, Value);
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_2A_2T_1R
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
- * and one implicit return value.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_2A_2T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL;
- ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Execute the opcode */
-
- switch (WalkState->Opcode)
- {
- case AML_DIVIDE_OP:
-
- /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */
-
- ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc1)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc2)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */
-
- Status = AcpiUtDivide (Operand[0]->Integer.Value,
- Operand[1]->Integer.Value,
- &ReturnDesc1->Integer.Value,
- &ReturnDesc2->Integer.Value);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
- /* Store the results to the target reference operands */
-
- Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
-Cleanup:
- /*
- * Since the remainder is not returned indirectly, remove a reference to
- * it. Only the quotient is returned indirectly.
- */
- AcpiUtRemoveReference (ReturnDesc2);
-
- if (ACPI_FAILURE (Status))
- {
- /* Delete the return object */
-
- AcpiUtRemoveReference (ReturnDesc1);
- }
-
- /* Save return object (the remainder) on success */
-
- else
- {
- WalkState->ResultObj = ReturnDesc1;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_2A_1T_1R
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute opcode with two arguments, one target, and a return
- * value.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_2A_1T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
- UINT64 Index;
- ACPI_STATUS Status = AE_OK;
- ACPI_SIZE Length;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Execute the opcode */
-
- if (WalkState->OpInfo->Flags & AML_MATH)
- {
- /* All simple math opcodes (add, etc.) */
-
- ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode,
- Operand[0]->Integer.Value,
- Operand[1]->Integer.Value);
- goto StoreResultToTarget;
- }
-
- switch (WalkState->Opcode)
- {
- case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
-
- ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* ReturnDesc will contain the remainder */
-
- Status = AcpiUtDivide (Operand[0]->Integer.Value,
- Operand[1]->Integer.Value,
- NULL,
- &ReturnDesc->Integer.Value);
- break;
-
-
- case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
-
- Status = AcpiExDoConcatenate (Operand[0], Operand[1],
- &ReturnDesc, WalkState);
- break;
-
-
- case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
-
- /*
- * Input object is guaranteed to be a buffer at this point (it may have
- * been converted.) Copy the raw buffer data to a new object of
- * type String.
- */
-
- /*
- * Get the length of the new string. It is the smallest of:
- * 1) Length of the input buffer
- * 2) Max length as specified in the ToString operator
- * 3) Length of input buffer up to a zero byte (null terminator)
- *
- * NOTE: A length of zero is ok, and will create a zero-length, null
- * terminated string.
- */
- Length = 0;
- while ((Length < Operand[0]->Buffer.Length) &&
- (Length < Operand[1]->Integer.Value) &&
- (Operand[0]->Buffer.Pointer[Length]))
- {
- Length++;
- }
-
- /* Allocate a new string object */
-
- ReturnDesc = AcpiUtCreateStringObject (Length);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /*
- * Copy the raw buffer data with no transform.
- * (NULL terminated already)
- */
- ACPI_MEMCPY (ReturnDesc->String.Pointer,
- Operand[0]->Buffer.Pointer, Length);
- break;
-
-
- case AML_CONCAT_RES_OP:
-
- /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
-
- Status = AcpiExConcatTemplate (Operand[0], Operand[1],
- &ReturnDesc, WalkState);
- break;
-
-
- case AML_INDEX_OP: /* Index (Source Index Result) */
-
- /* Create the internal return object */
-
- ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Initialize the Index reference object */
-
- Index = Operand[1]->Integer.Value;
- ReturnDesc->Reference.Value = (UINT32) Index;
- ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX;
-
- /*
- * At this point, the Source operand is a String, Buffer, or Package.
- * Verify that the index is within range.
- */
- switch ((Operand[0])->Common.Type)
- {
- case ACPI_TYPE_STRING:
-
- if (Index >= Operand[0]->String.Length)
- {
- Status = AE_AML_STRING_LIMIT;
- }
-
- ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
- break;
-
- case ACPI_TYPE_BUFFER:
-
- if (Index >= Operand[0]->Buffer.Length)
- {
- Status = AE_AML_BUFFER_LIMIT;
- }
-
- ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;
- break;
-
- case ACPI_TYPE_PACKAGE:
-
- if (Index >= Operand[0]->Package.Count)
- {
- Status = AE_AML_PACKAGE_LIMIT;
- }
-
- ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;
- ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index];
- break;
-
- default:
-
- Status = AE_AML_INTERNAL;
- goto Cleanup;
- }
-
- /* Failure means that the Index was beyond the end of the object */
-
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Index (0x%8.8X%8.8X) is beyond end of object",
- ACPI_FORMAT_UINT64 (Index)));
- goto Cleanup;
- }
-
- /*
- * Save the target object and add a reference to it for the life
- * of the index
- */
- ReturnDesc->Reference.Object = Operand[0];
- AcpiUtAddReference (Operand[0]);
-
- /* Store the reference to the Target */
-
- Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
-
- /* Return the reference */
-
- WalkState->ResultObj = ReturnDesc;
- goto Cleanup;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- break;
- }
-
-
-StoreResultToTarget:
-
- if (ACPI_SUCCESS (Status))
- {
- /*
- * Store the result of the operation (which is now in ReturnDesc) into
- * the Target descriptor.
- */
- Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- if (!WalkState->ResultObj)
- {
- WalkState->ResultObj = ReturnDesc;
- }
- }
-
-
-Cleanup:
-
- /* Delete return object on error */
-
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (ReturnDesc);
- WalkState->ResultObj = NULL;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_2A_0T_1R
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_2A_0T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
- ACPI_STATUS Status = AE_OK;
- BOOLEAN LogicalResult = FALSE;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- /* Create the internal return object */
-
- ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Execute the Opcode */
-
- if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)
- {
- /* LogicalOp (Operand0, Operand1) */
-
- Status = AcpiExDoLogicalNumericOp (WalkState->Opcode,
- Operand[0]->Integer.Value, Operand[1]->Integer.Value,
- &LogicalResult);
- goto StoreLogicalResult;
- }
- else if (WalkState->OpInfo->Flags & AML_LOGICAL)
- {
- /* LogicalOp (Operand0, Operand1) */
-
- Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],
- Operand[1], &LogicalResult);
- goto StoreLogicalResult;
- }
-
- switch (WalkState->Opcode)
- {
- case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */
-
- Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
- if (Status == AE_TIME)
- {
- LogicalResult = TRUE; /* TRUE = Acquire timed out */
- Status = AE_OK;
- }
- break;
-
-
- case AML_WAIT_OP: /* Wait (EventObject, Timeout) */
-
- Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
- if (Status == AE_TIME)
- {
- LogicalResult = TRUE; /* TRUE, Wait timed out */
- Status = AE_OK;
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
-
-StoreLogicalResult:
- /*
- * Set return value to according to LogicalResult. logical TRUE (all ones)
- * Default is FALSE (zero)
- */
- if (LogicalResult)
- {
- ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
- }
-
-Cleanup:
-
- /* Delete return object on error */
-
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (ReturnDesc);
- }
-
- /* Save return object on success */
-
- else
- {
- WalkState->ResultObj = ReturnDesc;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exoparg3.c
--- a/head/sys/contrib/dev/acpica/executer/exoparg3.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
- *
- *****************************************************************************/
-
-/*
- * 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 __EXOPARG3_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/acparser.h>
-#include <contrib/dev/acpica/include/amlcode.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exoparg3")
-
-
-/*!
- * Naming convention for AML interpreter execution routines.
- *
- * The routines that begin execution of AML opcodes are named with a common
- * convention based upon the number of arguments, the number of target operands,
- * and whether or not a value is returned:
- *
- * AcpiExOpcode_xA_yT_zR
- *
- * Where:
- *
- * xA - ARGUMENTS: The number of arguments (input operands) that are
- * required for this opcode type (1 through 6 args).
- * yT - TARGETS: The number of targets (output operands) that are required
- * for this opcode type (0, 1, or 2 targets).
- * zR - RETURN VALUE: Indicates whether this opcode type returns a value
- * as the function return (0 or 1).
- *
- * The AcpiExOpcode* functions are called via the Dispatcher component with
- * fully resolved operands.
-!*/
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_3A_0T_0R
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute Triadic operator (3 operands)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_3A_0T_0R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_SIGNAL_FATAL_INFO *Fatal;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- switch (WalkState->Opcode)
- {
- case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
- (UINT32) Operand[0]->Integer.Value,
- (UINT32) Operand[1]->Integer.Value,
- (UINT32) Operand[2]->Integer.Value));
-
- Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO));
- if (Fatal)
- {
- Fatal->Type = (UINT32) Operand[0]->Integer.Value;
- Fatal->Code = (UINT32) Operand[1]->Integer.Value;
- Fatal->Argument = (UINT32) Operand[2]->Integer.Value;
- }
-
- /* Always signal the OS! */
-
- Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal);
-
- /* Might return while OS is shutting down, just continue */
-
- ACPI_FREE (Fatal);
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
-
-Cleanup:
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_3A_1T_1R
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute Triadic operator (3 operands)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_3A_1T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
- char *Buffer = NULL;
- ACPI_STATUS Status = AE_OK;
- UINT64 Index;
- ACPI_SIZE Length;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- switch (WalkState->Opcode)
- {
- case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
-
- /*
- * Create the return object. The Source operand is guaranteed to be
- * either a String or a Buffer, so just use its type.
- */
- ReturnDesc = AcpiUtCreateInternalObject (
- (Operand[0])->Common.Type);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Get the Integer values from the objects */
-
- Index = Operand[1]->Integer.Value;
- Length = (ACPI_SIZE) Operand[2]->Integer.Value;
-
- /*
- * If the index is beyond the length of the String/Buffer, or if the
- * requested length is zero, return a zero-length String/Buffer
- */
- if (Index >= Operand[0]->String.Length)
- {
- Length = 0;
- }
-
- /* Truncate request if larger than the actual String/Buffer */
-
- else if ((Index + Length) > Operand[0]->String.Length)
- {
- Length = (ACPI_SIZE) Operand[0]->String.Length -
- (ACPI_SIZE) Index;
- }
-
- /* Strings always have a sub-pointer, not so for buffers */
-
- switch ((Operand[0])->Common.Type)
- {
- case ACPI_TYPE_STRING:
-
- /* Always allocate a new buffer for the String */
-
- Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1);
- if (!Buffer)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
- break;
-
- case ACPI_TYPE_BUFFER:
-
- /* If the requested length is zero, don't allocate a buffer */
-
- if (Length > 0)
- {
- /* Allocate a new buffer for the Buffer */
-
- Buffer = ACPI_ALLOCATE_ZEROED (Length);
- if (!Buffer)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
- }
- break;
-
- default: /* Should not happen */
-
- Status = AE_AML_OPERAND_TYPE;
- goto Cleanup;
- }
-
- if (Buffer)
- {
- /* We have a buffer, copy the portion requested */
-
- ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index,
- Length);
- }
-
- /* Set the length of the new String/Buffer */
-
- ReturnDesc->String.Pointer = Buffer;
- ReturnDesc->String.Length = (UINT32) Length;
-
- /* Mark buffer initialized */
-
- ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
- /* Store the result in the target */
-
- Status = AcpiExStore (ReturnDesc, Operand[3], WalkState);
-
-Cleanup:
-
- /* Delete return object on error */
-
- if (ACPI_FAILURE (Status) || WalkState->ResultObj)
- {
- AcpiUtRemoveReference (ReturnDesc);
- WalkState->ResultObj = NULL;
- }
-
- /* Set the return object and exit */
-
- else
- {
- WalkState->ResultObj = ReturnDesc;
- }
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exoparg6.c
--- a/head/sys/contrib/dev/acpica/executer/exoparg6.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
- *
- *****************************************************************************/
-
-/*
- * 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 __EXOPARG6_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/acparser.h>
-#include <contrib/dev/acpica/include/amlcode.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exoparg6")
-
-
-/*!
- * Naming convention for AML interpreter execution routines.
- *
- * The routines that begin execution of AML opcodes are named with a common
- * convention based upon the number of arguments, the number of target operands,
- * and whether or not a value is returned:
- *
- * AcpiExOpcode_xA_yT_zR
- *
- * Where:
- *
- * xA - ARGUMENTS: The number of arguments (input operands) that are
- * required for this opcode type (1 through 6 args).
- * yT - TARGETS: The number of targets (output operands) that are required
- * for this opcode type (0, 1, or 2 targets).
- * zR - RETURN VALUE: Indicates whether this opcode type returns a value
- * as the function return (0 or 1).
- *
- * The AcpiExOpcode* functions are called via the Dispatcher component with
- * fully resolved operands.
-!*/
-
-/* Local prototypes */
-
-static BOOLEAN
-AcpiExDoMatch (
- UINT32 MatchOp,
- ACPI_OPERAND_OBJECT *PackageObj,
- ACPI_OPERAND_OBJECT *MatchObj);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDoMatch
- *
- * PARAMETERS: MatchOp - The AML match operand
- * PackageObj - Object from the target package
- * MatchObj - Object to be matched
- *
- * RETURN: TRUE if the match is successful, FALSE otherwise
- *
- * DESCRIPTION: Implements the low-level match for the ASL Match operator.
- * Package elements will be implicitly converted to the type of
- * the match object (Integer/Buffer/String).
- *
- ******************************************************************************/
-
-static BOOLEAN
-AcpiExDoMatch (
- UINT32 MatchOp,
- ACPI_OPERAND_OBJECT *PackageObj,
- ACPI_OPERAND_OBJECT *MatchObj)
-{
- BOOLEAN LogicalResult = TRUE;
- ACPI_STATUS Status;
-
-
- /*
- * Note: Since the PackageObj/MatchObj ordering is opposite to that of
- * the standard logical operators, we have to reverse them when we call
- * DoLogicalOp in order to make the implicit conversion rules work
- * correctly. However, this means we have to flip the entire equation
- * also. A bit ugly perhaps, but overall, better than fussing the
- * parameters around at runtime, over and over again.
- *
- * Below, P[i] refers to the package element, M refers to the Match object.
- */
- switch (MatchOp)
- {
- case MATCH_MTR:
-
- /* Always true */
-
- break;
-
- case MATCH_MEQ:
-
- /*
- * True if equal: (P[i] == M)
- * Change to: (M == P[i])
- */
- Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj,
- &LogicalResult);
- if (ACPI_FAILURE (Status))
- {
- return (FALSE);
- }
- break;
-
- case MATCH_MLE:
-
- /*
- * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M)
- * Change to: (M >= P[i]) (M NotLess than P[i])
- */
- Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
- &LogicalResult);
- if (ACPI_FAILURE (Status))
- {
- return (FALSE);
- }
- LogicalResult = (BOOLEAN) !LogicalResult;
- break;
-
- case MATCH_MLT:
-
- /*
- * True if less than: (P[i] < M)
- * Change to: (M > P[i])
- */
- Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
- &LogicalResult);
- if (ACPI_FAILURE (Status))
- {
- return (FALSE);
- }
- break;
-
- case MATCH_MGE:
-
- /*
- * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M)
- * Change to: (M <= P[i]) (M NotGreater than P[i])
- */
- Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj,
- &LogicalResult);
- if (ACPI_FAILURE (Status))
- {
- return (FALSE);
- }
- LogicalResult = (BOOLEAN)!LogicalResult;
- break;
-
- case MATCH_MGT:
-
- /*
- * True if greater than: (P[i] > M)
- * Change to: (M < P[i])
- */
- Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj,
- &LogicalResult);
- if (ACPI_FAILURE (Status))
- {
- return (FALSE);
- }
- break;
-
- default:
-
- /* Undefined */
-
- return (FALSE);
- }
-
- return LogicalResult;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExOpcode_6A_0T_1R
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExOpcode_6A_0T_1R (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
- ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
- ACPI_STATUS Status = AE_OK;
- UINT64 Index;
- ACPI_OPERAND_OBJECT *ThisElement;
-
-
- ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R,
- AcpiPsGetOpcodeName (WalkState->Opcode));
-
-
- switch (WalkState->Opcode)
- {
- case AML_MATCH_OP:
- /*
- * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2],
- * MatchOp2[3], MatchObj2[4], StartIndex[5])
- */
-
- /* Validate both Match Term Operators (MTR, MEQ, etc.) */
-
- if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) ||
- (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR))
- {
- ACPI_ERROR ((AE_INFO, "Match operator out of range"));
- Status = AE_AML_OPERAND_VALUE;
- goto Cleanup;
- }
-
- /* Get the package StartIndex, validate against the package length */
-
- Index = Operand[5]->Integer.Value;
- if (Index >= Operand[0]->Package.Count)
- {
- ACPI_ERROR ((AE_INFO,
- "Index (0x%8.8X%8.8X) beyond package end (0x%X)",
- ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count));
- Status = AE_AML_PACKAGE_LIMIT;
- goto Cleanup;
- }
-
- /* Create an integer for the return value */
- /* Default return value is ACPI_UINT64_MAX if no match found */
-
- ReturnDesc = AcpiUtCreateIntegerObject (ACPI_UINT64_MAX);
- if (!ReturnDesc)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
-
- }
-
- /*
- * Examine each element until a match is found. Both match conditions
- * must be satisfied for a match to occur. Within the loop,
- * "continue" signifies that the current element does not match
- * and the next should be examined.
- *
- * Upon finding a match, the loop will terminate via "break" at
- * the bottom. If it terminates "normally", MatchValue will be
- * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no
- * match was found.
- */
- for ( ; Index < Operand[0]->Package.Count; Index++)
- {
- /* Get the current package element */
-
- ThisElement = Operand[0]->Package.Elements[Index];
-
- /* Treat any uninitialized (NULL) elements as non-matching */
-
- if (!ThisElement)
- {
- continue;
- }
-
- /*
- * Both match conditions must be satisfied. Execution of a continue
- * (proceed to next iteration of enclosing for loop) signifies a
- * non-match.
- */
- if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value,
- ThisElement, Operand[2]))
- {
- continue;
- }
-
- if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value,
- ThisElement, Operand[4]))
- {
- continue;
- }
-
- /* Match found: Index is the return value */
-
- ReturnDesc->Integer.Value = Index;
- break;
- }
- break;
-
-
- case AML_LOAD_TABLE_OP:
-
- Status = AcpiExLoadTableOp (WalkState, &ReturnDesc);
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- WalkState->Opcode));
- Status = AE_AML_BAD_OPCODE;
- goto Cleanup;
- }
-
-
-Cleanup:
-
- /* Delete return object on error */
-
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (ReturnDesc);
- }
-
- /* Save return object on success */
-
- else
- {
- WalkState->ResultObj = ReturnDesc;
- }
-
- return_ACPI_STATUS (Status);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exprep.c
--- a/head/sys/contrib/dev/acpica/executer/exprep.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,648 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exprep - ACPI AML (p-code) execution - field prep 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 __EXPREP_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>
-#include <contrib/dev/acpica/include/acnamesp.h>
-#include <contrib/dev/acpica/include/acdispat.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exprep")
-
-/* Local prototypes */
-
-static UINT32
-AcpiExDecodeFieldAccess (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT8 FieldFlags,
- UINT32 *ReturnByteAlignment);
-
-
-#ifdef ACPI_UNDER_DEVELOPMENT
-
-static UINT32
-AcpiExGenerateAccess (
- UINT32 FieldBitOffset,
- UINT32 FieldBitLength,
- UINT32 RegionLength);
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExGenerateAccess
- *
- * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer
- * FieldBitLength - Length of field in bits
- * RegionLength - Length of parent in bytes
- *
- * RETURN: Field granularity (8, 16, 32 or 64) and
- * ByteAlignment (1, 2, 3, or 4)
- *
- * DESCRIPTION: Generate an optimal access width for fields defined with the
- * AnyAcc keyword.
- *
- * NOTE: Need to have the RegionLength in order to check for boundary
- * conditions (end-of-region). However, the RegionLength is a deferred
- * operation. Therefore, to complete this implementation, the generation
- * of this access width must be deferred until the region length has
- * been evaluated.
- *
- ******************************************************************************/
-
-static UINT32
-AcpiExGenerateAccess (
- UINT32 FieldBitOffset,
- UINT32 FieldBitLength,
- UINT32 RegionLength)
-{
- UINT32 FieldByteLength;
- UINT32 FieldByteOffset;
- UINT32 FieldByteEndOffset;
- UINT32 AccessByteWidth;
- UINT32 FieldStartOffset;
- UINT32 FieldEndOffset;
- UINT32 MinimumAccessWidth = 0xFFFFFFFF;
- UINT32 MinimumAccesses = 0xFFFFFFFF;
- UINT32 Accesses;
-
-
- ACPI_FUNCTION_TRACE (ExGenerateAccess);
-
-
- /* Round Field start offset and length to "minimal" byte boundaries */
-
- FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8));
- FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength +
- FieldBitOffset, 8));
- FieldByteLength = FieldByteEndOffset - FieldByteOffset;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Bit length %u, Bit offset %u\n",
- FieldBitLength, FieldBitOffset));
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Byte Length %u, Byte Offset %u, End Offset %u\n",
- FieldByteLength, FieldByteOffset, FieldByteEndOffset));
-
- /*
- * Iterative search for the maximum access width that is both aligned
- * and does not go beyond the end of the region
- *
- * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes)
- */
- for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1)
- {
- /*
- * 1) Round end offset up to next access boundary and make sure that
- * this does not go beyond the end of the parent region.
- * 2) When the Access width is greater than the FieldByteLength, we
- * are done. (This does not optimize for the perfectly aligned
- * case yet).
- */
- if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength)
- {
- FieldStartOffset =
- ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) /
- AccessByteWidth;
-
- FieldEndOffset =
- ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset),
- AccessByteWidth) / AccessByteWidth;
-
- Accesses = FieldEndOffset - FieldStartOffset;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "AccessWidth %u end is within region\n", AccessByteWidth));
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Field Start %u, Field End %u -- requires %u accesses\n",
- FieldStartOffset, FieldEndOffset, Accesses));
-
- /* Single access is optimal */
-
- if (Accesses <= 1)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Entire field can be accessed with one operation of size %u\n",
- AccessByteWidth));
- return_VALUE (AccessByteWidth);
- }
-
- /*
- * Fits in the region, but requires more than one read/write.
- * try the next wider access on next iteration
- */
- if (Accesses < MinimumAccesses)
- {
- MinimumAccesses = Accesses;
- MinimumAccessWidth = AccessByteWidth;
- }
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "AccessWidth %u end is NOT within region\n", AccessByteWidth));
- if (AccessByteWidth == 1)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Field goes beyond end-of-region!\n"));
-
- /* Field does not fit in the region at all */
-
- return_VALUE (0);
- }
-
- /*
- * This width goes beyond the end-of-region, back off to
- * previous access
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Backing off to previous optimal access width of %u\n",
- MinimumAccessWidth));
- return_VALUE (MinimumAccessWidth);
- }
- }
-
- /*
- * Could not read/write field with one operation,
- * just use max access width
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Cannot access field in one operation, using width 8\n"));
- return_VALUE (8);
-}
-#endif /* ACPI_UNDER_DEVELOPMENT */
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDecodeFieldAccess
- *
- * PARAMETERS: ObjDesc - Field object
- * FieldFlags - Encoded fieldflags (contains access bits)
- * ReturnByteAlignment - Where the byte alignment is returned
- *
- * RETURN: Field granularity (8, 16, 32 or 64) and
- * ByteAlignment (1, 2, 3, or 4)
- *
- * DESCRIPTION: Decode the AccessType bits of a field definition.
- *
- ******************************************************************************/
-
-static UINT32
-AcpiExDecodeFieldAccess (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT8 FieldFlags,
- UINT32 *ReturnByteAlignment)
-{
- UINT32 Access;
- UINT32 ByteAlignment;
- UINT32 BitLength;
-
-
- ACPI_FUNCTION_TRACE (ExDecodeFieldAccess);
-
-
- Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK);
-
- switch (Access)
- {
- case AML_FIELD_ACCESS_ANY:
-
-#ifdef ACPI_UNDER_DEVELOPMENT
- ByteAlignment =
- AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset,
- ObjDesc->CommonField.BitLength,
- 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */);
- BitLength = ByteAlignment * 8;
-#endif
-
- ByteAlignment = 1;
- BitLength = 8;
- break;
-
- case AML_FIELD_ACCESS_BYTE:
- case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */
- ByteAlignment = 1;
- BitLength = 8;
- break;
-
- case AML_FIELD_ACCESS_WORD:
- ByteAlignment = 2;
- BitLength = 16;
- break;
-
- case AML_FIELD_ACCESS_DWORD:
- ByteAlignment = 4;
- BitLength = 32;
- break;
-
- case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
- ByteAlignment = 8;
- BitLength = 64;
- break;
-
- default:
- /* Invalid field access type */
-
- ACPI_ERROR ((AE_INFO,
- "Unknown field access type 0x%X",
- Access));
- return_UINT32 (0);
- }
-
- if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
- {
- /*
- * BufferField access can be on any byte boundary, so the
- * ByteAlignment is always 1 byte -- regardless of any ByteAlignment
- * implied by the field access type.
- */
- ByteAlignment = 1;
- }
-
- *ReturnByteAlignment = ByteAlignment;
- return_UINT32 (BitLength);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExPrepCommonFieldObject
- *
- * PARAMETERS: ObjDesc - The field object
- * FieldFlags - Access, LockRule, and UpdateRule.
- * The format of a FieldFlag is described
- * in the ACPI specification
- * FieldAttribute - Special attributes (not used)
- * FieldBitPosition - Field start position
- * FieldBitLength - Field length in number of bits
- *
- * RETURN: Status
- *
- * DESCRIPTION: Initialize the areas of the field object that are common
- * to the various types of fields. Note: This is very "sensitive"
- * code because we are solving the general case for field
- * alignment.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExPrepCommonFieldObject (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT8 FieldFlags,
- UINT8 FieldAttribute,
- UINT32 FieldBitPosition,
- UINT32 FieldBitLength)
-{
- UINT32 AccessBitWidth;
- UINT32 ByteAlignment;
- UINT32 NearestByteAddress;
-
-
- ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject);
-
-
- /*
- * Note: the structure being initialized is the
- * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common
- * area are initialized by this procedure.
- */
- ObjDesc->CommonField.FieldFlags = FieldFlags;
- ObjDesc->CommonField.Attribute = FieldAttribute;
- ObjDesc->CommonField.BitLength = FieldBitLength;
-
- /*
- * Decode the access type so we can compute offsets. The access type gives
- * two pieces of information - the width of each field access and the
- * necessary ByteAlignment (address granularity) of the access.
- *
- * For AnyAcc, the AccessBitWidth is the largest width that is both
- * necessary and possible in an attempt to access the whole field in one
- * I/O operation. However, for AnyAcc, the ByteAlignment is always one
- * byte.
- *
- * For all Buffer Fields, the ByteAlignment is always one byte.
- *
- * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
- * the same (equivalent) as the ByteAlignment.
- */
- AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
- &ByteAlignment);
- if (!AccessBitWidth)
- {
- return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
- }
-
- /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */
-
- ObjDesc->CommonField.AccessByteWidth = (UINT8)
- ACPI_DIV_8 (AccessBitWidth);
-
- /*
- * BaseByteOffset is the address of the start of the field within the
- * region. It is the byte address of the first *datum* (field-width data
- * unit) of the field. (i.e., the first datum that contains at least the
- * first *bit* of the field.)
- *
- * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
- * (Byte access), and it defines the addressing granularity of the parent
- * region or buffer.
- */
- NearestByteAddress =
- ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
- ObjDesc->CommonField.BaseByteOffset = (UINT32)
- ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
-
- /*
- * StartFieldBitOffset is the offset of the first bit of the field within
- * a field datum.
- */
- ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
- (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExPrepFieldValue
- *
- * PARAMETERS: Info - Contains all field creation info
- *
- * RETURN: Status
- *
- * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
- * connect it to the parent Node.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExPrepFieldValue (
- ACPI_CREATE_FIELD_INFO *Info)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_OPERAND_OBJECT *SecondDesc = NULL;
- ACPI_STATUS Status;
- UINT32 AccessByteWidth;
- UINT32 Type;
-
-
- ACPI_FUNCTION_TRACE (ExPrepFieldValue);
-
-
- /* Parameter validation */
-
- if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
- {
- if (!Info->RegionNode)
- {
- ACPI_ERROR ((AE_INFO, "Null RegionNode"));
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
-
- Type = AcpiNsGetType (Info->RegionNode);
- if (Type != ACPI_TYPE_REGION)
- {
- ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
- Type, AcpiUtGetTypeName (Type)));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- }
-
- /* Allocate a new field object */
-
- ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
- if (!ObjDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Initialize areas of the object that are common to all fields */
-
- ObjDesc->CommonField.Node = Info->FieldNode;
- Status = AcpiExPrepCommonFieldObject (ObjDesc,
- Info->FieldFlags, Info->Attribute,
- Info->FieldBitPosition, Info->FieldBitLength);
- if (ACPI_FAILURE (Status))
- {
- AcpiUtDeleteObjectDesc (ObjDesc);
- return_ACPI_STATUS (Status);
- }
-
- /* Initialize areas of the object that are specific to the field type */
-
- switch (Info->FieldType)
- {
- case ACPI_TYPE_LOCAL_REGION_FIELD:
-
- ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
-
- /* Fields specific to GenericSerialBus fields */
-
- ObjDesc->Field.AccessLength = Info->AccessLength;
-
- if (Info->ConnectionNode)
- {
- SecondDesc = Info->ConnectionNode->Object;
- if (!(SecondDesc->Common.Flags & AOPOBJ_DATA_VALID))
- {
- Status = AcpiDsGetBufferArguments (SecondDesc);
- if (ACPI_FAILURE (Status))
- {
- AcpiUtDeleteObjectDesc (ObjDesc);
- return_ACPI_STATUS (Status);
- }
- }
-
- ObjDesc->Field.ResourceBuffer = SecondDesc->Buffer.Pointer;
- ObjDesc->Field.ResourceLength = (UINT16) SecondDesc->Buffer.Length;
- }
- else if (Info->ResourceBuffer)
- {
- ObjDesc->Field.ResourceBuffer = Info->ResourceBuffer;
- ObjDesc->Field.ResourceLength = Info->ResourceLength;
- }
-
- /* Allow full data read from EC address space */
-
- if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) &&
- (ObjDesc->CommonField.BitLength > 8))
- {
- AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES (
- ObjDesc->CommonField.BitLength);
-
- /* Maximum byte width supported is 255 */
-
- if (AccessByteWidth < 256)
- {
- ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth;
- }
- }
-
- /* An additional reference for the container */
-
- AcpiUtAddReference (ObjDesc->Field.RegionObj);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
- ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
- ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
- break;
-
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- ObjDesc->BankField.Value = Info->BankValue;
- ObjDesc->BankField.RegionObj =
- AcpiNsGetAttachedObject (Info->RegionNode);
- ObjDesc->BankField.BankObj =
- AcpiNsGetAttachedObject (Info->RegisterNode);
-
- /* An additional reference for the attached objects */
-
- AcpiUtAddReference (ObjDesc->BankField.RegionObj);
- AcpiUtAddReference (ObjDesc->BankField.BankObj);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
- ObjDesc->BankField.StartFieldBitOffset,
- ObjDesc->BankField.BaseByteOffset,
- ObjDesc->Field.AccessByteWidth,
- ObjDesc->BankField.RegionObj,
- ObjDesc->BankField.BankObj));
-
- /*
- * Remember location in AML stream of the field unit
- * opcode and operands -- since the BankValue
- * operands must be evaluated.
- */
- SecondDesc = ObjDesc->Common.NextObject;
- SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
- Info->DataRegisterNode)->Named.Data;
- SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT,
- Info->DataRegisterNode)->Named.Length;
-
- break;
-
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- /* Get the Index and Data registers */
-
- ObjDesc->IndexField.IndexObj =
- AcpiNsGetAttachedObject (Info->RegisterNode);
- ObjDesc->IndexField.DataObj =
- AcpiNsGetAttachedObject (Info->DataRegisterNode);
-
- if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
- {
- ACPI_ERROR ((AE_INFO, "Null Index Object during field prep"));
- AcpiUtDeleteObjectDesc (ObjDesc);
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- /* An additional reference for the attached objects */
-
- AcpiUtAddReference (ObjDesc->IndexField.DataObj);
- AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
-
- /*
- * April 2006: Changed to match MS behavior
- *
- * The value written to the Index register is the byte offset of the
- * target field in units of the granularity of the IndexField
- *
- * Previously, the value was calculated as an index in terms of the
- * width of the Data register, as below:
- *
- * ObjDesc->IndexField.Value = (UINT32)
- * (Info->FieldBitPosition / ACPI_MUL_8 (
- * ObjDesc->Field.AccessByteWidth));
- *
- * February 2006: Tried value as a byte offset:
- * ObjDesc->IndexField.Value = (UINT32)
- * ACPI_DIV_8 (Info->FieldBitPosition);
- */
- ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN (
- ACPI_DIV_8 (Info->FieldBitPosition),
- ObjDesc->IndexField.AccessByteWidth);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
- ObjDesc->IndexField.StartFieldBitOffset,
- ObjDesc->IndexField.BaseByteOffset,
- ObjDesc->IndexField.Value,
- ObjDesc->Field.AccessByteWidth,
- ObjDesc->IndexField.IndexObj,
- ObjDesc->IndexField.DataObj));
- break;
-
- default:
- /* No other types should get here */
- break;
- }
-
- /*
- * Store the constructed descriptor (ObjDesc) into the parent Node,
- * preserving the current type of that NamedObj.
- */
- Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
- AcpiNsGetType (Info->FieldNode));
-
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
- Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
-
- /* Remove local reference to the object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exregion.c
--- a/head/sys/contrib/dev/acpica/executer/exregion.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,565 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exregion - ACPI default OpRegion (address space) handlers
- *
- *****************************************************************************/
-
-/*
- * 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 __EXREGION_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exregion")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemMemorySpaceHandler
- *
- * PARAMETERS: Function - Read or Write operation
- * Address - Where in the space to read or write
- * BitWidth - Field width in bits (8, 16, or 32)
- * Value - Pointer to in or out value
- * HandlerContext - Pointer to Handler's context
- * RegionContext - Pointer to context specific to the
- * accessed region
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handler for the System Memory address space (Op Region)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemMemorySpaceHandler (
- UINT32 Function,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 BitWidth,
- UINT64 *Value,
- void *HandlerContext,
- void *RegionContext)
-{
- ACPI_STATUS Status = AE_OK;
- void *LogicalAddrPtr = NULL;
- ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
- UINT32 Length;
- ACPI_SIZE MapLength;
- ACPI_SIZE PageBoundaryMapLength;
-#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
- UINT32 Remainder;
-#endif
-
-
- ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
-
-
- /* Validate and translate the bit width */
-
- switch (BitWidth)
- {
- case 8:
- Length = 1;
- break;
-
- case 16:
- Length = 2;
- break;
-
- case 32:
- Length = 4;
- break;
-
- case 64:
- Length = 8;
- break;
-
- default:
- ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
- BitWidth));
- return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
- }
-
-#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
- /*
- * Hardware does not support non-aligned data transfers, we must verify
- * the request.
- */
- (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder);
- if (Remainder != 0)
- {
- return_ACPI_STATUS (AE_AML_ALIGNMENT);
- }
-#endif
-
- /*
- * Does the request fit into the cached memory mapping?
- * Is 1) Address below the current mapping? OR
- * 2) Address beyond the current mapping?
- */
- if ((Address < MemInfo->MappedPhysicalAddress) ||
- (((UINT64) Address + Length) >
- ((UINT64)
- MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
- {
- /*
- * The request cannot be resolved by the current memory mapping;
- * Delete the existing mapping and create a new one.
- */
- if (MemInfo->MappedLength)
- {
- /* Valid mapping, delete it */
-
- AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress,
- MemInfo->MappedLength);
- }
-
- /*
- * October 2009: Attempt to map from the requested address to the
- * end of the region. However, we will never map more than one
- * page, nor will we cross a page boundary.
- */
- MapLength = (ACPI_SIZE)
- ((MemInfo->Address + MemInfo->Length) - Address);
-
- /*
- * If mapping the entire remaining portion of the region will cross
- * a page boundary, just map up to the page boundary, do not cross.
- * On some systems, crossing a page boundary while mapping regions
- * can cause warnings if the pages have different attributes
- * due to resource management.
- *
- * This has the added benefit of constraining a single mapping to
- * one page, which is similar to the original code that used a 4k
- * maximum window.
- */
- PageBoundaryMapLength =
- ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address;
- if (PageBoundaryMapLength == 0)
- {
- PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE;
- }
-
- if (MapLength > PageBoundaryMapLength)
- {
- MapLength = PageBoundaryMapLength;
- }
-
- /* Create a new mapping starting at the address given */
-
- MemInfo->MappedLogicalAddress = AcpiOsMapMemory (
- (ACPI_PHYSICAL_ADDRESS) Address, MapLength);
- if (!MemInfo->MappedLogicalAddress)
- {
- ACPI_ERROR ((AE_INFO,
- "Could not map memory at 0x%8.8X%8.8X, size %u",
- ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength));
- MemInfo->MappedLength = 0;
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Save the physical address and mapping size */
-
- MemInfo->MappedPhysicalAddress = Address;
- MemInfo->MappedLength = MapLength;
- }
-
- /*
- * Generate a logical pointer corresponding to the address we want to
- * access
- */
- LogicalAddrPtr = MemInfo->MappedLogicalAddress +
- ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
- BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
-
- /*
- * Perform the memory read or write
- *
- * Note: For machines that do not support non-aligned transfers, the target
- * address was checked for alignment above. We do not attempt to break the
- * transfer up into smaller (byte-size) chunks because the AML specifically
- * asked for a transfer width that the hardware may require.
- */
- switch (Function)
- {
- case ACPI_READ:
-
- *Value = 0;
- switch (BitWidth)
- {
- case 8:
- *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
- break;
-
- case 16:
- *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
- break;
-
- case 32:
- *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
- break;
-
- case 64:
- *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
- break;
-
- default:
- /* BitWidth was already validated */
- break;
- }
- break;
-
- case ACPI_WRITE:
-
- switch (BitWidth)
- {
- case 8:
- ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value;
- break;
-
- case 16:
- ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value;
- break;
-
- case 32:
- ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value;
- break;
-
- case 64:
- ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value;
- break;
-
- default:
- /* BitWidth was already validated */
- break;
- }
- break;
-
- default:
- Status = AE_BAD_PARAMETER;
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemIoSpaceHandler
- *
- * PARAMETERS: Function - Read or Write operation
- * Address - Where in the space to read or write
- * BitWidth - Field width in bits (8, 16, or 32)
- * Value - Pointer to in or out value
- * HandlerContext - Pointer to Handler's context
- * RegionContext - Pointer to context specific to the
- * accessed region
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handler for the System IO address space (Op Region)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemIoSpaceHandler (
- UINT32 Function,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 BitWidth,
- UINT64 *Value,
- void *HandlerContext,
- void *RegionContext)
-{
- ACPI_STATUS Status = AE_OK;
- UINT32 Value32;
-
-
- ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
- BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
-
- /* Decode the function parameter */
-
- switch (Function)
- {
- case ACPI_READ:
-
- Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
- &Value32, BitWidth);
- *Value = Value32;
- break;
-
- case ACPI_WRITE:
-
- Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
- (UINT32) *Value, BitWidth);
- break;
-
- default:
- Status = AE_BAD_PARAMETER;
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExPciConfigSpaceHandler
- *
- * PARAMETERS: Function - Read or Write operation
- * Address - Where in the space to read or write
- * BitWidth - Field width in bits (8, 16, or 32)
- * Value - Pointer to in or out value
- * HandlerContext - Pointer to Handler's context
- * RegionContext - Pointer to context specific to the
- * accessed region
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handler for the PCI Config address space (Op Region)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExPciConfigSpaceHandler (
- UINT32 Function,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 BitWidth,
- UINT64 *Value,
- void *HandlerContext,
- void *RegionContext)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PCI_ID *PciId;
- UINT16 PciRegister;
-
-
- ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler);
-
-
- /*
- * The arguments to AcpiOs(Read|Write)PciConfiguration are:
- *
- * PciSegment is the PCI bus segment range 0-31
- * PciBus is the PCI bus number range 0-255
- * PciDevice is the PCI device number range 0-31
- * PciFunction is the PCI device function number
- * PciRegister is the Config space register range 0-255 bytes
- *
- * Value - input value for write, output address for read
- *
- */
- PciId = (ACPI_PCI_ID *) RegionContext;
- PciRegister = (UINT16) (UINT32) Address;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
- Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
- PciId->Function, PciRegister));
-
- switch (Function)
- {
- case ACPI_READ:
-
- *Value = 0;
- Status = AcpiOsReadPciConfiguration (PciId, PciRegister,
- Value, BitWidth);
- break;
-
- case ACPI_WRITE:
-
- Status = AcpiOsWritePciConfiguration (PciId, PciRegister,
- *Value, BitWidth);
- break;
-
- default:
-
- Status = AE_BAD_PARAMETER;
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCmosSpaceHandler
- *
- * PARAMETERS: Function - Read or Write operation
- * Address - Where in the space to read or write
- * BitWidth - Field width in bits (8, 16, or 32)
- * Value - Pointer to in or out value
- * HandlerContext - Pointer to Handler's context
- * RegionContext - Pointer to context specific to the
- * accessed region
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handler for the CMOS address space (Op Region)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExCmosSpaceHandler (
- UINT32 Function,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 BitWidth,
- UINT64 *Value,
- void *HandlerContext,
- void *RegionContext)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
-
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExPciBarSpaceHandler
- *
- * PARAMETERS: Function - Read or Write operation
- * Address - Where in the space to read or write
- * BitWidth - Field width in bits (8, 16, or 32)
- * Value - Pointer to in or out value
- * HandlerContext - Pointer to Handler's context
- * RegionContext - Pointer to context specific to the
- * accessed region
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExPciBarSpaceHandler (
- UINT32 Function,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 BitWidth,
- UINT64 *Value,
- void *HandlerContext,
- void *RegionContext)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler);
-
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDataTableSpaceHandler
- *
- * PARAMETERS: Function - Read or Write operation
- * Address - Where in the space to read or write
- * BitWidth - Field width in bits (8, 16, or 32)
- * Value - Pointer to in or out value
- * HandlerContext - Pointer to Handler's context
- * RegionContext - Pointer to context specific to the
- * accessed region
- *
- * RETURN: Status
- *
- * DESCRIPTION: Handler for the Data Table address space (Op Region)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExDataTableSpaceHandler (
- UINT32 Function,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 BitWidth,
- UINT64 *Value,
- void *HandlerContext,
- void *RegionContext)
-{
- ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler);
-
-
- /*
- * Perform the memory read or write. The BitWidth was already
- * validated.
- */
- switch (Function)
- {
- case ACPI_READ:
-
- ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
- ACPI_DIV_8 (BitWidth));
- break;
-
- case ACPI_WRITE:
-
- ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
- ACPI_DIV_8 (BitWidth));
- break;
-
- default:
-
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exresnte.c
--- a/head/sys/contrib/dev/acpica/executer/exresnte.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,302 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exresnte - AML Interpreter object resolution
- *
- *****************************************************************************/
-
-/*
- * 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 __EXRESNTE_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>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exresnte")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExResolveNodeToValue
- *
- * PARAMETERS: ObjectPtr - Pointer to a location that contains
- * a pointer to a NS node, and will receive a
- * pointer to the resolved object.
- * WalkState - Current state. Valid only if executing AML
- * code. NULL if simply resolving an object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Resolve a Namespace node to a valued object
- *
- * Note: for some of the data types, the pointer attached to the Node
- * can be either a pointer to an actual internal object or a pointer into the
- * AML stream itself. These types are currently:
- *
- * ACPI_TYPE_INTEGER
- * ACPI_TYPE_STRING
- * ACPI_TYPE_BUFFER
- * ACPI_TYPE_MUTEX
- * ACPI_TYPE_PACKAGE
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExResolveNodeToValue (
- ACPI_NAMESPACE_NODE **ObjectPtr,
- ACPI_WALK_STATE *WalkState)
-
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *SourceDesc;
- ACPI_OPERAND_OBJECT *ObjDesc = NULL;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_OBJECT_TYPE EntryType;
-
-
- ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
-
-
- /*
- * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
- * object that is attached to the Node.
- */
- Node = *ObjectPtr;
- SourceDesc = AcpiNsGetAttachedObject (Node);
- EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
- Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
-
- if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
- (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
- {
- /* There is always exactly one level of indirection */
-
- Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
- SourceDesc = AcpiNsGetAttachedObject (Node);
- EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
- *ObjectPtr = Node;
- }
-
- /*
- * Several object types require no further processing:
- * 1) Device/Thermal objects don't have a "real" subobject, return the Node
- * 2) Method locals and arguments have a pseudo-Node
- * 3) 10/2007: Added method type to assist with Package construction.
- */
- if ((EntryType == ACPI_TYPE_DEVICE) ||
- (EntryType == ACPI_TYPE_THERMAL) ||
- (EntryType == ACPI_TYPE_METHOD) ||
- (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- if (!SourceDesc)
- {
- ACPI_ERROR ((AE_INFO, "No object attached to node %p",
- Node));
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
-
- /*
- * Action is based on the type of the Node, which indicates the type
- * of the attached object or pointer
- */
- switch (EntryType)
- {
- case ACPI_TYPE_PACKAGE:
-
- if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
- {
- ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
- AcpiUtGetObjectTypeName (SourceDesc)));
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- Status = AcpiDsGetPackageArguments (SourceDesc);
- if (ACPI_SUCCESS (Status))
- {
- /* Return an additional reference to the object */
-
- ObjDesc = SourceDesc;
- AcpiUtAddReference (ObjDesc);
- }
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
- {
- ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
- AcpiUtGetObjectTypeName (SourceDesc)));
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- Status = AcpiDsGetBufferArguments (SourceDesc);
- if (ACPI_SUCCESS (Status))
- {
- /* Return an additional reference to the object */
-
- ObjDesc = SourceDesc;
- AcpiUtAddReference (ObjDesc);
- }
- break;
-
-
- case ACPI_TYPE_STRING:
-
- if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
- {
- ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
- AcpiUtGetObjectTypeName (SourceDesc)));
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /* Return an additional reference to the object */
-
- ObjDesc = SourceDesc;
- AcpiUtAddReference (ObjDesc);
- break;
-
-
- case ACPI_TYPE_INTEGER:
-
- if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
- {
- ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
- AcpiUtGetObjectTypeName (SourceDesc)));
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /* Return an additional reference to the object */
-
- ObjDesc = SourceDesc;
- AcpiUtAddReference (ObjDesc);
- break;
-
-
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "FieldRead Node=%p SourceDesc=%p Type=%X\n",
- Node, SourceDesc, EntryType));
-
- Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
- break;
-
- /* For these objects, just return the object attached to the Node */
-
- case ACPI_TYPE_MUTEX:
- case ACPI_TYPE_POWER:
- case ACPI_TYPE_PROCESSOR:
- case ACPI_TYPE_EVENT:
- case ACPI_TYPE_REGION:
-
- /* Return an additional reference to the object */
-
- ObjDesc = SourceDesc;
- AcpiUtAddReference (ObjDesc);
- break;
-
- /* TYPE_ANY is untyped, and thus there is no object associated with it */
-
- case ACPI_TYPE_ANY:
-
- ACPI_ERROR ((AE_INFO,
- "Untyped entry %p, no attached object!", Node));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
-
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- switch (SourceDesc->Reference.Class)
- {
- case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */
- case ACPI_REFCLASS_REFOF:
- case ACPI_REFCLASS_INDEX:
-
- /* Return an additional reference to the object */
-
- ObjDesc = SourceDesc;
- AcpiUtAddReference (ObjDesc);
- break;
-
- default:
- /* No named references are allowed here */
-
- ACPI_ERROR ((AE_INFO,
- "Unsupported Reference type 0x%X",
- SourceDesc->Reference.Class));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- break;
-
-
- default:
-
- /* Default case is for unknown types */
-
- ACPI_ERROR ((AE_INFO,
- "Node %p - Unknown object type 0x%X",
- Node, EntryType));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
-
- } /* switch (EntryType) */
-
-
- /* Return the object descriptor */
-
- *ObjectPtr = (void *) ObjDesc;
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exresolv.c
--- a/head/sys/contrib/dev/acpica/executer/exresolv.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,580 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exresolv - AML Interpreter object resolution
- *
- *****************************************************************************/
-
-/*
- * 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 __EXRESOLV_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>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exresolv")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiExResolveObjectToValue (
- ACPI_OPERAND_OBJECT **StackPtr,
- ACPI_WALK_STATE *WalkState);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExResolveToValue
- *
- * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can
- * be either an (ACPI_OPERAND_OBJECT *)
- * or an ACPI_HANDLE.
- * WalkState - Current method state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert Reference objects to values
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExResolveToValue (
- ACPI_OPERAND_OBJECT **StackPtr,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr);
-
-
- if (!StackPtr || !*StackPtr)
- {
- ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
-
- /*
- * The entity pointed to by the StackPtr can be either
- * 1) A valid ACPI_OPERAND_OBJECT, or
- * 2) A ACPI_NAMESPACE_NODE (NamedObj)
- */
- if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND)
- {
- Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (!*StackPtr)
- {
- ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
- }
-
- /*
- * Object on the stack may have changed if AcpiExResolveObjectToValue()
- * was called (i.e., we can't use an _else_ here.)
- */
- if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED)
- {
- Status = AcpiExResolveNodeToValue (
- ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr),
- WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExResolveObjectToValue
- *
- * PARAMETERS: StackPtr - Pointer to an internal object
- * WalkState - Current method state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Retrieve the value from an internal object. The Reference type
- * uses the associated AML opcode to determine the value.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExResolveObjectToValue (
- ACPI_OPERAND_OBJECT **StackPtr,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *StackDesc;
- ACPI_OPERAND_OBJECT *ObjDesc = NULL;
- UINT8 RefType;
-
-
- ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
-
-
- StackDesc = *StackPtr;
-
- /* This is an ACPI_OPERAND_OBJECT */
-
- switch (StackDesc->Common.Type)
- {
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- RefType = StackDesc->Reference.Class;
-
- switch (RefType)
- {
- case ACPI_REFCLASS_LOCAL:
- case ACPI_REFCLASS_ARG:
-
- /*
- * Get the local from the method's state info
- * Note: this increments the local's object reference count
- */
- Status = AcpiDsMethodDataGetValue (RefType,
- StackDesc->Reference.Value, WalkState, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
- StackDesc->Reference.Value, ObjDesc));
-
- /*
- * Now we can delete the original Reference Object and
- * replace it with the resolved value
- */
- AcpiUtRemoveReference (StackDesc);
- *StackPtr = ObjDesc;
- break;
-
-
- case ACPI_REFCLASS_INDEX:
-
- switch (StackDesc->Reference.TargetType)
- {
- case ACPI_TYPE_BUFFER_FIELD:
-
- /* Just return - do not dereference */
- break;
-
-
- case ACPI_TYPE_PACKAGE:
-
- /* If method call or CopyObject - do not dereference */
-
- if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
- (WalkState->Opcode == AML_COPY_OP))
- {
- break;
- }
-
- /* Otherwise, dereference the PackageIndex to a package element */
-
- ObjDesc = *StackDesc->Reference.Where;
- if (ObjDesc)
- {
- /*
- * Valid object descriptor, copy pointer to return value
- * (i.e., dereference the package index)
- * Delete the ref object, increment the returned object
- */
- AcpiUtRemoveReference (StackDesc);
- AcpiUtAddReference (ObjDesc);
- *StackPtr = ObjDesc;
- }
- else
- {
- /*
- * A NULL object descriptor means an uninitialized element of
- * the package, can't dereference it
- */
- ACPI_ERROR ((AE_INFO,
- "Attempt to dereference an Index to NULL package element Idx=%p",
- StackDesc));
- Status = AE_AML_UNINITIALIZED_ELEMENT;
- }
- break;
-
-
- default:
-
- /* Invalid reference object */
-
- ACPI_ERROR ((AE_INFO,
- "Unknown TargetType 0x%X in Index/Reference object %p",
- StackDesc->Reference.TargetType, StackDesc));
- Status = AE_AML_INTERNAL;
- break;
- }
- break;
-
-
- case ACPI_REFCLASS_REFOF:
- case ACPI_REFCLASS_DEBUG:
- case ACPI_REFCLASS_TABLE:
-
- /* Just leave the object as-is, do not dereference */
-
- break;
-
- case ACPI_REFCLASS_NAME: /* Reference to a named object */
-
- /* Dereference the name */
-
- if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
- (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
- {
- /* These node types do not have 'real' subobjects */
-
- *StackPtr = (void *) StackDesc->Reference.Node;
- }
- else
- {
- /* Get the object pointed to by the namespace node */
-
- *StackPtr = (StackDesc->Reference.Node)->Object;
- AcpiUtAddReference (*StackPtr);
- }
-
- AcpiUtRemoveReference (StackDesc);
- break;
-
- default:
-
- ACPI_ERROR ((AE_INFO,
- "Unknown Reference type 0x%X in %p", RefType, StackDesc));
- Status = AE_AML_INTERNAL;
- break;
- }
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- Status = AcpiDsGetBufferArguments (StackDesc);
- break;
-
-
- case ACPI_TYPE_PACKAGE:
-
- Status = AcpiDsGetPackageArguments (StackDesc);
- break;
-
-
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n",
- StackDesc, StackDesc->Common.Type));
-
- Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
-
- /* Remove a reference to the original operand, then override */
-
- AcpiUtRemoveReference (*StackPtr);
- *StackPtr = (void *) ObjDesc;
- break;
-
- default:
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExResolveMultiple
- *
- * PARAMETERS: WalkState - Current state (contains AML opcode)
- * Operand - Starting point for resolution
- * ReturnType - Where the object type is returned
- * ReturnDesc - Where the resolved object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Return the base object and type. Traverse a reference list if
- * necessary to get to the base object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExResolveMultiple (
- ACPI_WALK_STATE *WalkState,
- ACPI_OPERAND_OBJECT *Operand,
- ACPI_OBJECT_TYPE *ReturnType,
- ACPI_OPERAND_OBJECT **ReturnDesc)
-{
- ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_OBJECT_TYPE Type;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
-
-
- /* Operand can be either a namespace node or an operand descriptor */
-
- switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
- {
- case ACPI_DESC_TYPE_OPERAND:
- Type = ObjDesc->Common.Type;
- break;
-
- case ACPI_DESC_TYPE_NAMED:
- Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
- ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
-
- /* If we had an Alias node, use the attached object for type info */
-
- if (Type == ACPI_TYPE_LOCAL_ALIAS)
- {
- Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
- ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
- }
- break;
-
- default:
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /* If type is anything other than a reference, we are done */
-
- if (Type != ACPI_TYPE_LOCAL_REFERENCE)
- {
- goto Exit;
- }
-
- /*
- * For reference objects created via the RefOf, Index, or Load/LoadTable
- * operators, we need to get to the base object (as per the ACPI
- * specification of the ObjectType and SizeOf operators). This means
- * traversing the list of possibly many nested references.
- */
- while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
- {
- switch (ObjDesc->Reference.Class)
- {
- case ACPI_REFCLASS_REFOF:
- case ACPI_REFCLASS_NAME:
-
- /* Dereference the reference pointer */
-
- if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)
- {
- Node = ObjDesc->Reference.Object;
- }
- else /* AML_INT_NAMEPATH_OP */
- {
- Node = ObjDesc->Reference.Node;
- }
-
- /* All "References" point to a NS node */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
- {
- ACPI_ERROR ((AE_INFO,
- "Not a namespace node %p [%s]",
- Node, AcpiUtGetDescriptorName (Node)));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- /* Get the attached object */
-
- ObjDesc = AcpiNsGetAttachedObject (Node);
- if (!ObjDesc)
- {
- /* No object, use the NS node type */
-
- Type = AcpiNsGetType (Node);
- goto Exit;
- }
-
- /* Check for circular references */
-
- if (ObjDesc == Operand)
- {
- return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
- }
- break;
-
-
- case ACPI_REFCLASS_INDEX:
-
- /* Get the type of this reference (index into another object) */
-
- Type = ObjDesc->Reference.TargetType;
- if (Type != ACPI_TYPE_PACKAGE)
- {
- goto Exit;
- }
-
- /*
- * The main object is a package, we want to get the type
- * of the individual package element that is referenced by
- * the index.
- *
- * This could of course in turn be another reference object.
- */
- ObjDesc = *(ObjDesc->Reference.Where);
- if (!ObjDesc)
- {
- /* NULL package elements are allowed */
-
- Type = 0; /* Uninitialized */
- goto Exit;
- }
- break;
-
-
- case ACPI_REFCLASS_TABLE:
-
- Type = ACPI_TYPE_DDB_HANDLE;
- goto Exit;
-
-
- case ACPI_REFCLASS_LOCAL:
- case ACPI_REFCLASS_ARG:
-
- if (ReturnDesc)
- {
- Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
- ObjDesc->Reference.Value, WalkState, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- AcpiUtRemoveReference (ObjDesc);
- }
- else
- {
- Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
- ObjDesc->Reference.Value, WalkState, &Node);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- ObjDesc = AcpiNsGetAttachedObject (Node);
- if (!ObjDesc)
- {
- Type = ACPI_TYPE_ANY;
- goto Exit;
- }
- }
- break;
-
-
- case ACPI_REFCLASS_DEBUG:
-
- /* The Debug Object is of type "DebugObject" */
-
- Type = ACPI_TYPE_DEBUG_OBJECT;
- goto Exit;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO,
- "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
- }
-
- /*
- * Now we are guaranteed to have an object that has not been created
- * via the RefOf or Index operators.
- */
- Type = ObjDesc->Common.Type;
-
-
-Exit:
- /* Convert internal types to external types */
-
- switch (Type)
- {
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- Type = ACPI_TYPE_FIELD_UNIT;
- break;
-
- case ACPI_TYPE_LOCAL_SCOPE:
-
- /* Per ACPI Specification, Scope is untyped */
-
- Type = ACPI_TYPE_ANY;
- break;
-
- default:
- /* No change to Type required */
- break;
- }
-
- *ReturnType = Type;
- if (ReturnDesc)
- {
- *ReturnDesc = ObjDesc;
- }
- return_ACPI_STATUS (AE_OK);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exresop.c
--- a/head/sys/contrib/dev/acpica/executer/exresop.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,738 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exresop - AML Interpreter operand/object resolution
- *
- *****************************************************************************/
-
-/*
- * 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 __EXRESOP_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/acparser.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exresop")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiExCheckObjectType (
- ACPI_OBJECT_TYPE TypeNeeded,
- ACPI_OBJECT_TYPE ThisType,
- void *Object);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExCheckObjectType
- *
- * PARAMETERS: TypeNeeded Object type needed
- * ThisType Actual object type
- * Object Object pointer
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check required type against actual type
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExCheckObjectType (
- ACPI_OBJECT_TYPE TypeNeeded,
- ACPI_OBJECT_TYPE ThisType,
- void *Object)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- if (TypeNeeded == ACPI_TYPE_ANY)
- {
- /* All types OK, so we don't perform any typechecks */
-
- return (AE_OK);
- }
-
- if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE)
- {
- /*
- * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
- * objects and thus allow them to be targets. (As per the ACPI
- * specification, a store to a constant is a noop.)
- */
- if ((ThisType == ACPI_TYPE_INTEGER) &&
- (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
- {
- return (AE_OK);
- }
- }
-
- if (TypeNeeded != ThisType)
- {
- ACPI_ERROR ((AE_INFO,
- "Needed type [%s], found [%s] %p",
- AcpiUtGetTypeName (TypeNeeded),
- AcpiUtGetTypeName (ThisType), Object));
-
- return (AE_AML_OPERAND_TYPE);
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExResolveOperands
- *
- * PARAMETERS: Opcode - Opcode being interpreted
- * StackPtr - Pointer to the operand stack to be
- * resolved
- * WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert multiple input operands to the types required by the
- * target operator.
- *
- * Each 5-bit group in ArgTypes represents one required
- * operand and indicates the required Type. The corresponding operand
- * will be converted to the required type if possible, otherwise we
- * abort with an exception.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExResolveOperands (
- UINT16 Opcode,
- ACPI_OPERAND_OBJECT **StackPtr,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status = AE_OK;
- UINT8 ObjectType;
- UINT32 ArgTypes;
- const ACPI_OPCODE_INFO *OpInfo;
- UINT32 ThisArgType;
- ACPI_OBJECT_TYPE TypeNeeded;
- UINT16 TargetOp = 0;
-
-
- ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode);
-
-
- OpInfo = AcpiPsGetOpcodeInfo (Opcode);
- if (OpInfo->Class == AML_CLASS_UNKNOWN)
- {
- return_ACPI_STATUS (AE_AML_BAD_OPCODE);
- }
-
- ArgTypes = OpInfo->RuntimeArgs;
- if (ArgTypes == ARGI_INVALID_OPCODE)
- {
- ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
- Opcode));
-
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Opcode %X [%s] RequiredOperandTypes=%8.8X\n",
- Opcode, OpInfo->Name, ArgTypes));
-
- /*
- * Normal exit is with (ArgTypes == 0) at end of argument list.
- * Function will return an exception from within the loop upon
- * finding an entry which is not (or cannot be converted
- * to) the required type; if stack underflows; or upon
- * finding a NULL stack entry (which should not happen).
- */
- while (GET_CURRENT_ARG_TYPE (ArgTypes))
- {
- if (!StackPtr || !*StackPtr)
- {
- ACPI_ERROR ((AE_INFO, "Null stack entry at %p",
- StackPtr));
-
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- /* Extract useful items */
-
- ObjDesc = *StackPtr;
-
- /* Decode the descriptor type */
-
- switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
- {
- case ACPI_DESC_TYPE_NAMED:
-
- /* Namespace Node */
-
- ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
-
- /*
- * Resolve an alias object. The construction of these objects
- * guarantees that there is only one level of alias indirection;
- * thus, the attached object is always the aliased namespace node
- */
- if (ObjectType == ACPI_TYPE_LOCAL_ALIAS)
- {
- ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
- *StackPtr = ObjDesc;
- ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
- }
- break;
-
-
- case ACPI_DESC_TYPE_OPERAND:
-
- /* ACPI internal object */
-
- ObjectType = ObjDesc->Common.Type;
-
- /* Check for bad ACPI_OBJECT_TYPE */
-
- if (!AcpiUtValidObjectType (ObjectType))
- {
- ACPI_ERROR ((AE_INFO,
- "Bad operand object type [0x%X]", ObjectType));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE)
- {
- /* Validate the Reference */
-
- switch (ObjDesc->Reference.Class)
- {
- case ACPI_REFCLASS_DEBUG:
-
- TargetOp = AML_DEBUG_OP;
-
- /*lint -fallthrough */
-
- case ACPI_REFCLASS_ARG:
- case ACPI_REFCLASS_LOCAL:
- case ACPI_REFCLASS_INDEX:
- case ACPI_REFCLASS_REFOF:
- case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
- case ACPI_REFCLASS_NAME: /* Reference to a named object */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Operand is a Reference, Class [%s] %2.2X\n",
- AcpiUtGetReferenceName (ObjDesc),
- ObjDesc->Reference.Class));
- break;
-
- default:
-
- ACPI_ERROR ((AE_INFO,
- "Unknown Reference Class 0x%2.2X in %p",
- ObjDesc->Reference.Class, ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- }
- break;
-
-
- default:
-
- /* Invalid descriptor */
-
- ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]",
- ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /* Get one argument type, point to the next */
-
- ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
- INCREMENT_ARG_LIST (ArgTypes);
-
- /*
- * Handle cases where the object does not need to be
- * resolved to a value
- */
- switch (ThisArgType)
- {
- case ARGI_REF_OR_STRING: /* Can be a String or Reference */
-
- if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
- (ObjDesc->Common.Type == ACPI_TYPE_STRING))
- {
- /*
- * String found - the string references a named object and
- * must be resolved to a node
- */
- goto NextOperand;
- }
-
- /*
- * Else not a string - fall through to the normal Reference
- * case below
- */
- /*lint -fallthrough */
-
- case ARGI_REFERENCE: /* References: */
- case ARGI_INTEGER_REF:
- case ARGI_OBJECT_REF:
- case ARGI_DEVICE_REF:
- case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
- case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
- case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
-
- /*
- * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
- * A Namespace Node is OK as-is
- */
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
- {
- goto NextOperand;
- }
-
- Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE,
- ObjectType, ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- goto NextOperand;
-
-
- case ARGI_DATAREFOBJ: /* Store operator only */
-
- /*
- * We don't want to resolve IndexOp reference objects during
- * a store because this would be an implicit DeRefOf operation.
- * Instead, we just want to store the reference object.
- * -- All others must be resolved below.
- */
- if ((Opcode == AML_STORE_OP) &&
- ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
- ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX))
- {
- goto NextOperand;
- }
- break;
-
- default:
- /* All cases covered above */
- break;
- }
-
- /*
- * Resolve this object to a value
- */
- Status = AcpiExResolveToValue (StackPtr, WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Get the resolved object */
-
- ObjDesc = *StackPtr;
-
- /*
- * Check the resulting object (value) type
- */
- switch (ThisArgType)
- {
- /*
- * For the simple cases, only one type of resolved object
- * is allowed
- */
- case ARGI_MUTEX:
-
- /* Need an operand of type ACPI_TYPE_MUTEX */
-
- TypeNeeded = ACPI_TYPE_MUTEX;
- break;
-
- case ARGI_EVENT:
-
- /* Need an operand of type ACPI_TYPE_EVENT */
-
- TypeNeeded = ACPI_TYPE_EVENT;
- break;
-
- case ARGI_PACKAGE: /* Package */
-
- /* Need an operand of type ACPI_TYPE_PACKAGE */
-
- TypeNeeded = ACPI_TYPE_PACKAGE;
- break;
-
- case ARGI_ANYTYPE:
-
- /* Any operand type will do */
-
- TypeNeeded = ACPI_TYPE_ANY;
- break;
-
- case ARGI_DDBHANDLE:
-
- /* Need an operand of type ACPI_TYPE_DDB_HANDLE */
-
- TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE;
- break;
-
-
- /*
- * The more complex cases allow multiple resolved object types
- */
- case ARGI_INTEGER:
-
- /*
- * Need an operand of type ACPI_TYPE_INTEGER,
- * But we can implicitly convert from a STRING or BUFFER
- * Aka - "Implicit Source Operand Conversion"
- */
- Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_TYPE)
- {
- ACPI_ERROR ((AE_INFO,
- "Needed [Integer/String/Buffer], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- return_ACPI_STATUS (Status);
- }
-
- if (ObjDesc != *StackPtr)
- {
- AcpiUtRemoveReference (ObjDesc);
- }
- goto NextOperand;
-
-
- case ARGI_BUFFER:
-
- /*
- * Need an operand of type ACPI_TYPE_BUFFER,
- * But we can implicitly convert from a STRING or INTEGER
- * Aka - "Implicit Source Operand Conversion"
- */
- Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_TYPE)
- {
- ACPI_ERROR ((AE_INFO,
- "Needed [Integer/String/Buffer], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- return_ACPI_STATUS (Status);
- }
-
- if (ObjDesc != *StackPtr)
- {
- AcpiUtRemoveReference (ObjDesc);
- }
- goto NextOperand;
-
-
- case ARGI_STRING:
-
- /*
- * Need an operand of type ACPI_TYPE_STRING,
- * But we can implicitly convert from a BUFFER or INTEGER
- * Aka - "Implicit Source Operand Conversion"
- */
- Status = AcpiExConvertToString (ObjDesc, StackPtr,
- ACPI_IMPLICIT_CONVERT_HEX);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_TYPE)
- {
- ACPI_ERROR ((AE_INFO,
- "Needed [Integer/String/Buffer], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- return_ACPI_STATUS (Status);
- }
-
- if (ObjDesc != *StackPtr)
- {
- AcpiUtRemoveReference (ObjDesc);
- }
- goto NextOperand;
-
-
- case ARGI_COMPUTEDATA:
-
- /* Need an operand of type INTEGER, STRING or BUFFER */
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
-
- /* Valid operand */
- break;
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Needed [Integer/String/Buffer], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- goto NextOperand;
-
-
- case ARGI_BUFFER_OR_STRING:
-
- /* Need an operand of type STRING or BUFFER */
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
-
- /* Valid operand */
- break;
-
- case ACPI_TYPE_INTEGER:
-
- /* Highest priority conversion is to type Buffer */
-
- Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (ObjDesc != *StackPtr)
- {
- AcpiUtRemoveReference (ObjDesc);
- }
- break;
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Needed [Integer/String/Buffer], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- goto NextOperand;
-
-
- case ARGI_DATAOBJECT:
- /*
- * ARGI_DATAOBJECT is only used by the SizeOf operator.
- * Need a buffer, string, package, or RefOf reference.
- *
- * The only reference allowed here is a direct reference to
- * a namespace node.
- */
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_PACKAGE:
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- /* Valid operand */
- break;
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Needed [Buffer/String/Package/Reference], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- goto NextOperand;
-
-
- case ARGI_COMPLEXOBJ:
-
- /* Need a buffer or package or (ACPI 2.0) String */
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_PACKAGE:
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
-
- /* Valid operand */
- break;
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Needed [Buffer/String/Package], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- goto NextOperand;
-
-
- case ARGI_REGION_OR_BUFFER: /* Used by Load() only */
-
- /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_REGION:
-
- /* Valid operand */
- break;
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Needed [Region/Buffer], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- goto NextOperand;
-
-
- case ARGI_DATAREFOBJ:
-
- /* Used by the Store() operator only */
-
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_PACKAGE:
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_REFERENCE:
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
- case ACPI_TYPE_DDB_HANDLE:
-
- /* Valid operand */
- break;
-
- default:
-
- if (AcpiGbl_EnableInterpreterSlack)
- {
- /*
- * Enable original behavior of Store(), allowing any and all
- * objects as the source operand. The ACPI spec does not
- * allow this, however.
- */
- break;
- }
-
- if (TargetOp == AML_DEBUG_OP)
- {
- /* Allow store of any object to the Debug object */
-
- break;
- }
-
- ACPI_ERROR ((AE_INFO,
- "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
- AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
- goto NextOperand;
-
-
- default:
-
- /* Unknown type */
-
- ACPI_ERROR ((AE_INFO,
- "Internal - Unknown ARGI (required operand) type 0x%X",
- ThisArgType));
-
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /*
- * Make sure that the original object was resolved to the
- * required object type (Simple cases only).
- */
- Status = AcpiExCheckObjectType (TypeNeeded,
- (*StackPtr)->Common.Type, *StackPtr);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
-NextOperand:
- /*
- * If more operands needed, decrement StackPtr to point
- * to next operand on stack
- */
- if (GET_CURRENT_ARG_TYPE (ArgTypes))
- {
- StackPtr--;
- }
- }
-
- ACPI_DUMP_OPERANDS (WalkState->Operands,
- AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands);
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exstore.c
--- a/head/sys/contrib/dev/acpica/executer/exstore.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,531 +0,0 @@
-/******************************************************************************
- *
- * Module Name: exstore - AML Interpreter object store 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.
- */
-
-#define __EXSTORE_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/amlcode.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exstore")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiExStoreObjectToIndex (
- ACPI_OPERAND_OBJECT *ValDesc,
- ACPI_OPERAND_OBJECT *DestDesc,
- ACPI_WALK_STATE *WalkState);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExStore
- *
- * PARAMETERS: *SourceDesc - Value to be stored
- * *DestDesc - Where to store it. Must be an NS node
- * or an ACPI_OPERAND_OBJECT of type
- * Reference;
- * WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Store the value described by SourceDesc into the location
- * described by DestDesc. Called by various interpreter
- * functions to store the result of an operation into
- * the destination operand -- not just simply the actual "Store"
- * ASL operator.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExStore (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *DestDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *RefDesc = DestDesc;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc);
-
-
- /* Validate parameters */
-
- if (!SourceDesc || !DestDesc)
- {
- ACPI_ERROR ((AE_INFO, "Null parameter"));
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
-
- /* DestDesc can be either a namespace node or an ACPI object */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED)
- {
- /*
- * Dest is a namespace node,
- * Storing an object into a Named node.
- */
- Status = AcpiExStoreObjectToNode (SourceDesc,
- (ACPI_NAMESPACE_NODE *) DestDesc, WalkState,
- ACPI_IMPLICIT_CONVERSION);
-
- return_ACPI_STATUS (Status);
- }
-
- /* Destination object must be a Reference or a Constant object */
-
- switch (DestDesc->Common.Type)
- {
- case ACPI_TYPE_LOCAL_REFERENCE:
- break;
-
- case ACPI_TYPE_INTEGER:
-
- /* Allow stores to Constants -- a Noop as per ACPI spec */
-
- if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /*lint -fallthrough */
-
- default:
-
- /* Destination is not a Reference object */
-
- ACPI_ERROR ((AE_INFO,
- "Target is not a Reference or Constant object - %s [%p]",
- AcpiUtGetObjectTypeName (DestDesc), DestDesc));
-
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * Examine the Reference class. These cases are handled:
- *
- * 1) Store to Name (Change the object associated with a name)
- * 2) Store to an indexed area of a Buffer or Package
- * 3) Store to a Method Local or Arg
- * 4) Store to the debug object
- */
- switch (RefDesc->Reference.Class)
- {
- case ACPI_REFCLASS_REFOF:
-
- /* Storing an object into a Name "container" */
-
- Status = AcpiExStoreObjectToNode (SourceDesc,
- RefDesc->Reference.Object,
- WalkState, ACPI_IMPLICIT_CONVERSION);
- break;
-
-
- case ACPI_REFCLASS_INDEX:
-
- /* Storing to an Index (pointer into a packager or buffer) */
-
- Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);
- break;
-
-
- case ACPI_REFCLASS_LOCAL:
- case ACPI_REFCLASS_ARG:
-
- /* Store to a method local/arg */
-
- Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class,
- RefDesc->Reference.Value, SourceDesc, WalkState);
- break;
-
-
- case ACPI_REFCLASS_DEBUG:
-
- /*
- * Storing to the Debug object causes the value stored to be
- * displayed and otherwise has no effect -- see ACPI Specification
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "**** Write to Debug Object: Object %p %s ****:\n\n",
- SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));
-
- ACPI_DEBUG_OBJECT (SourceDesc, 0, 0);
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
- RefDesc->Reference.Class));
- ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO);
-
- Status = AE_AML_INTERNAL;
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExStoreObjectToIndex
- *
- * PARAMETERS: *SourceDesc - Value to be stored
- * *DestDesc - Named object to receive the value
- * WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Store the object to indexed Buffer or Package element
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiExStoreObjectToIndex (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *IndexDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_OPERAND_OBJECT *NewDesc;
- UINT8 Value = 0;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);
-
-
- /*
- * Destination must be a reference pointer, and
- * must point to either a buffer or a package
- */
- switch (IndexDesc->Reference.TargetType)
- {
- case ACPI_TYPE_PACKAGE:
- /*
- * Storing to a package element. Copy the object and replace
- * any existing object with the new object. No implicit
- * conversion is performed.
- *
- * The object at *(IndexDesc->Reference.Where) is the
- * element within the package that is to be modified.
- * The parent package object is at IndexDesc->Reference.Object
- */
- ObjDesc = *(IndexDesc->Reference.Where);
-
- if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE &&
- SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
- {
- /* This is a DDBHandle, just add a reference to it */
-
- AcpiUtAddReference (SourceDesc);
- NewDesc = SourceDesc;
- }
- else
- {
- /* Normal object, copy it */
-
- Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- if (ObjDesc)
- {
- /* Decrement reference count by the ref count of the parent package */
-
- for (i = 0;
- i < ((ACPI_OPERAND_OBJECT *)
- IndexDesc->Reference.Object)->Common.ReferenceCount;
- i++)
- {
- AcpiUtRemoveReference (ObjDesc);
- }
- }
-
- *(IndexDesc->Reference.Where) = NewDesc;
-
- /* Increment ref count by the ref count of the parent package-1 */
-
- for (i = 1;
- i < ((ACPI_OPERAND_OBJECT *)
- IndexDesc->Reference.Object)->Common.ReferenceCount;
- i++)
- {
- AcpiUtAddReference (NewDesc);
- }
-
- break;
-
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- /*
- * Store into a Buffer or String (not actually a real BufferField)
- * at a location defined by an Index.
- *
- * The first 8-bit element of the source object is written to the
- * 8-bit Buffer location defined by the Index destination object,
- * according to the ACPI 2.0 specification.
- */
-
- /*
- * Make sure the target is a Buffer or String. An error should
- * not happen here, since the ReferenceObject was constructed
- * by the INDEX_OP code.
- */
- ObjDesc = IndexDesc->Reference.Object;
- if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) &&
- (ObjDesc->Common.Type != ACPI_TYPE_STRING))
- {
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * The assignment of the individual elements will be slightly
- * different for each source type.
- */
- switch (SourceDesc->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
-
- /* Use the least-significant byte of the integer */
-
- Value = (UINT8) (SourceDesc->Integer.Value);
- break;
-
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_STRING:
-
- /* Note: Takes advantage of common string/buffer fields */
-
- Value = SourceDesc->Buffer.Pointer[0];
- break;
-
- default:
-
- /* All other types are invalid */
-
- ACPI_ERROR ((AE_INFO,
- "Source must be Integer/Buffer/String type, not %s",
- AcpiUtGetObjectTypeName (SourceDesc)));
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /* Store the source value into the target buffer byte */
-
- ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value;
- break;
-
-
- default:
- ACPI_ERROR ((AE_INFO,
- "Target is not a Package or BufferField"));
- Status = AE_AML_OPERAND_TYPE;
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExStoreObjectToNode
- *
- * PARAMETERS: SourceDesc - Value to be stored
- * Node - Named object to receive the value
- * WalkState - Current walk state
- * ImplicitConversion - Perform implicit conversion (yes/no)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Store the object to the named object.
- *
- * The Assignment of an object to a named object is handled here
- * The value passed in will replace the current value (if any)
- * with the input value.
- *
- * When storing into an object the data is converted to the
- * target object type then stored in the object. This means
- * that the target object type (for an initialized target) will
- * not be changed by a store operation.
- *
- * Assumes parameters are already validated.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExStoreObjectToNode (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_NAMESPACE_NODE *Node,
- ACPI_WALK_STATE *WalkState,
- UINT8 ImplicitConversion)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *TargetDesc;
- ACPI_OPERAND_OBJECT *NewDesc;
- ACPI_OBJECT_TYPE TargetType;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);
-
-
- /* Get current type of the node, and object attached to Node */
-
- TargetType = AcpiNsGetType (Node);
- TargetDesc = AcpiNsGetAttachedObject (Node);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
- SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),
- Node, AcpiUtGetTypeName (TargetType)));
-
- /*
- * Resolve the source object to an actual value
- * (If it is a reference object)
- */
- Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* If no implicit conversion, drop into the default case below */
-
- if ((!ImplicitConversion) ||
- ((WalkState->Opcode == AML_COPY_OP) &&
- (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) &&
- (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) &&
- (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD)))
- {
- /*
- * Force execution of default (no implicit conversion). Note:
- * CopyObject does not perform an implicit conversion, as per the ACPI
- * spec -- except in case of region/bank/index fields -- because these
- * objects must retain their original type permanently.
- */
- TargetType = ACPI_TYPE_ANY;
- }
-
- /* Do the actual store operation */
-
- switch (TargetType)
- {
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- /* For fields, copy the source data to the target field. */
-
- Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,
- &WalkState->ResultObj);
- break;
-
-
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
-
- /*
- * These target types are all of type Integer/String/Buffer, and
- * therefore support implicit conversion before the store.
- *
- * Copy and/or convert the source object to a new target object
- */
- Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,
- &NewDesc, WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (NewDesc != TargetDesc)
- {
- /*
- * Store the new NewDesc as the new value of the Name, and set
- * the Name's type to that of the value being stored in it.
- * SourceDesc reference count is incremented by AttachObject.
- *
- * Note: This may change the type of the node if an explicit store
- * has been performed such that the node/object type has been
- * changed.
- */
- Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Store %s into %s via Convert/Attach\n",
- AcpiUtGetObjectTypeName (SourceDesc),
- AcpiUtGetObjectTypeName (NewDesc)));
- }
- break;
-
-
- default:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
- AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node));
-
- /* No conversions for all other types. Just attach the source object */
-
- Status = AcpiNsAttachObject (Node, SourceDesc,
- SourceDesc->Common.Type);
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exstoren.c
--- a/head/sys/contrib/dev/acpica/executer/exstoren.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,314 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exstoren - AML Interpreter object store support,
- * Store to Node (namespace object)
- *
- *****************************************************************************/
-
-/*
- * 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 __EXSTOREN_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 ("exstoren")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExResolveObject
- *
- * PARAMETERS: SourceDescPtr - Pointer to the source object
- * TargetType - Current type of the target
- * WalkState - Current walk state
- *
- * RETURN: Status, resolved object in SourceDescPtr.
- *
- * DESCRIPTION: Resolve an object. If the object is a reference, dereference
- * it and return the actual object in the SourceDescPtr.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExResolveObject (
- ACPI_OPERAND_OBJECT **SourceDescPtr,
- ACPI_OBJECT_TYPE TargetType,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExResolveObject);
-
-
- /* Ensure we have a Target that can be stored to */
-
- switch (TargetType)
- {
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
- /*
- * These cases all require only Integers or values that
- * can be converted to Integers (Strings or Buffers)
- */
-
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
-
- /*
- * Stores into a Field/Region or into a Integer/Buffer/String
- * are all essentially the same. This case handles the
- * "interchangeable" types Integer, String, and Buffer.
- */
- if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
- {
- /* Resolve a reference object first */
-
- Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
- if (ACPI_FAILURE (Status))
- {
- break;
- }
- }
-
- /* For CopyObject, no further validation necessary */
-
- if (WalkState->Opcode == AML_COPY_OP)
- {
- break;
- }
-
- /* Must have a Integer, Buffer, or String */
-
- if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
- (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) &&
- (SourceDesc->Common.Type != ACPI_TYPE_STRING) &&
- !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
- (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE)))
- {
- /* Conversion successful but still not a valid type */
-
- ACPI_ERROR ((AE_INFO,
- "Cannot assign type %s to %s (must be type Int/Str/Buf)",
- AcpiUtGetObjectTypeName (SourceDesc),
- AcpiUtGetTypeName (TargetType)));
- Status = AE_AML_OPERAND_TYPE;
- }
- break;
-
-
- case ACPI_TYPE_LOCAL_ALIAS:
- case ACPI_TYPE_LOCAL_METHOD_ALIAS:
-
- /*
- * All aliases should have been resolved earlier, during the
- * operand resolution phase.
- */
- ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object"));
- Status = AE_AML_INTERNAL;
- break;
-
-
- case ACPI_TYPE_PACKAGE:
- default:
-
- /*
- * All other types than Alias and the various Fields come here,
- * including the untyped case - ACPI_TYPE_ANY.
- */
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExStoreObjectToObject
- *
- * PARAMETERS: SourceDesc - Object to store
- * DestDesc - Object to receive a copy of the source
- * NewDesc - New object if DestDesc is obsoleted
- * WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: "Store" an object to another object. This may include
- * converting the source type to the target type (implicit
- * conversion), and a copy of the value of the source to
- * the target.
- *
- * The Assignment of an object to another (not named) object
- * is handled here.
- * The Source passed in will replace the current value (if any)
- * with the input value.
- *
- * When storing into an object the data is converted to the
- * target object type then stored in the object. This means
- * that the target object type (for an initialized target) will
- * not be changed by a store operation.
- *
- * This module allows destination types of Number, String,
- * Buffer, and Package.
- *
- * Assumes parameters are already validated. NOTE: SourceDesc
- * resolution (from a reference object) must be performed by
- * the caller if necessary.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExStoreObjectToObject (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *DestDesc,
- ACPI_OPERAND_OBJECT **NewDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT *ActualSrcDesc;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc);
-
-
- ActualSrcDesc = SourceDesc;
- if (!DestDesc)
- {
- /*
- * There is no destination object (An uninitialized node or
- * package element), so we can simply copy the source object
- * creating a new destination object
- */
- Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState);
- return_ACPI_STATUS (Status);
- }
-
- if (SourceDesc->Common.Type != DestDesc->Common.Type)
- {
- /*
- * The source type does not match the type of the destination.
- * Perform the "implicit conversion" of the source to the current type
- * of the target as per the ACPI specification.
- *
- * If no conversion performed, ActualSrcDesc = SourceDesc.
- * Otherwise, ActualSrcDesc is a temporary object to hold the
- * converted object.
- */
- Status = AcpiExConvertToTargetType (DestDesc->Common.Type,
- SourceDesc, &ActualSrcDesc, WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (SourceDesc == ActualSrcDesc)
- {
- /*
- * No conversion was performed. Return the SourceDesc as the
- * new object.
- */
- *NewDesc = SourceDesc;
- return_ACPI_STATUS (AE_OK);
- }
- }
-
- /*
- * We now have two objects of identical types, and we can perform a
- * copy of the *value* of the source object.
- */
- switch (DestDesc->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
-
- DestDesc->Integer.Value = ActualSrcDesc->Integer.Value;
-
- /* Truncate value if we are executing from a 32-bit ACPI table */
-
- AcpiExTruncateFor32bitTable (DestDesc);
- break;
-
- case ACPI_TYPE_STRING:
-
- Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc);
- break;
-
- case ACPI_TYPE_BUFFER:
-
- Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc);
- break;
-
- case ACPI_TYPE_PACKAGE:
-
- Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc,
- WalkState);
- break;
-
- default:
- /*
- * All other types come here.
- */
- ACPI_WARNING ((AE_INFO, "Store into type %s not implemented",
- AcpiUtGetObjectTypeName (DestDesc)));
-
- Status = AE_NOT_IMPLEMENTED;
- break;
- }
-
- if (ActualSrcDesc != SourceDesc)
- {
- /* Delete the intermediate (temporary) source object */
-
- AcpiUtRemoveReference (ActualSrcDesc);
- }
-
- *NewDesc = DestDesc;
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exstorob.c
--- a/head/sys/contrib/dev/acpica/executer/exstorob.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,244 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exstorob - AML Interpreter object store support, store to object
- *
- *****************************************************************************/
-
-/*
- * 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 __EXSTOROB_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exstorob")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExStoreBufferToBuffer
- *
- * PARAMETERS: SourceDesc - Source object to copy
- * TargetDesc - Destination object of the copy
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy a buffer object to another buffer object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExStoreBufferToBuffer (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *TargetDesc)
-{
- UINT32 Length;
- UINT8 *Buffer;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc);
-
-
- /* If Source and Target are the same, just return */
-
- if (SourceDesc == TargetDesc)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* We know that SourceDesc is a buffer by now */
-
- Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer);
- Length = SourceDesc->Buffer.Length;
-
- /*
- * If target is a buffer of length zero or is a static buffer,
- * allocate a new buffer of the proper length
- */
- if ((TargetDesc->Buffer.Length == 0) ||
- (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))
- {
- TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length);
- if (!TargetDesc->Buffer.Pointer)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- TargetDesc->Buffer.Length = Length;
- }
-
- /* Copy source buffer to target buffer */
-
- if (Length <= TargetDesc->Buffer.Length)
- {
- /* Clear existing buffer and copy in the new one */
-
- ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
- ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length);
-
-#ifdef ACPI_OBSOLETE_BEHAVIOR
- /*
- * NOTE: ACPI versions up to 3.0 specified that the buffer must be
- * truncated if the string is smaller than the buffer. However, "other"
- * implementations of ACPI never did this and thus became the defacto
- * standard. ACPI 3.0A changes this behavior such that the buffer
- * is no longer truncated.
- */
-
- /*
- * OBSOLETE BEHAVIOR:
- * If the original source was a string, we must truncate the buffer,
- * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer
- * copy must not truncate the original buffer.
- */
- if (OriginalSrcType == ACPI_TYPE_STRING)
- {
- /* Set the new length of the target */
-
- TargetDesc->Buffer.Length = Length;
- }
-#endif
- }
- else
- {
- /* Truncate the source, copy only what will fit */
-
- ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer,
- TargetDesc->Buffer.Length);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Truncating source buffer from %X to %X\n",
- Length, TargetDesc->Buffer.Length));
- }
-
- /* Copy flags */
-
- TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags;
- TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExStoreStringToString
- *
- * PARAMETERS: SourceDesc - Source object to copy
- * TargetDesc - Destination object of the copy
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy a String object to another String object
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExStoreStringToString (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *TargetDesc)
-{
- UINT32 Length;
- UINT8 *Buffer;
-
-
- ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc);
-
-
- /* If Source and Target are the same, just return */
-
- if (SourceDesc == TargetDesc)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* We know that SourceDesc is a string by now */
-
- Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer);
- Length = SourceDesc->String.Length;
-
- /*
- * Replace existing string value if it will fit and the string
- * pointer is not a static pointer (part of an ACPI table)
- */
- if ((Length < TargetDesc->String.Length) &&
- (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
- {
- /*
- * String will fit in existing non-static buffer.
- * Clear old string and copy in the new one
- */
- ACPI_MEMSET (TargetDesc->String.Pointer, 0,
- (ACPI_SIZE) TargetDesc->String.Length + 1);
- ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
- }
- else
- {
- /*
- * Free the current buffer, then allocate a new buffer
- * large enough to hold the value
- */
- if (TargetDesc->String.Pointer &&
- (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
- {
- /* Only free if not a pointer into the DSDT */
-
- ACPI_FREE (TargetDesc->String.Pointer);
- }
-
- TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED (
- (ACPI_SIZE) Length + 1);
- if (!TargetDesc->String.Pointer)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
- ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
- }
-
- /* Set the new target length */
-
- TargetDesc->String.Length = Length;
- return_ACPI_STATUS (AE_OK);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exsystem.c
--- a/head/sys/contrib/dev/acpica/executer/exsystem.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,355 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exsystem - Interface to OS services
- *
- *****************************************************************************/
-
-/*
- * 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 __EXSYSTEM_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-#define _COMPONENT ACPI_EXECUTER
- ACPI_MODULE_NAME ("exsystem")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemWaitSemaphore
- *
- * PARAMETERS: Semaphore - Semaphore to wait on
- * Timeout - Max time to wait
- *
- * RETURN: Status
- *
- * DESCRIPTION: Implements a semaphore wait with a check to see if the
- * semaphore is available immediately. If it is not, the
- * interpreter is released before waiting.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemWaitSemaphore (
- ACPI_SEMAPHORE Semaphore,
- UINT16 Timeout)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore);
-
-
- Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT);
- if (ACPI_SUCCESS (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (Status == AE_TIME)
- {
- /* We must wait, so unlock the interpreter */
-
- AcpiExRelinquishInterpreter ();
-
- Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "*** Thread awake after blocking, %s\n",
- AcpiFormatException (Status)));
-
- /* Reacquire the interpreter */
-
- AcpiExReacquireInterpreter ();
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemWaitMutex
- *
- * PARAMETERS: Mutex - Mutex to wait on
- * Timeout - Max time to wait
- *
- * RETURN: Status
- *
- * DESCRIPTION: Implements a mutex wait with a check to see if the
- * mutex is available immediately. If it is not, the
- * interpreter is released before waiting.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemWaitMutex (
- ACPI_MUTEX Mutex,
- UINT16 Timeout)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (ExSystemWaitMutex);
-
-
- Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT);
- if (ACPI_SUCCESS (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (Status == AE_TIME)
- {
- /* We must wait, so unlock the interpreter */
-
- AcpiExRelinquishInterpreter ();
-
- Status = AcpiOsAcquireMutex (Mutex, Timeout);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "*** Thread awake after blocking, %s\n",
- AcpiFormatException (Status)));
-
- /* Reacquire the interpreter */
-
- AcpiExReacquireInterpreter ();
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemDoStall
- *
- * PARAMETERS: HowLong - The amount of time to stall,
- * in microseconds
- *
- * RETURN: Status
- *
- * DESCRIPTION: Suspend running thread for specified amount of time.
- * Note: ACPI specification requires that Stall() does not
- * relinquish the processor, and delays longer than 100 usec
- * should use Sleep() instead. We allow stalls up to 255 usec
- * for compatibility with other interpreters and existing BIOSs.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemDoStall (
- UINT32 HowLong)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (HowLong > 255) /* 255 microseconds */
- {
- /*
- * Longer than 255 usec, this is an error
- *
- * (ACPI specifies 100 usec as max, but this gives some slack in
- * order to support existing BIOSs)
- */
- ACPI_ERROR ((AE_INFO, "Time parameter is too large (%u)",
- HowLong));
- Status = AE_AML_OPERAND_VALUE;
- }
- else
- {
- AcpiOsStall (HowLong);
- }
-
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemDoSleep
- *
- * PARAMETERS: HowLong - The amount of time to sleep,
- * in milliseconds
- *
- * RETURN: None
- *
- * DESCRIPTION: Sleep the running thread for specified amount of time.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemDoSleep (
- UINT64 HowLong)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Since this thread will sleep, we must release the interpreter */
-
- AcpiExRelinquishInterpreter ();
-
- /*
- * For compatibility with other ACPI implementations and to prevent
- * accidental deep sleeps, limit the sleep time to something reasonable.
- */
- if (HowLong > ACPI_MAX_SLEEP)
- {
- HowLong = ACPI_MAX_SLEEP;
- }
-
- AcpiOsSleep (HowLong);
-
- /* And now we must get the interpreter again */
-
- AcpiExReacquireInterpreter ();
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemSignalEvent
- *
- * PARAMETERS: ObjDesc - The object descriptor for this op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Provides an access point to perform synchronization operations
- * within the AML.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemSignalEvent (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExSystemSignalEvent);
-
-
- if (ObjDesc)
- {
- Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemWaitEvent
- *
- * PARAMETERS: TimeDesc - The 'time to delay' object descriptor
- * ObjDesc - The object descriptor for this op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Provides an access point to perform synchronization operations
- * within the AML. This operation is a request to wait for an
- * event.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemWaitEvent (
- ACPI_OPERAND_OBJECT *TimeDesc,
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (ExSystemWaitEvent);
-
-
- if (ObjDesc)
- {
- Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore,
- (UINT16) TimeDesc->Integer.Value);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExSystemResetEvent
- *
- * PARAMETERS: ObjDesc - The object descriptor for this op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Reset an event to a known state.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiExSystemResetEvent (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_SEMAPHORE TempSemaphore;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * We are going to simply delete the existing semaphore and
- * create a new one!
- */
- Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore);
- if (ACPI_SUCCESS (Status))
- {
- (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore);
- ObjDesc->Event.OsSemaphore = TempSemaphore;
- }
-
- return (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/executer/exutils.c
--- a/head/sys/contrib/dev/acpica/executer/exutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,532 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: exutils - interpreter/scanner 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 __EXUTILS_C__
-
-/*
- * DEFINE_AML_GLOBALS is tested in amlcode.h
- * to determine whether certain global names should be "defined" or only
- * "declared" in the current compilation. This enhances maintainability
- * by enabling a single header file to embody all knowledge of the names
- * in question.
- *
- * Exactly one module of any executable should #define DEFINE_GLOBALS
- * before #including the header files which use this convention. The
- * names in question will be defined and initialized in that module,
- * and declared as extern in all other modules which #include those
- * header files.
- */
-
-#define DEFINE_AML_GLOBALS
-
-#include <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 ("exutils")
-
-/* Local prototypes */
-
-static UINT32
-AcpiExDigitsNeeded (
- UINT64 Value,
- UINT32 Base);
-
-
-#ifndef ACPI_NO_METHOD_EXECUTION
-/*******************************************************************************
- *
- * FUNCTION: AcpiExEnterInterpreter
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Enter the interpreter execution region. Failure to enter
- * the interpreter region is a fatal system error. Used in
- * conjunction with ExitInterpreter.
- *
- ******************************************************************************/
-
-void
-AcpiExEnterInterpreter (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (ExEnterInterpreter);
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
- if (ACPI_FAILURE (Status))
- {
- ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
- }
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExReacquireInterpreter
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Reacquire the interpreter execution region from within the
- * interpreter code. Failure to enter the interpreter region is a
- * fatal system error. Used in conjuction with
- * RelinquishInterpreter
- *
- ******************************************************************************/
-
-void
-AcpiExReacquireInterpreter (
- void)
-{
- ACPI_FUNCTION_TRACE (ExReacquireInterpreter);
-
-
- /*
- * If the global serialized flag is set, do not release the interpreter,
- * since it was not actually released by AcpiExRelinquishInterpreter.
- * This forces the interpreter to be single threaded.
- */
- if (!AcpiGbl_AllMethodsSerialized)
- {
- AcpiExEnterInterpreter ();
- }
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExExitInterpreter
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Exit the interpreter execution region. This is the top level
- * routine used to exit the interpreter when all processing has
- * been completed.
- *
- ******************************************************************************/
-
-void
-AcpiExExitInterpreter (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (ExExitInterpreter);
-
-
- Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
- if (ACPI_FAILURE (Status))
- {
- ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex"));
- }
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExRelinquishInterpreter
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Exit the interpreter execution region, from within the
- * interpreter - before attempting an operation that will possibly
- * block the running thread.
- *
- * Cases where the interpreter is unlocked internally
- * 1) Method to be blocked on a Sleep() AML opcode
- * 2) Method to be blocked on an Acquire() AML opcode
- * 3) Method to be blocked on a Wait() AML opcode
- * 4) Method to be blocked to acquire the global lock
- * 5) Method to be blocked waiting to execute a serialized control method
- * that is currently executing
- * 6) About to invoke a user-installed opregion handler
- *
- ******************************************************************************/
-
-void
-AcpiExRelinquishInterpreter (
- void)
-{
- ACPI_FUNCTION_TRACE (ExRelinquishInterpreter);
-
-
- /*
- * If the global serialized flag is set, do not release the interpreter.
- * This forces the interpreter to be single threaded.
- */
- if (!AcpiGbl_AllMethodsSerialized)
- {
- AcpiExExitInterpreter ();
- }
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExTruncateFor32bitTable
- *
- * PARAMETERS: ObjDesc - Object to be truncated
- *
- * RETURN: none
- *
- * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
- * 32-bit, as determined by the revision of the DSDT.
- *
- ******************************************************************************/
-
-void
-AcpiExTruncateFor32bitTable (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * Object must be a valid number and we must be executing
- * a control method. NS node could be there for AML_INT_NAMEPATH_OP.
- */
- if ((!ObjDesc) ||
- (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) ||
- (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
- {
- return;
- }
-
- if (AcpiGbl_IntegerByteWidth == 4)
- {
- /*
- * We are running a method that exists in a 32-bit ACPI table.
- * Truncate the value to 32 bits by zeroing out the upper 32-bit field
- */
- ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExAcquireGlobalLock
- *
- * PARAMETERS: FieldFlags - Flags with Lock rule:
- * AlwaysLock or NeverLock
- *
- * RETURN: None
- *
- * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
- * flags specifiy that it is to be obtained before field access.
- *
- ******************************************************************************/
-
-void
-AcpiExAcquireGlobalLock (
- UINT32 FieldFlags)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (ExAcquireGlobalLock);
-
-
- /* Only use the lock if the AlwaysLock bit is set */
-
- if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
- {
- return_VOID;
- }
-
- /* Attempt to get the global lock, wait forever */
-
- Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER,
- AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
-
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not acquire Global Lock"));
- }
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExReleaseGlobalLock
- *
- * PARAMETERS: FieldFlags - Flags with Lock rule:
- * AlwaysLock or NeverLock
- *
- * RETURN: None
- *
- * DESCRIPTION: Release the ACPI hardware Global Lock
- *
- ******************************************************************************/
-
-void
-AcpiExReleaseGlobalLock (
- UINT32 FieldFlags)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (ExReleaseGlobalLock);
-
-
- /* Only use the lock if the AlwaysLock bit is set */
-
- if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
- {
- return_VOID;
- }
-
- /* Release the global lock */
-
- Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
- if (ACPI_FAILURE (Status))
- {
- /* Report the error, but there isn't much else we can do */
-
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not release Global Lock"));
- }
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExDigitsNeeded
- *
- * PARAMETERS: Value - Value to be represented
- * Base - Base of representation
- *
- * RETURN: The number of digits.
- *
- * DESCRIPTION: Calculate the number of digits needed to represent the Value
- * in the given Base (Radix)
- *
- ******************************************************************************/
-
-static UINT32
-AcpiExDigitsNeeded (
- UINT64 Value,
- UINT32 Base)
-{
- UINT32 NumDigits;
- UINT64 CurrentValue;
-
-
- ACPI_FUNCTION_TRACE (ExDigitsNeeded);
-
-
- /* UINT64 is unsigned, so we don't worry about a '-' prefix */
-
- if (Value == 0)
- {
- return_UINT32 (1);
- }
-
- CurrentValue = Value;
- NumDigits = 0;
-
- /* Count the digits in the requested base */
-
- while (CurrentValue)
- {
- (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL);
- NumDigits++;
- }
-
- return_UINT32 (NumDigits);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExEisaIdToString
- *
- * PARAMETERS: CompressedId - EISAID to be converted
- * OutString - Where to put the converted string (8 bytes)
- *
- * RETURN: None
- *
- * DESCRIPTION: Convert a numeric EISAID to string representation. Return
- * buffer must be large enough to hold the string. The string
- * returned is always exactly of length ACPI_EISAID_STRING_SIZE
- * (includes null terminator). The EISAID is always 32 bits.
- *
- ******************************************************************************/
-
-void
-AcpiExEisaIdToString (
- char *OutString,
- UINT64 CompressedId)
-{
- UINT32 SwappedId;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* The EISAID should be a 32-bit integer */
-
- if (CompressedId > ACPI_UINT32_MAX)
- {
- ACPI_WARNING ((AE_INFO,
- "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating",
- ACPI_FORMAT_UINT64 (CompressedId)));
- }
-
- /* Swap ID to big-endian to get contiguous bits */
-
- SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId);
-
- /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
-
- OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F));
- OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F));
- OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F));
- OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12);
- OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8);
- OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4);
- OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0);
- OutString[7] = 0;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiExIntegerToString
- *
- * PARAMETERS: OutString - Where to put the converted string. At least
- * 21 bytes are needed to hold the largest
- * possible 64-bit integer.
- * Value - Value to be converted
- *
- * RETURN: None, string
- *
- * DESCRIPTION: Convert a 64-bit integer to decimal string representation.
- * Assumes string buffer is large enough to hold the string. The
- * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1).
- *
- ******************************************************************************/
-
-void
-AcpiExIntegerToString (
- char *OutString,
- UINT64 Value)
-{
- UINT32 Count;
- UINT32 DigitsNeeded;
- UINT32 Remainder;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
- OutString[DigitsNeeded] = 0;
-
- for (Count = DigitsNeeded; Count > 0; Count--)
- {
- (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder);
- OutString[Count-1] = (char) ('0' + Remainder);\
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiIsValidSpaceId
- *
- * PARAMETERS: SpaceId - ID to be validated
- *
- * RETURN: TRUE if valid/supported ID.
- *
- * DESCRIPTION: Validate an operation region SpaceID.
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiIsValidSpaceId (
- UINT8 SpaceId)
-{
-
- if ((SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) &&
- (SpaceId < ACPI_USER_REGION_BEGIN) &&
- (SpaceId != ACPI_ADR_SPACE_DATA_TABLE) &&
- (SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE))
- {
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-
-#endif
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwacpi.c
--- a/head/sys/contrib/dev/acpica/hardware/hwacpi.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
- *
- *****************************************************************************/
-
-/*
- * 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 __HWACPI_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-
-#define _COMPONENT ACPI_HARDWARE
- ACPI_MODULE_NAME ("hwacpi")
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwSetMode
- *
- * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY
- *
- * RETURN: Status
- *
- * DESCRIPTION: Transitions the system into the requested mode.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwSetMode (
- UINT32 Mode)
-{
-
- ACPI_STATUS Status;
- UINT32 Retry;
-
-
- ACPI_FUNCTION_TRACE (HwSetMode);
-
- /*
- * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
- * system does not support mode transition.
- */
- if (!AcpiGbl_FADT.SmiCommand)
- {
- ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed"));
- return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
- }
-
- /*
- * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE
- * in FADT: If it is zero, enabling or disabling is not supported.
- * As old systems may have used zero for mode transition,
- * we make sure both the numbers are zero to determine these
- * transitions are not supported.
- */
- if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable)
- {
- ACPI_ERROR ((AE_INFO,
- "No ACPI mode transition supported in this system "
- "(enable/disable both zero)"));
- return_ACPI_STATUS (AE_OK);
- }
-
- switch (Mode)
- {
- case ACPI_SYS_MODE_ACPI:
-
- /* BIOS should have disabled ALL fixed and GP events */
-
- Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
- (UINT32) AcpiGbl_FADT.AcpiEnable, 8);
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
- break;
-
- case ACPI_SYS_MODE_LEGACY:
-
- /*
- * BIOS should clear all fixed status bits and restore fixed event
- * enable bits to default
- */
- Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
- (UINT32) AcpiGbl_FADT.AcpiDisable, 8);
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Attempting to enable Legacy (non-ACPI) mode\n"));
- break;
-
- default:
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not write ACPI mode change"));
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Some hardware takes a LONG time to switch modes. Give them 3 sec to
- * do so, but allow faster systems to proceed more quickly.
- */
- Retry = 3000;
- while (Retry)
- {
- if (AcpiHwGetMode() == Mode)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n",
- Mode));
- return_ACPI_STATUS (AE_OK);
- }
- AcpiOsStall(1000);
- Retry--;
- }
-
- ACPI_ERROR ((AE_INFO, "Hardware did not change modes"));
- return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwGetMode
- *
- * PARAMETERS: none
- *
- * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY
- *
- * DESCRIPTION: Return current operating state of system. Determined by
- * querying the SCI_EN bit.
- *
- ******************************************************************************/
-
-UINT32
-AcpiHwGetMode (
- void)
-{
- ACPI_STATUS Status;
- UINT32 Value;
-
-
- ACPI_FUNCTION_TRACE (HwGetMode);
-
-
- /*
- * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
- * system does not support mode transition.
- */
- if (!AcpiGbl_FADT.SmiCommand)
- {
- return_UINT32 (ACPI_SYS_MODE_ACPI);
- }
-
- Status = AcpiReadBitRegister (ACPI_BITREG_SCI_ENABLE, &Value);
- if (ACPI_FAILURE (Status))
- {
- return_UINT32 (ACPI_SYS_MODE_LEGACY);
- }
-
- if (Value)
- {
- return_UINT32 (ACPI_SYS_MODE_ACPI);
- }
- else
- {
- return_UINT32 (ACPI_SYS_MODE_LEGACY);
- }
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwgpe.c
--- a/head/sys/contrib/dev/acpica/hardware/hwgpe.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,540 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: hwgpe - Low level GPE enable/disable/clear 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_HARDWARE
- ACPI_MODULE_NAME ("hwgpe")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiHwEnableWakeupGpeBlock (
- ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
- ACPI_GPE_BLOCK_INFO *GpeBlock,
- void *Context);
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwGetGpeRegisterBit
- *
- * PARAMETERS: GpeEventInfo - Info block for the GPE
- * GpeRegisterInfo - Info block for the GPE register
- *
- * RETURN: Register mask with a one in the GPE bit position
- *
- * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
- * correct position for the input GPE.
- *
- ******************************************************************************/
-
-UINT32
-AcpiHwGetGpeRegisterBit (
- ACPI_GPE_EVENT_INFO *GpeEventInfo,
- ACPI_GPE_REGISTER_INFO *GpeRegisterInfo)
-{
-
- return ((UINT32) 1 <<
- (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber));
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwLowSetGpe
- *
- * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled
- * Action - Enable or disable
- *
- * RETURN: Status
- *
- * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwLowSetGpe (
- ACPI_GPE_EVENT_INFO *GpeEventInfo,
- UINT32 Action)
-{
- ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
- ACPI_STATUS Status;
- UINT32 EnableMask;
- UINT32 RegisterBit;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Get the info block for the entire GPE register */
-
- GpeRegisterInfo = GpeEventInfo->RegisterInfo;
- if (!GpeRegisterInfo)
- {
- return (AE_NOT_EXIST);
- }
-
- /* Get current value of the enable register that contains this GPE */
-
- Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Set or clear just the bit that corresponds to this GPE */
-
- RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
- switch (Action)
- {
- case ACPI_GPE_CONDITIONAL_ENABLE:
-
- /* Only enable if the EnableForRun bit is set */
-
- if (!(RegisterBit & GpeRegisterInfo->EnableForRun))
- {
- return (AE_BAD_PARAMETER);
- }
-
- /*lint -fallthrough */
-
- case ACPI_GPE_ENABLE:
- ACPI_SET_BIT (EnableMask, RegisterBit);
- break;
-
- case ACPI_GPE_DISABLE:
- ACPI_CLEAR_BIT (EnableMask, RegisterBit);
- break;
-
- default:
- ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u\n", Action));
- return (AE_BAD_PARAMETER);
- }
-
- /* Write the updated enable mask */
-
- Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
- return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwClearGpe
- *
- * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared
- *
- * RETURN: Status
- *
- * DESCRIPTION: Clear the status bit for a single GPE.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwClearGpe (
- ACPI_GPE_EVENT_INFO *GpeEventInfo)
-{
- ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
- ACPI_STATUS Status;
- UINT32 RegisterBit;
-
-
- ACPI_FUNCTION_ENTRY ();
-
- /* Get the info block for the entire GPE register */
-
- GpeRegisterInfo = GpeEventInfo->RegisterInfo;
- if (!GpeRegisterInfo)
- {
- return (AE_NOT_EXIST);
- }
-
- /*
- * Write a one to the appropriate bit in the status register to
- * clear this GPE.
- */
- RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
-
- Status = AcpiHwWrite (RegisterBit,
- &GpeRegisterInfo->StatusAddress);
-
- return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwGetGpeStatus
- *
- * PARAMETERS: GpeEventInfo - Info block for the GPE to queried
- * EventStatus - Where the GPE status is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Return the status of a single GPE.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwGetGpeStatus (
- ACPI_GPE_EVENT_INFO *GpeEventInfo,
- ACPI_EVENT_STATUS *EventStatus)
-{
- UINT32 InByte;
- UINT32 RegisterBit;
- ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
- ACPI_EVENT_STATUS LocalEventStatus = 0;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!EventStatus)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Get the info block for the entire GPE register */
-
- GpeRegisterInfo = GpeEventInfo->RegisterInfo;
-
- /* Get the register bitmask for this GPE */
-
- RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
-
- /* GPE currently enabled? (enabled for runtime?) */
-
- if (RegisterBit & GpeRegisterInfo->EnableForRun)
- {
- LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
- }
-
- /* GPE enabled for wake? */
-
- if (RegisterBit & GpeRegisterInfo->EnableForWake)
- {
- LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
- }
-
- /* GPE currently active (status bit == 1)? */
-
- Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- if (RegisterBit & InByte)
- {
- LocalEventStatus |= ACPI_EVENT_FLAG_SET;
- }
-
- /* Set return value */
-
- (*EventStatus) = LocalEventStatus;
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwDisableGpeBlock
- *
- * PARAMETERS: GpeXruptInfo - GPE Interrupt info
- * GpeBlock - Gpe Block info
- *
- * RETURN: Status
- *
- * DESCRIPTION: Disable all GPEs within a single GPE block
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwDisableGpeBlock (
- ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
- ACPI_GPE_BLOCK_INFO *GpeBlock,
- void *Context)
-{
- UINT32 i;
- ACPI_STATUS Status;
-
-
- /* Examine each GPE Register within the block */
-
- for (i = 0; i < GpeBlock->RegisterCount; i++)
- {
- /* Disable all GPEs in this register */
-
- Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwClearGpeBlock
- *
- * PARAMETERS: GpeXruptInfo - GPE Interrupt info
- * GpeBlock - Gpe Block info
- *
- * RETURN: Status
- *
- * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwClearGpeBlock (
- ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
- ACPI_GPE_BLOCK_INFO *GpeBlock,
- void *Context)
-{
- UINT32 i;
- ACPI_STATUS Status;
-
-
- /* Examine each GPE Register within the block */
-
- for (i = 0; i < GpeBlock->RegisterCount; i++)
- {
- /* Clear status on all GPEs in this register */
-
- Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwEnableRuntimeGpeBlock
- *
- * PARAMETERS: GpeXruptInfo - GPE Interrupt info
- * GpeBlock - Gpe Block info
- *
- * RETURN: Status
- *
- * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
- * combination wake/run GPEs.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwEnableRuntimeGpeBlock (
- ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
- ACPI_GPE_BLOCK_INFO *GpeBlock,
- void *Context)
-{
- UINT32 i;
- ACPI_STATUS Status;
-
-
- /* NOTE: assumes that all GPEs are currently disabled */
-
- /* Examine each GPE Register within the block */
-
- for (i = 0; i < GpeBlock->RegisterCount; i++)
- {
- if (!GpeBlock->RegisterInfo[i].EnableForRun)
- {
- continue;
- }
-
- /* Enable all "runtime" GPEs in this register */
-
- Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun,
- &GpeBlock->RegisterInfo[i].EnableAddress);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwEnableWakeupGpeBlock
- *
- * PARAMETERS: GpeXruptInfo - GPE Interrupt info
- * GpeBlock - Gpe Block info
- *
- * RETURN: Status
- *
- * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
- * combination wake/run GPEs.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiHwEnableWakeupGpeBlock (
- ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
- ACPI_GPE_BLOCK_INFO *GpeBlock,
- void *Context)
-{
- UINT32 i;
- ACPI_STATUS Status;
-
-
- /* Examine each GPE Register within the block */
-
- for (i = 0; i < GpeBlock->RegisterCount; i++)
- {
- if (!GpeBlock->RegisterInfo[i].EnableForWake)
- {
- continue;
- }
-
- /* Enable all "wake" GPEs in this register */
-
- Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake,
- &GpeBlock->RegisterInfo[i].EnableAddress);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwDisableAllGpes
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwDisableAllGpes (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (HwDisableAllGpes);
-
-
- Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
- Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
- return_ACPI_STATUS (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwEnableAllRuntimeGpes
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwEnableAllRuntimeGpes (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
-
-
- Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
- return_ACPI_STATUS (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwEnableAllWakeupGpes
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwEnableAllWakeupGpes (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
-
-
- Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
- return_ACPI_STATUS (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwpci.c
--- a/head/sys/contrib/dev/acpica/hardware/hwpci.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,459 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: hwpci - Obtain PCI bus, device, and function numbers
- *
- ******************************************************************************/
-
-/*
- * 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 __HWPCI_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("hwpci")
-
-
-/* PCI configuration space values */
-
-#define PCI_CFG_HEADER_TYPE_REG 0x0E
-#define PCI_CFG_PRIMARY_BUS_NUMBER_REG 0x18
-#define PCI_CFG_SECONDARY_BUS_NUMBER_REG 0x19
-
-/* PCI header values */
-
-#define PCI_HEADER_TYPE_MASK 0x7F
-#define PCI_TYPE_BRIDGE 0x01
-#define PCI_TYPE_CARDBUS_BRIDGE 0x02
-
-typedef struct acpi_pci_device
-{
- ACPI_HANDLE Device;
- struct acpi_pci_device *Next;
-
-} ACPI_PCI_DEVICE;
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiHwBuildPciList (
- ACPI_HANDLE RootPciDevice,
- ACPI_HANDLE PciRegion,
- ACPI_PCI_DEVICE **ReturnListHead);
-
-static ACPI_STATUS
-AcpiHwProcessPciList (
- ACPI_PCI_ID *PciId,
- ACPI_PCI_DEVICE *ListHead);
-
-static void
-AcpiHwDeletePciList (
- ACPI_PCI_DEVICE *ListHead);
-
-static ACPI_STATUS
-AcpiHwGetPciDeviceInfo (
- ACPI_PCI_ID *PciId,
- ACPI_HANDLE PciDevice,
- UINT16 *BusNumber,
- BOOLEAN *IsBridge);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwDerivePciId
- *
- * PARAMETERS: PciId - Initial values for the PCI ID. May be
- * modified by this function.
- * RootPciDevice - A handle to a PCI device object. This
- * object must be a PCI Root Bridge having a
- * _HID value of either PNP0A03 or PNP0A08
- * PciRegion - A handle to a PCI configuration space
- * Operation Region being initialized
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function derives a full PCI ID for a PCI device,
- * consisting of a Segment number, Bus number, Device number,
- * and function code.
- *
- * The PCI hardware dynamically configures PCI bus numbers
- * depending on the bus topology discovered during system
- * initialization. This function is invoked during configuration
- * of a PCI_Config Operation Region in order to (possibly) update
- * the Bus/Device/Function numbers in the PciId with the actual
- * values as determined by the hardware and operating system
- * configuration.
- *
- * The PciId parameter is initially populated during the Operation
- * Region initialization. This function is then called, and is
- * will make any necessary modifications to the Bus, Device, or
- * Function number PCI ID subfields as appropriate for the
- * current hardware and OS configuration.
- *
- * NOTE: Created 08/2010. Replaces the previous OSL AcpiOsDerivePciId
- * interface since this feature is OS-independent. This module
- * specifically avoids any use of recursion by building a local
- * temporary device list.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwDerivePciId (
- ACPI_PCI_ID *PciId,
- ACPI_HANDLE RootPciDevice,
- ACPI_HANDLE PciRegion)
-{
- ACPI_STATUS Status;
- ACPI_PCI_DEVICE *ListHead = NULL;
-
-
- ACPI_FUNCTION_TRACE (HwDerivePciId);
-
-
- if (!PciId)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Build a list of PCI devices, from PciRegion up to RootPciDevice */
-
- Status = AcpiHwBuildPciList (RootPciDevice, PciRegion, &ListHead);
- if (ACPI_SUCCESS (Status))
- {
- /* Walk the list, updating the PCI device/function/bus numbers */
-
- Status = AcpiHwProcessPciList (PciId, ListHead);
- }
-
- /* Always delete the list */
-
- AcpiHwDeletePciList (ListHead);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwBuildPciList
- *
- * PARAMETERS: RootPciDevice - A handle to a PCI device object. This
- * object is guaranteed to be a PCI Root
- * Bridge having a _HID value of either
- * PNP0A03 or PNP0A08
- * PciRegion - A handle to the PCI configuration space
- * Operation Region
- * ReturnListHead - Where the PCI device list is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Builds a list of devices from the input PCI region up to the
- * Root PCI device for this namespace subtree.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiHwBuildPciList (
- ACPI_HANDLE RootPciDevice,
- ACPI_HANDLE PciRegion,
- ACPI_PCI_DEVICE **ReturnListHead)
-{
- ACPI_HANDLE CurrentDevice;
- ACPI_HANDLE ParentDevice;
- ACPI_STATUS Status;
- ACPI_PCI_DEVICE *ListElement;
- ACPI_PCI_DEVICE *ListHead = NULL;
-
-
- /*
- * Ascend namespace branch until the RootPciDevice is reached, building
- * a list of device nodes. Loop will exit when either the PCI device is
- * found, or the root of the namespace is reached.
- */
- CurrentDevice = PciRegion;
- while (1)
- {
- Status = AcpiGetParent (CurrentDevice, &ParentDevice);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Finished when we reach the PCI root device (PNP0A03 or PNP0A08) */
-
- if (ParentDevice == RootPciDevice)
- {
- *ReturnListHead = ListHead;
- return (AE_OK);
- }
-
- ListElement = ACPI_ALLOCATE (sizeof (ACPI_PCI_DEVICE));
- if (!ListElement)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Put new element at the head of the list */
-
- ListElement->Next = ListHead;
- ListElement->Device = ParentDevice;
- ListHead = ListElement;
-
- CurrentDevice = ParentDevice;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwProcessPciList
- *
- * PARAMETERS: PciId - Initial values for the PCI ID. May be
- * modified by this function.
- * ListHead - Device list created by
- * AcpiHwBuildPciList
- *
- * RETURN: Status
- *
- * DESCRIPTION: Walk downward through the PCI device list, getting the device
- * info for each, via the PCI configuration space and updating
- * the PCI ID as necessary. Deletes the list during traversal.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiHwProcessPciList (
- ACPI_PCI_ID *PciId,
- ACPI_PCI_DEVICE *ListHead)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PCI_DEVICE *Info;
- UINT16 BusNumber;
- BOOLEAN IsBridge = TRUE;
-
-
- ACPI_FUNCTION_NAME (HwProcessPciList);
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
- "Input PciId: Seg %4.4X Bus %4.4X Dev %4.4X Func %4.4X\n",
- PciId->Segment, PciId->Bus, PciId->Device, PciId->Function));
-
- BusNumber = PciId->Bus;
-
- /*
- * Descend down the namespace tree, collecting PCI device, function,
- * and bus numbers. BusNumber is only important for PCI bridges.
- * Algorithm: As we descend the tree, use the last valid PCI device,
- * function, and bus numbers that are discovered, and assign them
- * to the PCI ID for the target device.
- */
- Info = ListHead;
- while (Info)
- {
- Status = AcpiHwGetPciDeviceInfo (PciId, Info->Device,
- &BusNumber, &IsBridge);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Info = Info->Next;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
- "Output PciId: Seg %4.4X Bus %4.4X Dev %4.4X Func %4.4X "
- "Status %X BusNumber %X IsBridge %X\n",
- PciId->Segment, PciId->Bus, PciId->Device, PciId->Function,
- Status, BusNumber, IsBridge));
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwDeletePciList
- *
- * PARAMETERS: ListHead - Device list created by
- * AcpiHwBuildPciList
- *
- * RETURN: None
- *
- * DESCRIPTION: Free the entire PCI list.
- *
- ******************************************************************************/
-
-static void
-AcpiHwDeletePciList (
- ACPI_PCI_DEVICE *ListHead)
-{
- ACPI_PCI_DEVICE *Next;
- ACPI_PCI_DEVICE *Previous;
-
-
- Next = ListHead;
- while (Next)
- {
- Previous = Next;
- Next = Previous->Next;
- ACPI_FREE (Previous);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwGetPciDeviceInfo
- *
- * PARAMETERS: PciId - Initial values for the PCI ID. May be
- * modified by this function.
- * PciDevice - Handle for the PCI device object
- * BusNumber - Where a PCI bridge bus number is returned
- * IsBridge - Return value, indicates if this PCI
- * device is a PCI bridge
- *
- * RETURN: Status
- *
- * DESCRIPTION: Get the device info for a single PCI device object. Get the
- * _ADR (contains PCI device and function numbers), and for PCI
- * bridge devices, get the bus number from PCI configuration
- * space.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiHwGetPciDeviceInfo (
- ACPI_PCI_ID *PciId,
- ACPI_HANDLE PciDevice,
- UINT16 *BusNumber,
- BOOLEAN *IsBridge)
-{
- ACPI_STATUS Status;
- ACPI_OBJECT_TYPE ObjectType;
- UINT64 ReturnValue;
- UINT64 PciValue;
-
-
- /* We only care about objects of type Device */
-
- Status = AcpiGetType (PciDevice, &ObjectType);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- if (ObjectType != ACPI_TYPE_DEVICE)
- {
- return (AE_OK);
- }
-
- /* We need an _ADR. Ignore device if not present */
-
- Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR,
- PciDevice, &ReturnValue);
- if (ACPI_FAILURE (Status))
- {
- return (AE_OK);
- }
-
- /*
- * From _ADR, get the PCI Device and Function and
- * update the PCI ID.
- */
- PciId->Device = ACPI_HIWORD (ACPI_LODWORD (ReturnValue));
- PciId->Function = ACPI_LOWORD (ACPI_LODWORD (ReturnValue));
-
- /*
- * If the previous device was a bridge, use the previous
- * device bus number
- */
- if (*IsBridge)
- {
- PciId->Bus = *BusNumber;
- }
-
- /*
- * Get the bus numbers from PCI Config space:
- *
- * First, get the PCI HeaderType
- */
- *IsBridge = FALSE;
- Status = AcpiOsReadPciConfiguration (PciId,
- PCI_CFG_HEADER_TYPE_REG, &PciValue, 8);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* We only care about bridges (1=PciBridge, 2=CardBusBridge) */
-
- PciValue &= PCI_HEADER_TYPE_MASK;
-
- if ((PciValue != PCI_TYPE_BRIDGE) &&
- (PciValue != PCI_TYPE_CARDBUS_BRIDGE))
- {
- return (AE_OK);
- }
-
- /* Bridge: Get the Primary BusNumber */
-
- Status = AcpiOsReadPciConfiguration (PciId,
- PCI_CFG_PRIMARY_BUS_NUMBER_REG, &PciValue, 8);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- *IsBridge = TRUE;
- PciId->Bus = (UINT16) PciValue;
-
- /* Bridge: Get the Secondary BusNumber */
-
- Status = AcpiOsReadPciConfiguration (PciId,
- PCI_CFG_SECONDARY_BUS_NUMBER_REG, &PciValue, 8);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- *BusNumber = (UINT16) PciValue;
- return (AE_OK);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwregs.c
--- a/head/sys/contrib/dev/acpica/hardware/hwregs.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,733 +0,0 @@
-
-/*******************************************************************************
- *
- * Module Name: hwregs - Read/write access functions for the various ACPI
- * control and status registers.
- *
- ******************************************************************************/
-
-/*
- * 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 __HWREGS_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acevents.h>
-
-#define _COMPONENT ACPI_HARDWARE
- ACPI_MODULE_NAME ("hwregs")
-
-
-/* Local Prototypes */
-
-static ACPI_STATUS
-AcpiHwReadMultiple (
- UINT32 *Value,
- ACPI_GENERIC_ADDRESS *RegisterA,
- ACPI_GENERIC_ADDRESS *RegisterB);
-
-static ACPI_STATUS
-AcpiHwWriteMultiple (
- UINT32 Value,
- ACPI_GENERIC_ADDRESS *RegisterA,
- ACPI_GENERIC_ADDRESS *RegisterB);
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwValidateRegister
- *
- * PARAMETERS: Reg - GAS register structure
- * MaxBitWidth - Max BitWidth supported (32 or 64)
- * Address - Pointer to where the gas->address
- * is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS
- * pointer, Address, SpaceId, BitWidth, and BitOffset.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwValidateRegister (
- ACPI_GENERIC_ADDRESS *Reg,
- UINT8 MaxBitWidth,
- UINT64 *Address)
-{
-
- /* Must have a valid pointer to a GAS structure */
-
- if (!Reg)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * Copy the target address. This handles possible alignment issues.
- * Address must not be null. A null address also indicates an optional
- * ACPI register that is not supported, so no error message.
- */
- ACPI_MOVE_64_TO_64 (Address, &Reg->Address);
- if (!(*Address))
- {
- return (AE_BAD_ADDRESS);
- }
-
- /* Validate the SpaceID */
-
- if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
- (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
- {
- ACPI_ERROR ((AE_INFO,
- "Unsupported address space: 0x%X", Reg->SpaceId));
- return (AE_SUPPORT);
- }
-
- /* Validate the BitWidth */
-
- if ((Reg->BitWidth != 8) &&
- (Reg->BitWidth != 16) &&
- (Reg->BitWidth != 32) &&
- (Reg->BitWidth != MaxBitWidth))
- {
- ACPI_ERROR ((AE_INFO,
- "Unsupported register bit width: 0x%X", Reg->BitWidth));
- return (AE_SUPPORT);
- }
-
- /* Validate the BitOffset. Just a warning for now. */
-
- if (Reg->BitOffset != 0)
- {
- ACPI_WARNING ((AE_INFO,
- "Unsupported register bit offset: 0x%X", Reg->BitOffset));
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwRead
- *
- * PARAMETERS: Value - Where the value is returned
- * Reg - GAS register structure
- *
- * RETURN: Status
- *
- * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max
- * version of AcpiRead, used internally since the overhead of
- * 64-bit values is not needed.
- *
- * LIMITATIONS: <These limitations also apply to AcpiHwWrite>
- * BitWidth must be exactly 8, 16, or 32.
- * SpaceID must be SystemMemory or SystemIO.
- * BitOffset and AccessWidth are currently ignored, as there has
- * not been a need to implement these.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwRead (
- UINT32 *Value,
- ACPI_GENERIC_ADDRESS *Reg)
-{
- UINT64 Address;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_NAME (HwRead);
-
-
- /* Validate contents of the GAS register */
-
- Status = AcpiHwValidateRegister (Reg, 32, &Address);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Initialize entire 32-bit return value to zero */
-
- *Value = 0;
-
- /*
- * Two address spaces supported: Memory or IO. PCI_Config is
- * not supported here because the GAS structure is insufficient
- */
- if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
- {
- Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
- Address, Value, Reg->BitWidth);
- }
- else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
- {
- Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
- Address, Value, Reg->BitWidth);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO,
- "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
- *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
- AcpiUtGetRegionName (Reg->SpaceId)));
-
- return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwWrite
- *
- * PARAMETERS: Value - Value to be written
- * Reg - GAS register structure
- *
- * RETURN: Status
- *
- * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max
- * version of AcpiWrite, used internally since the overhead of
- * 64-bit values is not needed.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwWrite (
- UINT32 Value,
- ACPI_GENERIC_ADDRESS *Reg)
-{
- UINT64 Address;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_NAME (HwWrite);
-
-
- /* Validate contents of the GAS register */
-
- Status = AcpiHwValidateRegister (Reg, 32, &Address);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * Two address spaces supported: Memory or IO. PCI_Config is
- * not supported here because the GAS structure is insufficient
- */
- if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
- {
- Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
- Address, Value, Reg->BitWidth);
- }
- else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
- {
- Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
- Address, Value, Reg->BitWidth);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO,
- "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
- Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
- AcpiUtGetRegionName (Reg->SpaceId)));
-
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwClearAcpiStatus
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Clears all fixed and general purpose status bits
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwClearAcpiStatus (
- void)
-{
- ACPI_STATUS Status;
- ACPI_CPU_FLAGS LockFlags = 0;
-
-
- ACPI_FUNCTION_TRACE (HwClearAcpiStatus);
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n",
- ACPI_BITMASK_ALL_FIXED_STATUS,
- ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address)));
-
- LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
-
- /* Clear the fixed events in PM1 A/B */
-
- Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
- ACPI_BITMASK_ALL_FIXED_STATUS);
- if (ACPI_FAILURE (Status))
- {
- goto UnlockAndExit;
- }
-
- /* Clear the GPE Bits in all GPE registers in all GPE blocks */
-
- Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
-
-UnlockAndExit:
- AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiHwGetRegisterBitMask
- *
- * PARAMETERS: RegisterId - Index of ACPI Register to access
- *
- * RETURN: The bitmask to be used when accessing the register
- *
- * DESCRIPTION: Map RegisterId into a register bitmask.
- *
- ******************************************************************************/
-
-ACPI_BIT_REGISTER_INFO *
-AcpiHwGetBitRegisterInfo (
- UINT32 RegisterId)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- if (RegisterId > ACPI_BITREG_MAX)
- {
- ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: 0x%X", RegisterId));
- return (NULL);
- }
-
- return (&AcpiGbl_BitRegisterInfo[RegisterId]);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwWritePm1Control
- *
- * PARAMETERS: Pm1aControl - Value to be written to PM1A control
- * Pm1bControl - Value to be written to PM1B control
- *
- * RETURN: Status
- *
- * DESCRIPTION: Write the PM1 A/B control registers. These registers are
- * different than than the PM1 A/B status and enable registers
- * in that different values can be written to the A/B registers.
- * Most notably, the SLP_TYP bits can be different, as per the
- * values returned from the _Sx predefined methods.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwWritePm1Control (
- UINT32 Pm1aControl,
- UINT32 Pm1bControl)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (HwWritePm1Control);
-
-
- Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (AcpiGbl_FADT.XPm1bControlBlock.Address)
- {
- Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock);
- }
- return_ACPI_STATUS (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwRegisterRead
- *
- * PARAMETERS: RegisterId - ACPI Register ID
- * ReturnValue - Where the register value is returned
- *
- * RETURN: Status and the value read.
- *
- * DESCRIPTION: Read from the specified ACPI register
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwRegisterRead (
- UINT32 RegisterId,
- UINT32 *ReturnValue)
-{
- UINT32 Value = 0;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (HwRegisterRead);
-
-
- switch (RegisterId)
- {
- case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
-
- Status = AcpiHwReadMultiple (&Value,
- &AcpiGbl_XPm1aStatus,
- &AcpiGbl_XPm1bStatus);
- break;
-
-
- case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
-
- Status = AcpiHwReadMultiple (&Value,
- &AcpiGbl_XPm1aEnable,
- &AcpiGbl_XPm1bEnable);
- break;
-
-
- case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
-
- Status = AcpiHwReadMultiple (&Value,
- &AcpiGbl_FADT.XPm1aControlBlock,
- &AcpiGbl_FADT.XPm1bControlBlock);
-
- /*
- * Zero the write-only bits. From the ACPI specification, "Hardware
- * Write-Only Bits": "Upon reads to registers with write-only bits,
- * software masks out all write-only bits."
- */
- Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS;
- break;
-
-
- case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
-
- Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock);
- break;
-
-
- case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
-
- Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock);
- break;
-
-
- case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
-
- Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8);
- break;
-
-
- default:
- ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
- RegisterId));
- Status = AE_BAD_PARAMETER;
- break;
- }
-
- if (ACPI_SUCCESS (Status))
- {
- *ReturnValue = Value;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwRegisterWrite
- *
- * PARAMETERS: RegisterId - ACPI Register ID
- * Value - The value to write
- *
- * RETURN: Status
- *
- * DESCRIPTION: Write to the specified ACPI register
- *
- * NOTE: In accordance with the ACPI specification, this function automatically
- * preserves the value of the following bits, meaning that these bits cannot be
- * changed via this interface:
- *
- * PM1_CONTROL[0] = SCI_EN
- * PM1_CONTROL[9]
- * PM1_STATUS[11]
- *
- * ACPI References:
- * 1) Hardware Ignored Bits: When software writes to a register with ignored
- * bit fields, it preserves the ignored bit fields
- * 2) SCI_EN: OSPM always preserves this bit position
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiHwRegisterWrite (
- UINT32 RegisterId,
- UINT32 Value)
-{
- ACPI_STATUS Status;
- UINT32 ReadValue;
-
-
- ACPI_FUNCTION_TRACE (HwRegisterWrite);
-
-
- switch (RegisterId)
- {
- case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */
- /*
- * Handle the "ignored" bit in PM1 Status. According to the ACPI
- * specification, ignored bits are to be preserved when writing.
- * Normally, this would mean a read/modify/write sequence. However,
- * preserving a bit in the status register is different. Writing a
- * one clears the status, and writing a zero preserves the status.
- * Therefore, we must always write zero to the ignored bit.
- *
- * This behavior is clarified in the ACPI 4.0 specification.
- */
- Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS;
-
- Status = AcpiHwWriteMultiple (Value,
- &AcpiGbl_XPm1aStatus,
- &AcpiGbl_XPm1bStatus);
- break;
-
-
- case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
-
- Status = AcpiHwWriteMultiple (Value,
- &AcpiGbl_XPm1aEnable,
- &AcpiGbl_XPm1bEnable);
- break;
-
-
- case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */
-
- /*
- * Perform a read first to preserve certain bits (per ACPI spec)
- * Note: This includes SCI_EN, we never want to change this bit
- */
- Status = AcpiHwReadMultiple (&ReadValue,
- &AcpiGbl_FADT.XPm1aControlBlock,
- &AcpiGbl_FADT.XPm1bControlBlock);
- if (ACPI_FAILURE (Status))
- {
- goto Exit;
- }
-
- /* Insert the bits to be preserved */
-
- ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue);
-
- /* Now we can write the data */
-
- Status = AcpiHwWriteMultiple (Value,
- &AcpiGbl_FADT.XPm1aControlBlock,
- &AcpiGbl_FADT.XPm1bControlBlock);
- break;
-
-
- case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
-
- /*
- * For control registers, all reserved bits must be preserved,
- * as per the ACPI spec.
- */
- Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock);
- if (ACPI_FAILURE (Status))
- {
- goto Exit;
- }
-
- /* Insert the bits to be preserved */
-
- ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue);
-
- Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock);
- break;
-
-
- case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
-
- Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock);
- break;
-
-
- case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
-
- /* SMI_CMD is currently always in IO space */
-
- Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8);
- break;
-
-
- default:
- ACPI_ERROR ((AE_INFO, "Unknown Register ID: 0x%X",
- RegisterId));
- Status = AE_BAD_PARAMETER;
- break;
- }
-
-Exit:
- return_ACPI_STATUS (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwReadMultiple
- *
- * PARAMETERS: Value - Where the register value is returned
- * RegisterA - First ACPI register (required)
- * RegisterB - Second ACPI register (optional)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B)
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiHwReadMultiple (
- UINT32 *Value,
- ACPI_GENERIC_ADDRESS *RegisterA,
- ACPI_GENERIC_ADDRESS *RegisterB)
-{
- UINT32 ValueA = 0;
- UINT32 ValueB = 0;
- ACPI_STATUS Status;
-
-
- /* The first register is always required */
-
- Status = AcpiHwRead (&ValueA, RegisterA);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Second register is optional */
-
- if (RegisterB->Address)
- {
- Status = AcpiHwRead (&ValueB, RegisterB);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- /*
- * OR the two return values together. No shifting or masking is necessary,
- * because of how the PM1 registers are defined in the ACPI specification:
- *
- * "Although the bits can be split between the two register blocks (each
- * register block has a unique pointer within the FADT), the bit positions
- * are maintained. The register block with unimplemented bits (that is,
- * those implemented in the other register block) always returns zeros,
- * and writes have no side effects"
- */
- *Value = (ValueA | ValueB);
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwWriteMultiple
- *
- * PARAMETERS: Value - The value to write
- * RegisterA - First ACPI register (required)
- * RegisterB - Second ACPI register (optional)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B)
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiHwWriteMultiple (
- UINT32 Value,
- ACPI_GENERIC_ADDRESS *RegisterA,
- ACPI_GENERIC_ADDRESS *RegisterB)
-{
- ACPI_STATUS Status;
-
-
- /* The first register is always required */
-
- Status = AcpiHwWrite (Value, RegisterA);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * Second register is optional
- *
- * No bit shifting or clearing is necessary, because of how the PM1
- * registers are defined in the ACPI specification:
- *
- * "Although the bits can be split between the two register blocks (each
- * register block has a unique pointer within the FADT), the bit positions
- * are maintained. The register block with unimplemented bits (that is,
- * those implemented in the other register block) always returns zeros,
- * and writes have no side effects"
- */
- if (RegisterB->Address)
- {
- Status = AcpiHwWrite (Value, RegisterB);
- }
-
- return (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwsleep.c
--- a/head/sys/contrib/dev/acpica/hardware/hwsleep.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,653 +0,0 @@
-
-/******************************************************************************
- *
- * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
- *
- *****************************************************************************/
-
-/*
- * 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>
-
-#define _COMPONENT ACPI_HARDWARE
- ACPI_MODULE_NAME ("hwsleep")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiSetFirmwareWakingVector
- *
- * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode
- * entry point.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiSetFirmwareWakingVector (
- UINT32 PhysicalAddress)
-{
- ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector);
-
-
- /* Set the 32-bit vector */
-
- AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress;
-
- /* Clear the 64-bit vector if it exists */
-
- if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1))
- {
- AcpiGbl_FACS->XFirmwareWakingVector = 0;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector)
-
-
-#if ACPI_MACHINE_WIDTH == 64
-/*******************************************************************************
- *
- * FUNCTION: AcpiSetFirmwareWakingVector64
- *
- * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected
- * mode entry point.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if
- * it exists in the table. This function is intended for use with
- * 64-bit host operating systems.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiSetFirmwareWakingVector64 (
- UINT64 PhysicalAddress)
-{
- ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64);
-
-
- /* Determine if the 64-bit vector actually exists */
-
- if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1))
- {
- return_ACPI_STATUS (AE_NOT_EXIST);
- }
-
- /* Clear 32-bit vector, set the 64-bit X_ vector */
-
- AcpiGbl_FACS->FirmwareWakingVector = 0;
- AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress;
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64)
-#endif
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiEnterSleepStatePrep
- *
- * PARAMETERS: SleepState - Which sleep state to enter
- *
- * RETURN: Status
- *
- * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
- * This function must execute with interrupts enabled.
- * We break sleeping into 2 stages so that OSPM can handle
- * various OS-specific tasks between the two steps.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiEnterSleepStatePrep (
- UINT8 SleepState)
-{
- ACPI_STATUS Status;
- ACPI_OBJECT_LIST ArgList;
- ACPI_OBJECT Arg;
-
-
- ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep);
-
-
- /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */
-
- Status = AcpiGetSleepTypeData (SleepState,
- &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Execute the _PTS method (Prepare To Sleep) */
-
- ArgList.Count = 1;
- ArgList.Pointer = &Arg;
- Arg.Type = ACPI_TYPE_INTEGER;
- Arg.Integer.Value = SleepState;
-
- Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL);
- if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Setup the argument to the _SST method (System STatus) */
-
- switch (SleepState)
- {
- case ACPI_STATE_S0:
- Arg.Integer.Value = ACPI_SST_WORKING;
- break;
-
- case ACPI_STATE_S1:
- case ACPI_STATE_S2:
- case ACPI_STATE_S3:
- Arg.Integer.Value = ACPI_SST_SLEEPING;
- break;
-
- case ACPI_STATE_S4:
- Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT;
- break;
-
- default:
- Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */
- break;
- }
-
- /*
- * Set the system indicators to show the desired sleep state.
- * _SST is an optional method (return no error if not found)
- */
- Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
- if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "While executing method _SST"));
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiEnterSleepState
- *
- * PARAMETERS: SleepState - Which sleep state to enter
- *
- * RETURN: Status
- *
- * DESCRIPTION: Enter a system sleep state
- * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiEnterSleepState (
- UINT8 SleepState)
-{
- UINT32 Pm1aControl;
- UINT32 Pm1bControl;
- ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
- ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
- UINT32 InValue;
- ACPI_OBJECT_LIST ArgList;
- ACPI_OBJECT Arg;
- UINT32 Retry;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiEnterSleepState);
-
-
- if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) ||
- (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX))
- {
- ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
- AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB));
- return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
- }
-
- SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE);
- SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);
-
- /* Clear wake status */
-
- Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Clear all fixed and general purpose status bits */
-
- Status = AcpiHwClearAcpiStatus ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (SleepState != ACPI_STATE_S5)
- {
- /*
- * Disable BM arbitration. This feature is contained within an
- * optional register (PM2 Control), so ignore a BAD_ADDRESS
- * exception.
- */
- Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1);
- if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * 1) Disable/Clear all GPEs
- * 2) Enable all wakeup GPEs
- */
- Status = AcpiHwDisableAllGpes ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- AcpiGbl_SystemAwakeAndRunning = FALSE;
-
- Status = AcpiHwEnableAllWakeupGpes ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Execute the _GTS method (Going To Sleep) */
-
- ArgList.Count = 1;
- ArgList.Pointer = &Arg;
- Arg.Type = ACPI_TYPE_INTEGER;
- Arg.Integer.Value = SleepState;
-
- Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL);
- if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Get current value of PM1A control */
-
- Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL,
- &Pm1aControl);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
- "Entering sleep state [S%u]\n", SleepState));
-
- /* Clear the SLP_EN and SLP_TYP fields */
-
- Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask |
- SleepEnableRegInfo->AccessBitMask);
- Pm1bControl = Pm1aControl;
-
- /* Insert the SLP_TYP bits */
-
- Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
- Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
-
- /*
- * We split the writes of SLP_TYP and SLP_EN to workaround
- * poorly implemented hardware.
- */
-
- /* Write #1: write the SLP_TYP data to the PM1 Control registers */
-
- Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Insert the sleep enable (SLP_EN) bit */
-
- Pm1aControl |= SleepEnableRegInfo->AccessBitMask;
- Pm1bControl |= SleepEnableRegInfo->AccessBitMask;
-
- /* Flush caches, as per ACPI specification */
-
- ACPI_FLUSH_CPU_CACHE ();
-
- /* Write #2: Write both SLP_TYP + SLP_EN */
-
- Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (SleepState > ACPI_STATE_S3)
- {
- /*
- * We wanted to sleep > S3, but it didn't happen (by virtue of the
- * fact that we are still executing!)
- *
- * Wait ten seconds, then try again. This is to get S4/S5 to work on
- * all machines.
- *
- * We wait so long to allow chipsets that poll this reg very slowly
- * to still read the right value. Ideally, this block would go
- * away entirely.
- */
- AcpiOsStall (10000000);
-
- Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL,
- SleepEnableRegInfo->AccessBitMask);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /* Wait until we enter sleep state */
-
- Retry = 1000;
- do
- {
- Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (AcpiGbl_EnableInterpreterSlack)
- {
- /*
- * Some BIOSs don't set WAK_STS at all. Give up waiting after
- * 1000 retries if it still isn't set.
- */
- if (Retry-- == 0)
- {
- break;
- }
- }
-
- /* Spin until we wake */
-
- } while (!InValue);
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiEnterSleepState)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiEnterSleepStateS4bios
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Perform a S4 bios request.
- * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiEnterSleepStateS4bios (
- void)
-{
- UINT32 InValue;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios);
-
-
- /* Clear the wake status bit (PM1) */
-
- Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiHwClearAcpiStatus ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * 1) Disable/Clear all GPEs
- * 2) Enable all wakeup GPEs
- */
- Status = AcpiHwDisableAllGpes ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- AcpiGbl_SystemAwakeAndRunning = FALSE;
-
- Status = AcpiHwEnableAllWakeupGpes ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- ACPI_FLUSH_CPU_CACHE ();
-
- Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand,
- (UINT32) AcpiGbl_FADT.S4BiosRequest, 8);
-
- do {
- AcpiOsStall(1000);
- Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- } while (!InValue);
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiLeaveSleepState
- *
- * PARAMETERS: SleepState - Which sleep state we just exited
- *
- * RETURN: Status
- *
- * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
- * Called with interrupts ENABLED.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiLeaveSleepState (
- UINT8 SleepState)
-{
- ACPI_OBJECT_LIST ArgList;
- ACPI_OBJECT Arg;
- ACPI_STATUS Status;
- ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
- ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
- UINT32 Pm1aControl;
- UINT32 Pm1bControl;
-
-
- ACPI_FUNCTION_TRACE (AcpiLeaveSleepState);
-
-
- /*
- * Set SLP_TYPE and SLP_EN to state S0.
- * This is unclear from the ACPI Spec, but it is required
- * by some machines.
- */
- Status = AcpiGetSleepTypeData (ACPI_STATE_S0,
- &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
- if (ACPI_SUCCESS (Status))
- {
- SleepTypeRegInfo =
- AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE);
- SleepEnableRegInfo =
- AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);
-
- /* Get current value of PM1A control */
-
- Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL,
- &Pm1aControl);
- if (ACPI_SUCCESS (Status))
- {
- /* Clear the SLP_EN and SLP_TYP fields */
-
- Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask |
- SleepEnableRegInfo->AccessBitMask);
- Pm1bControl = Pm1aControl;
-
- /* Insert the SLP_TYP bits */
-
- Pm1aControl |= (AcpiGbl_SleepTypeA <<
- SleepTypeRegInfo->BitPosition);
- Pm1bControl |= (AcpiGbl_SleepTypeB <<
- SleepTypeRegInfo->BitPosition);
-
- /* Write the control registers and ignore any errors */
-
- (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
- }
- }
-
- /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
-
- AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
-
- /* Setup parameter object */
-
- ArgList.Count = 1;
- ArgList.Pointer = &Arg;
- Arg.Type = ACPI_TYPE_INTEGER;
-
- /* Ignore any errors from these methods */
-
- Arg.Integer.Value = ACPI_SST_WAKING;
- Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
- if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST"));
- }
-
- Arg.Integer.Value = SleepState;
- Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL);
- if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During Method _BFS"));
- }
-
- Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL);
- if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During Method _WAK"));
- }
- /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
-
- /*
- * Restore the GPEs:
- * 1) Disable/Clear all GPEs
- * 2) Enable all runtime GPEs
- */
- Status = AcpiHwDisableAllGpes ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- AcpiGbl_SystemAwakeAndRunning = TRUE;
-
- Status = AcpiHwEnableAllRuntimeGpes ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Enable power button */
-
- (void) AcpiWriteBitRegister(
- AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId,
- ACPI_ENABLE_EVENT);
-
- (void) AcpiWriteBitRegister(
- AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId,
- ACPI_CLEAR_STATUS);
-
- /*
- * Enable BM arbitration. This feature is contained within an
- * optional register (PM2 Control), so ignore a BAD_ADDRESS
- * exception.
- */
- Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0);
- if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS))
- {
- return_ACPI_STATUS (Status);
- }
-
- Arg.Integer.Value = ACPI_SST_WORKING;
- Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
- if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST"));
- }
-
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState)
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwtimer.c
--- a/head/sys/contrib/dev/acpica/hardware/hwtimer.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-
-/******************************************************************************
- *
- * Name: hwtimer.c - ACPI Power Management Timer Interface
- *
- *****************************************************************************/
-
-/*
- * 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>
-
-#define _COMPONENT ACPI_HARDWARE
- ACPI_MODULE_NAME ("hwtimer")
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiGetTimerResolution
- *
- * PARAMETERS: Resolution - Where the resolution is returned
- *
- * RETURN: Status and timer resolution
- *
- * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits).
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetTimerResolution (
- UINT32 *Resolution)
-{
- ACPI_FUNCTION_TRACE (AcpiGetTimerResolution);
-
-
- if (!Resolution)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
- {
- *Resolution = 24;
- }
- else
- {
- *Resolution = 32;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetTimerResolution)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiGetTimer
- *
- * PARAMETERS: Ticks - Where the timer value is returned
- *
- * RETURN: Status and current timer value (ticks)
- *
- * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks).
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetTimer (
- UINT32 *Ticks)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetTimer);
-
-
- if (!Ticks)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock);
-
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetTimer)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiGetTimerDuration
- *
- * PARAMETERS: StartTicks - Starting timestamp
- * EndTicks - End timestamp
- * TimeElapsed - Where the elapsed time is returned
- *
- * RETURN: Status and TimeElapsed
- *
- * DESCRIPTION: Computes the time elapsed (in microseconds) between two
- * PM Timer time stamps, taking into account the possibility of
- * rollovers, the timer resolution, and timer frequency.
- *
- * The PM Timer's clock ticks at roughly 3.6 times per
- * _microsecond_, and its clock continues through Cx state
- * transitions (unlike many CPU timestamp counters) -- making it
- * a versatile and accurate timer.
- *
- * Note that this function accommodates only a single timer
- * rollover. Thus for 24-bit timers, this function should only
- * be used for calculating durations less than ~4.6 seconds
- * (~20 minutes for 32-bit timers) -- calculations below:
- *
- * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec
- * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetTimerDuration (
- UINT32 StartTicks,
- UINT32 EndTicks,
- UINT32 *TimeElapsed)
-{
- ACPI_STATUS Status;
- UINT32 DeltaTicks;
- UINT64 Quotient;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetTimerDuration);
-
-
- if (!TimeElapsed)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /*
- * Compute Tick Delta:
- * Handle (max one) timer rollovers on 24-bit versus 32-bit timers.
- */
- if (StartTicks < EndTicks)
- {
- DeltaTicks = EndTicks - StartTicks;
- }
- else if (StartTicks > EndTicks)
- {
- if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0)
- {
- /* 24-bit Timer */
-
- DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF);
- }
- else
- {
- /* 32-bit Timer */
-
- DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks;
- }
- }
- else /* StartTicks == EndTicks */
- {
- *TimeElapsed = 0;
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Compute Duration (Requires a 64-bit multiply and divide):
- *
- * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY;
- */
- Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000,
- PM_TIMER_FREQUENCY, &Quotient, NULL);
-
- *TimeElapsed = (UINT32) Quotient;
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetTimerDuration)
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwvalid.c
--- a/head/sys/contrib/dev/acpica/hardware/hwvalid.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,368 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: hwvalid - I/O request validation
- *
- *****************************************************************************/
-
-/*
- * 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 __HWVALID_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#define _COMPONENT ACPI_HARDWARE
- ACPI_MODULE_NAME ("hwvalid")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiHwValidateIoRequest (
- ACPI_IO_ADDRESS Address,
- UINT32 BitWidth);
-
-
-/*
- * Protected I/O ports. Some ports are always illegal, and some are
- * conditionally illegal. This table must remain ordered by port address.
- *
- * The table is used to implement the Microsoft port access rules that
- * first appeared in Windows XP. Some ports are always illegal, and some
- * ports are only illegal if the BIOS calls _OSI with a WinXP string or
- * later (meaning that the BIOS itelf is post-XP.)
- *
- * This provides ACPICA with the desired port protections and
- * Microsoft compatibility.
- *
- * Description of port entries:
- * DMA: DMA controller
- * PIC0: Programmable Interrupt Controller (8259A)
- * PIT1: System Timer 1
- * PIT2: System Timer 2 failsafe
- * RTC: Real-time clock
- * CMOS: Extended CMOS
- * DMA1: DMA 1 page registers
- * DMA1L: DMA 1 Ch 0 low page
- * DMA2: DMA 2 page registers
- * DMA2L: DMA 2 low page refresh
- * ARBC: Arbitration control
- * SETUP: Reserved system board setup
- * POS: POS channel select
- * PIC1: Cascaded PIC
- * IDMA: ISA DMA
- * ELCR: PIC edge/level registers
- * PCI: PCI configuration space
- */
-static const ACPI_PORT_INFO AcpiProtectedPorts[] =
-{
- {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP},
- {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL},
- {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP},
- {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP},
- {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP},
- {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP},
- {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP},
- {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP},
- {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP},
- {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP},
- {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP},
- {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP},
- {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP},
- {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL},
- {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP},
- {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL},
- {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP}
-};
-
-#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwValidateIoRequest
- *
- * PARAMETERS: Address Address of I/O port/register
- * BitWidth Number of bits (8,16,32)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Validates an I/O request (address/length). Certain ports are
- * always illegal and some ports are only illegal depending on
- * the requests the BIOS AML code makes to the predefined
- * _OSI method.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiHwValidateIoRequest (
- ACPI_IO_ADDRESS Address,
- UINT32 BitWidth)
-{
- UINT32 i;
- UINT32 ByteWidth;
- ACPI_IO_ADDRESS LastAddress;
- const ACPI_PORT_INFO *PortInfo;
-
-
- ACPI_FUNCTION_TRACE (HwValidateIoRequest);
-
-
- /* Supported widths are 8/16/32 */
-
- if ((BitWidth != 8) &&
- (BitWidth != 16) &&
- (BitWidth != 32))
- {
- ACPI_ERROR ((AE_INFO,
- "Bad BitWidth parameter: %8.8X", BitWidth));
- return (AE_BAD_PARAMETER);
- }
-
- PortInfo = AcpiProtectedPorts;
- ByteWidth = ACPI_DIV_8 (BitWidth);
- LastAddress = Address + ByteWidth - 1;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X",
- ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress),
- ByteWidth));
-
- /* Maximum 16-bit address in I/O space */
-
- if (LastAddress > ACPI_UINT16_MAX)
- {
- ACPI_ERROR ((AE_INFO,
- "Illegal I/O port address/length above 64K: %p/0x%X",
- ACPI_CAST_PTR (void, Address), ByteWidth));
- return_ACPI_STATUS (AE_LIMIT);
- }
-
- /* Exit if requested address is not within the protected port table */
-
- if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Check request against the list of protected I/O ports */
-
- for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++)
- {
- /*
- * Check if the requested address range will write to a reserved
- * port. Four cases to consider:
- *
- * 1) Address range is contained completely in the port address range
- * 2) Address range overlaps port range at the port range start
- * 3) Address range overlaps port range at the port range end
- * 4) Address range completely encompasses the port range
- */
- if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start))
- {
- /* Port illegality may depend on the _OSI calls made by the BIOS */
-
- if (AcpiGbl_OsiData >= PortInfo->OsiDependency)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_IO,
- "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)",
- ACPI_CAST_PTR (void, Address), ByteWidth, PortInfo->Name,
- PortInfo->Start, PortInfo->End));
-
- return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS);
- }
- }
-
- /* Finished if address range ends before the end of this port */
-
- if (LastAddress <= PortInfo->End)
- {
- break;
- }
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwReadPort
- *
- * PARAMETERS: Address Address of I/O port/register to read
- * Value Where value is placed
- * Width Number of bits
- *
- * RETURN: Status and value read from port
- *
- * DESCRIPTION: Read data from an I/O port or register. This is a front-end
- * to AcpiOsReadPort that performs validation on both the port
- * address and the length.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiHwReadPort (
- ACPI_IO_ADDRESS Address,
- UINT32 *Value,
- UINT32 Width)
-{
- ACPI_STATUS Status;
- UINT32 OneByte;
- UINT32 i;
-
-
- /* Truncate address to 16 bits if requested */
-
- if (AcpiGbl_TruncateIoAddresses)
- {
- Address &= ACPI_UINT16_MAX;
- }
-
- /* Validate the entire request and perform the I/O */
-
- Status = AcpiHwValidateIoRequest (Address, Width);
- if (ACPI_SUCCESS (Status))
- {
- Status = AcpiOsReadPort (Address, Value, Width);
- return (Status);
- }
-
- if (Status != AE_AML_ILLEGAL_ADDRESS)
- {
- return (Status);
- }
-
- /*
- * There has been a protection violation within the request. Fall
- * back to byte granularity port I/O and ignore the failing bytes.
- * This provides Windows compatibility.
- */
- for (i = 0, *Value = 0; i < Width; i += 8)
- {
- /* Validate and read one byte */
-
- if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
- {
- Status = AcpiOsReadPort (Address, &OneByte, 8);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- *Value |= (OneByte << i);
- }
-
- Address++;
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiHwWritePort
- *
- * PARAMETERS: Address Address of I/O port/register to write
- * Value Value to write
- * Width Number of bits
- *
- * RETURN: Status
- *
- * DESCRIPTION: Write data to an I/O port or register. This is a front-end
- * to AcpiOsWritePort that performs validation on both the port
- * address and the length.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiHwWritePort (
- ACPI_IO_ADDRESS Address,
- UINT32 Value,
- UINT32 Width)
-{
- ACPI_STATUS Status;
- UINT32 i;
-
-
- /* Truncate address to 16 bits if requested */
-
- if (AcpiGbl_TruncateIoAddresses)
- {
- Address &= ACPI_UINT16_MAX;
- }
-
- /* Validate the entire request and perform the I/O */
-
- Status = AcpiHwValidateIoRequest (Address, Width);
- if (ACPI_SUCCESS (Status))
- {
- Status = AcpiOsWritePort (Address, Value, Width);
- return (Status);
- }
-
- if (Status != AE_AML_ILLEGAL_ADDRESS)
- {
- return (Status);
- }
-
- /*
- * There has been a protection violation within the request. Fall
- * back to byte granularity port I/O and ignore the failing bytes.
- * This provides Windows compatibility.
- */
- for (i = 0; i < Width; i += 8)
- {
- /* Validate and write one byte */
-
- if (AcpiHwValidateIoRequest (Address, 8) == AE_OK)
- {
- Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- Address++;
- }
-
- return (AE_OK);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/hardware/hwxface.c
--- a/head/sys/contrib/dev/acpica/hardware/hwxface.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,638 +0,0 @@
-
-/******************************************************************************
- *
- * Module Name: hwxface - Public ACPICA hardware 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/acnamesp.h>
-
-#define _COMPONENT ACPI_HARDWARE
- ACPI_MODULE_NAME ("hwxface")
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiReset
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
- * support reset register in PCI config space, this must be
- * handled separately.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiReset (
- void)
-{
- ACPI_GENERIC_ADDRESS *ResetReg;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiReset);
-
-
- ResetReg = &AcpiGbl_FADT.ResetRegister;
-
- /* Check if the reset register is supported */
-
- if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) ||
- !ResetReg->Address)
- {
- return_ACPI_STATUS (AE_NOT_EXIST);
- }
-
- if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO)
- {
- /*
- * For I/O space, write directly to the OSL. This bypasses the port
- * validation mechanism, which may block a valid write to the reset
- * register.
- */
- Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address,
- AcpiGbl_FADT.ResetValue, ResetReg->BitWidth);
- }
- else
- {
- /* Write the reset value to the reset register */
-
- Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiReset)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiRead
- *
- * PARAMETERS: Value - Where the value is returned
- * Reg - GAS register structure
- *
- * RETURN: Status
- *
- * DESCRIPTION: Read from either memory or IO space.
- *
- * LIMITATIONS: <These limitations also apply to AcpiWrite>
- * BitWidth must be exactly 8, 16, 32, or 64.
- * SpaceID must be SystemMemory or SystemIO.
- * BitOffset and AccessWidth are currently ignored, as there has
- * not been a need to implement these.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRead (
- UINT64 *ReturnValue,
- ACPI_GENERIC_ADDRESS *Reg)
-{
- UINT32 Value;
- UINT32 Width;
- UINT64 Address;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_NAME (AcpiRead);
-
-
- if (!ReturnValue)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Validate contents of the GAS register. Allow 64-bit transfers */
-
- Status = AcpiHwValidateRegister (Reg, 64, &Address);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Width = Reg->BitWidth;
- if (Width == 64)
- {
- Width = 32; /* Break into two 32-bit transfers */
- }
-
- /* Initialize entire 64-bit return value to zero */
-
- *ReturnValue = 0;
- Value = 0;
-
- /*
- * Two address spaces supported: Memory or IO. PCI_Config is
- * not supported here because the GAS structure is insufficient
- */
- if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
- {
- Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
- Address, &Value, Width);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- *ReturnValue = Value;
-
- if (Reg->BitWidth == 64)
- {
- /* Read the top 32 bits */
-
- Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
- (Address + 4), &Value, 32);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- *ReturnValue |= ((UINT64) Value << 32);
- }
- }
- else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
- {
- Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
- Address, &Value, Width);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- *ReturnValue = Value;
-
- if (Reg->BitWidth == 64)
- {
- /* Read the top 32 bits */
-
- Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
- (Address + 4), &Value, 32);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- *ReturnValue |= ((UINT64) Value << 32);
- }
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO,
- "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n",
- ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth,
- ACPI_FORMAT_UINT64 (Address),
- AcpiUtGetRegionName (Reg->SpaceId)));
-
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiRead)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiWrite
- *
- * PARAMETERS: Value - Value to be written
- * Reg - GAS register structure
- *
- * RETURN: Status
- *
- * DESCRIPTION: Write to either memory or IO space.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiWrite (
- UINT64 Value,
- ACPI_GENERIC_ADDRESS *Reg)
-{
- UINT32 Width;
- UINT64 Address;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_NAME (AcpiWrite);
-
-
- /* Validate contents of the GAS register. Allow 64-bit transfers */
-
- Status = AcpiHwValidateRegister (Reg, 64, &Address);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Width = Reg->BitWidth;
- if (Width == 64)
- {
- Width = 32; /* Break into two 32-bit transfers */
- }
-
- /*
- * Two address spaces supported: Memory or IO. PCI_Config is
- * not supported here because the GAS structure is insufficient
- */
- if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
- {
- Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
- Address, ACPI_LODWORD (Value), Width);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- if (Reg->BitWidth == 64)
- {
- Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
- (Address + 4), ACPI_HIDWORD (Value), 32);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- }
- else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
- {
- Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
- Address, ACPI_LODWORD (Value), Width);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- if (Reg->BitWidth == 64)
- {
- Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
- (Address + 4), ACPI_HIDWORD (Value), 32);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO,
- "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n",
- ACPI_FORMAT_UINT64 (Value), Reg->BitWidth,
- ACPI_FORMAT_UINT64 (Address),
- AcpiUtGetRegionName (Reg->SpaceId)));
-
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiWrite)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiReadBitRegister
- *
- * PARAMETERS: RegisterId - ID of ACPI Bit Register to access
- * ReturnValue - Value that was read from the register,
- * normalized to bit position zero.
- *
- * RETURN: Status and the value read from the specified Register. Value
- * returned is normalized to bit0 (is shifted all the way right)
- *
- * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock.
- *
- * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
- * PM2 Control.
- *
- * Note: The hardware lock is not required when reading the ACPI bit registers
- * since almost all of them are single bit and it does not matter that
- * the parent hardware register can be split across two physical
- * registers. The only multi-bit field is SLP_TYP in the PM1 control
- * register, but this field does not cross an 8-bit boundary (nor does
- * it make much sense to actually read this field.)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiReadBitRegister (
- UINT32 RegisterId,
- UINT32 *ReturnValue)
-{
- ACPI_BIT_REGISTER_INFO *BitRegInfo;
- UINT32 RegisterValue;
- UINT32 Value;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId);
-
-
- /* Get the info structure corresponding to the requested ACPI Register */
-
- BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
- if (!BitRegInfo)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Read the entire parent register */
-
- Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
- &RegisterValue);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Normalize the value that was read, mask off other bits */
-
- Value = ((RegisterValue & BitRegInfo->AccessBitMask)
- >> BitRegInfo->BitPosition);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO,
- "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
- RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
-
- *ReturnValue = Value;
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiReadBitRegister)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiWriteBitRegister
- *
- * PARAMETERS: RegisterId - ID of ACPI Bit Register to access
- * Value - Value to write to the register, in bit
- * position zero. The bit is automaticallly
- * shifted to the correct position.
- *
- * RETURN: Status
- *
- * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
- * since most operations require a read/modify/write sequence.
- *
- * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
- * PM2 Control.
- *
- * Note that at this level, the fact that there may be actually two
- * hardware registers (A and B - and B may not exist) is abstracted.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiWriteBitRegister (
- UINT32 RegisterId,
- UINT32 Value)
-{
- ACPI_BIT_REGISTER_INFO *BitRegInfo;
- ACPI_CPU_FLAGS LockFlags;
- UINT32 RegisterValue;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId);
-
-
- /* Get the info structure corresponding to the requested ACPI Register */
-
- BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
- if (!BitRegInfo)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
-
- /*
- * At this point, we know that the parent register is one of the
- * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
- */
- if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS)
- {
- /*
- * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
- *
- * Perform a register read to preserve the bits that we are not
- * interested in
- */
- Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
- &RegisterValue);
- if (ACPI_FAILURE (Status))
- {
- goto UnlockAndExit;
- }
-
- /*
- * Insert the input bit into the value that was just read
- * and write the register
- */
- ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
- BitRegInfo->AccessBitMask, Value);
-
- Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister,
- RegisterValue);
- }
- else
- {
- /*
- * 2) Case for PM1 Status
- *
- * The Status register is different from the rest. Clear an event
- * by writing 1, writing 0 has no effect. So, the only relevant
- * information is the single bit we're interested in, all others
- * should be written as 0 so they will be left unchanged.
- */
- RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value,
- BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
-
- /* No need to write the register if value is all zeros */
-
- if (RegisterValue)
- {
- Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
- RegisterValue);
- }
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_IO,
- "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
- RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue));
-
-
-UnlockAndExit:
-
- AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetSleepTypeData
- *
- * PARAMETERS: SleepState - Numeric sleep state
- * *SleepTypeA - Where SLP_TYPa is returned
- * *SleepTypeB - Where SLP_TYPb is returned
- *
- * RETURN: Status - ACPI status
- *
- * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
- * state.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetSleepTypeData (
- UINT8 SleepState,
- UINT8 *SleepTypeA,
- UINT8 *SleepTypeB)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_EVALUATE_INFO *Info;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData);
-
-
- /* Validate parameters */
-
- if ((SleepState > ACPI_S_STATES_MAX) ||
- !SleepTypeA ||
- !SleepTypeB)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Allocate the evaluation information block */
-
- Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
- if (!Info)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]);
-
- /* Evaluate the namespace object containing the values for this state */
-
- Status = AcpiNsEvaluate (Info);
- if (ACPI_FAILURE (Status))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "%s while evaluating SleepState [%s]\n",
- AcpiFormatException (Status), Info->Pathname));
-
- goto Cleanup;
- }
-
- /* Must have a return object */
-
- if (!Info->ReturnObject)
- {
- ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]",
- Info->Pathname));
- Status = AE_NOT_EXIST;
- }
-
- /* It must be of type Package */
-
- else if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
- {
- ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package"));
- Status = AE_AML_OPERAND_TYPE;
- }
-
- /*
- * The package must have at least two elements. NOTE (March 2005): This
- * goes against the current ACPI spec which defines this object as a
- * package with one encoded DWORD element. However, existing practice
- * by BIOS vendors seems to be to have 2 or more elements, at least
- * one per sleep type (A/B).
- */
- else if (Info->ReturnObject->Package.Count < 2)
- {
- ACPI_ERROR ((AE_INFO,
- "Sleep State return package does not have at least two elements"));
- Status = AE_AML_NO_OPERAND;
- }
-
- /* The first two elements must both be of type Integer */
-
- else if (((Info->ReturnObject->Package.Elements[0])->Common.Type
- != ACPI_TYPE_INTEGER) ||
- ((Info->ReturnObject->Package.Elements[1])->Common.Type
- != ACPI_TYPE_INTEGER))
- {
- ACPI_ERROR ((AE_INFO,
- "Sleep State return package elements are not both Integers "
- "(%s, %s)",
- AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]),
- AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1])));
- Status = AE_AML_OPERAND_TYPE;
- }
- else
- {
- /* Valid _Sx_ package size, type, and value */
-
- *SleepTypeA = (UINT8)
- (Info->ReturnObject->Package.Elements[0])->Integer.Value;
- *SleepTypeB = (UINT8)
- (Info->ReturnObject->Package.Elements[1])->Integer.Value;
- }
-
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "While evaluating SleepState [%s], bad Sleep object %p type %s",
- Info->Pathname, Info->ReturnObject,
- AcpiUtGetObjectTypeName (Info->ReturnObject)));
- }
-
- AcpiUtRemoveReference (Info->ReturnObject);
-
-Cleanup:
- ACPI_FREE (Info);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acconfig.h
--- a/head/sys/contrib/dev/acpica/include/acconfig.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acconfig.h Fri Mar 02 17:09:07 2012 +0200
@@ -86,6 +86,23 @@
*/
#define ACPI_CHECKSUM_ABORT FALSE
+/*
+ * Generate a version of ACPICA that only supports "reduced hardware"
+ * platforms (as defined in ACPI 5.0). Set to TRUE to generate a specialized
+ * version of ACPICA that ONLY supports the ACPI 5.0 "reduced hardware"
+ * model. In other words, no ACPI hardware is supported.
+ *
+ * If TRUE, this means no support for the following:
+ * 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)
+ */
+#define ACPI_REDUCED_HARDWARE FALSE
+
/******************************************************************************
*
@@ -95,7 +112,7 @@
/* Version of ACPI supported */
-#define ACPI_CA_SUPPORT_LEVEL 3
+#define ACPI_CA_SUPPORT_LEVEL 5
/* Maximum count for a semaphore object */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acdebug.h
--- a/head/sys/contrib/dev/acpica/include/acdebug.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acdebug.h Fri Mar 02 17:09:07 2012 +0200
@@ -137,18 +137,20 @@
AcpiDbDisplayResources (
char *ObjectArg);
+ACPI_HW_DEPENDENT_RETURN_VOID (
void
AcpiDbDisplayGpes (
- void);
+ void))
void
AcpiDbDisplayHandlers (
void);
+ACPI_HW_DEPENDENT_RETURN_VOID (
void
AcpiDbGenerateGpe (
char *GpeArg,
- char *BlockArg);
+ char *BlockArg))
/*
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acevents.h
--- a/head/sys/contrib/dev/acpica/include/acevents.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acevents.h Fri Mar 02 17:09:07 2012 +0200
@@ -85,13 +85,15 @@
AcpiEvInitGlobalLockHandler (
void);
+ACPI_HW_DEPENDENT_RETURN_OK (
ACPI_STATUS
AcpiEvAcquireGlobalLock(
- UINT16 Timeout);
+ UINT16 Timeout))
+ACPI_HW_DEPENDENT_RETURN_OK (
ACPI_STATUS
AcpiEvReleaseGlobalLock(
- void);
+ void))
ACPI_STATUS
AcpiEvRemoveGlobalLockHandler (
@@ -154,9 +156,10 @@
ACPI_GPE_BLOCK_INFO *GpeBlock,
void *Context);
+ACPI_HW_DEPENDENT_RETURN_OK (
ACPI_STATUS
AcpiEvDeleteGpeBlock (
- ACPI_GPE_BLOCK_INFO *GpeBlock);
+ ACPI_GPE_BLOCK_INFO *GpeBlock))
UINT32
AcpiEvGpeDispatch (
@@ -171,9 +174,10 @@
AcpiEvGpeInitialize (
void);
+ACPI_HW_DEPENDENT_RETURN_VOID (
void
AcpiEvUpdateGpes (
- ACPI_OWNER_ID TableOwnerId);
+ ACPI_OWNER_ID TableOwnerId))
ACPI_STATUS
AcpiEvMatchGpeMethod (
@@ -335,9 +339,9 @@
AcpiEvInitializeSCI (
UINT32 ProgramSCI);
+ACPI_HW_DEPENDENT_RETURN_VOID (
void
AcpiEvTerminate (
- void);
-
+ void))
#endif /* __ACEVENTS_H__ */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acexcep.h
--- a/head/sys/contrib/dev/acpica/include/acexcep.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acexcep.h Fri Mar 02 17:09:07 2012 +0200
@@ -92,8 +92,9 @@
#define AE_SAME_HANDLER (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL)
#define AE_NO_HANDLER (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL)
#define AE_OWNER_ID_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_CONFIGURED (ACPI_STATUS) (0x001C | AE_CODE_ENVIRONMENTAL)
-#define AE_CODE_ENV_MAX 0x001B
+#define AE_CODE_ENV_MAX 0x001C
/*
@@ -222,7 +223,8 @@
"AE_ABORT_METHOD",
"AE_SAME_HANDLER",
"AE_NO_HANDLER",
- "AE_OWNER_ID_LIMIT"
+ "AE_OWNER_ID_LIMIT",
+ "AE_NOT_CONFIGURED"
};
char const *AcpiGbl_ExceptionNames_Pgm[] =
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acglobal.h
--- a/head/sys/contrib/dev/acpica/include/acglobal.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acglobal.h Fri Mar 02 17:09:07 2012 +0200
@@ -150,8 +150,7 @@
*/
BOOLEAN AcpiGbl_ReducedHardware;
-
-#endif
+#endif /* DEFINE_ACPI_GLOBALS */
/* Do not disassemble buffers to resource descriptors */
@@ -168,8 +167,12 @@
* found in the RSDT/XSDT.
*/
ACPI_EXTERN ACPI_TABLE_LIST AcpiGbl_RootTableList;
+
+#if (!ACPI_REDUCED_HARDWARE)
ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS;
+#endif /* !ACPI_REDUCED_HARDWARE */
+
/* These addresses are calculated from the FADT Event Block addresses */
ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aStatus;
@@ -381,6 +384,8 @@
*
****************************************************************************/
+#if (!ACPI_REDUCED_HARDWARE)
+
ACPI_EXTERN UINT8 AcpiGbl_AllGpesInitialized;
ACPI_EXTERN ACPI_GPE_XRUPT_INFO *AcpiGbl_GpeXruptListHead;
ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS];
@@ -389,6 +394,7 @@
ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS];
extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS];
+#endif /* !ACPI_REDUCED_HARDWARE */
/*****************************************************************************
*
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/achware.h
--- a/head/sys/contrib/dev/acpica/include/achware.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/achware.h Fri Mar 02 17:09:07 2012 +0200
@@ -110,6 +110,43 @@
/*
+ * hwsleep - sleep/wake support (Legacy sleep registers)
+ */
+ACPI_STATUS
+AcpiHwLegacySleep (
+ UINT8 SleepState);
+
+ACPI_STATUS
+AcpiHwLegacyWakePrep (
+ UINT8 SleepState);
+
+ACPI_STATUS
+AcpiHwLegacyWake (
+ UINT8 SleepState);
+
+
+/*
+ * hwesleep - sleep/wake support (Extended FADT-V5 sleep registers)
+ */
+void
+AcpiHwExecuteSleepMethod (
+ char *MethodName,
+ UINT32 IntegerArgument);
+
+ACPI_STATUS
+AcpiHwExtendedSleep (
+ UINT8 SleepState);
+
+ACPI_STATUS
+AcpiHwExtendedWakePrep (
+ UINT8 SleepState);
+
+ACPI_STATUS
+AcpiHwExtendedWake (
+ UINT8 SleepState);
+
+
+/*
* hwvalid - Port I/O with validation
*/
ACPI_STATUS
@@ -188,22 +225,4 @@
ACPI_HANDLE PciRegion);
-/*
- * hwtimer - ACPI Timer prototypes
- */
-ACPI_STATUS
-AcpiGetTimerResolution (
- UINT32 *Resolution);
-
-ACPI_STATUS
-AcpiGetTimer (
- UINT32 *Ticks);
-
-ACPI_STATUS
-AcpiGetTimerDuration (
- UINT32 StartTicks,
- UINT32 EndTicks,
- UINT32 *TimeElapsed);
-
-
#endif /* __ACHWARE_H__ */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acmacros.h
--- a/head/sys/contrib/dev/acpica/include/acmacros.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acmacros.h Fri Mar 02 17:09:07 2012 +0200
@@ -428,7 +428,6 @@
#endif /* ACPI_SIMPLE_RETURN_MACROS */
-
/* Conditional execution */
#define ACPI_DEBUG_EXEC(a) a
@@ -477,6 +476,14 @@
#endif /* ACPI_DEBUG_OUTPUT */
+
+#if (!ACPI_REDUCED_HARDWARE)
+#define ACPI_HW_OPTIONAL_FUNCTION(addr) addr
+#else
+#define ACPI_HW_OPTIONAL_FUNCTION(addr) NULL
+#endif
+
+
/*
* Some code only gets executed when the debugger is built in.
* Note that this is entirely independent of whether the
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acpiosxf.h
--- a/head/sys/contrib/dev/acpica/include/acpiosxf.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acpiosxf.h Fri Mar 02 17:09:07 2012 +0200
@@ -112,6 +112,12 @@
ACPI_TABLE_HEADER *ExistingTable,
ACPI_TABLE_HEADER **NewTable);
+ACPI_STATUS
+AcpiOsPhysicalTableOverride (
+ ACPI_TABLE_HEADER *ExistingTable,
+ ACPI_PHYSICAL_ADDRESS *NewAddress,
+ UINT32 *NewTableLength);
+
/*
* Spinlock primitives
@@ -302,13 +308,13 @@
ACPI_STATUS
AcpiOsReadMemory (
ACPI_PHYSICAL_ADDRESS Address,
- UINT32 *Value,
+ UINT64 *Value,
UINT32 Width);
ACPI_STATUS
AcpiOsWriteMemory (
ACPI_PHYSICAL_ADDRESS Address,
- UINT32 Value,
+ UINT64 Value,
UINT32 Width);
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/acpixf.h
--- a/head/sys/contrib/dev/acpica/include/acpixf.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/acpixf.h Fri Mar 02 17:09:07 2012 +0200
@@ -48,8 +48,9 @@
/* Current ACPICA subsystem version in YYYYMMDD format */
-#define ACPI_CA_VERSION 0x20120111
+#define ACPI_CA_VERSION 0x20120215
+#include <contrib/dev/acpica/include/acconfig.h>
#include <contrib/dev/acpica/include/actypes.h>
#include <contrib/dev/acpica/include/actbl.h>
@@ -81,6 +82,34 @@
/*
+ * Hardware-reduced prototypes. All interfaces that use these macros will
+ * be configured out of the ACPICA build if the ACPI_REDUCED_HARDWARE flag
+ * is set to TRUE.
+ */
+#if (!ACPI_REDUCED_HARDWARE)
+#define ACPI_HW_DEPENDENT_RETURN_STATUS(Prototype) \
+ Prototype;
+
+#define ACPI_HW_DEPENDENT_RETURN_OK(Prototype) \
+ Prototype;
+
+#define ACPI_HW_DEPENDENT_RETURN_VOID(Prototype) \
+ Prototype;
+
+#else
+#define ACPI_HW_DEPENDENT_RETURN_STATUS(Prototype) \
+ static ACPI_INLINE Prototype {return(AE_NOT_CONFIGURED);}
+
+#define ACPI_HW_DEPENDENT_RETURN_OK(Prototype) \
+ static ACPI_INLINE Prototype {return(AE_OK);}
+
+#define ACPI_HW_DEPENDENT_RETURN_VOID(Prototype) \
+ static ACPI_INLINE Prototype {}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+/*
* Initialization
*/
ACPI_STATUS
@@ -109,13 +138,15 @@
/*
* Miscellaneous global interfaces
*/
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiEnable (
- void);
+ void))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiDisable (
- void);
+ void))
ACPI_STATUS
AcpiSubsystemStatus (
@@ -321,35 +352,40 @@
ACPI_INIT_HANDLER Handler,
UINT32 Function);
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiInstallGlobalEventHandler (
ACPI_GBL_EVENT_HANDLER Handler,
- void *Context);
+ void *Context))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiInstallFixedEventHandler (
UINT32 AcpiEvent,
ACPI_EVENT_HANDLER Handler,
- void *Context);
+ void *Context))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiRemoveFixedEventHandler (
UINT32 AcpiEvent,
- ACPI_EVENT_HANDLER Handler);
+ ACPI_EVENT_HANDLER Handler))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiInstallGpeHandler (
ACPI_HANDLE GpeDevice,
UINT32 GpeNumber,
UINT32 Type,
ACPI_GPE_HANDLER Address,
- void *Context);
+ void *Context))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiRemoveGpeHandler (
ACPI_HANDLE GpeDevice,
UINT32 GpeNumber,
- ACPI_GPE_HANDLER Address);
+ ACPI_GPE_HANDLER Address))
ACPI_STATUS
AcpiInstallNotifyHandler (
@@ -390,14 +426,16 @@
/*
* Global Lock interfaces
*/
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiAcquireGlobalLock (
UINT16 Timeout,
- UINT32 *Handle);
+ UINT32 *Handle))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiReleaseGlobalLock (
- UINT32 Handle);
+ UINT32 Handle))
/*
@@ -418,100 +456,118 @@
/*
* Fixed Event interfaces
*/
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiEnableEvent (
UINT32 Event,
- UINT32 Flags);
+ UINT32 Flags))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiDisableEvent (
UINT32 Event,
- UINT32 Flags);
+ UINT32 Flags))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiClearEvent (
- UINT32 Event);
+ UINT32 Event))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiGetEventStatus (
UINT32 Event,
- ACPI_EVENT_STATUS *EventStatus);
+ ACPI_EVENT_STATUS *EventStatus))
/*
* General Purpose Event (GPE) Interfaces
*/
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiUpdateAllGpes (
- void);
+ void))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiEnableGpe (
ACPI_HANDLE GpeDevice,
- UINT32 GpeNumber);
+ UINT32 GpeNumber))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiDisableGpe (
ACPI_HANDLE GpeDevice,
- UINT32 GpeNumber);
+ UINT32 GpeNumber))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiClearGpe (
ACPI_HANDLE GpeDevice,
- UINT32 GpeNumber);
+ UINT32 GpeNumber))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiSetGpe (
ACPI_HANDLE GpeDevice,
UINT32 GpeNumber,
- UINT8 Action);
+ UINT8 Action))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiFinishGpe (
ACPI_HANDLE GpeDevice,
- UINT32 GpeNumber);
+ UINT32 GpeNumber))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiSetupGpeForWake (
ACPI_HANDLE ParentDevice,
ACPI_HANDLE GpeDevice,
- UINT32 GpeNumber);
+ UINT32 GpeNumber))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiSetGpeWakeMask (
ACPI_HANDLE GpeDevice,
UINT32 GpeNumber,
- UINT8 Action);
+ UINT8 Action))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiGetGpeStatus (
ACPI_HANDLE GpeDevice,
UINT32 GpeNumber,
- ACPI_EVENT_STATUS *EventStatus);
+ ACPI_EVENT_STATUS *EventStatus))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiDisableAllGpes (
- void);
+ void))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiEnableAllRuntimeGpes (
- void);
+ void))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiGetGpeDevice (
UINT32 GpeIndex,
- ACPI_HANDLE *GpeDevice);
+ ACPI_HANDLE *GpeDevice))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiInstallGpeBlock (
ACPI_HANDLE GpeDevice,
ACPI_GENERIC_ADDRESS *GpeBlockAddress,
UINT32 RegisterCount,
- UINT32 InterruptNumber);
+ UINT32 InterruptNumber))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiRemoveGpeBlock (
- ACPI_HANDLE GpeDevice);
+ ACPI_HANDLE GpeDevice))
/*
@@ -590,16 +646,22 @@
UINT64 Value,
ACPI_GENERIC_ADDRESS *Reg);
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiReadBitRegister (
UINT32 RegisterId,
- UINT32 *ReturnValue);
+ UINT32 *ReturnValue))
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiWriteBitRegister (
UINT32 RegisterId,
- UINT32 Value);
+ UINT32 Value))
+
+/*
+ * Sleep/Wake interfaces
+ */
ACPI_STATUS
AcpiGetSleepTypeData (
UINT8 SleepState,
@@ -614,26 +676,54 @@
AcpiEnterSleepState (
UINT8 SleepState);
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiEnterSleepStateS4bios (
- void);
+ void))
+
+ACPI_STATUS
+AcpiLeaveSleepStatePrep (
+ UINT8 SleepState);
ACPI_STATUS
AcpiLeaveSleepState (
- UINT8 SleepState)
- ;
+ UINT8 SleepState);
+
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiSetFirmwareWakingVector (
- UINT32 PhysicalAddress);
+ UINT32 PhysicalAddress))
#if ACPI_MACHINE_WIDTH == 64
+ACPI_HW_DEPENDENT_RETURN_STATUS (
ACPI_STATUS
AcpiSetFirmwareWakingVector64 (
- UINT64 PhysicalAddress);
+ UINT64 PhysicalAddress))
#endif
/*
+ * ACPI Timer interfaces
+ */
+ACPI_HW_DEPENDENT_RETURN_STATUS (
+ACPI_STATUS
+AcpiGetTimerResolution (
+ UINT32 *Resolution))
+
+ACPI_HW_DEPENDENT_RETURN_STATUS (
+ACPI_STATUS
+AcpiGetTimer (
+ UINT32 *Ticks))
+
+ACPI_HW_DEPENDENT_RETURN_STATUS (
+ACPI_STATUS
+AcpiGetTimerDuration (
+ UINT32 StartTicks,
+ UINT32 EndTicks,
+ UINT32 *TimeElapsed))
+
+
+/*
* Error/Warning output
*/
void ACPI_INTERNAL_VAR_XFACE
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/actables.h
--- a/head/sys/contrib/dev/acpica/include/actables.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/actables.h Fri Mar 02 17:09:07 2012 +0200
@@ -84,6 +84,11 @@
AcpiTbVerifyTable (
ACPI_TABLE_DESC *TableDesc);
+ACPI_TABLE_HEADER *
+AcpiTbTableOverride (
+ ACPI_TABLE_HEADER *TableHeader,
+ ACPI_TABLE_DESC *TableDesc);
+
ACPI_STATUS
AcpiTbAddTable (
ACPI_TABLE_DESC *TableDesc,
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/actbl.h
--- a/head/sys/contrib/dev/acpica/include/actbl.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/actbl.h Fri Mar 02 17:09:07 2012 +0200
@@ -354,6 +354,13 @@
PM_TABLET = 8
};
+/* Values for SleepStatus and SleepControl registers (V5 FADT) */
+
+#define ACPI_X_WAKE_STATUS 0x80
+#define ACPI_X_SLEEP_TYPE_MASK 0x1C
+#define ACPI_X_SLEEP_TYPE_POSITION 0x02
+#define ACPI_X_SLEEP_ENABLE 0x20
+
/* Reset to default packing */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/include/actypes.h
--- a/head/sys/contrib/dev/acpica/include/actypes.h Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/include/actypes.h Fri Mar 02 17:09:07 2012 +0200
@@ -534,8 +534,9 @@
#define ACPI_NOTIFY_DEVICE_PLD_CHECK (UINT8) 0x09
#define ACPI_NOTIFY_RESERVED (UINT8) 0x0A
#define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B
+#define ACPI_NOTIFY_SHUTDOWN_REQUEST (UINT8) 0x0C
-#define ACPI_NOTIFY_MAX 0x0B
+#define ACPI_NOTIFY_MAX 0x0C
/*
* Types associated with ACPI names and objects. The first group of
@@ -701,7 +702,8 @@
#define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY)
#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3
-#define ACPI_MAX_SYS_NOTIFY 0x7f
+#define ACPI_MAX_SYS_NOTIFY 0x7F
+#define ACPI_MAX_DEVICE_SPECIFIC_NOTIFY 0xBF
/* Address Space (Operation Region) Types */
@@ -792,6 +794,19 @@
#define ACPI_DISABLE_EVENT 0
+/* Sleep function dispatch */
+
+typedef ACPI_STATUS (*ACPI_SLEEP_FUNCTION) (
+ UINT8 SleepState);
+
+typedef struct acpi_sleep_functions
+{
+ ACPI_SLEEP_FUNCTION LegacyFunction;
+ ACPI_SLEEP_FUNCTION ExtendedFunction;
+
+} ACPI_SLEEP_FUNCTIONS;
+
+
/*
* External ACPI object definition
*/
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsaccess.c
--- a/head/sys/contrib/dev/acpica/namespace/nsaccess.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,700 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsaccess - Top-level functions for accessing 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.
- */
-
-#define __NSACCESS_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/acnamesp.h>
-#include <contrib/dev/acpica/include/acdispat.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsaccess")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsRootInitialize
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Allocate and initialize the default root named objects
- *
- * MUTEX: Locks namespace for entire execution
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsRootInitialize (
- void)
-{
- ACPI_STATUS Status;
- const ACPI_PREDEFINED_NAMES *InitVal = NULL;
- ACPI_NAMESPACE_NODE *NewNode;
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STRING Val = NULL;
-
-
- ACPI_FUNCTION_TRACE (NsRootInitialize);
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * The global root ptr is initially NULL, so a non-NULL value indicates
- * that AcpiNsRootInitialize() has already been called; just return.
- */
- if (AcpiGbl_RootNode)
- {
- Status = AE_OK;
- goto UnlockAndExit;
- }
-
- /*
- * Tell the rest of the subsystem that the root is initialized
- * (This is OK because the namespace is locked)
- */
- AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
-
- /* Enter the pre-defined names in the name table */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Entering predefined entries into namespace\n"));
-
- for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
- {
- /* _OSI is optional for now, will be permanent later */
-
- if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
- {
- continue;
- }
-
- Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type,
- ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,
- NULL, &NewNode);
-
- if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not create predefined name %s",
- InitVal->Name));
- }
-
- /*
- * Name entered successfully. If entry in PreDefinedNames[] specifies
- * an initial value, create the initial value.
- */
- if (InitVal->Val)
- {
- Status = AcpiOsPredefinedOverride (InitVal, &Val);
- if (ACPI_FAILURE (Status))
- {
- ACPI_ERROR ((AE_INFO,
- "Could not override predefined %s",
- InitVal->Name));
- }
-
- if (!Val)
- {
- Val = InitVal->Val;
- }
-
- /*
- * Entry requests an initial value, allocate a
- * descriptor for it.
- */
- ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
- if (!ObjDesc)
- {
- Status = AE_NO_MEMORY;
- goto UnlockAndExit;
- }
-
- /*
- * Convert value string from table entry to
- * internal representation. Only types actually
- * used for initial values are implemented here.
- */
- switch (InitVal->Type)
- {
- case ACPI_TYPE_METHOD:
- ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
- ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
-
-#if defined (ACPI_ASL_COMPILER)
-
- /* Save the parameter count for the iASL compiler */
-
- NewNode->Value = ObjDesc->Method.ParamCount;
-#else
- /* Mark this as a very SPECIAL method */
-
- ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
- ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
-#endif
- break;
-
- case ACPI_TYPE_INTEGER:
-
- ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
- break;
-
-
- case ACPI_TYPE_STRING:
-
- /* Build an object around the static string */
-
- ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val);
- ObjDesc->String.Pointer = Val;
- ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
- break;
-
-
- case ACPI_TYPE_MUTEX:
-
- ObjDesc->Mutex.Node = NewNode;
- ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
-
- /* Create a mutex */
-
- Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (ObjDesc);
- goto UnlockAndExit;
- }
-
- /* Special case for ACPI Global Lock */
-
- if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
- {
- AcpiGbl_GlobalLockMutex = ObjDesc;
-
- /* Create additional counting semaphore for global lock */
-
- Status = AcpiOsCreateSemaphore (
- 1, 0, &AcpiGbl_GlobalLockSemaphore);
- if (ACPI_FAILURE (Status))
- {
- AcpiUtRemoveReference (ObjDesc);
- goto UnlockAndExit;
- }
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
- InitVal->Type));
- AcpiUtRemoveReference (ObjDesc);
- ObjDesc = NULL;
- continue;
- }
-
- /* Store pointer to value descriptor in the Node */
-
- Status = AcpiNsAttachObject (NewNode, ObjDesc,
- ObjDesc->Common.Type);
-
- /* Remove local reference to the object */
-
- AcpiUtRemoveReference (ObjDesc);
- }
- }
-
-
-UnlockAndExit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-
- /* Save a handle to "_GPE", it is always present */
-
- if (ACPI_SUCCESS (Status))
- {
- Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
- &AcpiGbl_FadtGpeDevice);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsLookup
- *
- * PARAMETERS: ScopeInfo - Current scope info block
- * Pathname - Search pathname, in internal format
- * (as represented in the AML stream)
- * Type - Type associated with name
- * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found
- * Flags - Flags describing the search restrictions
- * WalkState - Current state of the walk
- * ReturnNode - Where the Node is placed (if found
- * or created successfully)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Find or enter the passed name in the name space.
- * Log an error if name not found in Exec mode.
- *
- * MUTEX: Assumes namespace is locked.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsLookup (
- ACPI_GENERIC_STATE *ScopeInfo,
- char *Pathname,
- ACPI_OBJECT_TYPE Type,
- ACPI_INTERPRETER_MODE InterpreterMode,
- UINT32 Flags,
- ACPI_WALK_STATE *WalkState,
- ACPI_NAMESPACE_NODE **ReturnNode)
-{
- ACPI_STATUS Status;
- char *Path = Pathname;
- ACPI_NAMESPACE_NODE *PrefixNode;
- ACPI_NAMESPACE_NODE *CurrentNode = NULL;
- ACPI_NAMESPACE_NODE *ThisNode = NULL;
- UINT32 NumSegments;
- UINT32 NumCarats;
- ACPI_NAME SimpleName;
- ACPI_OBJECT_TYPE TypeToCheckFor;
- ACPI_OBJECT_TYPE ThisSearchType;
- UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT;
- UINT32 LocalFlags;
-
-
- ACPI_FUNCTION_TRACE (NsLookup);
-
-
- if (!ReturnNode)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT);
- *ReturnNode = ACPI_ENTRY_NOT_FOUND;
- AcpiGbl_NsLookupCount++;
-
- if (!AcpiGbl_RootNode)
- {
- return_ACPI_STATUS (AE_NO_NAMESPACE);
- }
-
- /* Get the prefix scope. A null scope means use the root scope */
-
- if ((!ScopeInfo) ||
- (!ScopeInfo->Scope.Node))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Null scope prefix, using root node (%p)\n",
- AcpiGbl_RootNode));
-
- PrefixNode = AcpiGbl_RootNode;
- }
- else
- {
- PrefixNode = ScopeInfo->Scope.Node;
- if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED)
- {
- ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]",
- PrefixNode, AcpiUtGetDescriptorName (PrefixNode)));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE))
- {
- /*
- * This node might not be a actual "scope" node (such as a
- * Device/Method, etc.) It could be a Package or other object
- * node. Backup up the tree to find the containing scope node.
- */
- while (!AcpiNsOpensScope (PrefixNode->Type) &&
- PrefixNode->Type != ACPI_TYPE_ANY)
- {
- PrefixNode = PrefixNode->Parent;
- }
- }
- }
-
- /* Save type. TBD: may be no longer necessary */
-
- TypeToCheckFor = Type;
-
- /*
- * Begin examination of the actual pathname
- */
- if (!Pathname)
- {
- /* A Null NamePath is allowed and refers to the root */
-
- NumSegments = 0;
- ThisNode = AcpiGbl_RootNode;
- Path = "";
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Null Pathname (Zero segments), Flags=%X\n", Flags));
- }
- else
- {
- /*
- * Name pointer is valid (and must be in internal name format)
- *
- * Check for scope prefixes:
- *
- * As represented in the AML stream, a namepath consists of an
- * optional scope prefix followed by a name segment part.
- *
- * If present, the scope prefix is either a Root Prefix (in
- * which case the name is fully qualified), or one or more
- * Parent Prefixes (in which case the name's scope is relative
- * to the current scope).
- */
- if (*Path == (UINT8) AML_ROOT_PREFIX)
- {
- /* Pathname is fully qualified, start from the root */
-
- ThisNode = AcpiGbl_RootNode;
- SearchParentFlag = ACPI_NS_NO_UPSEARCH;
-
- /* Point to name segment part */
-
- Path++;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Path is absolute from root [%p]\n", ThisNode));
- }
- else
- {
- /* Pathname is relative to current scope, start there */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Searching relative to prefix scope [%4.4s] (%p)\n",
- AcpiUtGetNodeName (PrefixNode), PrefixNode));
-
- /*
- * Handle multiple Parent Prefixes (carat) by just getting
- * the parent node for each prefix instance.
- */
- ThisNode = PrefixNode;
- NumCarats = 0;
- while (*Path == (UINT8) AML_PARENT_PREFIX)
- {
- /* Name is fully qualified, no search rules apply */
-
- SearchParentFlag = ACPI_NS_NO_UPSEARCH;
-
- /*
- * Point past this prefix to the name segment
- * part or the next Parent Prefix
- */
- Path++;
-
- /* Backup to the parent node */
-
- NumCarats++;
- ThisNode = ThisNode->Parent;
- if (!ThisNode)
- {
- /* Current scope has no parent scope */
-
- ACPI_ERROR ((AE_INFO,
- "ACPI path has too many parent prefixes (^) "
- "- reached beyond root node"));
- return_ACPI_STATUS (AE_NOT_FOUND);
- }
- }
-
- if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Search scope is [%4.4s], path has %u carat(s)\n",
- AcpiUtGetNodeName (ThisNode), NumCarats));
- }
- }
-
- /*
- * Determine the number of ACPI name segments in this pathname.
- *
- * The segment part consists of either:
- * - A Null name segment (0)
- * - A DualNamePrefix followed by two 4-byte name segments
- * - A MultiNamePrefix followed by a byte indicating the
- * number of segments and the segments themselves.
- * - A single 4-byte name segment
- *
- * Examine the name prefix opcode, if any, to determine the number of
- * segments.
- */
- switch (*Path)
- {
- case 0:
- /*
- * Null name after a root or parent prefixes. We already
- * have the correct target node and there are no name segments.
- */
- NumSegments = 0;
- Type = ThisNode->Type;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Prefix-only Pathname (Zero name segments), Flags=%X\n",
- Flags));
- break;
-
- case AML_DUAL_NAME_PREFIX:
-
- /* More than one NameSeg, search rules do not apply */
-
- SearchParentFlag = ACPI_NS_NO_UPSEARCH;
-
- /* Two segments, point to first name segment */
-
- NumSegments = 2;
- Path++;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Dual Pathname (2 segments, Flags=%X)\n", Flags));
- break;
-
- case AML_MULTI_NAME_PREFIX_OP:
-
- /* More than one NameSeg, search rules do not apply */
-
- SearchParentFlag = ACPI_NS_NO_UPSEARCH;
-
- /* Extract segment count, point to first name segment */
-
- Path++;
- NumSegments = (UINT32) (UINT8) *Path;
- Path++;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Multi Pathname (%u Segments, Flags=%X)\n",
- NumSegments, Flags));
- break;
-
- default:
- /*
- * Not a Null name, no Dual or Multi prefix, hence there is
- * only one name segment and Pathname is already pointing to it.
- */
- NumSegments = 1;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Simple Pathname (1 segment, Flags=%X)\n", Flags));
- break;
- }
-
- ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path));
- }
-
-
- /*
- * Search namespace for each segment of the name. Loop through and
- * verify (or add to the namespace) each name segment.
- *
- * The object type is significant only at the last name
- * segment. (We don't care about the types along the path, only
- * the type of the final target object.)
- */
- ThisSearchType = ACPI_TYPE_ANY;
- CurrentNode = ThisNode;
- while (NumSegments && CurrentNode)
- {
- NumSegments--;
- if (!NumSegments)
- {
- /* This is the last segment, enable typechecking */
-
- ThisSearchType = Type;
-
- /*
- * Only allow automatic parent search (search rules) if the caller
- * requested it AND we have a single, non-fully-qualified NameSeg
- */
- if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
- (Flags & ACPI_NS_SEARCH_PARENT))
- {
- LocalFlags |= ACPI_NS_SEARCH_PARENT;
- }
-
- /* Set error flag according to caller */
-
- if (Flags & ACPI_NS_ERROR_IF_FOUND)
- {
- LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
- }
- }
-
- /* Extract one ACPI name from the front of the pathname */
-
- ACPI_MOVE_32_TO_32 (&SimpleName, Path);
-
- /* Try to find the single (4 character) ACPI name */
-
- Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
- InterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_NOT_FOUND)
- {
- /* Name not found in ACPI namespace */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Name [%4.4s] not found in scope [%4.4s] %p\n",
- (char *) &SimpleName, (char *) &CurrentNode->Name,
- CurrentNode));
- }
-
- *ReturnNode = ThisNode;
- return_ACPI_STATUS (Status);
- }
-
- /* More segments to follow? */
-
- if (NumSegments > 0)
- {
- /*
- * If we have an alias to an object that opens a scope (such as a
- * device or processor), we need to dereference the alias here so
- * that we can access any children of the original node (via the
- * remaining segments).
- */
- if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS)
- {
- if (!ThisNode->Object)
- {
- return_ACPI_STATUS (AE_NOT_EXIST);
- }
-
- if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *)
- ThisNode->Object)->Type))
- {
- ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object;
- }
- }
- }
-
- /* Special handling for the last segment (NumSegments == 0) */
-
- else
- {
- /*
- * Sanity typecheck of the target object:
- *
- * If 1) This is the last segment (NumSegments == 0)
- * 2) And we are looking for a specific type
- * (Not checking for TYPE_ANY)
- * 3) Which is not an alias
- * 4) Which is not a local type (TYPE_SCOPE)
- * 5) And the type of target object is known (not TYPE_ANY)
- * 6) And target object does not match what we are looking for
- *
- * Then we have a type mismatch. Just warn and ignore it.
- */
- if ((TypeToCheckFor != ACPI_TYPE_ANY) &&
- (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) &&
- (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
- (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) &&
- (ThisNode->Type != ACPI_TYPE_ANY) &&
- (ThisNode->Type != TypeToCheckFor))
- {
- /* Complain about a type mismatch */
-
- ACPI_WARNING ((AE_INFO,
- "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
- ACPI_CAST_PTR (char, &SimpleName),
- AcpiUtGetTypeName (ThisNode->Type),
- AcpiUtGetTypeName (TypeToCheckFor)));
- }
-
- /*
- * If this is the last name segment and we are not looking for a
- * specific type, but the type of found object is known, use that
- * type to (later) see if it opens a scope.
- */
- if (Type == ACPI_TYPE_ANY)
- {
- Type = ThisNode->Type;
- }
- }
-
- /* Point to next name segment and make this node current */
-
- Path += ACPI_NAME_SIZE;
- CurrentNode = ThisNode;
- }
-
- /* Always check if we need to open a new scope */
-
- if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
- {
- /*
- * If entry is a type which opens a scope, push the new scope on the
- * scope stack.
- */
- if (AcpiNsOpensScope (Type))
- {
- Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
- }
-
- *ReturnNode = ThisNode;
- return_ACPI_STATUS (AE_OK);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsalloc.c
--- a/head/sys/contrib/dev/acpica/namespace/nsalloc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,588 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsalloc - Namespace allocation and deletion 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 __NSALLOC_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsalloc")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCreateNode
- *
- * PARAMETERS: Name - Name of the new node (4 char ACPI name)
- *
- * RETURN: New namespace node (Null on failure)
- *
- * DESCRIPTION: Create a namespace node
- *
- ******************************************************************************/
-
-ACPI_NAMESPACE_NODE *
-AcpiNsCreateNode (
- UINT32 Name)
-{
- ACPI_NAMESPACE_NODE *Node;
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- UINT32 Temp;
-#endif
-
-
- ACPI_FUNCTION_TRACE (NsCreateNode);
-
-
- Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache);
- if (!Node)
- {
- return_PTR (NULL);
- }
-
- ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++);
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- Temp = AcpiGbl_NsNodeList->TotalAllocated -
- AcpiGbl_NsNodeList->TotalFreed;
- if (Temp > AcpiGbl_NsNodeList->MaxOccupied)
- {
- AcpiGbl_NsNodeList->MaxOccupied = Temp;
- }
-#endif
-
- Node->Name.Integer = Name;
- ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED);
- return_PTR (Node);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDeleteNode
- *
- * PARAMETERS: Node - Node to be deleted
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete a namespace node. All node deletions must come through
- * here. Detaches any attached objects, including any attached
- * data. If a handler is associated with attached data, it is
- * invoked before the node is deleted.
- *
- ******************************************************************************/
-
-void
-AcpiNsDeleteNode (
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_NAME (NsDeleteNode);
-
-
- /* Detach an object if there is one */
-
- AcpiNsDetachObject (Node);
-
- /*
- * Delete an attached data object if present (an object that was created
- * and attached via AcpiAttachData). Note: After any normal object is
- * detached above, the only possible remaining object is a data object.
- */
- ObjDesc = Node->Object;
- if (ObjDesc &&
- (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
- {
- /* Invoke the attached data deletion handler if present */
-
- if (ObjDesc->Data.Handler)
- {
- ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer);
- }
-
- AcpiUtRemoveReference (ObjDesc);
- }
-
- /* Now we can delete the node */
-
- (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node);
-
- ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++);
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n",
- Node, AcpiGbl_CurrentNodeCount));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsRemoveNode
- *
- * PARAMETERS: Node - Node to be removed/deleted
- *
- * RETURN: None
- *
- * DESCRIPTION: Remove (unlink) and delete a namespace node
- *
- ******************************************************************************/
-
-void
-AcpiNsRemoveNode (
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_NAMESPACE_NODE *ParentNode;
- ACPI_NAMESPACE_NODE *PrevNode;
- ACPI_NAMESPACE_NODE *NextNode;
-
-
- ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node);
-
-
- ParentNode = Node->Parent;
-
- PrevNode = NULL;
- NextNode = ParentNode->Child;
-
- /* Find the node that is the previous peer in the parent's child list */
-
- while (NextNode != Node)
- {
- PrevNode = NextNode;
- NextNode = NextNode->Peer;
- }
-
- if (PrevNode)
- {
- /* Node is not first child, unlink it */
-
- PrevNode->Peer = Node->Peer;
- }
- else
- {
- /*
- * Node is first child (has no previous peer).
- * Link peer list to parent
- */
- ParentNode->Child = Node->Peer;
- }
-
- /* Delete the node and any attached objects */
-
- AcpiNsDeleteNode (Node);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsInstallNode
- *
- * PARAMETERS: WalkState - Current state of the walk
- * ParentNode - The parent of the new Node
- * Node - The new Node to install
- * Type - ACPI object type of the new Node
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize a new namespace node and install it amongst
- * its peers.
- *
- * Note: Current namespace lookup is linear search. This appears
- * to be sufficient as namespace searches consume only a small
- * fraction of the execution time of the ACPI subsystem.
- *
- ******************************************************************************/
-
-void
-AcpiNsInstallNode (
- ACPI_WALK_STATE *WalkState,
- ACPI_NAMESPACE_NODE *ParentNode, /* Parent */
- ACPI_NAMESPACE_NODE *Node, /* New Child*/
- ACPI_OBJECT_TYPE Type)
-{
- ACPI_OWNER_ID OwnerId = 0;
- ACPI_NAMESPACE_NODE *ChildNode;
-
-
- ACPI_FUNCTION_TRACE (NsInstallNode);
-
-
- if (WalkState)
- {
- /*
- * Get the owner ID from the Walk state. The owner ID is used to
- * track table deletion and deletion of objects created by methods.
- */
- OwnerId = WalkState->OwnerId;
-
- if ((WalkState->MethodDesc) &&
- (ParentNode != WalkState->MethodNode))
- {
- /*
- * A method is creating a new node that is not a child of the
- * method (it is non-local). Mark the executing method as having
- * modified the namespace. This is used for cleanup when the
- * method exits.
- */
- WalkState->MethodDesc->Method.InfoFlags |= ACPI_METHOD_MODIFIED_NAMESPACE;
- }
- }
-
- /* Link the new entry into the parent and existing children */
-
- Node->Peer = NULL;
- Node->Parent = ParentNode;
- ChildNode = ParentNode->Child;
-
- if (!ChildNode)
- {
- ParentNode->Child = Node;
- }
- else
- {
- /* Add node to the end of the peer list */
-
- while (ChildNode->Peer)
- {
- ChildNode = ChildNode->Peer;
- }
-
- ChildNode->Peer = Node;
- }
-
- /* Init the new entry */
-
- Node->OwnerId = OwnerId;
- Node->Type = (UINT8) Type;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n",
- AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId,
- AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type),
- ParentNode));
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDeleteChildren
- *
- * PARAMETERS: ParentNode - Delete this objects children
- *
- * RETURN: None.
- *
- * DESCRIPTION: Delete all children of the parent object. In other words,
- * deletes a "scope".
- *
- ******************************************************************************/
-
-void
-AcpiNsDeleteChildren (
- ACPI_NAMESPACE_NODE *ParentNode)
-{
- ACPI_NAMESPACE_NODE *NextNode;
- ACPI_NAMESPACE_NODE *NodeToDelete;
-
-
- ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode);
-
-
- if (!ParentNode)
- {
- return_VOID;
- }
-
- /* Deallocate all children at this level */
-
- NextNode = ParentNode->Child;
- while (NextNode)
- {
- /* Grandchildren should have all been deleted already */
-
- if (NextNode->Child)
- {
- ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p",
- ParentNode, NextNode));
- }
-
- /*
- * Delete this child node and move on to the next child in the list.
- * No need to unlink the node since we are deleting the entire branch.
- */
- NodeToDelete = NextNode;
- NextNode = NextNode->Peer;
- AcpiNsDeleteNode (NodeToDelete);
- };
-
- /* Clear the parent's child pointer */
-
- ParentNode->Child = NULL;
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDeleteNamespaceSubtree
- *
- * PARAMETERS: ParentNode - Root of the subtree to be deleted
- *
- * RETURN: None.
- *
- * DESCRIPTION: Delete a subtree of the namespace. This includes all objects
- * stored within the subtree.
- *
- ******************************************************************************/
-
-void
-AcpiNsDeleteNamespaceSubtree (
- ACPI_NAMESPACE_NODE *ParentNode)
-{
- ACPI_NAMESPACE_NODE *ChildNode = NULL;
- UINT32 Level = 1;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree);
-
-
- if (!ParentNode)
- {
- return_VOID;
- }
-
- /* Lock namespace for possible update */
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return_VOID;
- }
-
- /*
- * Traverse the tree of objects until we bubble back up
- * to where we started.
- */
- while (Level > 0)
- {
- /* Get the next node in this scope (NULL if none) */
-
- ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
- if (ChildNode)
- {
- /* Found a child node - detach any attached object */
-
- AcpiNsDetachObject (ChildNode);
-
- /* Check if this node has any children */
-
- if (ChildNode->Child)
- {
- /*
- * There is at least one child of this node,
- * visit the node
- */
- Level++;
- ParentNode = ChildNode;
- ChildNode = NULL;
- }
- }
- else
- {
- /*
- * No more children of this parent node.
- * Move up to the grandparent.
- */
- Level--;
-
- /*
- * Now delete all of the children of this parent
- * all at the same time.
- */
- AcpiNsDeleteChildren (ParentNode);
-
- /* New "last child" is this parent node */
-
- ChildNode = ParentNode;
-
- /* Move up the tree to the grandparent */
-
- ParentNode = ParentNode->Parent;
- }
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDeleteNamespaceByOwner
- *
- * PARAMETERS: OwnerId - All nodes with this owner will be deleted
- *
- * RETURN: Status
- *
- * DESCRIPTION: Delete entries within the namespace that are owned by a
- * specific ID. Used to delete entire ACPI tables. All
- * reference counts are updated.
- *
- * MUTEX: Locks namespace during deletion walk.
- *
- ******************************************************************************/
-
-void
-AcpiNsDeleteNamespaceByOwner (
- ACPI_OWNER_ID OwnerId)
-{
- ACPI_NAMESPACE_NODE *ChildNode;
- ACPI_NAMESPACE_NODE *DeletionNode;
- ACPI_NAMESPACE_NODE *ParentNode;
- UINT32 Level;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId);
-
-
- if (OwnerId == 0)
- {
- return_VOID;
- }
-
- /* Lock namespace for possible update */
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return_VOID;
- }
-
- DeletionNode = NULL;
- ParentNode = AcpiGbl_RootNode;
- ChildNode = NULL;
- Level = 1;
-
- /*
- * Traverse the tree of nodes until we bubble back up
- * to where we started.
- */
- while (Level > 0)
- {
- /*
- * Get the next child of this parent node. When ChildNode is NULL,
- * the first child of the parent is returned
- */
- ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
-
- if (DeletionNode)
- {
- AcpiNsDeleteChildren (DeletionNode);
- AcpiNsRemoveNode (DeletionNode);
- DeletionNode = NULL;
- }
-
- if (ChildNode)
- {
- if (ChildNode->OwnerId == OwnerId)
- {
- /* Found a matching child node - detach any attached object */
-
- AcpiNsDetachObject (ChildNode);
- }
-
- /* Check if this node has any children */
-
- if (ChildNode->Child)
- {
- /*
- * There is at least one child of this node,
- * visit the node
- */
- Level++;
- ParentNode = ChildNode;
- ChildNode = NULL;
- }
- else if (ChildNode->OwnerId == OwnerId)
- {
- DeletionNode = ChildNode;
- }
- }
- else
- {
- /*
- * No more children of this parent node.
- * Move up to the grandparent.
- */
- Level--;
- if (Level != 0)
- {
- if (ParentNode->OwnerId == OwnerId)
- {
- DeletionNode = ParentNode;
- }
- }
-
- /* New "last child" is this parent node */
-
- ChildNode = ParentNode;
-
- /* Move up the tree to the grandparent */
-
- ParentNode = ParentNode->Parent;
- }
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return_VOID;
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsdump.c
--- a/head/sys/contrib/dev/acpica/namespace/nsdump.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,769 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsdump - table dumping routines for debug
- *
- *****************************************************************************/
-
-/*
- * 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 __NSDUMP_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsdump")
-
-/* Local prototypes */
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-void
-AcpiNsDumpRootDevices (
- void);
-
-static ACPI_STATUS
-AcpiNsDumpOneDevice (
- ACPI_HANDLE ObjHandle,
- UINT32 Level,
- void *Context,
- void **ReturnValue);
-#endif
-
-
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsPrintPathname
- *
- * PARAMETERS: NumSegments - Number of ACPI name segments
- * Pathname - The compressed (internal) path
- *
- * RETURN: None
- *
- * DESCRIPTION: Print an object's full namespace pathname
- *
- ******************************************************************************/
-
-void
-AcpiNsPrintPathname (
- UINT32 NumSegments,
- char *Pathname)
-{
- UINT32 i;
-
-
- ACPI_FUNCTION_NAME (NsPrintPathname);
-
-
- if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
- {
- return;
- }
-
- /* Print the entire name */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
-
- while (NumSegments)
- {
- for (i = 0; i < 4; i++)
- {
- ACPI_IS_PRINT (Pathname[i]) ?
- AcpiOsPrintf ("%c", Pathname[i]) :
- AcpiOsPrintf ("?");
- }
-
- Pathname += ACPI_NAME_SIZE;
- NumSegments--;
- if (NumSegments)
- {
- AcpiOsPrintf (".");
- }
- }
-
- AcpiOsPrintf ("]\n");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDumpPathname
- *
- * PARAMETERS: Handle - Object
- * Msg - Prefix message
- * Level - Desired debug level
- * Component - Caller's component ID
- *
- * RETURN: None
- *
- * DESCRIPTION: Print an object's full namespace pathname
- * Manages allocation/freeing of a pathname buffer
- *
- ******************************************************************************/
-
-void
-AcpiNsDumpPathname (
- ACPI_HANDLE Handle,
- char *Msg,
- UINT32 Level,
- UINT32 Component)
-{
-
- ACPI_FUNCTION_TRACE (NsDumpPathname);
-
-
- /* Do this only if the requested debug level and component are enabled */
-
- if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
- {
- return_VOID;
- }
-
- /* Convert handle to a full pathname and print it (with supplied message) */
-
- AcpiNsPrintNodePathname (Handle, Msg);
- AcpiOsPrintf ("\n");
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDumpOneObject
- *
- * PARAMETERS: ObjHandle - Node to be dumped
- * Level - Nesting level of the handle
- * Context - Passed into WalkNamespace
- * ReturnValue - Not used
- *
- * RETURN: Status
- *
- * DESCRIPTION: Dump a single Node
- * This procedure is a UserFunction called by AcpiNsWalkNamespace.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsDumpOneObject (
- ACPI_HANDLE ObjHandle,
- UINT32 Level,
- void *Context,
- void **ReturnValue)
-{
- ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
- ACPI_NAMESPACE_NODE *ThisNode;
- ACPI_OPERAND_OBJECT *ObjDesc = NULL;
- ACPI_OBJECT_TYPE ObjType;
- ACPI_OBJECT_TYPE Type;
- UINT32 BytesToDump;
- UINT32 DbgLevel;
- UINT32 i;
-
-
- ACPI_FUNCTION_NAME (NsDumpOneObject);
-
-
- /* Is output enabled? */
-
- if (!(AcpiDbgLevel & Info->DebugLevel))
- {
- return (AE_OK);
- }
-
- if (!ObjHandle)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
- return (AE_OK);
- }
-
- ThisNode = AcpiNsValidateHandle (ObjHandle);
- if (!ThisNode)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
- ObjHandle));
- return (AE_OK);
- }
-
- Type = ThisNode->Type;
-
- /* Check if the owner matches */
-
- if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
- (Info->OwnerId != ThisNode->OwnerId))
- {
- return (AE_OK);
- }
-
- if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
- {
- /* Indent the object according to the level */
-
- AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
-
- /* Check the node type and name */
-
- if (Type > ACPI_TYPE_LOCAL_MAX)
- {
- ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type));
- }
-
- AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
- }
-
- /* Now we can print out the pertinent information */
-
- AcpiOsPrintf (" %-12s %p %2.2X ",
- AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
-
- DbgLevel = AcpiDbgLevel;
- AcpiDbgLevel = 0;
- ObjDesc = AcpiNsGetAttachedObject (ThisNode);
- AcpiDbgLevel = DbgLevel;
-
- /* Temp nodes are those nodes created by a control method */
-
- if (ThisNode->Flags & ANOBJ_TEMPORARY)
- {
- AcpiOsPrintf ("(T) ");
- }
-
- switch (Info->DisplayType & ACPI_DISPLAY_MASK)
- {
- case ACPI_DISPLAY_SUMMARY:
-
- if (!ObjDesc)
- {
- /* No attached object, we are done */
-
- AcpiOsPrintf ("\n");
- return (AE_OK);
- }
-
- switch (Type)
- {
- case ACPI_TYPE_PROCESSOR:
-
- AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
- ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
- ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
- break;
-
-
- case ACPI_TYPE_DEVICE:
-
- AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
- break;
-
-
- case ACPI_TYPE_METHOD:
-
- AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
- (UINT32) ObjDesc->Method.ParamCount,
- ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
- break;
-
-
- case ACPI_TYPE_INTEGER:
-
- AcpiOsPrintf ("= %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
- break;
-
-
- case ACPI_TYPE_PACKAGE:
-
- if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
- {
- AcpiOsPrintf ("Elements %.2X\n",
- ObjDesc->Package.Count);
- }
- else
- {
- AcpiOsPrintf ("[Length not yet evaluated]\n");
- }
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
- {
- AcpiOsPrintf ("Len %.2X",
- ObjDesc->Buffer.Length);
-
- /* Dump some of the buffer */
-
- if (ObjDesc->Buffer.Length > 0)
- {
- AcpiOsPrintf (" =");
- for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
- {
- AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
- }
- }
- AcpiOsPrintf ("\n");
- }
- else
- {
- AcpiOsPrintf ("[Length not yet evaluated]\n");
- }
- break;
-
-
- case ACPI_TYPE_STRING:
-
- AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
- AcpiUtPrintString (ObjDesc->String.Pointer, 32);
- AcpiOsPrintf ("\n");
- break;
-
-
- case ACPI_TYPE_REGION:
-
- AcpiOsPrintf ("[%s]",
- AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
- if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
- {
- AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
- ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
- ObjDesc->Region.Length);
- }
- else
- {
- AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
- }
- break;
-
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
- break;
-
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- if (ObjDesc->BufferField.BufferObj &&
- ObjDesc->BufferField.BufferObj->Buffer.Node)
- {
- AcpiOsPrintf ("Buf [%4.4s]",
- AcpiUtGetNodeName (
- ObjDesc->BufferField.BufferObj->Buffer.Node));
- }
- break;
-
-
- case ACPI_TYPE_LOCAL_REGION_FIELD:
-
- AcpiOsPrintf ("Rgn [%4.4s]",
- AcpiUtGetNodeName (
- ObjDesc->CommonField.RegionObj->Region.Node));
- break;
-
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
- AcpiUtGetNodeName (
- ObjDesc->CommonField.RegionObj->Region.Node),
- AcpiUtGetNodeName (
- ObjDesc->BankField.BankObj->CommonField.Node));
- break;
-
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
- AcpiUtGetNodeName (
- ObjDesc->IndexField.IndexObj->CommonField.Node),
- AcpiUtGetNodeName (
- ObjDesc->IndexField.DataObj->CommonField.Node));
- break;
-
-
- case ACPI_TYPE_LOCAL_ALIAS:
- case ACPI_TYPE_LOCAL_METHOD_ALIAS:
-
- AcpiOsPrintf ("Target %4.4s (%p)\n",
- AcpiUtGetNodeName (ObjDesc), ObjDesc);
- break;
-
- default:
-
- AcpiOsPrintf ("Object %p\n", ObjDesc);
- break;
- }
-
- /* Common field handling */
-
- switch (Type)
- {
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
- (ObjDesc->CommonField.BaseByteOffset * 8)
- + ObjDesc->CommonField.StartFieldBitOffset,
- ObjDesc->CommonField.BitLength,
- ObjDesc->CommonField.AccessByteWidth);
- break;
-
- default:
- break;
- }
- break;
-
-
- case ACPI_DISPLAY_OBJECTS:
-
- AcpiOsPrintf ("O:%p", ObjDesc);
- if (!ObjDesc)
- {
- /* No attached object, we are done */
-
- AcpiOsPrintf ("\n");
- return (AE_OK);
- }
-
- AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
-
- switch (Type)
- {
- case ACPI_TYPE_METHOD:
-
- /* Name is a Method and its AML offset/length are set */
-
- AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
- ObjDesc->Method.AmlLength);
- break;
-
- case ACPI_TYPE_INTEGER:
-
- AcpiOsPrintf (" I:%8.8X8.8%X\n",
- ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
- break;
-
- case ACPI_TYPE_STRING:
-
- AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
- ObjDesc->String.Length);
- break;
-
- case ACPI_TYPE_BUFFER:
-
- AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
- ObjDesc->Buffer.Length);
- break;
-
- default:
-
- AcpiOsPrintf ("\n");
- break;
- }
- break;
-
-
- default:
- AcpiOsPrintf ("\n");
- break;
- }
-
- /* If debug turned off, done */
-
- if (!(AcpiDbgLevel & ACPI_LV_VALUES))
- {
- return (AE_OK);
- }
-
- /* If there is an attached object, display it */
-
- DbgLevel = AcpiDbgLevel;
- AcpiDbgLevel = 0;
- ObjDesc = AcpiNsGetAttachedObject (ThisNode);
- AcpiDbgLevel = DbgLevel;
-
- /* Dump attached objects */
-
- while (ObjDesc)
- {
- ObjType = ACPI_TYPE_INVALID;
- AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
-
- /* Decode the type of attached object and dump the contents */
-
- switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
- {
- case ACPI_DESC_TYPE_NAMED:
-
- AcpiOsPrintf ("(Ptr to Node)\n");
- BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
- ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
- break;
-
- case ACPI_DESC_TYPE_OPERAND:
-
- ObjType = ObjDesc->Common.Type;
-
- if (ObjType > ACPI_TYPE_LOCAL_MAX)
- {
- AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
- ObjType);
- BytesToDump = 32;
- }
- else
- {
- AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
- ObjType, AcpiUtGetTypeName (ObjType));
- BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
- }
-
- ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
- break;
-
- default:
-
- break;
- }
-
- /* If value is NOT an internal object, we are done */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
- {
- goto Cleanup;
- }
-
- /* Valid object, get the pointer to next level, if any */
-
- switch (ObjType)
- {
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_STRING:
- /*
- * NOTE: takes advantage of common fields between string/buffer
- */
- BytesToDump = ObjDesc->String.Length;
- ObjDesc = (void *) ObjDesc->String.Pointer;
- AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
- ObjDesc, BytesToDump);
- ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
- goto Cleanup;
-
- case ACPI_TYPE_BUFFER_FIELD:
- ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
- break;
-
- case ACPI_TYPE_PACKAGE:
- ObjDesc = (void *) ObjDesc->Package.Elements;
- break;
-
- case ACPI_TYPE_METHOD:
- ObjDesc = (void *) ObjDesc->Method.AmlStart;
- break;
-
- case ACPI_TYPE_LOCAL_REGION_FIELD:
- ObjDesc = (void *) ObjDesc->Field.RegionObj;
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- ObjDesc = (void *) ObjDesc->BankField.RegionObj;
- break;
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
- ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
- break;
-
- default:
- goto Cleanup;
- }
-
- ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
- }
-
-Cleanup:
- AcpiOsPrintf ("\n");
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDumpObjects
- *
- * PARAMETERS: Type - Object type to be dumped
- * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
- * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
- * for an effectively unlimited depth.
- * OwnerId - Dump only objects owned by this ID. Use
- * ACPI_UINT32_MAX to match all owners.
- * StartHandle - Where in namespace to start/end search
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
- * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
- *
- ******************************************************************************/
-
-void
-AcpiNsDumpObjects (
- ACPI_OBJECT_TYPE Type,
- UINT8 DisplayType,
- UINT32 MaxDepth,
- ACPI_OWNER_ID OwnerId,
- ACPI_HANDLE StartHandle)
-{
- ACPI_WALK_INFO Info;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * Just lock the entire namespace for the duration of the dump.
- * We don't want any changes to the namespace during this time,
- * especially the temporary nodes since we are going to display
- * them also.
- */
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsPrintf ("Could not acquire namespace mutex\n");
- return;
- }
-
- Info.DebugLevel = ACPI_LV_TABLES;
- Info.OwnerId = OwnerId;
- Info.DisplayType = DisplayType;
-
- (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
- ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
- AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDumpEntry
- *
- * PARAMETERS: Handle - Node to be dumped
- * DebugLevel - Output level
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump a single Node
- *
- ******************************************************************************/
-
-void
-AcpiNsDumpEntry (
- ACPI_HANDLE Handle,
- UINT32 DebugLevel)
-{
- ACPI_WALK_INFO Info;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- Info.DebugLevel = DebugLevel;
- Info.OwnerId = ACPI_OWNER_ID_MAX;
- Info.DisplayType = ACPI_DISPLAY_SUMMARY;
-
- (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
-}
-
-
-#ifdef ACPI_ASL_COMPILER
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDumpTables
- *
- * PARAMETERS: SearchBase - Root of subtree to be dumped, or
- * NS_ALL to dump the entire namespace
- * MaxDepth - Maximum depth of dump. Use INT_MAX
- * for an effectively unlimited depth.
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump the name space, or a portion of it.
- *
- ******************************************************************************/
-
-void
-AcpiNsDumpTables (
- ACPI_HANDLE SearchBase,
- UINT32 MaxDepth)
-{
- ACPI_HANDLE SearchHandle = SearchBase;
-
-
- ACPI_FUNCTION_TRACE (NsDumpTables);
-
-
- if (!AcpiGbl_RootNode)
- {
- /*
- * If the name space has not been initialized,
- * there is nothing to dump.
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
- return_VOID;
- }
-
- if (ACPI_NS_ALL == SearchBase)
- {
- /* Entire namespace */
-
- SearchHandle = AcpiGbl_RootNode;
- ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
- }
-
- AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
- ACPI_OWNER_ID_MAX, SearchHandle);
- return_VOID;
-}
-#endif
-#endif
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsdumpdv.c
--- a/head/sys/contrib/dev/acpica/namespace/nsdumpdv.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsdump - table dumping routines for debug
- *
- *****************************************************************************/
-
-/*
- * 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 __NSDUMPDV_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-
-
-/* TBD: This entire module is apparently obsolete and should be removed */
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsdumpdv")
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDumpOneDevice
- *
- * PARAMETERS: Handle - Node to be dumped
- * Level - Nesting level of the handle
- * Context - Passed into WalkNamespace
- * ReturnValue - Not used
- *
- * RETURN: Status
- *
- * DESCRIPTION: Dump a single Node that represents a device
- * This procedure is a UserFunction called by AcpiNsWalkNamespace.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsDumpOneDevice (
- ACPI_HANDLE ObjHandle,
- UINT32 Level,
- void *Context,
- void **ReturnValue)
-{
- ACPI_BUFFER Buffer;
- ACPI_DEVICE_INFO *Info;
- ACPI_STATUS Status;
- UINT32 i;
-
-
- ACPI_FUNCTION_NAME (NsDumpOneDevice);
-
-
- Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue);
-
- Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
- Status = AcpiGetObjectInfo (ObjHandle, &Buffer);
- if (ACPI_SUCCESS (Status))
- {
- Info = Buffer.Pointer;
- for (i = 0; i < Level; i++)
- {
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
- }
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES,
- " HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
- Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address),
- Info->CurrentStatus));
- ACPI_FREE (Info);
- }
-
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDumpRootDevices
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump all objects of type "device"
- *
- ******************************************************************************/
-
-void
-AcpiNsDumpRootDevices (
- void)
-{
- ACPI_HANDLE SysBusHandle;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_NAME (NsDumpRootDevices);
-
-
- /* Only dump the table if tracing is enabled */
-
- if (!(ACPI_LV_TABLES & AcpiDbgLevel))
- {
- return;
- }
-
- Status = AcpiGetHandle (NULL, ACPI_NS_SYSTEM_BUS, &SysBusHandle);
- if (ACPI_FAILURE (Status))
- {
- return;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
- "Display of all devices in the namespace:\n"));
-
- Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle,
- ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
- AcpiNsDumpOneDevice, NULL, NULL, NULL);
-}
-
-#endif
-#endif
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nseval.c
--- a/head/sys/contrib/dev/acpica/namespace/nseval.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,485 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nseval - Object evaluation, includes 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.
- */
-
-#define __NSEVAL_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/acinterp.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nseval")
-
-/* Local prototypes */
-
-static void
-AcpiNsExecModuleCode (
- ACPI_OPERAND_OBJECT *MethodObj,
- ACPI_EVALUATE_INFO *Info);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsEvaluate
- *
- * PARAMETERS: Info - Evaluation info block, contains:
- * PrefixNode - Prefix or Method/Object Node to execute
- * Pathname - Name of method to execute, If NULL, the
- * Node is the object to execute
- * Parameters - List of parameters to pass to the method,
- * terminated by NULL. Params itself may be
- * NULL if no parameters are being passed.
- * ReturnObject - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * ParameterType - Type of Parameter list
- * ReturnObject - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * Flags - ACPI_IGNORE_RETURN_VALUE to delete return
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute a control method or return the current value of an
- * ACPI namespace object.
- *
- * MUTEX: Locks interpreter
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsEvaluate (
- ACPI_EVALUATE_INFO *Info)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (NsEvaluate);
-
-
- if (!Info)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Initialize the return value to an invalid object */
-
- Info->ReturnObject = NULL;
- Info->ParamCount = 0;
-
- /*
- * Get the actual namespace node for the target object. Handles these cases:
- *
- * 1) Null node, Pathname (absolute path)
- * 2) Node, Pathname (path relative to Node)
- * 3) Node, Null Pathname
- */
- Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname,
- ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * For a method alias, we must grab the actual method node so that proper
- * scoping context will be established before execution.
- */
- if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
- {
- Info->ResolvedNode =
- ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname,
- Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode)));
-
- Node = Info->ResolvedNode;
-
- /*
- * Two major cases here:
- *
- * 1) The object is a control method -- execute it
- * 2) The object is not a method -- just return it's current value
- */
- if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD)
- {
- /*
- * 1) Object is a control method - execute it
- */
-
- /* Verify that there is a method object associated with this node */
-
- Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode);
- if (!Info->ObjDesc)
- {
- ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object"));
- return_ACPI_STATUS (AE_NULL_OBJECT);
- }
-
- /* Count the number of arguments being passed to the method */
-
- if (Info->Parameters)
- {
- while (Info->Parameters[Info->ParamCount])
- {
- if (Info->ParamCount > ACPI_METHOD_MAX_ARG)
- {
- return_ACPI_STATUS (AE_LIMIT);
- }
- Info->ParamCount++;
- }
- }
-
- ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method",
- ACPI_LV_INFO, _COMPONENT);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Method at AML address %p Length %X\n",
- Info->ObjDesc->Method.AmlStart + 1,
- Info->ObjDesc->Method.AmlLength - 1));
-
- /*
- * Any namespace deletion must acquire both the namespace and
- * interpreter locks to ensure that no thread is using the portion of
- * the namespace that is being deleted.
- *
- * Execute the method via the interpreter. The interpreter is locked
- * here before calling into the AML parser
- */
- AcpiExEnterInterpreter ();
- Status = AcpiPsExecuteMethod (Info);
- AcpiExExitInterpreter ();
- }
- else
- {
- /*
- * 2) Object is not a method, return its current value
- *
- * Disallow certain object types. For these, "evaluation" is undefined.
- */
- switch (Info->ResolvedNode->Type)
- {
- case ACPI_TYPE_DEVICE:
- case ACPI_TYPE_EVENT:
- case ACPI_TYPE_MUTEX:
- case ACPI_TYPE_REGION:
- case ACPI_TYPE_THERMAL:
- case ACPI_TYPE_LOCAL_SCOPE:
-
- ACPI_ERROR ((AE_INFO,
- "[%4.4s] Evaluation of object type [%s] is not supported",
- Info->ResolvedNode->Name.Ascii,
- AcpiUtGetTypeName (Info->ResolvedNode->Type)));
-
- return_ACPI_STATUS (AE_TYPE);
-
- default:
- break;
- }
-
- /*
- * Objects require additional resolution steps (e.g., the Node may be
- * a field that must be read, etc.) -- we can't just grab the object
- * out of the node.
- *
- * Use ResolveNodeToValue() to get the associated value.
- *
- * NOTE: we can get away with passing in NULL for a walk state because
- * ResolvedNode is guaranteed to not be a reference to either a method
- * local or a method argument (because this interface is never called
- * from a running method.)
- *
- * Even though we do not directly invoke the interpreter for object
- * resolution, we must lock it because we could access an opregion.
- * The opregion access code assumes that the interpreter is locked.
- */
- AcpiExEnterInterpreter ();
-
- /* Function has a strange interface */
-
- Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL);
- AcpiExExitInterpreter ();
-
- /*
- * If AcpiExResolveNodeToValue() succeeded, the return value was placed
- * in ResolvedNode.
- */
- if (ACPI_SUCCESS (Status))
- {
- Status = AE_CTRL_RETURN_VALUE;
- Info->ReturnObject =
- ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n",
- Info->ReturnObject,
- AcpiUtGetObjectTypeName (Info->ReturnObject)));
- }
- }
-
- /*
- * Check input argument count against the ASL-defined count for a method.
- * Also check predefined names: argument count and return value against
- * the ACPI specification. Some incorrect return value types are repaired.
- */
- (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount,
- Status, &Info->ReturnObject);
-
- /* Check if there is a return value that must be dealt with */
-
- if (Status == AE_CTRL_RETURN_VALUE)
- {
- /* If caller does not want the return value, delete it */
-
- if (Info->Flags & ACPI_IGNORE_RETURN_VALUE)
- {
- AcpiUtRemoveReference (Info->ReturnObject);
- Info->ReturnObject = NULL;
- }
-
- /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */
-
- Status = AE_OK;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "*** Completed evaluation of object %s ***\n", Info->Pathname));
-
- /*
- * Namespace was unlocked by the handling AcpiNs* function, so we
- * just return
- */
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsExecModuleCodeList
- *
- * PARAMETERS: None
- *
- * RETURN: None. Exceptions during method execution are ignored, since
- * we cannot abort a table load.
- *
- * DESCRIPTION: Execute all elements of the global module-level code list.
- * Each element is executed as a single control method.
- *
- ******************************************************************************/
-
-void
-AcpiNsExecModuleCodeList (
- void)
-{
- ACPI_OPERAND_OBJECT *Prev;
- ACPI_OPERAND_OBJECT *Next;
- ACPI_EVALUATE_INFO *Info;
- UINT32 MethodCount = 0;
-
-
- ACPI_FUNCTION_TRACE (NsExecModuleCodeList);
-
-
- /* Exit now if the list is empty */
-
- Next = AcpiGbl_ModuleCodeList;
- if (!Next)
- {
- return_VOID;
- }
-
- /* Allocate the evaluation information block */
-
- Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO));
- if (!Info)
- {
- return_VOID;
- }
-
- /* Walk the list, executing each "method" */
-
- while (Next)
- {
- Prev = Next;
- Next = Next->Method.Mutex;
-
- /* Clear the link field and execute the method */
-
- Prev->Method.Mutex = NULL;
- AcpiNsExecModuleCode (Prev, Info);
- MethodCount++;
-
- /* Delete the (temporary) method object */
-
- AcpiUtRemoveReference (Prev);
- }
-
- ACPI_INFO ((AE_INFO,
- "Executed %u blocks of module-level executable AML code",
- MethodCount));
-
- ACPI_FREE (Info);
- AcpiGbl_ModuleCodeList = NULL;
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsExecModuleCode
- *
- * PARAMETERS: MethodObj - Object container for the module-level code
- * Info - Info block for method evaluation
- *
- * RETURN: None. Exceptions during method execution are ignored, since
- * we cannot abort a table load.
- *
- * DESCRIPTION: Execute a control method containing a block of module-level
- * executable AML code. The control method is temporarily
- * installed to the root node, then evaluated.
- *
- ******************************************************************************/
-
-static void
-AcpiNsExecModuleCode (
- ACPI_OPERAND_OBJECT *MethodObj,
- ACPI_EVALUATE_INFO *Info)
-{
- ACPI_OPERAND_OBJECT *ParentObj;
- ACPI_NAMESPACE_NODE *ParentNode;
- ACPI_OBJECT_TYPE Type;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (NsExecModuleCode);
-
-
- /*
- * Get the parent node. We cheat by using the NextObject field
- * of the method object descriptor.
- */
- ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
- MethodObj->Method.NextObject);
- Type = AcpiNsGetType (ParentNode);
-
- /*
- * Get the region handler and save it in the method object. We may need
- * this if an operation region declaration causes a _REG method to be run.
- *
- * We can't do this in AcpiPsLinkModuleCode because
- * AcpiGbl_RootNode->Object is NULL at PASS1.
- */
- if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)
- {
- MethodObj->Method.Dispatch.Handler =
- ParentNode->Object->Device.Handler;
- }
-
- /* Must clear NextObject (AcpiNsAttachObject needs the field) */
-
- MethodObj->Method.NextObject = NULL;
-
- /* Initialize the evaluation information block */
-
- ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
- Info->PrefixNode = ParentNode;
-
- /*
- * Get the currently attached parent object. Add a reference, because the
- * ref count will be decreased when the method object is installed to
- * the parent node.
- */
- ParentObj = AcpiNsGetAttachedObject (ParentNode);
- if (ParentObj)
- {
- AcpiUtAddReference (ParentObj);
- }
-
- /* Install the method (module-level code) in the parent node */
-
- Status = AcpiNsAttachObject (ParentNode, MethodObj,
- ACPI_TYPE_METHOD);
- if (ACPI_FAILURE (Status))
- {
- goto Exit;
- }
-
- /* Execute the parent node as a control method */
-
- Status = AcpiNsEvaluate (Info);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n",
- MethodObj->Method.AmlStart));
-
- /* Delete a possible implicit return value (in slack mode) */
-
- if (Info->ReturnObject)
- {
- AcpiUtRemoveReference (Info->ReturnObject);
- }
-
- /* Detach the temporary method object */
-
- AcpiNsDetachObject (ParentNode);
-
- /* Restore the original parent object */
-
- if (ParentObj)
- {
- Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);
- }
- else
- {
- ParentNode->Type = (UINT8) Type;
- }
-
-Exit:
- if (ParentObj)
- {
- AcpiUtRemoveReference (ParentObj);
- }
- return_VOID;
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsinit.c
--- a/head/sys/contrib/dev/acpica/namespace/nsinit.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,665 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsinit - namespace 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.
- */
-
-
-#define __NSXFINIT_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/acdispat.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsinit")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiNsInitOneObject (
- ACPI_HANDLE ObjHandle,
- UINT32 Level,
- void *Context,
- void **ReturnValue);
-
-static ACPI_STATUS
-AcpiNsInitOneDevice (
- ACPI_HANDLE ObjHandle,
- UINT32 NestingLevel,
- void *Context,
- void **ReturnValue);
-
-static ACPI_STATUS
-AcpiNsFindIniMethods (
- ACPI_HANDLE ObjHandle,
- UINT32 NestingLevel,
- void *Context,
- void **ReturnValue);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsInitializeObjects
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Walk the entire namespace and perform any necessary
- * initialization on the objects found therein
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsInitializeObjects (
- void)
-{
- ACPI_STATUS Status;
- ACPI_INIT_WALK_INFO Info;
-
-
- ACPI_FUNCTION_TRACE (NsInitializeObjects);
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
- "**** Starting initialization of namespace objects ****\n"));
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
- "Completing Region/Field/Buffer/Package initialization:"));
-
- /* Set all init info to zero */
-
- ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
-
- /* Walk entire namespace from the supplied root */
-
- Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL,
- &Info, NULL);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
- }
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
- "\nInitialized %u/%u Regions %u/%u Fields %u/%u "
- "Buffers %u/%u Packages (%u nodes)\n",
- Info.OpRegionInit, Info.OpRegionCount,
- Info.FieldInit, Info.FieldCount,
- Info.BufferInit, Info.BufferCount,
- Info.PackageInit, Info.PackageCount, Info.ObjectCount));
-
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
- "%u Control Methods found\n", Info.MethodCount));
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
- "%u Op Regions found\n", Info.OpRegionCount));
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsInitializeDevices
- *
- * PARAMETERS: None
- *
- * RETURN: ACPI_STATUS
- *
- * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
- * This means running _INI on all present devices.
- *
- * Note: We install PCI config space handler on region access,
- * not here.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsInitializeDevices (
- void)
-{
- ACPI_STATUS Status;
- ACPI_DEVICE_WALK_INFO Info;
-
-
- ACPI_FUNCTION_TRACE (NsInitializeDevices);
-
-
- /* Init counters */
-
- Info.DeviceCount = 0;
- Info.Num_STA = 0;
- Info.Num_INI = 0;
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
- "Initializing Device/Processor/Thermal objects "
- "by executing _INI methods:"));
-
- /* Tree analysis: find all subtrees that contain _INI methods */
-
- Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL);
- if (ACPI_FAILURE (Status))
- {
- goto ErrorExit;
- }
-
- /* Allocate the evaluation information block */
-
- Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
- if (!Info.EvaluateInfo)
- {
- Status = AE_NO_MEMORY;
- goto ErrorExit;
- }
-
- /*
- * Execute the "global" _INI method that may appear at the root. This
- * support is provided for Windows compatibility (Vista+) and is not
- * part of the ACPI specification.
- */
- Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode;
- Info.EvaluateInfo->Pathname = METHOD_NAME__INI;
- Info.EvaluateInfo->Parameters = NULL;
- Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE;
-
- Status = AcpiNsEvaluate (Info.EvaluateInfo);
- if (ACPI_SUCCESS (Status))
- {
- Info.Num_INI++;
- }
-
- /* Walk namespace to execute all _INIs on present devices */
-
- Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL);
-
- /*
- * Any _OSI requests should be completed by now. If the BIOS has
- * requested any Windows OSI strings, we will always truncate
- * I/O addresses to 16 bits -- for Windows compatibility.
- */
- if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000)
- {
- AcpiGbl_TruncateIoAddresses = TRUE;
- }
-
- ACPI_FREE (Info.EvaluateInfo);
- if (ACPI_FAILURE (Status))
- {
- goto ErrorExit;
- }
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
- "\nExecuted %u _INI methods requiring %u _STA executions "
- "(examined %u objects)\n",
- Info.Num_INI, Info.Num_STA, Info.DeviceCount));
-
- return_ACPI_STATUS (Status);
-
-
-ErrorExit:
- ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization"));
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsInitOneObject
- *
- * PARAMETERS: ObjHandle - Node
- * Level - Current nesting level
- * Context - Points to a init info struct
- * ReturnValue - Not used
- *
- * RETURN: Status
- *
- * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
- * within the namespace.
- *
- * Currently, the only objects that require initialization are:
- * 1) Methods
- * 2) Op Regions
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsInitOneObject (
- ACPI_HANDLE ObjHandle,
- UINT32 Level,
- void *Context,
- void **ReturnValue)
-{
- ACPI_OBJECT_TYPE Type;
- ACPI_STATUS Status = AE_OK;
- ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
- ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_NAME (NsInitOneObject);
-
-
- Info->ObjectCount++;
-
- /* And even then, we are only interested in a few object types */
-
- Type = AcpiNsGetType (ObjHandle);
- ObjDesc = AcpiNsGetAttachedObject (Node);
- if (!ObjDesc)
- {
- return (AE_OK);
- }
-
- /* Increment counters for object types we are looking for */
-
- switch (Type)
- {
- case ACPI_TYPE_REGION:
- Info->OpRegionCount++;
- break;
-
- case ACPI_TYPE_BUFFER_FIELD:
- Info->FieldCount++;
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
- Info->FieldCount++;
- break;
-
- case ACPI_TYPE_BUFFER:
- Info->BufferCount++;
- break;
-
- case ACPI_TYPE_PACKAGE:
- Info->PackageCount++;
- break;
-
- default:
-
- /* No init required, just exit now */
- return (AE_OK);
- }
-
- /* If the object is already initialized, nothing else to do */
-
- if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
- {
- return (AE_OK);
- }
-
- /* Must lock the interpreter before executing AML code */
-
- AcpiExEnterInterpreter ();
-
- /*
- * Each of these types can contain executable AML code within the
- * declaration.
- */
- switch (Type)
- {
- case ACPI_TYPE_REGION:
-
- Info->OpRegionInit++;
- Status = AcpiDsGetRegionArguments (ObjDesc);
- break;
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- Info->FieldInit++;
- Status = AcpiDsGetBufferFieldArguments (ObjDesc);
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- Info->FieldInit++;
- Status = AcpiDsGetBankFieldArguments (ObjDesc);
- break;
-
- case ACPI_TYPE_BUFFER:
-
- Info->BufferInit++;
- Status = AcpiDsGetBufferArguments (ObjDesc);
- break;
-
- case ACPI_TYPE_PACKAGE:
-
- Info->PackageInit++;
- Status = AcpiDsGetPackageArguments (ObjDesc);
- break;
-
- default:
- /* No other types can get here */
- break;
- }
-
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not execute arguments for [%4.4s] (%s)",
- AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type)));
- }
-
- /*
- * Print a dot for each object unless we are going to print the entire
- * pathname
- */
- if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
- {
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
- }
-
- /*
- * We ignore errors from above, and always return OK, since we don't want
- * to abort the walk on any single error.
- */
- AcpiExExitInterpreter ();
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsFindIniMethods
- *
- * PARAMETERS: ACPI_WALK_CALLBACK
- *
- * RETURN: ACPI_STATUS
- *
- * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
- * device/processor/thermal objects, and marks the entire subtree
- * with a SUBTREE_HAS_INI flag. This flag is used during the
- * subsequent device initialization walk to avoid entire subtrees
- * that do not contain an _INI.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsFindIniMethods (
- ACPI_HANDLE ObjHandle,
- UINT32 NestingLevel,
- void *Context,
- void **ReturnValue)
-{
- ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
- ACPI_NAMESPACE_NODE *Node;
- ACPI_NAMESPACE_NODE *ParentNode;
-
-
- /* Keep count of device/processor/thermal objects */
-
- Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
- if ((Node->Type == ACPI_TYPE_DEVICE) ||
- (Node->Type == ACPI_TYPE_PROCESSOR) ||
- (Node->Type == ACPI_TYPE_THERMAL))
- {
- Info->DeviceCount++;
- return (AE_OK);
- }
-
- /* We are only looking for methods named _INI */
-
- if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI))
- {
- return (AE_OK);
- }
-
- /*
- * The only _INI methods that we care about are those that are
- * present under Device, Processor, and Thermal objects.
- */
- ParentNode = Node->Parent;
- switch (ParentNode->Type)
- {
- case ACPI_TYPE_DEVICE:
- case ACPI_TYPE_PROCESSOR:
- case ACPI_TYPE_THERMAL:
-
- /* Mark parent and bubble up the INI present flag to the root */
-
- while (ParentNode)
- {
- ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI;
- ParentNode = ParentNode->Parent;
- }
- break;
-
- default:
- break;
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsInitOneDevice
- *
- * PARAMETERS: ACPI_WALK_CALLBACK
- *
- * RETURN: ACPI_STATUS
- *
- * DESCRIPTION: This is called once per device soon after ACPI is enabled
- * to initialize each device. It determines if the device is
- * present, and if so, calls _INI.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsInitOneDevice (
- ACPI_HANDLE ObjHandle,
- UINT32 NestingLevel,
- void *Context,
- void **ReturnValue)
-{
- ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
- ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo;
- UINT32 Flags;
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *DeviceNode;
-
-
- ACPI_FUNCTION_TRACE (NsInitOneDevice);
-
-
- /* We are interested in Devices, Processors and ThermalZones only */
-
- DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
- if ((DeviceNode->Type != ACPI_TYPE_DEVICE) &&
- (DeviceNode->Type != ACPI_TYPE_PROCESSOR) &&
- (DeviceNode->Type != ACPI_TYPE_THERMAL))
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Because of an earlier namespace analysis, all subtrees that contain an
- * _INI method are tagged.
- *
- * If this device subtree does not contain any _INI methods, we
- * can exit now and stop traversing this entire subtree.
- */
- if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI))
- {
- return_ACPI_STATUS (AE_CTRL_DEPTH);
- }
-
- /*
- * Run _STA to determine if this device is present and functioning. We
- * must know this information for two important reasons (from ACPI spec):
- *
- * 1) We can only run _INI if the device is present.
- * 2) We must abort the device tree walk on this subtree if the device is
- * not present and is not functional (we will not examine the children)
- *
- * The _STA method is not required to be present under the device, we
- * assume the device is present if _STA does not exist.
- */
- ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
- ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA));
-
- Status = AcpiUtExecute_STA (DeviceNode, &Flags);
- if (ACPI_FAILURE (Status))
- {
- /* Ignore error and move on to next device */
-
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Flags == -1 means that _STA was not found. In this case, we assume that
- * the device is both present and functional.
- *
- * From the ACPI spec, description of _STA:
- *
- * "If a device object (including the processor object) does not have an
- * _STA object, then OSPM assumes that all of the above bits are set (in
- * other words, the device is present, ..., and functioning)"
- */
- if (Flags != ACPI_UINT32_MAX)
- {
- WalkInfo->Num_STA++;
- }
-
- /*
- * Examine the PRESENT and FUNCTIONING status bits
- *
- * Note: ACPI spec does not seem to specify behavior for the present but
- * not functioning case, so we assume functioning if present.
- */
- if (!(Flags & ACPI_STA_DEVICE_PRESENT))
- {
- /* Device is not present, we must examine the Functioning bit */
-
- if (Flags & ACPI_STA_DEVICE_FUNCTIONING)
- {
- /*
- * Device is not present but is "functioning". In this case,
- * we will not run _INI, but we continue to examine the children
- * of this device.
- *
- * From the ACPI spec, description of _STA: (Note - no mention
- * of whether to run _INI or not on the device in question)
- *
- * "_STA may return bit 0 clear (not present) with bit 3 set
- * (device is functional). This case is used to indicate a valid
- * device for which no device driver should be loaded (for example,
- * a bridge device.) Children of this device may be present and
- * valid. OSPM should continue enumeration below a device whose
- * _STA returns this bit combination"
- */
- return_ACPI_STATUS (AE_OK);
- }
- else
- {
- /*
- * Device is not present and is not functioning. We must abort the
- * walk of this subtree immediately -- don't look at the children
- * of such a device.
- *
- * From the ACPI spec, description of _INI:
- *
- * "If the _STA method indicates that the device is not present,
- * OSPM will not run the _INI and will not examine the children
- * of the device for _INI methods"
- */
- return_ACPI_STATUS (AE_CTRL_DEPTH);
- }
- }
-
- /*
- * The device is present or is assumed present if no _STA exists.
- * Run the _INI if it exists (not required to exist)
- *
- * Note: We know there is an _INI within this subtree, but it may not be
- * under this particular device, it may be lower in the branch.
- */
- ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
- ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI));
-
- Info->PrefixNode = DeviceNode;
- Info->Pathname = METHOD_NAME__INI;
- Info->Parameters = NULL;
- Info->Flags = ACPI_IGNORE_RETURN_VALUE;
-
- Status = AcpiNsEvaluate (Info);
- if (ACPI_SUCCESS (Status))
- {
- WalkInfo->Num_INI++;
-
- if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) &&
- (!(AcpiDbgLevel & ACPI_LV_INFO)))
- {
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
- }
- }
-
-#ifdef ACPI_DEBUG_OUTPUT
- else if (Status != AE_NOT_FOUND)
- {
- /* Ignore error and move on to next device */
-
- char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode);
-
- ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution",
- ScopeName));
- ACPI_FREE (ScopeName);
- }
-#endif
-
- /* Ignore errors from above */
-
- Status = AE_OK;
-
- /*
- * The _INI method has been run if present; call the Global Initialization
- * Handler for this device.
- */
- if (AcpiGbl_InitHandler)
- {
- Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI);
- }
-
- return_ACPI_STATUS (Status);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsload.c
--- a/head/sys/contrib/dev/acpica/namespace/nsload.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,356 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsload - namespace loading/expanding/contracting procedures
- *
- *****************************************************************************/
-
-/*
- * 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 __NSLOAD_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/acdispat.h>
-#include <contrib/dev/acpica/include/actables.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsload")
-
-/* Local prototypes */
-
-#ifdef ACPI_FUTURE_IMPLEMENTATION
-ACPI_STATUS
-AcpiNsUnloadNamespace (
- ACPI_HANDLE Handle);
-
-static ACPI_STATUS
-AcpiNsDeleteSubtree (
- ACPI_HANDLE StartHandle);
-#endif
-
-
-#ifndef ACPI_NO_METHOD_EXECUTION
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsLoadTable
- *
- * PARAMETERS: TableIndex - Index for table to be loaded
- * Node - Owning NS node
- *
- * RETURN: Status
- *
- * DESCRIPTION: Load one ACPI table into the namespace
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsLoadTable (
- UINT32 TableIndex,
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (NsLoadTable);
-
-
- /*
- * Parse the table and load the namespace with all named
- * objects found within. Control methods are NOT parsed
- * at this time. In fact, the control methods cannot be
- * parsed until the entire namespace is loaded, because
- * if a control method makes a forward reference (call)
- * to another control method, we can't continue parsing
- * because we don't know how many arguments to parse next!
- */
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* If table already loaded into namespace, just return */
-
- if (AcpiTbIsTableLoaded (TableIndex))
- {
- Status = AE_ALREADY_EXISTS;
- goto Unlock;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "**** Loading table into namespace ****\n"));
-
- Status = AcpiTbAllocateOwnerId (TableIndex);
- if (ACPI_FAILURE (Status))
- {
- goto Unlock;
- }
-
- Status = AcpiNsParseTable (TableIndex, Node);
- if (ACPI_SUCCESS (Status))
- {
- AcpiTbSetTableLoadedFlag (TableIndex, TRUE);
- }
- else
- {
- (void) AcpiTbReleaseOwnerId (TableIndex);
- }
-
-Unlock:
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Now we can parse the control methods. We always parse
- * them here for a sanity check, and if configured for
- * just-in-time parsing, we delete the control method
- * parse trees.
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "**** Begin Table Method Parsing and Object Initialization\n"));
-
- Status = AcpiDsInitializeObjects (TableIndex, Node);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "**** Completed Table Method Parsing and Object Initialization\n"));
-
- return_ACPI_STATUS (Status);
-}
-
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-/*******************************************************************************
- *
- * FUNCTION: AcpiLoadNamespace
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
- * (DSDT points to either the BIOS or a buffer.)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsLoadNamespace (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiLoadNameSpace);
-
-
- /* There must be at least a DSDT installed */
-
- if (AcpiGbl_DSDT == NULL)
- {
- ACPI_ERROR ((AE_INFO, "DSDT is not in memory"));
- return_ACPI_STATUS (AE_NO_ACPI_TABLES);
- }
-
- /*
- * Load the namespace. The DSDT is required,
- * but the SSDT and PSDT tables are optional.
- */
- Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Ignore exceptions from these */
-
- (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT);
- (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT);
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
- "ACPI Namespace successfully loaded at root %p\n",
- AcpiGbl_RootNode));
-
- return_ACPI_STATUS (Status);
-}
-#endif
-
-#ifdef ACPI_FUTURE_IMPLEMENTATION
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDeleteSubtree
- *
- * PARAMETERS: StartHandle - Handle in namespace where search begins
- *
- * RETURNS Status
- *
- * DESCRIPTION: Walks the namespace starting at the given handle and deletes
- * all objects, entries, and scopes in the entire subtree.
- *
- * Namespace/Interpreter should be locked or the subsystem should
- * be in shutdown before this routine is called.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsDeleteSubtree (
- ACPI_HANDLE StartHandle)
-{
- ACPI_STATUS Status;
- ACPI_HANDLE ChildHandle;
- ACPI_HANDLE ParentHandle;
- ACPI_HANDLE NextChildHandle;
- ACPI_HANDLE Dummy;
- UINT32 Level;
-
-
- ACPI_FUNCTION_TRACE (NsDeleteSubtree);
-
-
- ParentHandle = StartHandle;
- ChildHandle = NULL;
- Level = 1;
-
- /*
- * Traverse the tree of objects until we bubble back up
- * to where we started.
- */
- while (Level > 0)
- {
- /* Attempt to get the next object in this scope */
-
- Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle,
- ChildHandle, &NextChildHandle);
-
- ChildHandle = NextChildHandle;
-
- /* Did we get a new object? */
-
- if (ACPI_SUCCESS (Status))
- {
- /* Check if this object has any children */
-
- if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle,
- NULL, &Dummy)))
- {
- /*
- * There is at least one child of this object,
- * visit the object
- */
- Level++;
- ParentHandle = ChildHandle;
- ChildHandle = NULL;
- }
- }
- else
- {
- /*
- * No more children in this object, go back up to
- * the object's parent
- */
- Level--;
-
- /* Delete all children now */
-
- AcpiNsDeleteChildren (ChildHandle);
-
- ChildHandle = ParentHandle;
- Status = AcpiGetParent (ParentHandle, &ParentHandle);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
- }
-
- /* Now delete the starting object, and we are done */
-
- AcpiNsRemoveNode (ChildHandle);
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsUnloadNameSpace
- *
- * PARAMETERS: Handle - Root of namespace subtree to be deleted
- *
- * RETURN: Status
- *
- * DESCRIPTION: Shrinks the namespace, typically in response to an undocking
- * event. Deletes an entire subtree starting from (and
- * including) the given handle.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsUnloadNamespace (
- ACPI_HANDLE Handle)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (NsUnloadNameSpace);
-
-
- /* Parameter validation */
-
- if (!AcpiGbl_RootNode)
- {
- return_ACPI_STATUS (AE_NO_NAMESPACE);
- }
-
- if (!Handle)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* This function does the real work */
-
- Status = AcpiNsDeleteSubtree (Handle);
-
- return_ACPI_STATUS (Status);
-}
-#endif
-#endif
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsnames.c
--- a/head/sys/contrib/dev/acpica/namespace/nsnames.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsnames - Name manipulation and search
- *
- ******************************************************************************/
-
-/*
- * 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 __NSNAMES_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/acnamesp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsnames")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsBuildExternalPath
- *
- * PARAMETERS: Node - NS node whose pathname is needed
- * Size - Size of the pathname
- * *NameBuffer - Where to return the pathname
- *
- * RETURN: Status
- * Places the pathname into the NameBuffer, in external format
- * (name segments separated by path separators)
- *
- * DESCRIPTION: Generate a full pathaname
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsBuildExternalPath (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_SIZE Size,
- char *NameBuffer)
-{
- ACPI_SIZE Index;
- ACPI_NAMESPACE_NODE *ParentNode;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Special case for root */
-
- Index = Size - 1;
- if (Index < ACPI_NAME_SIZE)
- {
- NameBuffer[0] = AML_ROOT_PREFIX;
- NameBuffer[1] = 0;
- return (AE_OK);
- }
-
- /* Store terminator byte, then build name backwards */
-
- ParentNode = Node;
- NameBuffer[Index] = 0;
-
- while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode))
- {
- Index -= ACPI_NAME_SIZE;
-
- /* Put the name into the buffer */
-
- ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name);
- ParentNode = ParentNode->Parent;
-
- /* Prefix name with the path separator */
-
- Index--;
- NameBuffer[Index] = ACPI_PATH_SEPARATOR;
- }
-
- /* Overwrite final separator with the root prefix character */
-
- NameBuffer[Index] = AML_ROOT_PREFIX;
-
- if (Index != 0)
- {
- ACPI_ERROR ((AE_INFO,
- "Could not construct external pathname; index=%u, size=%u, Path=%s",
- (UINT32) Index, (UINT32) Size, &NameBuffer[Size]));
-
- return (AE_BAD_PARAMETER);
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetExternalPathname
- *
- * PARAMETERS: Node - Namespace node whose pathname is needed
- *
- * RETURN: Pointer to storage containing the fully qualified name of
- * the node, In external format (name segments separated by path
- * separators.)
- *
- * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
- * for error and debug statements.
- *
- ******************************************************************************/
-
-char *
-AcpiNsGetExternalPathname (
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_STATUS Status;
- char *NameBuffer;
- ACPI_SIZE Size;
-
-
- ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node);
-
-
- /* Calculate required buffer size based on depth below root */
-
- Size = AcpiNsGetPathnameLength (Node);
- if (!Size)
- {
- return_PTR (NULL);
- }
-
- /* Allocate a buffer to be returned to caller */
-
- NameBuffer = ACPI_ALLOCATE_ZEROED (Size);
- if (!NameBuffer)
- {
- ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size));
- return_PTR (NULL);
- }
-
- /* Build the path in the allocated buffer */
-
- Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer);
- if (ACPI_FAILURE (Status))
- {
- ACPI_FREE (NameBuffer);
- return_PTR (NULL);
- }
-
- return_PTR (NameBuffer);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetPathnameLength
- *
- * PARAMETERS: Node - Namespace node
- *
- * RETURN: Length of path, including prefix
- *
- * DESCRIPTION: Get the length of the pathname string for this node
- *
- ******************************************************************************/
-
-ACPI_SIZE
-AcpiNsGetPathnameLength (
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_SIZE Size;
- ACPI_NAMESPACE_NODE *NextNode;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * Compute length of pathname as 5 * number of name segments.
- * Go back up the parent tree to the root
- */
- Size = 0;
- NextNode = Node;
-
- while (NextNode && (NextNode != AcpiGbl_RootNode))
- {
- if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED)
- {
- ACPI_ERROR ((AE_INFO,
- "Invalid Namespace Node (%p) while traversing namespace",
- NextNode));
- return 0;
- }
- Size += ACPI_PATH_SEGMENT_LENGTH;
- NextNode = NextNode->Parent;
- }
-
- if (!Size)
- {
- Size = 1; /* Root node case */
- }
-
- return (Size + 1); /* +1 for null string terminator */
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsHandleToPathname
- *
- * PARAMETERS: TargetHandle - Handle of named object whose name is
- * to be found
- * Buffer - Where the pathname is returned
- *
- * RETURN: Status, Buffer is filled with pathname if status is AE_OK
- *
- * DESCRIPTION: Build and return a full namespace pathname
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsHandleToPathname (
- ACPI_HANDLE TargetHandle,
- ACPI_BUFFER *Buffer)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_SIZE RequiredSize;
-
-
- ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle);
-
-
- Node = AcpiNsValidateHandle (TargetHandle);
- if (!Node)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Determine size required for the caller buffer */
-
- RequiredSize = AcpiNsGetPathnameLength (Node);
- if (!RequiredSize)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (Buffer, RequiredSize);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Build the path in the caller buffer */
-
- Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n",
- (char *) Buffer->Pointer, (UINT32) RequiredSize));
- return_ACPI_STATUS (AE_OK);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsobject.c
--- a/head/sys/contrib/dev/acpica/namespace/nsobject.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,505 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsobject - Utilities for objects attached to namespace
- * table entries
- *
- ******************************************************************************/
-
-/*
- * 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 __NSOBJECT_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsobject")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsAttachObject
- *
- * PARAMETERS: Node - Parent Node
- * Object - Object to be attached
- * Type - Type of object, or ACPI_TYPE_ANY if not
- * known
- *
- * RETURN: Status
- *
- * DESCRIPTION: Record the given object as the value associated with the
- * name whose ACPI_HANDLE is passed. If Object is NULL
- * and Type is ACPI_TYPE_ANY, set the name as having no value.
- * Note: Future may require that the Node->Flags field be passed
- * as a parameter.
- *
- * MUTEX: Assumes namespace is locked
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsAttachObject (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_OPERAND_OBJECT *Object,
- ACPI_OBJECT_TYPE Type)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_OPERAND_OBJECT *LastObjDesc;
- ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY;
-
-
- ACPI_FUNCTION_TRACE (NsAttachObject);
-
-
- /*
- * Parameter validation
- */
- if (!Node)
- {
- /* Invalid handle */
-
- ACPI_ERROR ((AE_INFO, "Null NamedObj handle"));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (!Object && (ACPI_TYPE_ANY != Type))
- {
- /* Null object */
-
- ACPI_ERROR ((AE_INFO,
- "Null object, but type not ACPI_TYPE_ANY"));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
- {
- /* Not a name handle */
-
- ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]",
- Node, AcpiUtGetDescriptorName (Node)));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Check if this object is already attached */
-
- if (Node->Object == Object)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Obj %p already installed in NameObj %p\n",
- Object, Node));
-
- return_ACPI_STATUS (AE_OK);
- }
-
- /* If null object, we will just install it */
-
- if (!Object)
- {
- ObjDesc = NULL;
- ObjectType = ACPI_TYPE_ANY;
- }
-
- /*
- * If the source object is a namespace Node with an attached object,
- * we will use that (attached) object
- */
- else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) &&
- ((ACPI_NAMESPACE_NODE *) Object)->Object)
- {
- /*
- * Value passed is a name handle and that name has a
- * non-null value. Use that name's value and type.
- */
- ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object;
- ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type;
- }
-
- /*
- * Otherwise, we will use the parameter object, but we must type
- * it first
- */
- else
- {
- ObjDesc = (ACPI_OPERAND_OBJECT *) Object;
-
- /* Use the given type */
-
- ObjectType = Type;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
- ObjDesc, Node, AcpiUtGetNodeName (Node)));
-
- /* Detach an existing attached object if present */
-
- if (Node->Object)
- {
- AcpiNsDetachObject (Node);
- }
-
- if (ObjDesc)
- {
- /*
- * Must increment the new value's reference count
- * (if it is an internal object)
- */
- AcpiUtAddReference (ObjDesc);
-
- /*
- * Handle objects with multiple descriptors - walk
- * to the end of the descriptor list
- */
- LastObjDesc = ObjDesc;
- while (LastObjDesc->Common.NextObject)
- {
- LastObjDesc = LastObjDesc->Common.NextObject;
- }
-
- /* Install the object at the front of the object list */
-
- LastObjDesc->Common.NextObject = Node->Object;
- }
-
- Node->Type = (UINT8) ObjectType;
- Node->Object = ObjDesc;
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDetachObject
- *
- * PARAMETERS: Node - A Namespace node whose object will be detached
- *
- * RETURN: None.
- *
- * DESCRIPTION: Detach/delete an object associated with a namespace node.
- * if the object is an allocated object, it is freed.
- * Otherwise, the field is simply cleared.
- *
- ******************************************************************************/
-
-void
-AcpiNsDetachObject (
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_TRACE (NsDetachObject);
-
-
- ObjDesc = Node->Object;
-
- if (!ObjDesc ||
- (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
- {
- return_VOID;
- }
-
- if (Node->Flags & ANOBJ_ALLOCATED_BUFFER)
- {
- /* Free the dynamic aml buffer */
-
- if (ObjDesc->Common.Type == ACPI_TYPE_METHOD)
- {
- ACPI_FREE (ObjDesc->Method.AmlStart);
- }
- }
-
- /* Clear the entry in all cases */
-
- Node->Object = NULL;
- if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
- {
- Node->Object = ObjDesc->Common.NextObject;
- if (Node->Object &&
- ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA))
- {
- Node->Object = Node->Object->Common.NextObject;
- }
- }
-
- /* Reset the node type to untyped */
-
- Node->Type = ACPI_TYPE_ANY;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
- Node, AcpiUtGetNodeName (Node), ObjDesc));
-
- /* Remove one reference on the object (and all subobjects) */
-
- AcpiUtRemoveReference (ObjDesc);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetAttachedObject
- *
- * PARAMETERS: Node - Namespace node
- *
- * RETURN: Current value of the object field from the Node whose
- * handle is passed
- *
- * DESCRIPTION: Obtain the object attached to a namespace node.
- *
- ******************************************************************************/
-
-ACPI_OPERAND_OBJECT *
-AcpiNsGetAttachedObject (
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node);
-
-
- if (!Node)
- {
- ACPI_WARNING ((AE_INFO, "Null Node ptr"));
- return_PTR (NULL);
- }
-
- if (!Node->Object ||
- ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) &&
- (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) ||
- ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA))
- {
- return_PTR (NULL);
- }
-
- return_PTR (Node->Object);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetSecondaryObject
- *
- * PARAMETERS: Node - Namespace node
- *
- * RETURN: Current value of the object field from the Node whose
- * handle is passed.
- *
- * DESCRIPTION: Obtain a secondary object associated with a namespace node.
- *
- ******************************************************************************/
-
-ACPI_OPERAND_OBJECT *
-AcpiNsGetSecondaryObject (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc);
-
-
- if ((!ObjDesc) ||
- (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) ||
- (!ObjDesc->Common.NextObject) ||
- ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA))
- {
- return_PTR (NULL);
- }
-
- return_PTR (ObjDesc->Common.NextObject);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsAttachData
- *
- * PARAMETERS: Node - Namespace node
- * Handler - Handler to be associated with the data
- * Data - Data to be attached
- *
- * RETURN: Status
- *
- * DESCRIPTION: Low-level attach data. Create and attach a Data object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsAttachData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_OBJECT_HANDLER Handler,
- void *Data)
-{
- ACPI_OPERAND_OBJECT *PrevObjDesc;
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_OPERAND_OBJECT *DataDesc;
-
-
- /* We only allow one attachment per handler */
-
- PrevObjDesc = NULL;
- ObjDesc = Node->Object;
- while (ObjDesc)
- {
- if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
- (ObjDesc->Data.Handler == Handler))
- {
- return (AE_ALREADY_EXISTS);
- }
-
- PrevObjDesc = ObjDesc;
- ObjDesc = ObjDesc->Common.NextObject;
- }
-
- /* Create an internal object for the data */
-
- DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA);
- if (!DataDesc)
- {
- return (AE_NO_MEMORY);
- }
-
- DataDesc->Data.Handler = Handler;
- DataDesc->Data.Pointer = Data;
-
- /* Install the data object */
-
- if (PrevObjDesc)
- {
- PrevObjDesc->Common.NextObject = DataDesc;
- }
- else
- {
- Node->Object = DataDesc;
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsDetachData
- *
- * PARAMETERS: Node - Namespace node
- * Handler - Handler associated with the data
- *
- * RETURN: Status
- *
- * DESCRIPTION: Low-level detach data. Delete the data node, but the caller
- * is responsible for the actual data.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsDetachData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_OBJECT_HANDLER Handler)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_OPERAND_OBJECT *PrevObjDesc;
-
-
- PrevObjDesc = NULL;
- ObjDesc = Node->Object;
- while (ObjDesc)
- {
- if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
- (ObjDesc->Data.Handler == Handler))
- {
- if (PrevObjDesc)
- {
- PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject;
- }
- else
- {
- Node->Object = ObjDesc->Common.NextObject;
- }
-
- AcpiUtRemoveReference (ObjDesc);
- return (AE_OK);
- }
-
- PrevObjDesc = ObjDesc;
- ObjDesc = ObjDesc->Common.NextObject;
- }
-
- return (AE_NOT_FOUND);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetAttachedData
- *
- * PARAMETERS: Node - Namespace node
- * Handler - Handler associated with the data
- * Data - Where the data is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Low level interface to obtain data previously associated with
- * a namespace node.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsGetAttachedData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_OBJECT_HANDLER Handler,
- void **Data)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ObjDesc = Node->Object;
- while (ObjDesc)
- {
- if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
- (ObjDesc->Data.Handler == Handler))
- {
- *Data = ObjDesc->Data.Pointer;
- return (AE_OK);
- }
-
- ObjDesc = ObjDesc->Common.NextObject;
- }
-
- return (AE_NOT_FOUND);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsparse.c
--- a/head/sys/contrib/dev/acpica/namespace/nsparse.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsparse - namespace interface to AML parser
- *
- *****************************************************************************/
-
-/*
- * 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 __NSPARSE_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/acparser.h>
-#include <contrib/dev/acpica/include/acdispat.h>
-#include <contrib/dev/acpica/include/actables.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsparse")
-
-
-/*******************************************************************************
- *
- * FUNCTION: NsOneCompleteParse
- *
- * PARAMETERS: PassNumber - 1 or 2
- * TableDesc - The table to be parsed.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsOneCompleteParse (
- UINT32 PassNumber,
- UINT32 TableIndex,
- ACPI_NAMESPACE_NODE *StartNode)
-{
- ACPI_PARSE_OBJECT *ParseRoot;
- ACPI_STATUS Status;
- UINT32 AmlLength;
- UINT8 *AmlStart;
- ACPI_WALK_STATE *WalkState;
- ACPI_TABLE_HEADER *Table;
- ACPI_OWNER_ID OwnerId;
-
-
- ACPI_FUNCTION_TRACE (NsOneCompleteParse);
-
-
- Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Create and init a Root Node */
-
- ParseRoot = AcpiPsCreateScopeOp ();
- if (!ParseRoot)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Create and initialize a new walk state */
-
- WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL);
- if (!WalkState)
- {
- AcpiPsFreeOp (ParseRoot);
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Status = AcpiGetTableByIndex (TableIndex, &Table);
- if (ACPI_FAILURE (Status))
- {
- AcpiDsDeleteWalkState (WalkState);
- AcpiPsFreeOp (ParseRoot);
- return_ACPI_STATUS (Status);
- }
-
- /* Table must consist of at least a complete header */
-
- if (Table->Length < sizeof (ACPI_TABLE_HEADER))
- {
- Status = AE_BAD_HEADER;
- }
- else
- {
- AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER);
- AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
- Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL,
- AmlStart, AmlLength, NULL, (UINT8) PassNumber);
- }
-
- if (ACPI_FAILURE (Status))
- {
- AcpiDsDeleteWalkState (WalkState);
- goto Cleanup;
- }
-
- /* StartNode is the default location to load the table */
-
- if (StartNode && StartNode != AcpiGbl_RootNode)
- {
- Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState);
- if (ACPI_FAILURE (Status))
- {
- AcpiDsDeleteWalkState (WalkState);
- goto Cleanup;
- }
- }
-
- /* Parse the AML */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %u parse\n", PassNumber));
- Status = AcpiPsParseAml (WalkState);
-
-Cleanup:
- AcpiPsDeleteParseTree (ParseRoot);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsParseTable
- *
- * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse
- * StartNode - Where to enter the table into the namespace
- *
- * RETURN: Status
- *
- * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsParseTable (
- UINT32 TableIndex,
- ACPI_NAMESPACE_NODE *StartNode)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (NsParseTable);
-
-
- /*
- * AML Parse, pass 1
- *
- * In this pass, we load most of the namespace. Control methods
- * are not parsed until later. A parse tree is not created. Instead,
- * each Parser Op subtree is deleted when it is finished. This saves
- * a great deal of memory, and allows a small cache of parse objects
- * to service the entire parse. The second pass of the parse then
- * performs another complete parse of the AML.
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n"));
- Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1,
- TableIndex, StartNode);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * AML Parse, pass 2
- *
- * In this pass, we resolve forward references and other things
- * that could not be completed during the first pass.
- * Another complete parse of the AML is performed, but the
- * overhead of this is compensated for by the fact that the
- * parse objects are all cached.
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n"));
- Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2,
- TableIndex, StartNode);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nspredef.c
--- a/head/sys/contrib/dev/acpica/namespace/nspredef.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1243 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nspredef - Validation of ACPI predefined methods and objects
- *
- *****************************************************************************/
-
-/*
- * 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 ACPI_CREATE_PREDEFINED_TABLE
-
-#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/acpredef.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nspredef")
-
-
-/*******************************************************************************
- *
- * This module validates predefined ACPI objects that appear in the namespace,
- * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this
- * validation is to detect problems with BIOS-exposed predefined ACPI objects
- * before the results are returned to the ACPI-related drivers.
- *
- * There are several areas that are validated:
- *
- * 1) The number of input arguments as defined by the method/object in the
- * ASL is validated against the ACPI specification.
- * 2) The type of the return object (if any) is validated against the ACPI
- * specification.
- * 3) For returned package objects, the count of package elements is
- * validated, as well as the type of each package element. Nested
- * packages are supported.
- *
- * For any problems found, a warning message is issued.
- *
- ******************************************************************************/
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiNsCheckPackage (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-static ACPI_STATUS
-AcpiNsCheckPackageList (
- ACPI_PREDEFINED_DATA *Data,
- const ACPI_PREDEFINED_INFO *Package,
- ACPI_OPERAND_OBJECT **Elements,
- UINT32 Count);
-
-static ACPI_STATUS
-AcpiNsCheckPackageElements (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **Elements,
- UINT8 Type1,
- UINT32 Count1,
- UINT8 Type2,
- UINT32 Count2,
- UINT32 StartIndex);
-
-static ACPI_STATUS
-AcpiNsCheckObjectType (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr,
- UINT32 ExpectedBtypes,
- UINT32 PackageIndex);
-
-static ACPI_STATUS
-AcpiNsCheckReference (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT *ReturnObject);
-
-static void
-AcpiNsGetExpectedTypes (
- char *Buffer,
- UINT32 ExpectedBtypes);
-
-/*
- * Names for the types that can be returned by the predefined objects.
- * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
- */
-static const char *AcpiRtypeNames[] =
-{
- "/Integer",
- "/String",
- "/Buffer",
- "/Package",
- "/Reference",
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckPredefinedNames
- *
- * PARAMETERS: Node - Namespace node for the method/object
- * UserParamCount - Number of parameters actually passed
- * ReturnStatus - Status from the object evaluation
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check an ACPI name for a match in the predefined name list.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsCheckPredefinedNames (
- ACPI_NAMESPACE_NODE *Node,
- UINT32 UserParamCount,
- ACPI_STATUS ReturnStatus,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_STATUS Status = AE_OK;
- const ACPI_PREDEFINED_INFO *Predefined;
- char *Pathname;
- ACPI_PREDEFINED_DATA *Data;
-
-
- /* Match the name for this method/object against the predefined list */
-
- Predefined = AcpiNsCheckForPredefinedName (Node);
-
- /* Get the full pathname to the object, for use in warning messages */
-
- Pathname = AcpiNsGetExternalPathname (Node);
- if (!Pathname)
- {
- return (AE_OK); /* Could not get pathname, ignore */
- }
-
- /*
- * Check that the parameter count for this method matches the ASL
- * definition. For predefined names, ensure that both the caller and
- * the method itself are in accordance with the ACPI specification.
- */
- AcpiNsCheckParameterCount (Pathname, Node, UserParamCount, Predefined);
-
- /* If not a predefined name, we cannot validate the return object */
-
- if (!Predefined)
- {
- goto Cleanup;
- }
-
- /*
- * If the method failed or did not actually return an object, we cannot
- * validate the return object
- */
- if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE))
- {
- goto Cleanup;
- }
-
- /*
- * If there is no return value, check if we require a return value for
- * this predefined name. Either one return value is expected, or none,
- * for both methods and other objects.
- *
- * Exit now if there is no return object. Warning if one was expected.
- */
- if (!ReturnObject)
- {
- if ((Predefined->Info.ExpectedBtypes) &&
- (!(Predefined->Info.ExpectedBtypes & ACPI_RTYPE_NONE)))
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
- "Missing expected return value"));
-
- Status = AE_AML_NO_RETURN_VALUE;
- }
- goto Cleanup;
- }
-
- /*
- * Return value validation and possible repair.
- *
- * 1) Don't perform return value validation/repair if this feature
- * has been disabled via a global option.
- *
- * 2) We have a return value, but if one wasn't expected, just exit,
- * this is not a problem. For example, if the "Implicit Return"
- * feature is enabled, methods will always return a value.
- *
- * 3) If the return value can be of any type, then we cannot perform
- * any validation, just exit.
- */
- if (AcpiGbl_DisableAutoRepair ||
- (!Predefined->Info.ExpectedBtypes) ||
- (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL))
- {
- goto Cleanup;
- }
-
- /* Create the parameter data block for object validation */
-
- Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA));
- if (!Data)
- {
- goto Cleanup;
- }
- Data->Predefined = Predefined;
- Data->Node = Node;
- Data->NodeFlags = Node->Flags;
- Data->Pathname = Pathname;
-
- /*
- * Check that the type of the main return object is what is expected
- * for this predefined name
- */
- Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr,
- Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
- if (ACPI_FAILURE (Status))
- {
- goto Exit;
- }
-
- /*
- * For returned Package objects, check the type of all sub-objects.
- * Note: Package may have been newly created by call above.
- */
- if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE)
- {
- Data->ParentPackage = *ReturnObjectPtr;
- Status = AcpiNsCheckPackage (Data, ReturnObjectPtr);
- if (ACPI_FAILURE (Status))
- {
- goto Exit;
- }
- }
-
- /*
- * The return object was OK, or it was successfully repaired above.
- * Now make some additional checks such as verifying that package
- * objects are sorted correctly (if required) or buffer objects have
- * the correct data width (bytes vs. dwords). These repairs are
- * performed on a per-name basis, i.e., the code is specific to
- * particular predefined names.
- */
- Status = AcpiNsComplexRepairs (Data, Node, Status, ReturnObjectPtr);
-
-Exit:
- /*
- * If the object validation failed or if we successfully repaired one
- * or more objects, mark the parent node to suppress further warning
- * messages during the next evaluation of the same method/object.
- */
- if (ACPI_FAILURE (Status) || (Data->Flags & ACPI_OBJECT_REPAIRED))
- {
- Node->Flags |= ANOBJ_EVALUATED;
- }
- ACPI_FREE (Data);
-
-Cleanup:
- ACPI_FREE (Pathname);
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckParameterCount
- *
- * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
- * Node - Namespace node for the method/object
- * UserParamCount - Number of args passed in by the caller
- * Predefined - Pointer to entry in predefined name table
- *
- * RETURN: None
- *
- * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a
- * predefined name is what is expected (i.e., what is defined in
- * the ACPI specification for this predefined name.)
- *
- ******************************************************************************/
-
-void
-AcpiNsCheckParameterCount (
- char *Pathname,
- ACPI_NAMESPACE_NODE *Node,
- UINT32 UserParamCount,
- const ACPI_PREDEFINED_INFO *Predefined)
-{
- UINT32 ParamCount;
- UINT32 RequiredParamsCurrent;
- UINT32 RequiredParamsOld;
-
-
- /* Methods have 0-7 parameters. All other types have zero. */
-
- ParamCount = 0;
- if (Node->Type == ACPI_TYPE_METHOD)
- {
- ParamCount = Node->Object->Method.ParamCount;
- }
-
- if (!Predefined)
- {
- /*
- * Check the parameter count for non-predefined methods/objects.
- *
- * Warning if too few or too many arguments have been passed by the
- * caller. An incorrect number of arguments may not cause the method
- * to fail. However, the method will fail if there are too few
- * arguments and the method attempts to use one of the missing ones.
- */
- if (UserParamCount < ParamCount)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
- "Insufficient arguments - needs %u, found %u",
- ParamCount, UserParamCount));
- }
- else if (UserParamCount > ParamCount)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
- "Excess arguments - needs %u, found %u",
- ParamCount, UserParamCount));
- }
- return;
- }
-
- /*
- * Validate the user-supplied parameter count.
- * Allow two different legal argument counts (_SCP, etc.)
- */
- RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F;
- RequiredParamsOld = Predefined->Info.ParamCount >> 4;
-
- if (UserParamCount != ACPI_UINT32_MAX)
- {
- if ((UserParamCount != RequiredParamsCurrent) &&
- (UserParamCount != RequiredParamsOld))
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
- "Parameter count mismatch - "
- "caller passed %u, ACPI requires %u",
- UserParamCount, RequiredParamsCurrent));
- }
- }
-
- /*
- * Check that the ASL-defined parameter count is what is expected for
- * this predefined name (parameter count as defined by the ACPI
- * specification)
- */
- if ((ParamCount != RequiredParamsCurrent) &&
- (ParamCount != RequiredParamsOld))
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, Node->Flags,
- "Parameter count mismatch - ASL declared %u, ACPI requires %u",
- ParamCount, RequiredParamsCurrent));
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckForPredefinedName
- *
- * PARAMETERS: Node - Namespace node for the method/object
- *
- * RETURN: Pointer to entry in predefined table. NULL indicates not found.
- *
- * DESCRIPTION: Check an object name against the predefined object list.
- *
- ******************************************************************************/
-
-const ACPI_PREDEFINED_INFO *
-AcpiNsCheckForPredefinedName (
- ACPI_NAMESPACE_NODE *Node)
-{
- const ACPI_PREDEFINED_INFO *ThisName;
-
-
- /* Quick check for a predefined name, first character must be underscore */
-
- if (Node->Name.Ascii[0] != '_')
- {
- return (NULL);
- }
-
- /* Search info table for a predefined method/object name */
-
- ThisName = PredefinedNames;
- while (ThisName->Info.Name[0])
- {
- if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name))
- {
- return (ThisName);
- }
-
- /*
- * Skip next entry in the table if this name returns a Package
- * (next entry contains the package info)
- */
- if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)
- {
- ThisName++;
- }
-
- ThisName++;
- }
-
- return (NULL); /* Not found */
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckPackage
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check a returned package object for the correct count and
- * correct type of all sub-objects.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsCheckPackage (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- const ACPI_PREDEFINED_INFO *Package;
- ACPI_OPERAND_OBJECT **Elements;
- ACPI_STATUS Status = AE_OK;
- UINT32 ExpectedCount;
- UINT32 Count;
- UINT32 i;
-
-
- ACPI_FUNCTION_NAME (NsCheckPackage);
-
-
- /* The package info for this name is in the next table entry */
-
- Package = Data->Predefined + 1;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "%s Validating return Package of Type %X, Count %X\n",
- Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count));
-
- /*
- * For variable-length Packages, we can safely remove all embedded
- * and trailing NULL package elements
- */
- AcpiNsRemoveNullElements (Data, Package->RetInfo.Type, ReturnObject);
-
- /* Extract package count and elements array */
-
- Elements = ReturnObject->Package.Elements;
- Count = ReturnObject->Package.Count;
-
- /* The package must have at least one element, else invalid */
-
- if (!Count)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Return Package has no elements (empty)"));
-
- return (AE_AML_OPERAND_VALUE);
- }
-
- /*
- * Decode the type of the expected package contents
- *
- * PTYPE1 packages contain no subpackages
- * PTYPE2 packages contain sub-packages
- */
- switch (Package->RetInfo.Type)
- {
- case ACPI_PTYPE1_FIXED:
-
- /*
- * The package count is fixed and there are no sub-packages
- *
- * If package is too small, exit.
- * If package is larger than expected, issue warning but continue
- */
- ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
- if (Count < ExpectedCount)
- {
- goto PackageTooSmall;
- }
- else if (Count > ExpectedCount)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Return Package is larger than needed - "
- "found %u, expected %u\n",
- Data->Pathname, Count, ExpectedCount));
- }
-
- /* Validate all elements of the returned package */
-
- Status = AcpiNsCheckPackageElements (Data, Elements,
- Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
- Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0);
- break;
-
-
- case ACPI_PTYPE1_VAR:
-
- /*
- * The package count is variable, there are no sub-packages, and all
- * elements must be of the same type
- */
- for (i = 0; i < Count; i++)
- {
- Status = AcpiNsCheckObjectType (Data, Elements,
- Package->RetInfo.ObjectType1, i);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- Elements++;
- }
- break;
-
-
- case ACPI_PTYPE1_OPTION:
-
- /*
- * The package count is variable, there are no sub-packages. There are
- * a fixed number of required elements, and a variable number of
- * optional elements.
- *
- * Check if package is at least as large as the minimum required
- */
- ExpectedCount = Package->RetInfo3.Count;
- if (Count < ExpectedCount)
- {
- goto PackageTooSmall;
- }
-
- /* Variable number of sub-objects */
-
- for (i = 0; i < Count; i++)
- {
- if (i < Package->RetInfo3.Count)
- {
- /* These are the required package elements (0, 1, or 2) */
-
- Status = AcpiNsCheckObjectType (Data, Elements,
- Package->RetInfo3.ObjectType[i], i);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- else
- {
- /* These are the optional package elements */
-
- Status = AcpiNsCheckObjectType (Data, Elements,
- Package->RetInfo3.TailObjectType, i);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- Elements++;
- }
- break;
-
-
- case ACPI_PTYPE2_REV_FIXED:
-
- /* First element is the (Integer) revision */
-
- Status = AcpiNsCheckObjectType (Data, Elements,
- ACPI_RTYPE_INTEGER, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Elements++;
- Count--;
-
- /* Examine the sub-packages */
-
- Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
- break;
-
-
- case ACPI_PTYPE2_PKG_COUNT:
-
- /* First element is the (Integer) count of sub-packages to follow */
-
- Status = AcpiNsCheckObjectType (Data, Elements,
- ACPI_RTYPE_INTEGER, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * Count cannot be larger than the parent package length, but allow it
- * to be smaller. The >= accounts for the Integer above.
- */
- ExpectedCount = (UINT32) (*Elements)->Integer.Value;
- if (ExpectedCount >= Count)
- {
- goto PackageTooSmall;
- }
-
- Count = ExpectedCount;
- Elements++;
-
- /* Examine the sub-packages */
-
- Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
- break;
-
-
- case ACPI_PTYPE2:
- case ACPI_PTYPE2_FIXED:
- case ACPI_PTYPE2_MIN:
- case ACPI_PTYPE2_COUNT:
- case ACPI_PTYPE2_FIX_VAR:
-
- /*
- * These types all return a single Package that consists of a
- * variable number of sub-Packages.
- *
- * First, ensure that the first element is a sub-Package. If not,
- * the BIOS may have incorrectly returned the object as a single
- * package instead of a Package of Packages (a common error if
- * there is only one entry). We may be able to repair this by
- * wrapping the returned Package with a new outer Package.
- */
- if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE))
- {
- /* Create the new outer package and populate it */
-
- Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Update locals to point to the new package (of 1 element) */
-
- ReturnObject = *ReturnObjectPtr;
- Elements = ReturnObject->Package.Elements;
- Count = 1;
- }
-
- /* Examine the sub-packages */
-
- Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
- break;
-
-
- default:
-
- /* Should not get here if predefined info table is correct */
-
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Invalid internal return type in table entry: %X",
- Package->RetInfo.Type));
-
- return (AE_AML_INTERNAL);
- }
-
- return (Status);
-
-
-PackageTooSmall:
-
- /* Error exit for the case with an incorrect package count */
-
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Return Package is too small - found %u elements, expected %u",
- Count, ExpectedCount));
-
- return (AE_AML_OPERAND_VALUE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckPackageList
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * Package - Pointer to package-specific info for method
- * Elements - Element list of parent package. All elements
- * of this list should be of type Package.
- * Count - Count of subpackages
- *
- * RETURN: Status
- *
- * DESCRIPTION: Examine a list of subpackages
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsCheckPackageList (
- ACPI_PREDEFINED_DATA *Data,
- const ACPI_PREDEFINED_INFO *Package,
- ACPI_OPERAND_OBJECT **Elements,
- UINT32 Count)
-{
- ACPI_OPERAND_OBJECT *SubPackage;
- ACPI_OPERAND_OBJECT **SubElements;
- ACPI_STATUS Status;
- UINT32 ExpectedCount;
- UINT32 i;
- UINT32 j;
-
-
- /*
- * Validate each sub-Package in the parent Package
- *
- * NOTE: assumes list of sub-packages contains no NULL elements.
- * Any NULL elements should have been removed by earlier call
- * to AcpiNsRemoveNullElements.
- */
- for (i = 0; i < Count; i++)
- {
- SubPackage = *Elements;
- SubElements = SubPackage->Package.Elements;
- Data->ParentPackage = SubPackage;
-
- /* Each sub-object must be of type Package */
-
- Status = AcpiNsCheckObjectType (Data, &SubPackage,
- ACPI_RTYPE_PACKAGE, i);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Examine the different types of expected sub-packages */
-
- Data->ParentPackage = SubPackage;
- switch (Package->RetInfo.Type)
- {
- case ACPI_PTYPE2:
- case ACPI_PTYPE2_PKG_COUNT:
- case ACPI_PTYPE2_REV_FIXED:
-
- /* Each subpackage has a fixed number of elements */
-
- ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- goto PackageTooSmall;
- }
-
- Status = AcpiNsCheckPackageElements (Data, SubElements,
- Package->RetInfo.ObjectType1,
- Package->RetInfo.Count1,
- Package->RetInfo.ObjectType2,
- Package->RetInfo.Count2, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
-
- case ACPI_PTYPE2_FIX_VAR:
- /*
- * Each subpackage has a fixed number of elements and an
- * optional element
- */
- ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- goto PackageTooSmall;
- }
-
- Status = AcpiNsCheckPackageElements (Data, SubElements,
- Package->RetInfo.ObjectType1,
- Package->RetInfo.Count1,
- Package->RetInfo.ObjectType2,
- SubPackage->Package.Count - Package->RetInfo.Count1, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
-
- case ACPI_PTYPE2_FIXED:
-
- /* Each sub-package has a fixed length */
-
- ExpectedCount = Package->RetInfo2.Count;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- goto PackageTooSmall;
- }
-
- /* Check the type of each sub-package element */
-
- for (j = 0; j < ExpectedCount; j++)
- {
- Status = AcpiNsCheckObjectType (Data, &SubElements[j],
- Package->RetInfo2.ObjectType[j], j);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- break;
-
-
- case ACPI_PTYPE2_MIN:
-
- /* Each sub-package has a variable but minimum length */
-
- ExpectedCount = Package->RetInfo.Count1;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- goto PackageTooSmall;
- }
-
- /* Check the type of each sub-package element */
-
- Status = AcpiNsCheckPackageElements (Data, SubElements,
- Package->RetInfo.ObjectType1,
- SubPackage->Package.Count, 0, 0, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
-
- case ACPI_PTYPE2_COUNT:
-
- /*
- * First element is the (Integer) count of elements, including
- * the count field (the ACPI name is NumElements)
- */
- Status = AcpiNsCheckObjectType (Data, SubElements,
- ACPI_RTYPE_INTEGER, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * Make sure package is large enough for the Count and is
- * is as large as the minimum size
- */
- ExpectedCount = (UINT32) (*SubElements)->Integer.Value;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- goto PackageTooSmall;
- }
- if (SubPackage->Package.Count < Package->RetInfo.Count1)
- {
- ExpectedCount = Package->RetInfo.Count1;
- goto PackageTooSmall;
- }
- if (ExpectedCount == 0)
- {
- /*
- * Either the NumEntries element was originally zero or it was
- * a NULL element and repaired to an Integer of value zero.
- * In either case, repair it by setting NumEntries to be the
- * actual size of the subpackage.
- */
- ExpectedCount = SubPackage->Package.Count;
- (*SubElements)->Integer.Value = ExpectedCount;
- }
-
- /* Check the type of each sub-package element */
-
- Status = AcpiNsCheckPackageElements (Data, (SubElements + 1),
- Package->RetInfo.ObjectType1,
- (ExpectedCount - 1), 0, 0, 1);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
-
- default: /* Should not get here, type was validated by caller */
-
- return (AE_AML_INTERNAL);
- }
-
- Elements++;
- }
-
- return (AE_OK);
-
-
-PackageTooSmall:
-
- /* The sub-package count was smaller than required */
-
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Return Sub-Package[%u] is too small - found %u elements, expected %u",
- i, SubPackage->Package.Count, ExpectedCount));
-
- return (AE_AML_OPERAND_VALUE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckPackageElements
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * Elements - Pointer to the package elements array
- * Type1 - Object type for first group
- * Count1 - Count for first group
- * Type2 - Object type for second group
- * Count2 - Count for second group
- * StartIndex - Start of the first group of elements
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check that all elements of a package are of the correct object
- * type. Supports up to two groups of different object types.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsCheckPackageElements (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **Elements,
- UINT8 Type1,
- UINT32 Count1,
- UINT8 Type2,
- UINT32 Count2,
- UINT32 StartIndex)
-{
- ACPI_OPERAND_OBJECT **ThisElement = Elements;
- ACPI_STATUS Status;
- UINT32 i;
-
-
- /*
- * Up to two groups of package elements are supported by the data
- * structure. All elements in each group must be of the same type.
- * The second group can have a count of zero.
- */
- for (i = 0; i < Count1; i++)
- {
- Status = AcpiNsCheckObjectType (Data, ThisElement,
- Type1, i + StartIndex);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- ThisElement++;
- }
-
- for (i = 0; i < Count2; i++)
- {
- Status = AcpiNsCheckObjectType (Data, ThisElement,
- Type2, (i + Count1 + StartIndex));
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- ThisElement++;
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckObjectType
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- * ExpectedBtypes - Bitmap of expected return type(s)
- * PackageIndex - Index of object within parent package (if
- * applicable - ACPI_NOT_PACKAGE_ELEMENT
- * otherwise)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check the type of the return object against the expected object
- * type(s). Use of Btype allows multiple expected object types.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsCheckObjectType (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr,
- UINT32 ExpectedBtypes,
- UINT32 PackageIndex)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_STATUS Status = AE_OK;
- UINT32 ReturnBtype;
- char TypeBuffer[48]; /* Room for 5 types */
-
-
- /*
- * If we get a NULL ReturnObject here, it is a NULL package element.
- * Since all extraneous NULL package elements were removed earlier by a
- * call to AcpiNsRemoveNullElements, this is an unexpected NULL element.
- * We will attempt to repair it.
- */
- if (!ReturnObject)
- {
- Status = AcpiNsRepairNullElement (Data, ExpectedBtypes,
- PackageIndex, ReturnObjectPtr);
- if (ACPI_SUCCESS (Status))
- {
- return (AE_OK); /* Repair was successful */
- }
- goto TypeErrorExit;
- }
-
- /* A Namespace node should not get here, but make sure */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Invalid return type - Found a Namespace node [%4.4s] type %s",
- ReturnObject->Node.Name.Ascii,
- AcpiUtGetTypeName (ReturnObject->Node.Type)));
- return (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type.
- * The bitmapped type allows multiple possible return types.
- *
- * Note, the cases below must handle all of the possible types returned
- * from all of the predefined names (including elements of returned
- * packages)
- */
- switch (ReturnObject->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- ReturnBtype = ACPI_RTYPE_INTEGER;
- break;
-
- case ACPI_TYPE_BUFFER:
- ReturnBtype = ACPI_RTYPE_BUFFER;
- break;
-
- case ACPI_TYPE_STRING:
- ReturnBtype = ACPI_RTYPE_STRING;
- break;
-
- case ACPI_TYPE_PACKAGE:
- ReturnBtype = ACPI_RTYPE_PACKAGE;
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
- ReturnBtype = ACPI_RTYPE_REFERENCE;
- break;
-
- default:
- /* Not one of the supported objects, must be incorrect */
-
- goto TypeErrorExit;
- }
-
- /* Is the object one of the expected types? */
-
- if (ReturnBtype & ExpectedBtypes)
- {
- /* For reference objects, check that the reference type is correct */
-
- if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
- {
- Status = AcpiNsCheckReference (Data, ReturnObject);
- }
-
- return (Status);
- }
-
- /* Type mismatch -- attempt repair of the returned object */
-
- Status = AcpiNsRepairObject (Data, ExpectedBtypes,
- PackageIndex, ReturnObjectPtr);
- if (ACPI_SUCCESS (Status))
- {
- return (AE_OK); /* Repair was successful */
- }
-
-
-TypeErrorExit:
-
- /* Create a string with all expected types for this predefined object */
-
- AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes);
-
- if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Return type mismatch - found %s, expected %s",
- AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
- }
- else
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Return Package type mismatch at index %u - "
- "found %s, expected %s", PackageIndex,
- AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
- }
-
- return (AE_AML_OPERAND_TYPE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsCheckReference
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObject - Object returned from the evaluation of a
- * method or object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Check a returned reference object for the correct reference
- * type. The only reference type that can be returned from a
- * predefined method is a named reference. All others are invalid.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsCheckReference (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT *ReturnObject)
-{
-
- /*
- * Check the reference object for the correct reference type (opcode).
- * The only type of reference that can be converted to an ACPI_OBJECT is
- * a reference to a named object (reference class: NAME)
- */
- if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME)
- {
- return (AE_OK);
- }
-
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Return type mismatch - unexpected reference object type [%s] %2.2X",
- AcpiUtGetReferenceName (ReturnObject),
- ReturnObject->Reference.Class));
-
- return (AE_AML_OPERAND_TYPE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetExpectedTypes
- *
- * PARAMETERS: Buffer - Pointer to where the string is returned
- * ExpectedBtypes - Bitmap of expected return type(s)
- *
- * RETURN: Buffer is populated with type names.
- *
- * DESCRIPTION: Translate the expected types bitmap into a string of ascii
- * names of expected types, for use in warning messages.
- *
- ******************************************************************************/
-
-static void
-AcpiNsGetExpectedTypes (
- char *Buffer,
- UINT32 ExpectedBtypes)
-{
- UINT32 ThisRtype;
- UINT32 i;
- UINT32 j;
-
-
- j = 1;
- Buffer[0] = 0;
- ThisRtype = ACPI_RTYPE_INTEGER;
-
- for (i = 0; i < ACPI_NUM_RTYPES; i++)
- {
- /* If one of the expected types, concatenate the name of this type */
-
- if (ExpectedBtypes & ThisRtype)
- {
- ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]);
- j = 0; /* Use name separator from now on */
- }
- ThisRtype <<= 1; /* Next Rtype */
- }
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsrepair.c
--- a/head/sys/contrib/dev/acpica/namespace/nsrepair.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,802 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsrepair - Repair for objects returned by predefined 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.
- */
-
-#define __NSREPAIR_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/acinterp.h>
-#include <contrib/dev/acpica/include/acpredef.h>
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsrepair")
-
-
-/*******************************************************************************
- *
- * This module attempts to repair or convert objects returned by the
- * predefined methods to an object type that is expected, as per the ACPI
- * specification. The need for this code is dictated by the many machines that
- * return incorrect types for the standard predefined methods. Performing these
- * conversions here, in one place, eliminates the need for individual ACPI
- * device drivers to do the same. Note: Most of these conversions are different
- * than the internal object conversion routines used for implicit object
- * conversion.
- *
- * The following conversions can be performed as necessary:
- *
- * Integer -> String
- * Integer -> Buffer
- * String -> Integer
- * String -> Buffer
- * Buffer -> Integer
- * Buffer -> String
- * Buffer -> Package of Integers
- * Package -> Package of one Package
- *
- * Additional possible repairs:
- *
- * Required package elements that are NULL replaced by Integer/String/Buffer
- * Incorrect standalone package wrapped with required outer package
- *
- ******************************************************************************/
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiNsConvertToInteger (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject);
-
-static ACPI_STATUS
-AcpiNsConvertToString (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject);
-
-static ACPI_STATUS
-AcpiNsConvertToBuffer (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject);
-
-static ACPI_STATUS
-AcpiNsConvertToPackage (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsRepairObject
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ExpectedBtypes - Object types expected
- * PackageIndex - Index of object within parent package (if
- * applicable - ACPI_NOT_PACKAGE_ELEMENT
- * otherwise)
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if repair was successful.
- *
- * DESCRIPTION: Attempt to repair/convert a return object of a type that was
- * not expected.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsRepairObject (
- ACPI_PREDEFINED_DATA *Data,
- UINT32 ExpectedBtypes,
- UINT32 PackageIndex,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_OPERAND_OBJECT *NewObject;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_NAME (NsRepairObject);
-
-
- /*
- * At this point, we know that the type of the returned object was not
- * one of the expected types for this predefined name. Attempt to
- * repair the object by converting it to one of the expected object
- * types for this predefined name.
- */
- if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
- {
- Status = AcpiNsConvertToInteger (ReturnObject, &NewObject);
- if (ACPI_SUCCESS (Status))
- {
- goto ObjectRepaired;
- }
- }
- if (ExpectedBtypes & ACPI_RTYPE_STRING)
- {
- Status = AcpiNsConvertToString (ReturnObject, &NewObject);
- if (ACPI_SUCCESS (Status))
- {
- goto ObjectRepaired;
- }
- }
- if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
- {
- Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject);
- if (ACPI_SUCCESS (Status))
- {
- goto ObjectRepaired;
- }
- }
- if (ExpectedBtypes & ACPI_RTYPE_PACKAGE)
- {
- Status = AcpiNsConvertToPackage (ReturnObject, &NewObject);
- if (ACPI_SUCCESS (Status))
- {
- goto ObjectRepaired;
- }
- }
-
- /* We cannot repair this object */
-
- return (AE_AML_OPERAND_TYPE);
-
-
-ObjectRepaired:
-
- /* Object was successfully repaired */
-
- /*
- * If the original object is a package element, we need to:
- * 1. Set the reference count of the new object to match the
- * reference count of the old object.
- * 2. Decrement the reference count of the original object.
- */
- if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
- {
- NewObject->Common.ReferenceCount =
- ReturnObject->Common.ReferenceCount;
-
- if (ReturnObject->Common.ReferenceCount > 1)
- {
- ReturnObject->Common.ReferenceCount--;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Converted %s to expected %s at index %u\n",
- Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
- AcpiUtGetObjectTypeName (NewObject), PackageIndex));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Converted %s to expected %s\n",
- Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
- AcpiUtGetObjectTypeName (NewObject)));
- }
-
- /* Delete old object, install the new return object */
-
- AcpiUtRemoveReference (ReturnObject);
- *ReturnObjectPtr = NewObject;
- Data->Flags |= ACPI_OBJECT_REPAIRED;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsConvertToInteger
- *
- * PARAMETERS: OriginalObject - Object to be converted
- * ReturnObject - Where the new converted object is returned
- *
- * RETURN: Status. AE_OK if conversion was successful.
- *
- * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsConvertToInteger (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject)
-{
- ACPI_OPERAND_OBJECT *NewObject;
- ACPI_STATUS Status;
- UINT64 Value = 0;
- UINT32 i;
-
-
- switch (OriginalObject->Common.Type)
- {
- case ACPI_TYPE_STRING:
-
- /* String-to-Integer conversion */
-
- Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer,
- ACPI_ANY_BASE, &Value);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
- case ACPI_TYPE_BUFFER:
-
- /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
-
- if (OriginalObject->Buffer.Length > 8)
- {
- return (AE_AML_OPERAND_TYPE);
- }
-
- /* Extract each buffer byte to create the integer */
-
- for (i = 0; i < OriginalObject->Buffer.Length; i++)
- {
- Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8));
- }
- break;
-
- default:
- return (AE_AML_OPERAND_TYPE);
- }
-
- NewObject = AcpiUtCreateIntegerObject (Value);
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
-
- *ReturnObject = NewObject;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsConvertToString
- *
- * PARAMETERS: OriginalObject - Object to be converted
- * ReturnObject - Where the new converted object is returned
- *
- * RETURN: Status. AE_OK if conversion was successful.
- *
- * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsConvertToString (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject)
-{
- ACPI_OPERAND_OBJECT *NewObject;
- ACPI_SIZE Length;
- ACPI_STATUS Status;
-
-
- switch (OriginalObject->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- /*
- * Integer-to-String conversion. Commonly, convert
- * an integer of value 0 to a NULL string. The last element of
- * _BIF and _BIX packages occasionally need this fix.
- */
- if (OriginalObject->Integer.Value == 0)
- {
- /* Allocate a new NULL string object */
-
- NewObject = AcpiUtCreateStringObject (0);
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
- }
- else
- {
- Status = AcpiExConvertToString (OriginalObject, &NewObject,
- ACPI_IMPLICIT_CONVERT_HEX);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- break;
-
- case ACPI_TYPE_BUFFER:
- /*
- * Buffer-to-String conversion. Use a ToString
- * conversion, no transform performed on the buffer data. The best
- * example of this is the _BIF method, where the string data from
- * the battery is often (incorrectly) returned as buffer object(s).
- */
- Length = 0;
- while ((Length < OriginalObject->Buffer.Length) &&
- (OriginalObject->Buffer.Pointer[Length]))
- {
- Length++;
- }
-
- /* Allocate a new string object */
-
- NewObject = AcpiUtCreateStringObject (Length);
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
-
- /*
- * Copy the raw buffer data with no transform. String is already NULL
- * terminated at Length+1.
- */
- ACPI_MEMCPY (NewObject->String.Pointer,
- OriginalObject->Buffer.Pointer, Length);
- break;
-
- default:
- return (AE_AML_OPERAND_TYPE);
- }
-
- *ReturnObject = NewObject;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsConvertToBuffer
- *
- * PARAMETERS: OriginalObject - Object to be converted
- * ReturnObject - Where the new converted object is returned
- *
- * RETURN: Status. AE_OK if conversion was successful.
- *
- * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsConvertToBuffer (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject)
-{
- ACPI_OPERAND_OBJECT *NewObject;
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT **Elements;
- UINT32 *DwordBuffer;
- UINT32 Count;
- UINT32 i;
-
-
- switch (OriginalObject->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- /*
- * Integer-to-Buffer conversion.
- * Convert the Integer to a packed-byte buffer. _MAT and other
- * objects need this sometimes, if a read has been performed on a
- * Field object that is less than or equal to the global integer
- * size (32 or 64 bits).
- */
- Status = AcpiExConvertToBuffer (OriginalObject, &NewObject);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
- case ACPI_TYPE_STRING:
-
- /* String-to-Buffer conversion. Simple data copy */
-
- NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length);
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
-
- ACPI_MEMCPY (NewObject->Buffer.Pointer,
- OriginalObject->String.Pointer, OriginalObject->String.Length);
- break;
-
- case ACPI_TYPE_PACKAGE:
- /*
- * This case is often seen for predefined names that must return a
- * Buffer object with multiple DWORD integers within. For example,
- * _FDE and _GTM. The Package can be converted to a Buffer.
- */
-
- /* All elements of the Package must be integers */
-
- Elements = OriginalObject->Package.Elements;
- Count = OriginalObject->Package.Count;
-
- for (i = 0; i < Count; i++)
- {
- if ((!*Elements) ||
- ((*Elements)->Common.Type != ACPI_TYPE_INTEGER))
- {
- return (AE_AML_OPERAND_TYPE);
- }
- Elements++;
- }
-
- /* Create the new buffer object to replace the Package */
-
- NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count));
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Copy the package elements (integers) to the buffer as DWORDs */
-
- Elements = OriginalObject->Package.Elements;
- DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer);
-
- for (i = 0; i < Count; i++)
- {
- *DwordBuffer = (UINT32) (*Elements)->Integer.Value;
- DwordBuffer++;
- Elements++;
- }
- break;
-
- default:
- return (AE_AML_OPERAND_TYPE);
- }
-
- *ReturnObject = NewObject;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsConvertToPackage
- *
- * PARAMETERS: OriginalObject - Object to be converted
- * ReturnObject - Where the new converted object is returned
- *
- * RETURN: Status. AE_OK if conversion was successful.
- *
- * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
- * the buffer is converted to a single integer package element.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsConvertToPackage (
- ACPI_OPERAND_OBJECT *OriginalObject,
- ACPI_OPERAND_OBJECT **ReturnObject)
-{
- ACPI_OPERAND_OBJECT *NewObject;
- ACPI_OPERAND_OBJECT **Elements;
- UINT32 Length;
- UINT8 *Buffer;
-
-
- switch (OriginalObject->Common.Type)
- {
- case ACPI_TYPE_BUFFER:
-
- /* Buffer-to-Package conversion */
-
- Length = OriginalObject->Buffer.Length;
- NewObject = AcpiUtCreatePackageObject (Length);
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Convert each buffer byte to an integer package element */
-
- Elements = NewObject->Package.Elements;
- Buffer = OriginalObject->Buffer.Pointer;
-
- while (Length--)
- {
- *Elements = AcpiUtCreateIntegerObject ((UINT64) *Buffer);
- if (!*Elements)
- {
- AcpiUtRemoveReference (NewObject);
- return (AE_NO_MEMORY);
- }
- Elements++;
- Buffer++;
- }
- break;
-
- default:
- return (AE_AML_OPERAND_TYPE);
- }
-
- *ReturnObject = NewObject;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsRepairNullElement
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ExpectedBtypes - Object types expected
- * PackageIndex - Index of object within parent package (if
- * applicable - ACPI_NOT_PACKAGE_ELEMENT
- * otherwise)
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if repair was successful.
- *
- * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsRepairNullElement (
- ACPI_PREDEFINED_DATA *Data,
- UINT32 ExpectedBtypes,
- UINT32 PackageIndex,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_OPERAND_OBJECT *NewObject;
-
-
- ACPI_FUNCTION_NAME (NsRepairNullElement);
-
-
- /* No repair needed if return object is non-NULL */
-
- if (ReturnObject)
- {
- return (AE_OK);
- }
-
- /*
- * Attempt to repair a NULL element of a Package object. This applies to
- * predefined names that return a fixed-length package and each element
- * is required. It does not apply to variable-length packages where NULL
- * elements are allowed, especially at the end of the package.
- */
- if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
- {
- /* Need an Integer - create a zero-value integer */
-
- NewObject = AcpiUtCreateIntegerObject ((UINT64) 0);
- }
- else if (ExpectedBtypes & ACPI_RTYPE_STRING)
- {
- /* Need a String - create a NULL string */
-
- NewObject = AcpiUtCreateStringObject (0);
- }
- else if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
- {
- /* Need a Buffer - create a zero-length buffer */
-
- NewObject = AcpiUtCreateBufferObject (0);
- }
- else
- {
- /* Error for all other expected types */
-
- return (AE_AML_OPERAND_TYPE);
- }
-
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Set the reference count according to the parent Package object */
-
- NewObject->Common.ReferenceCount = Data->ParentPackage->Common.ReferenceCount;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Converted NULL package element to expected %s at index %u\n",
- Data->Pathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
-
- *ReturnObjectPtr = NewObject;
- Data->Flags |= ACPI_OBJECT_REPAIRED;
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsRemoveNullElements
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * PackageType - An AcpiReturnPackageTypes value
- * ObjDesc - A Package object
- *
- * RETURN: None.
- *
- * DESCRIPTION: Remove all NULL package elements from packages that contain
- * a variable number of sub-packages. For these types of
- * packages, NULL elements can be safely removed.
- *
- *****************************************************************************/
-
-void
-AcpiNsRemoveNullElements (
- ACPI_PREDEFINED_DATA *Data,
- UINT8 PackageType,
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
- ACPI_OPERAND_OBJECT **Source;
- ACPI_OPERAND_OBJECT **Dest;
- UINT32 Count;
- UINT32 NewCount;
- UINT32 i;
-
-
- ACPI_FUNCTION_NAME (NsRemoveNullElements);
-
-
- /*
- * We can safely remove all NULL elements from these package types:
- * PTYPE1_VAR packages contain a variable number of simple data types.
- * PTYPE2 packages contain a variable number of sub-packages.
- */
- switch (PackageType)
- {
- case ACPI_PTYPE1_VAR:
- case ACPI_PTYPE2:
- case ACPI_PTYPE2_COUNT:
- case ACPI_PTYPE2_PKG_COUNT:
- case ACPI_PTYPE2_FIXED:
- case ACPI_PTYPE2_MIN:
- case ACPI_PTYPE2_REV_FIXED:
- case ACPI_PTYPE2_FIX_VAR:
- break;
-
- default:
- case ACPI_PTYPE1_FIXED:
- case ACPI_PTYPE1_OPTION:
- return;
- }
-
- Count = ObjDesc->Package.Count;
- NewCount = Count;
-
- Source = ObjDesc->Package.Elements;
- Dest = Source;
-
- /* Examine all elements of the package object, remove nulls */
-
- for (i = 0; i < Count; i++)
- {
- if (!*Source)
- {
- NewCount--;
- }
- else
- {
- *Dest = *Source;
- Dest++;
- }
- Source++;
- }
-
- /* Update parent package if any null elements were removed */
-
- if (NewCount < Count)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Found and removed %u NULL elements\n",
- Data->Pathname, (Count - NewCount)));
-
- /* NULL terminate list and update the package count */
-
- *Dest = NULL;
- ObjDesc->Package.Count = NewCount;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsRepairPackageList
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ObjDescPtr - Pointer to the object to repair. The new
- * package object is returned here,
- * overwriting the old object.
- *
- * RETURN: Status, new object in *ObjDescPtr
- *
- * DESCRIPTION: Repair a common problem with objects that are defined to return
- * a variable-length Package of Packages. If the variable-length
- * is one, some BIOS code mistakenly simply declares a single
- * Package instead of a Package with one sub-Package. This
- * function attempts to repair this error by wrapping a Package
- * object around the original Package, creating the correct
- * Package with one sub-Package.
- *
- * Names that can be repaired in this manner include:
- * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsRepairPackageList (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ObjDescPtr)
-{
- ACPI_OPERAND_OBJECT *PkgObjDesc;
-
-
- ACPI_FUNCTION_NAME (NsRepairPackageList);
-
-
- /*
- * Create the new outer package and populate it. The new package will
- * have a single element, the lone subpackage.
- */
- PkgObjDesc = AcpiUtCreatePackageObject (1);
- if (!PkgObjDesc)
- {
- return (AE_NO_MEMORY);
- }
-
- PkgObjDesc->Package.Elements[0] = *ObjDescPtr;
-
- /* Return the new object in the object pointer */
-
- *ObjDescPtr = PkgObjDesc;
- Data->Flags |= ACPI_OBJECT_REPAIRED;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Repaired incorrectly formed Package\n", Data->Pathname));
-
- return (AE_OK);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsrepair2.c
--- a/head/sys/contrib/dev/acpica/namespace/nsrepair2.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,827 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsrepair2 - Repair for objects returned by specific
- * predefined 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.
- */
-
-#define __NSREPAIR2_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsrepair2")
-
-
-/*
- * Information structure and handler for ACPI predefined names that can
- * be repaired on a per-name basis.
- */
-typedef
-ACPI_STATUS (*ACPI_REPAIR_FUNCTION) (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-typedef struct acpi_repair_info
-{
- char Name[ACPI_NAME_SIZE];
- ACPI_REPAIR_FUNCTION RepairFunction;
-
-} ACPI_REPAIR_INFO;
-
-
-/* Local prototypes */
-
-static const ACPI_REPAIR_INFO *
-AcpiNsMatchRepairableName (
- ACPI_NAMESPACE_NODE *Node);
-
-static ACPI_STATUS
-AcpiNsRepair_ALR (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-static ACPI_STATUS
-AcpiNsRepair_CID (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-static ACPI_STATUS
-AcpiNsRepair_FDE (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-static ACPI_STATUS
-AcpiNsRepair_HID (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-static ACPI_STATUS
-AcpiNsRepair_PSS (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-static ACPI_STATUS
-AcpiNsRepair_TSS (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
-static ACPI_STATUS
-AcpiNsCheckSortedList (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT *ReturnObject,
- UINT32 ExpectedCount,
- UINT32 SortIndex,
- UINT8 SortDirection,
- char *SortKeyName);
-
-static void
-AcpiNsSortList (
- ACPI_OPERAND_OBJECT **Elements,
- UINT32 Count,
- UINT32 Index,
- UINT8 SortDirection);
-
-/* Values for SortDirection above */
-
-#define ACPI_SORT_ASCENDING 0
-#define ACPI_SORT_DESCENDING 1
-
-
-/*
- * This table contains the names of the predefined methods for which we can
- * perform more complex repairs.
- *
- * As necessary:
- *
- * _ALR: Sort the list ascending by AmbientIlluminance
- * _CID: Strings: uppercase all, remove any leading asterisk
- * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
- * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
- * _HID: Strings: uppercase all, remove any leading asterisk
- * _PSS: Sort the list descending by Power
- * _TSS: Sort the list descending by Power
- *
- * Names that must be packages, but cannot be sorted:
- *
- * _BCL: Values are tied to the Package index where they appear, and cannot
- * be moved or sorted. These index values are used for _BQC and _BCM.
- * However, we can fix the case where a buffer is returned, by converting
- * it to a Package of integers.
- */
-static const ACPI_REPAIR_INFO AcpiNsRepairableNames[] =
-{
- {"_ALR", AcpiNsRepair_ALR},
- {"_CID", AcpiNsRepair_CID},
- {"_FDE", AcpiNsRepair_FDE},
- {"_GTM", AcpiNsRepair_FDE}, /* _GTM has same repair as _FDE */
- {"_HID", AcpiNsRepair_HID},
- {"_PSS", AcpiNsRepair_PSS},
- {"_TSS", AcpiNsRepair_TSS},
- {{0,0,0,0}, NULL} /* Table terminator */
-};
-
-
-#define ACPI_FDE_FIELD_COUNT 5
-#define ACPI_FDE_BYTE_BUFFER_SIZE 5
-#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32))
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsComplexRepairs
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * Node - Namespace node for the method/object
- * ValidateStatus - Original status of earlier validation
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if repair was successful. If name is not
- * matched, ValidateStatus is returned.
- *
- * DESCRIPTION: Attempt to repair/convert a return object of a type that was
- * not expected.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiNsComplexRepairs (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_NAMESPACE_NODE *Node,
- ACPI_STATUS ValidateStatus,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- const ACPI_REPAIR_INFO *Predefined;
- ACPI_STATUS Status;
-
-
- /* Check if this name is in the list of repairable names */
-
- Predefined = AcpiNsMatchRepairableName (Node);
- if (!Predefined)
- {
- return (ValidateStatus);
- }
-
- Status = Predefined->RepairFunction (Data, ReturnObjectPtr);
- return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsMatchRepairableName
- *
- * PARAMETERS: Node - Namespace node for the method/object
- *
- * RETURN: Pointer to entry in repair table. NULL indicates not found.
- *
- * DESCRIPTION: Check an object name against the repairable object list.
- *
- *****************************************************************************/
-
-static const ACPI_REPAIR_INFO *
-AcpiNsMatchRepairableName (
- ACPI_NAMESPACE_NODE *Node)
-{
- const ACPI_REPAIR_INFO *ThisName;
-
-
- /* Search info table for a repairable predefined method/object name */
-
- ThisName = AcpiNsRepairableNames;
- while (ThisName->RepairFunction)
- {
- if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name))
- {
- return (ThisName);
- }
- ThisName++;
- }
-
- return (NULL); /* Not found */
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsRepair_ALR
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if object is OK or was repaired successfully
- *
- * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list
- * ascending by the ambient illuminance values.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiNsRepair_ALR (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_STATUS Status;
-
-
- Status = AcpiNsCheckSortedList (Data, ReturnObject, 2, 1,
- ACPI_SORT_ASCENDING, "AmbientIlluminance");
-
- return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsRepair_FDE
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if object is OK or was repaired successfully
- *
- * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
- * value is a Buffer of 5 DWORDs. This function repairs a common
- * problem where the return value is a Buffer of BYTEs, not
- * DWORDs.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiNsRepair_FDE (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_OPERAND_OBJECT *BufferObject;
- UINT8 *ByteBuffer;
- UINT32 *DwordBuffer;
- UINT32 i;
-
-
- ACPI_FUNCTION_NAME (NsRepair_FDE);
-
-
- switch (ReturnObject->Common.Type)
- {
- case ACPI_TYPE_BUFFER:
-
- /* This is the expected type. Length should be (at least) 5 DWORDs */
-
- if (ReturnObject->Buffer.Length >= ACPI_FDE_DWORD_BUFFER_SIZE)
- {
- return (AE_OK);
- }
-
- /* We can only repair if we have exactly 5 BYTEs */
-
- if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Incorrect return buffer length %u, expected %u",
- ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE));
-
- return (AE_AML_OPERAND_TYPE);
- }
-
- /* Create the new (larger) buffer object */
-
- BufferObject = AcpiUtCreateBufferObject (ACPI_FDE_DWORD_BUFFER_SIZE);
- if (!BufferObject)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Expand each byte to a DWORD */
-
- ByteBuffer = ReturnObject->Buffer.Pointer;
- DwordBuffer = ACPI_CAST_PTR (UINT32, BufferObject->Buffer.Pointer);
-
- for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++)
- {
- *DwordBuffer = (UINT32) *ByteBuffer;
- DwordBuffer++;
- ByteBuffer++;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s Expanded Byte Buffer to expected DWord Buffer\n",
- Data->Pathname));
- break;
-
- default:
- return (AE_AML_OPERAND_TYPE);
- }
-
- /* Delete the original return object, return the new buffer object */
-
- AcpiUtRemoveReference (ReturnObject);
- *ReturnObjectPtr = BufferObject;
-
- Data->Flags |= ACPI_OBJECT_REPAIRED;
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsRepair_CID
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if object is OK or was repaired successfully
- *
- * DESCRIPTION: Repair for the _CID object. If a string, ensure that all
- * letters are uppercase and that there is no leading asterisk.
- * If a Package, ensure same for all string elements.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiNsRepair_CID (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_OPERAND_OBJECT **ElementPtr;
- ACPI_OPERAND_OBJECT *OriginalElement;
- UINT16 OriginalRefCount;
- UINT32 i;
-
-
- /* Check for _CID as a simple string */
-
- if (ReturnObject->Common.Type == ACPI_TYPE_STRING)
- {
- Status = AcpiNsRepair_HID (Data, ReturnObjectPtr);
- return (Status);
- }
-
- /* Exit if not a Package */
-
- if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
- {
- return (AE_OK);
- }
-
- /* Examine each element of the _CID package */
-
- ElementPtr = ReturnObject->Package.Elements;
- for (i = 0; i < ReturnObject->Package.Count; i++)
- {
- OriginalElement = *ElementPtr;
- OriginalRefCount = OriginalElement->Common.ReferenceCount;
-
- Status = AcpiNsRepair_HID (Data, ElementPtr);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Take care with reference counts */
-
- if (OriginalElement != *ElementPtr)
- {
- /* Element was replaced */
-
- (*ElementPtr)->Common.ReferenceCount =
- OriginalRefCount;
-
- AcpiUtRemoveReference (OriginalElement);
- }
-
- ElementPtr++;
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsRepair_HID
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if object is OK or was repaired successfully
- *
- * DESCRIPTION: Repair for the _HID object. If a string, ensure that all
- * letters are uppercase and that there is no leading asterisk.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiNsRepair_HID (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_OPERAND_OBJECT *NewString;
- char *Source;
- char *Dest;
-
-
- ACPI_FUNCTION_NAME (NsRepair_HID);
-
-
- /* We only care about string _HID objects (not integers) */
-
- if (ReturnObject->Common.Type != ACPI_TYPE_STRING)
- {
- return (AE_OK);
- }
-
- if (ReturnObject->String.Length == 0)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Invalid zero-length _HID or _CID string"));
-
- /* Return AE_OK anyway, let driver handle it */
-
- Data->Flags |= ACPI_OBJECT_REPAIRED;
- return (AE_OK);
- }
-
- /* It is simplest to always create a new string object */
-
- NewString = AcpiUtCreateStringObject (ReturnObject->String.Length);
- if (!NewString)
- {
- return (AE_NO_MEMORY);
- }
-
- /*
- * Remove a leading asterisk if present. For some unknown reason, there
- * are many machines in the field that contains IDs like this.
- *
- * Examples: "*PNP0C03", "*ACPI0003"
- */
- Source = ReturnObject->String.Pointer;
- if (*Source == '*')
- {
- Source++;
- NewString->String.Length--;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Removed invalid leading asterisk\n", Data->Pathname));
- }
-
- /*
- * Copy and uppercase the string. From the ACPI 5.0 specification:
- *
- * A valid PNP ID must be of the form "AAA####" where A is an uppercase
- * letter and # is a hex digit. A valid ACPI ID must be of the form
- * "NNNN####" where N is an uppercase letter or decimal digit, and
- * # is a hex digit.
- */
- for (Dest = NewString->String.Pointer; *Source; Dest++, Source++)
- {
- *Dest = (char) ACPI_TOUPPER (*Source);
- }
-
- AcpiUtRemoveReference (ReturnObject);
- *ReturnObjectPtr = NewString;
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsRepair_TSS
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if object is OK or was repaired successfully
- *
- * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list
- * descending by the power dissipation values.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiNsRepair_TSS (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- /*
- * We can only sort the _TSS return package if there is no _PSS in the
- * same scope. This is because if _PSS is present, the ACPI specification
- * dictates that the _TSS Power Dissipation field is to be ignored, and
- * therefore some BIOSs leave garbage values in the _TSS Power field(s).
- * In this case, it is best to just return the _TSS package as-is.
- * (May, 2011)
- */
- Status = AcpiNsGetNode (Data->Node, "^_PSS", ACPI_NS_NO_UPSEARCH, &Node);
- if (ACPI_SUCCESS (Status))
- {
- return (AE_OK);
- }
-
- Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1,
- ACPI_SORT_DESCENDING, "PowerDissipation");
-
- return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsRepair_PSS
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if object is OK or was repaired successfully
- *
- * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list
- * by the CPU frequencies. Check that the power dissipation values
- * are all proportional to CPU frequency (i.e., sorting by
- * frequency should be the same as sorting by power.)
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiNsRepair_PSS (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_OPERAND_OBJECT **OuterElements;
- UINT32 OuterElementCount;
- ACPI_OPERAND_OBJECT **Elements;
- ACPI_OPERAND_OBJECT *ObjDesc;
- UINT32 PreviousValue;
- ACPI_STATUS Status;
- UINT32 i;
-
-
- /*
- * Entries (sub-packages) in the _PSS Package must be sorted by power
- * dissipation, in descending order. If it appears that the list is
- * incorrectly sorted, sort it. We sort by CpuFrequency, since this
- * should be proportional to the power.
- */
- Status =AcpiNsCheckSortedList (Data, ReturnObject, 6, 0,
- ACPI_SORT_DESCENDING, "CpuFrequency");
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * We now know the list is correctly sorted by CPU frequency. Check if
- * the power dissipation values are proportional.
- */
- PreviousValue = ACPI_UINT32_MAX;
- OuterElements = ReturnObject->Package.Elements;
- OuterElementCount = ReturnObject->Package.Count;
-
- for (i = 0; i < OuterElementCount; i++)
- {
- Elements = (*OuterElements)->Package.Elements;
- ObjDesc = Elements[1]; /* Index1 = PowerDissipation */
-
- if ((UINT32) ObjDesc->Integer.Value > PreviousValue)
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "SubPackage[%u,%u] - suspicious power dissipation values",
- i-1, i));
- }
-
- PreviousValue = (UINT32) ObjDesc->Integer.Value;
- OuterElements++;
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsCheckSortedList
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ReturnObject - Pointer to the top-level returned object
- * ExpectedCount - Minimum length of each sub-package
- * SortIndex - Sub-package entry to sort on
- * SortDirection - Ascending or descending
- * SortKeyName - Name of the SortIndex field
- *
- * RETURN: Status. AE_OK if the list is valid and is sorted correctly or
- * has been repaired by sorting the list.
- *
- * DESCRIPTION: Check if the package list is valid and sorted correctly by the
- * SortIndex. If not, then sort the list.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiNsCheckSortedList (
- ACPI_PREDEFINED_DATA *Data,
- ACPI_OPERAND_OBJECT *ReturnObject,
- UINT32 ExpectedCount,
- UINT32 SortIndex,
- UINT8 SortDirection,
- char *SortKeyName)
-{
- UINT32 OuterElementCount;
- ACPI_OPERAND_OBJECT **OuterElements;
- ACPI_OPERAND_OBJECT **Elements;
- ACPI_OPERAND_OBJECT *ObjDesc;
- UINT32 i;
- UINT32 PreviousValue;
-
-
- ACPI_FUNCTION_NAME (NsCheckSortedList);
-
-
- /* The top-level object must be a package */
-
- if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
- {
- return (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * NOTE: assumes list of sub-packages contains no NULL elements.
- * Any NULL elements should have been removed by earlier call
- * to AcpiNsRemoveNullElements.
- */
- OuterElements = ReturnObject->Package.Elements;
- OuterElementCount = ReturnObject->Package.Count;
- if (!OuterElementCount)
- {
- return (AE_AML_PACKAGE_LIMIT);
- }
-
- PreviousValue = 0;
- if (SortDirection == ACPI_SORT_DESCENDING)
- {
- PreviousValue = ACPI_UINT32_MAX;
- }
-
- /* Examine each subpackage */
-
- for (i = 0; i < OuterElementCount; i++)
- {
- /* Each element of the top-level package must also be a package */
-
- if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE)
- {
- return (AE_AML_OPERAND_TYPE);
- }
-
- /* Each sub-package must have the minimum length */
-
- if ((*OuterElements)->Package.Count < ExpectedCount)
- {
- return (AE_AML_PACKAGE_LIMIT);
- }
-
- Elements = (*OuterElements)->Package.Elements;
- ObjDesc = Elements[SortIndex];
-
- if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
- {
- return (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * The list must be sorted in the specified order. If we detect a
- * discrepancy, sort the entire list.
- */
- if (((SortDirection == ACPI_SORT_ASCENDING) &&
- (ObjDesc->Integer.Value < PreviousValue)) ||
- ((SortDirection == ACPI_SORT_DESCENDING) &&
- (ObjDesc->Integer.Value > PreviousValue)))
- {
- AcpiNsSortList (ReturnObject->Package.Elements,
- OuterElementCount, SortIndex, SortDirection);
-
- Data->Flags |= ACPI_OBJECT_REPAIRED;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
- "%s: Repaired unsorted list - now sorted by %s\n",
- Data->Pathname, SortKeyName));
- return (AE_OK);
- }
-
- PreviousValue = (UINT32) ObjDesc->Integer.Value;
- OuterElements++;
- }
-
- return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsSortList
- *
- * PARAMETERS: Elements - Package object element list
- * Count - Element count for above
- * Index - Sort by which package element
- * SortDirection - Ascending or Descending sort
- *
- * RETURN: None
- *
- * DESCRIPTION: Sort the objects that are in a package element list.
- *
- * NOTE: Assumes that all NULL elements have been removed from the package,
- * and that all elements have been verified to be of type Integer.
- *
- *****************************************************************************/
-
-static void
-AcpiNsSortList (
- ACPI_OPERAND_OBJECT **Elements,
- UINT32 Count,
- UINT32 Index,
- UINT8 SortDirection)
-{
- ACPI_OPERAND_OBJECT *ObjDesc1;
- ACPI_OPERAND_OBJECT *ObjDesc2;
- ACPI_OPERAND_OBJECT *TempObj;
- UINT32 i;
- UINT32 j;
-
-
- /* Simple bubble sort */
-
- for (i = 1; i < Count; i++)
- {
- for (j = (Count - 1); j >= i; j--)
- {
- ObjDesc1 = Elements[j-1]->Package.Elements[Index];
- ObjDesc2 = Elements[j]->Package.Elements[Index];
-
- if (((SortDirection == ACPI_SORT_ASCENDING) &&
- (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) ||
-
- ((SortDirection == ACPI_SORT_DESCENDING) &&
- (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value)))
- {
- TempObj = Elements[j-1];
- Elements[j-1] = Elements[j];
- Elements[j] = TempObj;
- }
- }
- }
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nssearch.c
--- a/head/sys/contrib/dev/acpica/namespace/nssearch.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,424 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nssearch - Namespace search
- *
- ******************************************************************************/
-
-/*
- * 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 __NSSEARCH_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-#ifdef ACPI_ASL_COMPILER
-#include <contrib/dev/acpica/include/amlcode.h>
-#endif
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nssearch")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiNsSearchParentTree (
- UINT32 TargetName,
- ACPI_NAMESPACE_NODE *Node,
- ACPI_OBJECT_TYPE Type,
- ACPI_NAMESPACE_NODE **ReturnNode);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsSearchOneScope
- *
- * PARAMETERS: TargetName - Ascii ACPI name to search for
- * ParentNode - Starting node where search will begin
- * Type - Object type to match
- * ReturnNode - Where the matched Named obj is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Search a single level of the namespace. Performs a
- * simple search of the specified level, and does not add
- * entries or search parents.
- *
- *
- * Named object lists are built (and subsequently dumped) in the
- * order in which the names are encountered during the namespace load;
- *
- * All namespace searching is linear in this implementation, but
- * could be easily modified to support any improved search
- * algorithm. However, the linear search was chosen for simplicity
- * and because the trees are small and the other interpreter
- * execution overhead is relatively high.
- *
- * Note: CPU execution analysis has shown that the AML interpreter spends
- * a very small percentage of its time searching the namespace. Therefore,
- * the linear search seems to be sufficient, as there would seem to be
- * little value in improving the search.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsSearchOneScope (
- UINT32 TargetName,
- ACPI_NAMESPACE_NODE *ParentNode,
- ACPI_OBJECT_TYPE Type,
- ACPI_NAMESPACE_NODE **ReturnNode)
-{
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (NsSearchOneScope);
-
-
-#ifdef ACPI_DEBUG_OUTPUT
- if (ACPI_LV_NAMES & AcpiDbgLevel)
- {
- char *ScopeName;
-
- ScopeName = AcpiNsGetExternalPathname (ParentNode);
- if (ScopeName)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Searching %s (%p) For [%4.4s] (%s)\n",
- ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName),
- AcpiUtGetTypeName (Type)));
-
- ACPI_FREE (ScopeName);
- }
- }
-#endif
-
- /*
- * Search for name at this namespace level, which is to say that we
- * must search for the name among the children of this object
- */
- Node = ParentNode->Child;
- while (Node)
- {
- /* Check for match against the name */
-
- if (Node->Name.Integer == TargetName)
- {
- /* Resolve a control method alias if any */
-
- if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
- {
- Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
- }
-
- /* Found matching entry */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
- ACPI_CAST_PTR (char, &TargetName),
- AcpiUtGetTypeName (Node->Type),
- Node, AcpiUtGetNodeName (ParentNode), ParentNode));
-
- *ReturnNode = Node;
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Didn't match name, move on to the next peer object */
-
- Node = Node->Peer;
- }
-
- /* Searched entire namespace level, not found */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Name [%4.4s] (%s) not found in search in scope [%4.4s] "
- "%p first child %p\n",
- ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type),
- AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child));
-
- return_ACPI_STATUS (AE_NOT_FOUND);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsSearchParentTree
- *
- * PARAMETERS: TargetName - Ascii ACPI name to search for
- * Node - Starting node where search will begin
- * Type - Object type to match
- * ReturnNode - Where the matched Node is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Called when a name has not been found in the current namespace
- * level. Before adding it or giving up, ACPI scope rules require
- * searching enclosing scopes in cases identified by AcpiNsLocal().
- *
- * "A name is located by finding the matching name in the current
- * name space, and then in the parent name space. If the parent
- * name space does not contain the name, the search continues
- * recursively until either the name is found or the name space
- * does not have a parent (the root of the name space). This
- * indicates that the name is not found" (From ACPI Specification,
- * section 5.3)
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsSearchParentTree (
- UINT32 TargetName,
- ACPI_NAMESPACE_NODE *Node,
- ACPI_OBJECT_TYPE Type,
- ACPI_NAMESPACE_NODE **ReturnNode)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *ParentNode;
-
-
- ACPI_FUNCTION_TRACE (NsSearchParentTree);
-
-
- ParentNode = Node->Parent;
-
- /*
- * If there is no parent (i.e., we are at the root) or type is "local",
- * we won't be searching the parent tree.
- */
- if (!ParentNode)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
- ACPI_CAST_PTR (char, &TargetName)));
- return_ACPI_STATUS (AE_NOT_FOUND);
- }
-
- if (AcpiNsLocal (Type))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
- ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type)));
- return_ACPI_STATUS (AE_NOT_FOUND);
- }
-
- /* Search the parent tree */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Searching parent [%4.4s] for [%4.4s]\n",
- AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName)));
-
- /* Search parents until target is found or we have backed up to the root */
-
- while (ParentNode)
- {
- /*
- * Search parent scope. Use TYPE_ANY because we don't care about the
- * object type at this point, we only care about the existence of
- * the actual name we are searching for. Typechecking comes later.
- */
- Status = AcpiNsSearchOneScope (
- TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode);
- if (ACPI_SUCCESS (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Not found here, go up another level (until we reach the root) */
-
- ParentNode = ParentNode->Parent;
- }
-
- /* Not found in parent tree */
-
- return_ACPI_STATUS (AE_NOT_FOUND);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsSearchAndEnter
- *
- * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars)
- * WalkState - Current state of the walk
- * Node - Starting node where search will begin
- * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x.
- * Otherwise,search only.
- * Type - Object type to match
- * Flags - Flags describing the search restrictions
- * ReturnNode - Where the Node is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Search for a name segment in a single namespace level,
- * optionally adding it if it is not found. If the passed
- * Type is not Any and the type previously stored in the
- * entry was Any (i.e. unknown), update the stored type.
- *
- * In ACPI_IMODE_EXECUTE, search only.
- * In other modes, search and add if not found.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsSearchAndEnter (
- UINT32 TargetName,
- ACPI_WALK_STATE *WalkState,
- ACPI_NAMESPACE_NODE *Node,
- ACPI_INTERPRETER_MODE InterpreterMode,
- ACPI_OBJECT_TYPE Type,
- UINT32 Flags,
- ACPI_NAMESPACE_NODE **ReturnNode)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *NewNode;
-
-
- ACPI_FUNCTION_TRACE (NsSearchAndEnter);
-
-
- /* Parameter validation */
-
- if (!Node || !TargetName || !ReturnNode)
- {
- ACPI_ERROR ((AE_INFO,
- "Null parameter: Node %p Name 0x%X ReturnNode %p",
- Node, TargetName, ReturnNode));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /*
- * Name must consist of valid ACPI characters. We will repair the name if
- * necessary because we don't want to abort because of this, but we want
- * all namespace names to be printable. A warning message is appropriate.
- *
- * This issue came up because there are in fact machines that exhibit
- * this problem, and we want to be able to enable ACPI support for them,
- * even though there are a few bad names.
- */
- AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName));
-
- /* Try to find the name in the namespace level specified by the caller */
-
- *ReturnNode = ACPI_ENTRY_NOT_FOUND;
- Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode);
- if (Status != AE_NOT_FOUND)
- {
- /*
- * If we found it AND the request specifies that a find is an error,
- * return the error
- */
- if ((Status == AE_OK) &&
- (Flags & ACPI_NS_ERROR_IF_FOUND))
- {
- Status = AE_ALREADY_EXISTS;
- }
-
-#ifdef ACPI_ASL_COMPILER
- if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY)
- {
- (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL;
- }
-#endif
-
- /* Either found it or there was an error: finished either way */
-
- return_ACPI_STATUS (Status);
- }
-
- /*
- * The name was not found. If we are NOT performing the first pass
- * (name entry) of loading the namespace, search the parent tree (all the
- * way to the root if necessary.) We don't want to perform the parent
- * search when the namespace is actually being loaded. We want to perform
- * the search when namespace references are being resolved (load pass 2)
- * and during the execution phase.
- */
- if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) &&
- (Flags & ACPI_NS_SEARCH_PARENT))
- {
- /*
- * Not found at this level - search parent tree according to the
- * ACPI specification
- */
- Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode);
- if (ACPI_SUCCESS (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /* In execute mode, just search, never add names. Exit now */
-
- if (InterpreterMode == ACPI_IMODE_EXECUTE)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "%4.4s Not found in %p [Not adding]\n",
- ACPI_CAST_PTR (char, &TargetName), Node));
-
- return_ACPI_STATUS (AE_NOT_FOUND);
- }
-
- /* Create the new named object */
-
- NewNode = AcpiNsCreateNode (TargetName);
- if (!NewNode)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
-#ifdef ACPI_ASL_COMPILER
-
- /* Node is an object defined by an External() statement */
-
- if (Flags & ACPI_NS_EXTERNAL ||
- (WalkState && WalkState->Opcode == AML_SCOPE_OP))
- {
- NewNode->Flags |= ANOBJ_IS_EXTERNAL;
- }
-#endif
-
- if (Flags & ACPI_NS_TEMPORARY)
- {
- NewNode->Flags |= ANOBJ_TEMPORARY;
- }
-
- /* Install the new object into the parent's list of children */
-
- AcpiNsInstallNode (WalkState, Node, NewNode, Type);
- *ReturnNode = NewNode;
- return_ACPI_STATUS (AE_OK);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsutils.c
--- a/head/sys/contrib/dev/acpica/namespace/nsutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,875 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
- * parents and siblings and Scope 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 __NSUTILS_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/amlcode.h>
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsutils")
-
-/* Local prototypes */
-
-static BOOLEAN
-AcpiNsValidPathSeparator (
- char Sep);
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-ACPI_NAME
-AcpiNsFindParentName (
- ACPI_NAMESPACE_NODE *NodeToSearch);
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsPrintNodePathname
- *
- * PARAMETERS: Node - Object
- * Message - Prefix message
- *
- * DESCRIPTION: Print an object's full namespace pathname
- * Manages allocation/freeing of a pathname buffer
- *
- ******************************************************************************/
-
-void
-AcpiNsPrintNodePathname (
- ACPI_NAMESPACE_NODE *Node,
- const char *Message)
-{
- ACPI_BUFFER Buffer;
- ACPI_STATUS Status;
-
-
- if (!Node)
- {
- AcpiOsPrintf ("[NULL NAME]");
- return;
- }
-
- /* Convert handle to full pathname and print it (with supplied message) */
-
- Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
-
- Status = AcpiNsHandleToPathname (Node, &Buffer);
- if (ACPI_SUCCESS (Status))
- {
- if (Message)
- {
- AcpiOsPrintf ("%s ", Message);
- }
-
- AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node);
- ACPI_FREE (Buffer.Pointer);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsValidRootPrefix
- *
- * PARAMETERS: Prefix - Character to be checked
- *
- * RETURN: TRUE if a valid prefix
- *
- * DESCRIPTION: Check if a character is a valid ACPI Root prefix
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiNsValidRootPrefix (
- char Prefix)
-{
-
- return ((BOOLEAN) (Prefix == '\\'));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsValidPathSeparator
- *
- * PARAMETERS: Sep - Character to be checked
- *
- * RETURN: TRUE if a valid path separator
- *
- * DESCRIPTION: Check if a character is a valid ACPI path separator
- *
- ******************************************************************************/
-
-static BOOLEAN
-AcpiNsValidPathSeparator (
- char Sep)
-{
-
- return ((BOOLEAN) (Sep == '.'));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetType
- *
- * PARAMETERS: Node - Parent Node to be examined
- *
- * RETURN: Type field from Node whose handle is passed
- *
- * DESCRIPTION: Return the type of a Namespace node
- *
- ******************************************************************************/
-
-ACPI_OBJECT_TYPE
-AcpiNsGetType (
- ACPI_NAMESPACE_NODE *Node)
-{
- ACPI_FUNCTION_TRACE (NsGetType);
-
-
- if (!Node)
- {
- ACPI_WARNING ((AE_INFO, "Null Node parameter"));
- return_UINT32 (ACPI_TYPE_ANY);
- }
-
- return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsLocal
- *
- * PARAMETERS: Type - A namespace object type
- *
- * RETURN: LOCAL if names must be found locally in objects of the
- * passed type, 0 if enclosing scopes should be searched
- *
- * DESCRIPTION: Returns scope rule for the given object type.
- *
- ******************************************************************************/
-
-UINT32
-AcpiNsLocal (
- ACPI_OBJECT_TYPE Type)
-{
- ACPI_FUNCTION_TRACE (NsLocal);
-
-
- if (!AcpiUtValidObjectType (Type))
- {
- /* Type code out of range */
-
- ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));
- return_UINT32 (ACPI_NS_NORMAL);
- }
-
- return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetInternalNameLength
- *
- * PARAMETERS: Info - Info struct initialized with the
- * external name pointer.
- *
- * RETURN: None
- *
- * DESCRIPTION: Calculate the length of the internal (AML) namestring
- * corresponding to the external (ASL) namestring.
- *
- ******************************************************************************/
-
-void
-AcpiNsGetInternalNameLength (
- ACPI_NAMESTRING_INFO *Info)
-{
- const char *NextExternalChar;
- UINT32 i;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- NextExternalChar = Info->ExternalName;
- Info->NumCarats = 0;
- Info->NumSegments = 0;
- Info->FullyQualified = FALSE;
-
- /*
- * For the internal name, the required length is 4 bytes per segment, plus
- * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null
- * (which is not really needed, but no there's harm in putting it there)
- *
- * strlen() + 1 covers the first NameSeg, which has no path separator
- */
- if (AcpiNsValidRootPrefix (*NextExternalChar))
- {
- Info->FullyQualified = TRUE;
- NextExternalChar++;
-
- /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */
-
- while (AcpiNsValidRootPrefix (*NextExternalChar))
- {
- NextExternalChar++;
- }
- }
- else
- {
- /* Handle Carat prefixes */
-
- while (*NextExternalChar == '^')
- {
- Info->NumCarats++;
- NextExternalChar++;
- }
- }
-
- /*
- * Determine the number of ACPI name "segments" by counting the number of
- * path separators within the string. Start with one segment since the
- * segment count is [(# separators) + 1], and zero separators is ok.
- */
- if (*NextExternalChar)
- {
- Info->NumSegments = 1;
- for (i = 0; NextExternalChar[i]; i++)
- {
- if (AcpiNsValidPathSeparator (NextExternalChar[i]))
- {
- Info->NumSegments++;
- }
- }
- }
-
- Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
- 4 + Info->NumCarats;
-
- Info->NextExternalChar = NextExternalChar;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsBuildInternalName
- *
- * PARAMETERS: Info - Info struct fully initialized
- *
- * RETURN: Status
- *
- * DESCRIPTION: Construct the internal (AML) namestring
- * corresponding to the external (ASL) namestring.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsBuildInternalName (
- ACPI_NAMESTRING_INFO *Info)
-{
- UINT32 NumSegments = Info->NumSegments;
- char *InternalName = Info->InternalName;
- const char *ExternalName = Info->NextExternalChar;
- char *Result = NULL;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (NsBuildInternalName);
-
-
- /* Setup the correct prefixes, counts, and pointers */
-
- if (Info->FullyQualified)
- {
- InternalName[0] = '\\';
-
- if (NumSegments <= 1)
- {
- Result = &InternalName[1];
- }
- else if (NumSegments == 2)
- {
- InternalName[1] = AML_DUAL_NAME_PREFIX;
- Result = &InternalName[2];
- }
- else
- {
- InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
- InternalName[2] = (char) NumSegments;
- Result = &InternalName[3];
- }
- }
- else
- {
- /*
- * Not fully qualified.
- * Handle Carats first, then append the name segments
- */
- i = 0;
- if (Info->NumCarats)
- {
- for (i = 0; i < Info->NumCarats; i++)
- {
- InternalName[i] = '^';
- }
- }
-
- if (NumSegments <= 1)
- {
- Result = &InternalName[i];
- }
- else if (NumSegments == 2)
- {
- InternalName[i] = AML_DUAL_NAME_PREFIX;
- Result = &InternalName[(ACPI_SIZE) i+1];
- }
- else
- {
- InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
- InternalName[(ACPI_SIZE) i+1] = (char) NumSegments;
- Result = &InternalName[(ACPI_SIZE) i+2];
- }
- }
-
- /* Build the name (minus path separators) */
-
- for (; NumSegments; NumSegments--)
- {
- for (i = 0; i < ACPI_NAME_SIZE; i++)
- {
- if (AcpiNsValidPathSeparator (*ExternalName) ||
- (*ExternalName == 0))
- {
- /* Pad the segment with underscore(s) if segment is short */
-
- Result[i] = '_';
- }
- else
- {
- /* Convert the character to uppercase and save it */
-
- Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
- ExternalName++;
- }
- }
-
- /* Now we must have a path separator, or the pathname is bad */
-
- if (!AcpiNsValidPathSeparator (*ExternalName) &&
- (*ExternalName != 0))
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Move on the next segment */
-
- ExternalName++;
- Result += ACPI_NAME_SIZE;
- }
-
- /* Terminate the string */
-
- *Result = 0;
-
- if (Info->FullyQualified)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",
- InternalName, InternalName));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
- InternalName, InternalName));
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsInternalizeName
- *
- * PARAMETERS: *ExternalName - External representation of name
- * **Converted Name - Where to return the resulting
- * internal represention of the name
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
- * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
- *
- *******************************************************************************/
-
-ACPI_STATUS
-AcpiNsInternalizeName (
- const char *ExternalName,
- char **ConvertedName)
-{
- char *InternalName;
- ACPI_NAMESTRING_INFO Info;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (NsInternalizeName);
-
-
- if ((!ExternalName) ||
- (*ExternalName == 0) ||
- (!ConvertedName))
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Get the length of the new internal name */
-
- Info.ExternalName = ExternalName;
- AcpiNsGetInternalNameLength (&Info);
-
- /* We need a segment to store the internal name */
-
- InternalName = ACPI_ALLOCATE_ZEROED (Info.Length);
- if (!InternalName)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Build the name */
-
- Info.InternalName = InternalName;
- Status = AcpiNsBuildInternalName (&Info);
- if (ACPI_FAILURE (Status))
- {
- ACPI_FREE (InternalName);
- return_ACPI_STATUS (Status);
- }
-
- *ConvertedName = InternalName;
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsExternalizeName
- *
- * PARAMETERS: InternalNameLength - Lenth of the internal name below
- * InternalName - Internal representation of name
- * ConvertedNameLength - Where the length is returned
- * ConvertedName - Where the resulting external name
- * is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
- * to its external (printable) form (e.g. "\_PR_.CPU0")
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsExternalizeName (
- UINT32 InternalNameLength,
- const char *InternalName,
- UINT32 *ConvertedNameLength,
- char **ConvertedName)
-{
- UINT32 NamesIndex = 0;
- UINT32 NumSegments = 0;
- UINT32 RequiredLength;
- UINT32 PrefixLength = 0;
- UINT32 i = 0;
- UINT32 j = 0;
-
-
- ACPI_FUNCTION_TRACE (NsExternalizeName);
-
-
- if (!InternalNameLength ||
- !InternalName ||
- !ConvertedName)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Check for a prefix (one '\' | one or more '^') */
-
- switch (InternalName[0])
- {
- case '\\':
- PrefixLength = 1;
- break;
-
- case '^':
- for (i = 0; i < InternalNameLength; i++)
- {
- if (InternalName[i] == '^')
- {
- PrefixLength = i + 1;
- }
- else
- {
- break;
- }
- }
-
- if (i == InternalNameLength)
- {
- PrefixLength = i;
- }
-
- break;
-
- default:
- break;
- }
-
- /*
- * Check for object names. Note that there could be 0-255 of these
- * 4-byte elements.
- */
- if (PrefixLength < InternalNameLength)
- {
- switch (InternalName[PrefixLength])
- {
- case AML_MULTI_NAME_PREFIX_OP:
-
- /* <count> 4-byte names */
-
- NamesIndex = PrefixLength + 2;
- NumSegments = (UINT8)
- InternalName[(ACPI_SIZE) PrefixLength + 1];
- break;
-
- case AML_DUAL_NAME_PREFIX:
-
- /* Two 4-byte names */
-
- NamesIndex = PrefixLength + 1;
- NumSegments = 2;
- break;
-
- case 0:
-
- /* NullName */
-
- NamesIndex = 0;
- NumSegments = 0;
- break;
-
- default:
-
- /* one 4-byte name */
-
- NamesIndex = PrefixLength;
- NumSegments = 1;
- break;
- }
- }
-
- /*
- * Calculate the length of ConvertedName, which equals the length
- * of the prefix, length of all object names, length of any required
- * punctuation ('.') between object names, plus the NULL terminator.
- */
- RequiredLength = PrefixLength + (4 * NumSegments) +
- ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
-
- /*
- * Check to see if we're still in bounds. If not, there's a problem
- * with InternalName (invalid format).
- */
- if (RequiredLength > InternalNameLength)
- {
- ACPI_ERROR ((AE_INFO, "Invalid internal name"));
- return_ACPI_STATUS (AE_BAD_PATHNAME);
- }
-
- /* Build the ConvertedName */
-
- *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength);
- if (!(*ConvertedName))
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- j = 0;
-
- for (i = 0; i < PrefixLength; i++)
- {
- (*ConvertedName)[j++] = InternalName[i];
- }
-
- if (NumSegments > 0)
- {
- for (i = 0; i < NumSegments; i++)
- {
- if (i > 0)
- {
- (*ConvertedName)[j++] = '.';
- }
-
- (*ConvertedName)[j++] = InternalName[NamesIndex++];
- (*ConvertedName)[j++] = InternalName[NamesIndex++];
- (*ConvertedName)[j++] = InternalName[NamesIndex++];
- (*ConvertedName)[j++] = InternalName[NamesIndex++];
- }
- }
-
- if (ConvertedNameLength)
- {
- *ConvertedNameLength = (UINT32) RequiredLength;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsValidateHandle
- *
- * PARAMETERS: Handle - Handle to be validated and typecast to a
- * namespace node.
- *
- * RETURN: A pointer to a namespace node
- *
- * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
- * cases for the root node.
- *
- * NOTE: Real integer handles would allow for more verification
- * and keep all pointers within this subsystem - however this introduces
- * more overhead and has not been necessary to this point. Drivers
- * holding handles are typically notified before a node becomes invalid
- * due to a table unload.
- *
- ******************************************************************************/
-
-ACPI_NAMESPACE_NODE *
-AcpiNsValidateHandle (
- ACPI_HANDLE Handle)
-{
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Parameter validation */
-
- if ((!Handle) || (Handle == ACPI_ROOT_OBJECT))
- {
- return (AcpiGbl_RootNode);
- }
-
- /* We can at least attempt to verify the handle */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
- {
- return (NULL);
- }
-
- return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsTerminate
- *
- * PARAMETERS: none
- *
- * RETURN: none
- *
- * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
- *
- ******************************************************************************/
-
-void
-AcpiNsTerminate (
- void)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
-
-
- ACPI_FUNCTION_TRACE (NsTerminate);
-
-
- /*
- * 1) Free the entire namespace -- all nodes and objects
- *
- * Delete all object descriptors attached to namepsace nodes
- */
- AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
-
- /* Detach any objects attached to the root */
-
- ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
- if (ObjDesc)
- {
- AcpiNsDetachObject (AcpiGbl_RootNode);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsOpensScope
- *
- * PARAMETERS: Type - A valid namespace type
- *
- * RETURN: NEWSCOPE if the passed type "opens a name scope" according
- * to the ACPI specification, else 0
- *
- ******************************************************************************/
-
-UINT32
-AcpiNsOpensScope (
- ACPI_OBJECT_TYPE Type)
-{
- ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type));
-
-
- if (!AcpiUtValidObjectType (Type))
- {
- /* type code out of range */
-
- ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));
- return_UINT32 (ACPI_NS_NORMAL);
- }
-
- return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetNode
- *
- * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
- * \ (backslash) and ^ (carat) prefixes, and the
- * . (period) to separate segments are supported.
- * PrefixNode - Root of subtree to be searched, or NS_ALL for the
- * root of the name space. If Name is fully
- * qualified (first INT8 is '\'), the passed value
- * of Scope will not be accessed.
- * Flags - Used to indicate whether to perform upsearch or
- * not.
- * ReturnNode - Where the Node is returned
- *
- * DESCRIPTION: Look up a name relative to a given scope and return the
- * corresponding Node. NOTE: Scope can be null.
- *
- * MUTEX: Locks namespace
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsGetNode (
- ACPI_NAMESPACE_NODE *PrefixNode,
- const char *Pathname,
- UINT32 Flags,
- ACPI_NAMESPACE_NODE **ReturnNode)
-{
- ACPI_GENERIC_STATE ScopeInfo;
- ACPI_STATUS Status;
- char *InternalPath;
-
-
- ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname));
-
-
- if (!Pathname)
- {
- *ReturnNode = PrefixNode;
- if (!PrefixNode)
- {
- *ReturnNode = AcpiGbl_RootNode;
- }
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Convert path to internal representation */
-
- Status = AcpiNsInternalizeName (Pathname, &InternalPath);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Must lock namespace during lookup */
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /* Setup lookup scope (search starting point) */
-
- ScopeInfo.Scope.Node = PrefixNode;
-
- /* Lookup the name in the namespace */
-
- Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,
- ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE),
- NULL, ReturnNode);
- if (ACPI_FAILURE (Status))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n",
- Pathname, AcpiFormatException (Status)));
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-
-Cleanup:
- ACPI_FREE (InternalPath);
- return_ACPI_STATUS (Status);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nswalk.c
--- a/head/sys/contrib/dev/acpica/namespace/nswalk.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,386 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nswalk - Functions for walking 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.
- */
-
-
-#define __NSWALK_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nswalk")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetNextNode
- *
- * PARAMETERS: ParentNode - Parent node whose children we are
- * getting
- * ChildNode - Previous child that was found.
- * The NEXT child will be returned
- *
- * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
- * none is found.
- *
- * DESCRIPTION: Return the next peer node within the namespace. If Handle
- * is valid, Scope is ignored. Otherwise, the first node
- * within Scope is returned.
- *
- ******************************************************************************/
-
-ACPI_NAMESPACE_NODE *
-AcpiNsGetNextNode (
- ACPI_NAMESPACE_NODE *ParentNode,
- ACPI_NAMESPACE_NODE *ChildNode)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!ChildNode)
- {
- /* It's really the parent's _scope_ that we want */
-
- return (ParentNode->Child);
- }
-
- /* Otherwise just return the next peer */
-
- return (ChildNode->Peer);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetNextNodeTyped
- *
- * PARAMETERS: Type - Type of node to be searched for
- * ParentNode - Parent node whose children we are
- * getting
- * ChildNode - Previous child that was found.
- * The NEXT child will be returned
- *
- * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
- * none is found.
- *
- * DESCRIPTION: Return the next peer node within the namespace. If Handle
- * is valid, Scope is ignored. Otherwise, the first node
- * within Scope is returned.
- *
- ******************************************************************************/
-
-ACPI_NAMESPACE_NODE *
-AcpiNsGetNextNodeTyped (
- ACPI_OBJECT_TYPE Type,
- ACPI_NAMESPACE_NODE *ParentNode,
- ACPI_NAMESPACE_NODE *ChildNode)
-{
- ACPI_NAMESPACE_NODE *NextNode = NULL;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- NextNode = AcpiNsGetNextNode (ParentNode, ChildNode);
-
- /* If any type is OK, we are done */
-
- if (Type == ACPI_TYPE_ANY)
- {
- /* NextNode is NULL if we are at the end-of-list */
-
- return (NextNode);
- }
-
- /* Must search for the node -- but within this scope only */
-
- while (NextNode)
- {
- /* If type matches, we are done */
-
- if (NextNode->Type == Type)
- {
- return (NextNode);
- }
-
- /* Otherwise, move on to the next peer node */
-
- NextNode = NextNode->Peer;
- }
-
- /* Not found */
-
- return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsWalkNamespace
- *
- * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
- * StartNode - Handle in namespace where search begins
- * MaxDepth - Depth to which search is to reach
- * Flags - Whether to unlock the NS before invoking
- * the callback routine
- * PreOrderVisit - Called during tree pre-order visit
- * when an object of "Type" is found
- * PostOrderVisit - Called during tree post-order visit
- * when an object of "Type" is found
- * Context - Passed to user function(s) above
- * ReturnValue - from the UserFunction if terminated
- * early. Otherwise, returns NULL.
- * RETURNS: Status
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- * starting (and ending) at the node specified by StartHandle.
- * The callback function is called whenever a node that matches
- * the type parameter is found. If the callback function returns
- * a non-zero value, the search is terminated immediately and
- * this value is returned to the caller.
- *
- * The point of this procedure is to provide a generic namespace
- * walk routine that can be called from multiple places to
- * provide multiple services; the callback function(s) can be
- * tailored to each task, whether it is a print function,
- * a compare function, etc.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiNsWalkNamespace (
- ACPI_OBJECT_TYPE Type,
- ACPI_HANDLE StartNode,
- UINT32 MaxDepth,
- UINT32 Flags,
- ACPI_WALK_CALLBACK PreOrderVisit,
- ACPI_WALK_CALLBACK PostOrderVisit,
- void *Context,
- void **ReturnValue)
-{
- ACPI_STATUS Status;
- ACPI_STATUS MutexStatus;
- ACPI_NAMESPACE_NODE *ChildNode;
- ACPI_NAMESPACE_NODE *ParentNode;
- ACPI_OBJECT_TYPE ChildType;
- UINT32 Level;
- BOOLEAN NodePreviouslyVisited = FALSE;
-
-
- ACPI_FUNCTION_TRACE (NsWalkNamespace);
-
-
- /* Special case for the namespace Root Node */
-
- if (StartNode == ACPI_ROOT_OBJECT)
- {
- StartNode = AcpiGbl_RootNode;
- }
-
- /* Null child means "get first node" */
-
- ParentNode = StartNode;
- ChildNode = AcpiNsGetNextNode (ParentNode, NULL);
- ChildType = ACPI_TYPE_ANY;
- Level = 1;
-
- /*
- * Traverse the tree of nodes until we bubble back up to where we
- * started. When Level is zero, the loop is done because we have
- * bubbled up to (and passed) the original parent handle (StartEntry)
- */
- while (Level > 0 && ChildNode)
- {
- Status = AE_OK;
-
- /* Found next child, get the type if we are not searching for ANY */
-
- if (Type != ACPI_TYPE_ANY)
- {
- ChildType = ChildNode->Type;
- }
-
- /*
- * Ignore all temporary namespace nodes (created during control
- * method execution) unless told otherwise. These temporary nodes
- * can cause a race condition because they can be deleted during
- * the execution of the user function (if the namespace is
- * unlocked before invocation of the user function.) Only the
- * debugger namespace dump will examine the temporary nodes.
- */
- if ((ChildNode->Flags & ANOBJ_TEMPORARY) &&
- !(Flags & ACPI_NS_WALK_TEMP_NODES))
- {
- Status = AE_CTRL_DEPTH;
- }
-
- /* Type must match requested type */
-
- else if (ChildType == Type)
- {
- /*
- * Found a matching node, invoke the user callback function.
- * Unlock the namespace if flag is set.
- */
- if (Flags & ACPI_NS_WALK_UNLOCK)
- {
- MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (MutexStatus))
- {
- return_ACPI_STATUS (MutexStatus);
- }
- }
-
- /*
- * Invoke the user function, either pre-order or post-order
- * or both.
- */
- if (!NodePreviouslyVisited)
- {
- if (PreOrderVisit)
- {
- Status = PreOrderVisit (ChildNode, Level,
- Context, ReturnValue);
- }
- }
- else
- {
- if (PostOrderVisit)
- {
- Status = PostOrderVisit (ChildNode, Level,
- Context, ReturnValue);
- }
- }
-
- if (Flags & ACPI_NS_WALK_UNLOCK)
- {
- MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (MutexStatus))
- {
- return_ACPI_STATUS (MutexStatus);
- }
- }
-
- switch (Status)
- {
- case AE_OK:
- case AE_CTRL_DEPTH:
-
- /* Just keep going */
- break;
-
- case AE_CTRL_TERMINATE:
-
- /* Exit now, with OK status */
-
- return_ACPI_STATUS (AE_OK);
-
- default:
-
- /* All others are valid exceptions */
-
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Depth first search: Attempt to go down another level in the
- * namespace if we are allowed to. Don't go any further if we have
- * reached the caller specified maximum depth or if the user
- * function has specified that the maximum depth has been reached.
- */
- if (!NodePreviouslyVisited &&
- (Level < MaxDepth) &&
- (Status != AE_CTRL_DEPTH))
- {
- if (ChildNode->Child)
- {
- /* There is at least one child of this node, visit it */
-
- Level++;
- ParentNode = ChildNode;
- ChildNode = AcpiNsGetNextNode (ParentNode, NULL);
- continue;
- }
- }
-
- /* No more children, re-visit this node */
-
- if (!NodePreviouslyVisited)
- {
- NodePreviouslyVisited = TRUE;
- continue;
- }
-
- /* No more children, visit peers */
-
- ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
- if (ChildNode)
- {
- NodePreviouslyVisited = FALSE;
- }
-
- /* No peers, re-visit parent */
-
- else
- {
- /*
- * No more children of this node (AcpiNsGetNextNode failed), go
- * back upwards in the namespace tree to the node's parent.
- */
- Level--;
- ChildNode = ParentNode;
- ParentNode = ParentNode->Parent;
-
- NodePreviouslyVisited = TRUE;
- }
- }
-
- /* Complete walk, not terminated by user function */
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsxfeval.c
--- a/head/sys/contrib/dev/acpica/namespace/nsxfeval.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,960 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
- * ACPI Object evaluation 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.
- */
-
-
-#define __NSXFEVAL_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/acinterp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsxfeval")
-
-/* Local prototypes */
-
-static void
-AcpiNsResolveReferences (
- ACPI_EVALUATE_INFO *Info);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiEvaluateObjectTyped
- *
- * PARAMETERS: Handle - Object handle (optional)
- * Pathname - Object pathname (optional)
- * ExternalParams - List of parameters to pass to method,
- * terminated by NULL. May be NULL
- * if no parameters are being passed.
- * ReturnBuffer - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * ReturnType - Expected type of return object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Find and evaluate the given object, passing the given
- * parameters if necessary. One of "Handle" or "Pathname" must
- * be valid (non-null)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiEvaluateObjectTyped (
- ACPI_HANDLE Handle,
- ACPI_STRING Pathname,
- ACPI_OBJECT_LIST *ExternalParams,
- ACPI_BUFFER *ReturnBuffer,
- ACPI_OBJECT_TYPE ReturnType)
-{
- ACPI_STATUS Status;
- BOOLEAN MustFree = FALSE;
-
-
- ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped);
-
-
- /* Return buffer must be valid */
-
- if (!ReturnBuffer)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER)
- {
- MustFree = TRUE;
- }
-
- /* Evaluate the object */
-
- Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Type ANY means "don't care" */
-
- if (ReturnType == ACPI_TYPE_ANY)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- if (ReturnBuffer->Length == 0)
- {
- /* Error because caller specifically asked for a return value */
-
- ACPI_ERROR ((AE_INFO, "No return value"));
- return_ACPI_STATUS (AE_NULL_OBJECT);
- }
-
- /* Examine the object type returned from EvaluateObject */
-
- if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Return object type does not match requested type */
-
- ACPI_ERROR ((AE_INFO,
- "Incorrect return type [%s] requested [%s]",
- AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type),
- AcpiUtGetTypeName (ReturnType)));
-
- if (MustFree)
- {
- /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
-
- AcpiOsFree (ReturnBuffer->Pointer);
- ReturnBuffer->Pointer = NULL;
- }
-
- ReturnBuffer->Length = 0;
- return_ACPI_STATUS (AE_TYPE);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiEvaluateObject
- *
- * PARAMETERS: Handle - Object handle (optional)
- * Pathname - Object pathname (optional)
- * ExternalParams - List of parameters to pass to method,
- * terminated by NULL. May be NULL
- * if no parameters are being passed.
- * ReturnBuffer - Where to put method's return value (if
- * any). If NULL, no value is returned.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Find and evaluate the given object, passing the given
- * parameters if necessary. One of "Handle" or "Pathname" must
- * be valid (non-null)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiEvaluateObject (
- ACPI_HANDLE Handle,
- ACPI_STRING Pathname,
- ACPI_OBJECT_LIST *ExternalParams,
- ACPI_BUFFER *ReturnBuffer)
-{
- ACPI_STATUS Status;
- ACPI_EVALUATE_INFO *Info;
- ACPI_SIZE BufferSpaceNeeded;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (AcpiEvaluateObject);
-
-
- /* Allocate and initialize the evaluation information block */
-
- Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
- if (!Info)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Info->Pathname = Pathname;
-
- /* Convert and validate the device handle */
-
- Info->PrefixNode = AcpiNsValidateHandle (Handle);
- if (!Info->PrefixNode)
- {
- Status = AE_BAD_PARAMETER;
- goto Cleanup;
- }
-
- /*
- * If there are parameters to be passed to a control method, the external
- * objects must all be converted to internal objects
- */
- if (ExternalParams && ExternalParams->Count)
- {
- /*
- * Allocate a new parameter block for the internal objects
- * Add 1 to count to allow for null terminated internal list
- */
- Info->Parameters = ACPI_ALLOCATE_ZEROED (
- ((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *));
- if (!Info->Parameters)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Convert each external object in the list to an internal object */
-
- for (i = 0; i < ExternalParams->Count; i++)
- {
- Status = AcpiUtCopyEobjectToIobject (
- &ExternalParams->Pointer[i], &Info->Parameters[i]);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
- }
- Info->Parameters[ExternalParams->Count] = NULL;
- }
-
- /*
- * Three major cases:
- * 1) Fully qualified pathname
- * 2) No handle, not fully qualified pathname (error)
- * 3) Valid handle
- */
- if ((Pathname) &&
- (AcpiNsValidRootPrefix (Pathname[0])))
- {
- /* The path is fully qualified, just evaluate by name */
-
- Info->PrefixNode = NULL;
- Status = AcpiNsEvaluate (Info);
- }
- else if (!Handle)
- {
- /*
- * A handle is optional iff a fully qualified pathname is specified.
- * Since we've already handled fully qualified names above, this is
- * an error
- */
- if (!Pathname)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Both Handle and Pathname are NULL"));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Null Handle with relative pathname [%s]", Pathname));
- }
-
- Status = AE_BAD_PARAMETER;
- }
- else
- {
- /* We have a namespace a node and a possible relative path */
-
- Status = AcpiNsEvaluate (Info);
- }
-
- /*
- * If we are expecting a return value, and all went well above,
- * copy the return value to an external object.
- */
- if (ReturnBuffer)
- {
- if (!Info->ReturnObject)
- {
- ReturnBuffer->Length = 0;
- }
- else
- {
- if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
- ACPI_DESC_TYPE_NAMED)
- {
- /*
- * If we received a NS Node as a return object, this means that
- * the object we are evaluating has nothing interesting to
- * return (such as a mutex, etc.) We return an error because
- * these types are essentially unsupported by this interface.
- * We don't check up front because this makes it easier to add
- * support for various types at a later date if necessary.
- */
- Status = AE_TYPE;
- Info->ReturnObject = NULL; /* No need to delete a NS Node */
- ReturnBuffer->Length = 0;
- }
-
- if (ACPI_SUCCESS (Status))
- {
- /* Dereference Index and RefOf references */
-
- AcpiNsResolveReferences (Info);
-
- /* Get the size of the returned object */
-
- Status = AcpiUtGetObjectSize (Info->ReturnObject,
- &BufferSpaceNeeded);
- if (ACPI_SUCCESS (Status))
- {
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (ReturnBuffer,
- BufferSpaceNeeded);
- if (ACPI_FAILURE (Status))
- {
- /*
- * Caller's buffer is too small or a new one can't
- * be allocated
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Needed buffer size %X, %s\n",
- (UINT32) BufferSpaceNeeded,
- AcpiFormatException (Status)));
- }
- else
- {
- /* We have enough space for the object, build it */
-
- Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject,
- ReturnBuffer);
- }
- }
- }
- }
- }
-
- if (Info->ReturnObject)
- {
- /*
- * Delete the internal return object. NOTE: Interpreter must be
- * locked to avoid race condition.
- */
- AcpiExEnterInterpreter ();
-
- /* Remove one reference on the return object (should delete it) */
-
- AcpiUtRemoveReference (Info->ReturnObject);
- AcpiExExitInterpreter ();
- }
-
-
-Cleanup:
-
- /* Free the input parameter list (if we created one) */
-
- if (Info->Parameters)
- {
- /* Free the allocated parameter block */
-
- AcpiUtDeleteInternalObjectList (Info->Parameters);
- }
-
- ACPI_FREE (Info);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiEvaluateObject)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsResolveReferences
- *
- * PARAMETERS: Info - Evaluation info block
- *
- * RETURN: Info->ReturnObject is replaced with the dereferenced object
- *
- * DESCRIPTION: Dereference certain reference objects. Called before an
- * internal return object is converted to an external ACPI_OBJECT.
- *
- * Performs an automatic dereference of Index and RefOf reference objects.
- * These reference objects are not supported by the ACPI_OBJECT, so this is a
- * last resort effort to return something useful. Also, provides compatibility
- * with other ACPI implementations.
- *
- * NOTE: does not handle references within returned package objects or nested
- * references, but this support could be added later if found to be necessary.
- *
- ******************************************************************************/
-
-static void
-AcpiNsResolveReferences (
- ACPI_EVALUATE_INFO *Info)
-{
- ACPI_OPERAND_OBJECT *ObjDesc = NULL;
- ACPI_NAMESPACE_NODE *Node;
-
-
- /* We are interested in reference objects only */
-
- if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
- {
- return;
- }
-
- /*
- * Two types of references are supported - those created by Index and
- * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted
- * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle
- * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
- * an ACPI_OBJECT.
- */
- switch (Info->ReturnObject->Reference.Class)
- {
- case ACPI_REFCLASS_INDEX:
-
- ObjDesc = *(Info->ReturnObject->Reference.Where);
- break;
-
- case ACPI_REFCLASS_REFOF:
-
- Node = Info->ReturnObject->Reference.Object;
- if (Node)
- {
- ObjDesc = Node->Object;
- }
- break;
-
- default:
- return;
- }
-
- /* Replace the existing reference object */
-
- if (ObjDesc)
- {
- AcpiUtAddReference (ObjDesc);
- AcpiUtRemoveReference (Info->ReturnObject);
- Info->ReturnObject = ObjDesc;
- }
-
- return;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiWalkNamespace
- *
- * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
- * StartObject - Handle in namespace where search begins
- * MaxDepth - Depth to which search is to reach
- * PreOrderVisit - Called during tree pre-order visit
- * when an object of "Type" is found
- * PostOrderVisit - Called during tree post-order visit
- * when an object of "Type" is found
- * Context - Passed to user function(s) above
- * ReturnValue - Location where return value of
- * UserFunction is put if terminated early
- *
- * RETURNS Return value from the UserFunction if terminated early.
- * Otherwise, returns NULL.
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- * starting (and ending) at the object specified by StartHandle.
- * The callback function is called whenever an object that matches
- * the type parameter is found. If the callback function returns
- * a non-zero value, the search is terminated immediately and this
- * value is returned to the caller.
- *
- * The point of this procedure is to provide a generic namespace
- * walk routine that can be called from multiple places to
- * provide multiple services; the callback function(s) can be
- * tailored to each task, whether it is a print function,
- * a compare function, etc.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiWalkNamespace (
- ACPI_OBJECT_TYPE Type,
- ACPI_HANDLE StartObject,
- UINT32 MaxDepth,
- ACPI_WALK_CALLBACK PreOrderVisit,
- ACPI_WALK_CALLBACK PostOrderVisit,
- void *Context,
- void **ReturnValue)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiWalkNamespace);
-
-
- /* Parameter validation */
-
- if ((Type > ACPI_TYPE_LOCAL_MAX) ||
- (!MaxDepth) ||
- (!PreOrderVisit && !PostOrderVisit))
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /*
- * Need to acquire the namespace reader lock to prevent interference
- * with any concurrent table unloads (which causes the deletion of
- * namespace objects). We cannot allow the deletion of a namespace node
- * while the user function is using it. The exception to this are the
- * nodes created and deleted during control method execution -- these
- * nodes are marked as temporary nodes and are ignored by the namespace
- * walk. Thus, control methods can be executed while holding the
- * namespace deletion lock (and the user function can execute control
- * methods.)
- */
- Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /*
- * Lock the namespace around the walk. The namespace will be
- * unlocked/locked around each call to the user function - since the user
- * function must be allowed to make ACPICA calls itself (for example, it
- * will typically execute control methods during device enumeration.)
- */
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- goto UnlockAndExit;
- }
-
- Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth,
- ACPI_NS_WALK_UNLOCK, PreOrderVisit,
- PostOrderVisit, Context, ReturnValue);
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-
-UnlockAndExit:
- (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiWalkNamespace)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiNsGetDeviceCallback
- *
- * PARAMETERS: Callback from AcpiGetDevice
- *
- * RETURN: Status
- *
- * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non-
- * present devices, or if they specified a HID, it filters based
- * on that.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsGetDeviceCallback (
- ACPI_HANDLE ObjHandle,
- UINT32 NestingLevel,
- void *Context,
- void **ReturnValue)
-{
- ACPI_GET_DEVICES_INFO *Info = Context;
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
- UINT32 Flags;
- ACPI_DEVICE_ID *Hid;
- ACPI_DEVICE_ID_LIST *Cid;
- UINT32 i;
- BOOLEAN Found;
- int NoMatch;
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Node = AcpiNsValidateHandle (ObjHandle);
- Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- if (!Node)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * First, filter based on the device HID and CID.
- *
- * 01/2010: For this case where a specific HID is requested, we don't
- * want to run _STA until we have an actual HID match. Thus, we will
- * not unnecessarily execute _STA on devices for which the caller
- * doesn't care about. Previously, _STA was executed unconditionally
- * on all devices found here.
- *
- * A side-effect of this change is that now we will continue to search
- * for a matching HID even under device trees where the parent device
- * would have returned a _STA that indicates it is not present or
- * not functioning (thus aborting the search on that branch).
- */
- if (Info->Hid != NULL)
- {
- Status = AcpiUtExecute_HID (Node, &Hid);
- if (Status == AE_NOT_FOUND)
- {
- return (AE_OK);
- }
- else if (ACPI_FAILURE (Status))
- {
- return (AE_CTRL_DEPTH);
- }
-
- NoMatch = ACPI_STRCMP (Hid->String, Info->Hid);
- ACPI_FREE (Hid);
-
- if (NoMatch)
- {
- /*
- * HID does not match, attempt match within the
- * list of Compatible IDs (CIDs)
- */
- Status = AcpiUtExecute_CID (Node, &Cid);
- if (Status == AE_NOT_FOUND)
- {
- return (AE_OK);
- }
- else if (ACPI_FAILURE (Status))
- {
- return (AE_CTRL_DEPTH);
- }
-
- /* Walk the CID list */
-
- Found = FALSE;
- for (i = 0; i < Cid->Count; i++)
- {
- if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0)
- {
- /* Found a matching CID */
-
- Found = TRUE;
- break;
- }
- }
-
- ACPI_FREE (Cid);
- if (!Found)
- {
- return (AE_OK);
- }
- }
- }
-
- /* Run _STA to determine if device is present */
-
- Status = AcpiUtExecute_STA (Node, &Flags);
- if (ACPI_FAILURE (Status))
- {
- return (AE_CTRL_DEPTH);
- }
-
- if (!(Flags & ACPI_STA_DEVICE_PRESENT) &&
- !(Flags & ACPI_STA_DEVICE_FUNCTIONING))
- {
- /*
- * Don't examine the children of the device only when the
- * device is neither present nor functional. See ACPI spec,
- * description of _STA for more information.
- */
- return (AE_CTRL_DEPTH);
- }
-
- /* We have a valid device, invoke the user function */
-
- Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context,
- ReturnValue);
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetDevices
- *
- * PARAMETERS: HID - HID to search for. Can be NULL.
- * UserFunction - Called when a matching object is found
- * Context - Passed to user function
- * ReturnValue - Location where return value of
- * UserFunction is put if terminated early
- *
- * RETURNS Return value from the UserFunction if terminated early.
- * Otherwise, returns NULL.
- *
- * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
- * starting (and ending) at the object specified by StartHandle.
- * The UserFunction is called whenever an object of type
- * Device is found. If the user function returns
- * a non-zero value, the search is terminated immediately and this
- * value is returned to the caller.
- *
- * This is a wrapper for WalkNamespace, but the callback performs
- * additional filtering. Please see AcpiNsGetDeviceCallback.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetDevices (
- char *HID,
- ACPI_WALK_CALLBACK UserFunction,
- void *Context,
- void **ReturnValue)
-{
- ACPI_STATUS Status;
- ACPI_GET_DEVICES_INFO Info;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetDevices);
-
-
- /* Parameter validation */
-
- if (!UserFunction)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /*
- * We're going to call their callback from OUR callback, so we need
- * to know what it is, and their context parameter.
- */
- Info.Hid = HID;
- Info.Context = Context;
- Info.UserFunction = UserFunction;
-
- /*
- * Lock the namespace around the walk.
- * The namespace will be unlocked/locked around each call
- * to the user function - since this function
- * must be allowed to make Acpi calls itself.
- */
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
- AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue);
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetDevices)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiAttachData
- *
- * PARAMETERS: ObjHandle - Namespace node
- * Handler - Handler for this attachment
- * Data - Pointer to data to be attached
- *
- * RETURN: Status
- *
- * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiAttachData (
- ACPI_HANDLE ObjHandle,
- ACPI_OBJECT_HANDLER Handler,
- void *Data)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!ObjHandle ||
- !Handler ||
- !Data)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Convert and validate the handle */
-
- Node = AcpiNsValidateHandle (ObjHandle);
- if (!Node)
- {
- Status = AE_BAD_PARAMETER;
- goto UnlockAndExit;
- }
-
- Status = AcpiNsAttachData (Node, Handler, Data);
-
-UnlockAndExit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiAttachData)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDetachData
- *
- * PARAMETERS: ObjHandle - Namespace node handle
- * Handler - Handler used in call to AcpiAttachData
- *
- * RETURN: Status
- *
- * DESCRIPTION: Remove data that was previously attached to a node.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDetachData (
- ACPI_HANDLE ObjHandle,
- ACPI_OBJECT_HANDLER Handler)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!ObjHandle ||
- !Handler)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Convert and validate the handle */
-
- Node = AcpiNsValidateHandle (ObjHandle);
- if (!Node)
- {
- Status = AE_BAD_PARAMETER;
- goto UnlockAndExit;
- }
-
- Status = AcpiNsDetachData (Node, Handler);
-
-UnlockAndExit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiDetachData)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetData
- *
- * PARAMETERS: ObjHandle - Namespace node
- * Handler - Handler used in call to AttachData
- * Data - Where the data is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetData (
- ACPI_HANDLE ObjHandle,
- ACPI_OBJECT_HANDLER Handler,
- void **Data)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!ObjHandle ||
- !Handler ||
- !Data)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Convert and validate the handle */
-
- Node = AcpiNsValidateHandle (ObjHandle);
- if (!Node)
- {
- Status = AE_BAD_PARAMETER;
- goto UnlockAndExit;
- }
-
- Status = AcpiNsGetAttachedData (Node, Handler, Data);
-
-UnlockAndExit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetData)
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsxfname.c
--- a/head/sys/contrib/dev/acpica/namespace/nsxfname.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,702 +0,0 @@
-/******************************************************************************
- *
- * Module Name: nsxfname - Public interfaces to the ACPI subsystem
- * ACPI Namespace oriented 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.
- */
-
-#define __NSXFNAME_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/acparser.h>
-#include <contrib/dev/acpica/include/amlcode.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsxfname")
-
-/* Local prototypes */
-
-static char *
-AcpiNsCopyDeviceId (
- ACPI_DEVICE_ID *Dest,
- ACPI_DEVICE_ID *Source,
- char *StringArea);
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiGetHandle
- *
- * PARAMETERS: Parent - Object to search under (search scope).
- * Pathname - Pointer to an asciiz string containing the
- * name
- * RetHandle - Where the return handle is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This routine will search for a caller specified name in the
- * name space. The caller can restrict the search region by
- * specifying a non NULL parent. The parent value is itself a
- * namespace handle.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetHandle (
- ACPI_HANDLE Parent,
- ACPI_STRING Pathname,
- ACPI_HANDLE *RetHandle)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node = NULL;
- ACPI_NAMESPACE_NODE *PrefixNode = NULL;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Parameter Validation */
-
- if (!RetHandle || !Pathname)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Convert a parent handle to a prefix node */
-
- if (Parent)
- {
- PrefixNode = AcpiNsValidateHandle (Parent);
- if (!PrefixNode)
- {
- return (AE_BAD_PARAMETER);
- }
- }
-
- /*
- * Valid cases are:
- * 1) Fully qualified pathname
- * 2) Parent + Relative pathname
- *
- * Error for <null Parent + relative path>
- */
- if (AcpiNsValidRootPrefix (Pathname[0]))
- {
- /* Pathname is fully qualified (starts with '\') */
-
- /* Special case for root-only, since we can't search for it */
-
- if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH))
- {
- *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode);
- return (AE_OK);
- }
- }
- else if (!PrefixNode)
- {
- /* Relative path with null prefix is disallowed */
-
- return (AE_BAD_PARAMETER);
- }
-
- /* Find the Node and convert to a handle */
-
- Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node);
- if (ACPI_SUCCESS (Status))
- {
- *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
- }
-
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetHandle)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiGetName
- *
- * PARAMETERS: Handle - Handle to be converted to a pathname
- * NameType - Full pathname or single segment
- * Buffer - Buffer for returned path
- *
- * RETURN: Pointer to a string containing the fully qualified Name.
- *
- * DESCRIPTION: This routine returns the fully qualified name associated with
- * the Handle parameter. This and the AcpiPathnameToHandle are
- * complementary functions.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetName (
- ACPI_HANDLE Handle,
- UINT32 NameType,
- ACPI_BUFFER *Buffer)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- /* Parameter validation */
-
- if (NameType > ACPI_NAME_TYPE_MAX)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtValidateBuffer (Buffer);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- if (NameType == ACPI_FULL_PATHNAME)
- {
- /* Get the full pathname (From the namespace root) */
-
- Status = AcpiNsHandleToPathname (Handle, Buffer);
- return (Status);
- }
-
- /*
- * Wants the single segment ACPI name.
- * Validate handle and convert to a namespace Node
- */
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Node = AcpiNsValidateHandle (Handle);
- if (!Node)
- {
- Status = AE_BAD_PARAMETER;
- goto UnlockAndExit;
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH);
- if (ACPI_FAILURE (Status))
- {
- goto UnlockAndExit;
- }
-
- /* Just copy the ACPI name from the Node and zero terminate it */
-
- ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node),
- ACPI_NAME_SIZE);
- ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0;
- Status = AE_OK;
-
-
-UnlockAndExit:
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetName)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiNsCopyDeviceId
- *
- * PARAMETERS: Dest - Pointer to the destination DEVICE_ID
- * Source - Pointer to the source DEVICE_ID
- * StringArea - Pointer to where to copy the dest string
- *
- * RETURN: Pointer to the next string area
- *
- * DESCRIPTION: Copy a single DEVICE_ID, including the string data.
- *
- ******************************************************************************/
-
-static char *
-AcpiNsCopyDeviceId (
- ACPI_DEVICE_ID *Dest,
- ACPI_DEVICE_ID *Source,
- char *StringArea)
-{
- /* Create the destination DEVICE_ID */
-
- Dest->String = StringArea;
- Dest->Length = Source->Length;
-
- /* Copy actual string and return a pointer to the next string area */
-
- ACPI_MEMCPY (StringArea, Source->String, Source->Length);
- return (StringArea + Source->Length);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiGetObjectInfo
- *
- * PARAMETERS: Handle - Object Handle
- * ReturnBuffer - Where the info is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Returns information about an object as gleaned from the
- * namespace node and possibly by running several standard
- * control methods (Such as in the case of a device.)
- *
- * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA,
- * _ADR, _SxW, and _SxD methods.
- *
- * Note: Allocates the return buffer, must be freed by the caller.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetObjectInfo (
- ACPI_HANDLE Handle,
- ACPI_DEVICE_INFO **ReturnBuffer)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_DEVICE_INFO *Info;
- ACPI_DEVICE_ID_LIST *CidList = NULL;
- ACPI_DEVICE_ID *Hid = NULL;
- ACPI_DEVICE_ID *Uid = NULL;
- char *NextIdString;
- ACPI_OBJECT_TYPE Type;
- ACPI_NAME Name;
- UINT8 ParamCount= 0;
- UINT8 Valid = 0;
- UINT32 InfoSize;
- UINT32 i;
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!Handle || !ReturnBuffer)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- Node = AcpiNsValidateHandle (Handle);
- if (!Node)
- {
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (AE_BAD_PARAMETER);
- }
-
- /* Get the namespace node data while the namespace is locked */
-
- InfoSize = sizeof (ACPI_DEVICE_INFO);
- Type = Node->Type;
- Name = Node->Name.Integer;
-
- if (Node->Type == ACPI_TYPE_METHOD)
- {
- ParamCount = Node->Object->Method.ParamCount;
- }
-
- Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- if ((Type == ACPI_TYPE_DEVICE) ||
- (Type == ACPI_TYPE_PROCESSOR))
- {
- /*
- * Get extra info for ACPI Device/Processor objects only:
- * Run the Device _HID, _UID, and _CID methods.
- *
- * Note: none of these methods are required, so they may or may
- * not be present for this device. The Info->Valid bitfield is used
- * to indicate which methods were found and run successfully.
- */
-
- /* Execute the Device._HID method */
-
- Status = AcpiUtExecute_HID (Node, &Hid);
- if (ACPI_SUCCESS (Status))
- {
- InfoSize += Hid->Length;
- Valid |= ACPI_VALID_HID;
- }
-
- /* Execute the Device._UID method */
-
- Status = AcpiUtExecute_UID (Node, &Uid);
- if (ACPI_SUCCESS (Status))
- {
- InfoSize += Uid->Length;
- Valid |= ACPI_VALID_UID;
- }
-
- /* Execute the Device._CID method */
-
- Status = AcpiUtExecute_CID (Node, &CidList);
- if (ACPI_SUCCESS (Status))
- {
- /* Add size of CID strings and CID pointer array */
-
- InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST));
- Valid |= ACPI_VALID_CID;
- }
- }
-
- /*
- * Now that we have the variable-length data, we can allocate the
- * return buffer
- */
- Info = ACPI_ALLOCATE_ZEROED (InfoSize);
- if (!Info)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Get the fixed-length data */
-
- if ((Type == ACPI_TYPE_DEVICE) ||
- (Type == ACPI_TYPE_PROCESSOR))
- {
- /*
- * Get extra info for ACPI Device/Processor objects only:
- * Run the _STA, _ADR and, SxW, and _SxD methods.
- *
- * Note: none of these methods are required, so they may or may
- * not be present for this device. The Info->Valid bitfield is used
- * to indicate which methods were found and run successfully.
- */
-
- /* Execute the Device._STA method */
-
- Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus);
- if (ACPI_SUCCESS (Status))
- {
- Valid |= ACPI_VALID_STA;
- }
-
- /* Execute the Device._ADR method */
-
- Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node,
- &Info->Address);
- if (ACPI_SUCCESS (Status))
- {
- Valid |= ACPI_VALID_ADR;
- }
-
- /* Execute the Device._SxW methods */
-
- Status = AcpiUtExecutePowerMethods (Node,
- AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS,
- Info->LowestDstates);
- if (ACPI_SUCCESS (Status))
- {
- Valid |= ACPI_VALID_SXWS;
- }
-
- /* Execute the Device._SxD methods */
-
- Status = AcpiUtExecutePowerMethods (Node,
- AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS,
- Info->HighestDstates);
- if (ACPI_SUCCESS (Status))
- {
- Valid |= ACPI_VALID_SXDS;
- }
- }
-
- /*
- * Create a pointer to the string area of the return buffer.
- * Point to the end of the base ACPI_DEVICE_INFO structure.
- */
- NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids);
- if (CidList)
- {
- /* Point past the CID DEVICE_ID array */
-
- NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID));
- }
-
- /*
- * Copy the HID, UID, and CIDs to the return buffer. The variable-length
- * strings are copied to the reserved area at the end of the buffer.
- *
- * For HID and CID, check if the ID is a PCI Root Bridge.
- */
- if (Hid)
- {
- NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId,
- Hid, NextIdString);
-
- if (AcpiUtIsPciRootBridge (Hid->String))
- {
- Info->Flags |= ACPI_PCI_ROOT_BRIDGE;
- }
- }
-
- if (Uid)
- {
- NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId,
- Uid, NextIdString);
- }
-
- if (CidList)
- {
- Info->CompatibleIdList.Count = CidList->Count;
- Info->CompatibleIdList.ListSize = CidList->ListSize;
-
- /* Copy each CID */
-
- for (i = 0; i < CidList->Count; i++)
- {
- NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i],
- &CidList->Ids[i], NextIdString);
-
- if (AcpiUtIsPciRootBridge (CidList->Ids[i].String))
- {
- Info->Flags |= ACPI_PCI_ROOT_BRIDGE;
- }
- }
- }
-
- /* Copy the fixed-length data */
-
- Info->InfoSize = InfoSize;
- Info->Type = Type;
- Info->Name = Name;
- Info->ParamCount = ParamCount;
- Info->Valid = Valid;
-
- *ReturnBuffer = Info;
- Status = AE_OK;
-
-
-Cleanup:
- if (Hid)
- {
- ACPI_FREE (Hid);
- }
- if (Uid)
- {
- ACPI_FREE (Uid);
- }
- if (CidList)
- {
- ACPI_FREE (CidList);
- }
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiInstallMethod
- *
- * PARAMETERS: Buffer - An ACPI table containing one control method
- *
- * RETURN: Status
- *
- * DESCRIPTION: Install a control method into the namespace. If the method
- * name already exists in the namespace, it is overwritten. The
- * input buffer must contain a valid DSDT or SSDT containing a
- * single control method.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiInstallMethod (
- UINT8 *Buffer)
-{
- ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer);
- UINT8 *AmlBuffer;
- UINT8 *AmlStart;
- char *Path;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_OPERAND_OBJECT *MethodObj;
- ACPI_PARSE_STATE ParserState;
- UINT32 AmlLength;
- UINT16 Opcode;
- UINT8 MethodFlags;
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!Buffer)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Table must be a DSDT or SSDT */
-
- if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) &&
- !ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
- {
- return (AE_BAD_HEADER);
- }
-
- /* First AML opcode in the table must be a control method */
-
- ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER);
- Opcode = AcpiPsPeekOpcode (&ParserState);
- if (Opcode != AML_METHOD_OP)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Extract method information from the raw AML */
-
- ParserState.Aml += AcpiPsGetOpcodeSize (Opcode);
- ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState);
- Path = AcpiPsGetNextNamestring (&ParserState);
- MethodFlags = *ParserState.Aml++;
- AmlStart = ParserState.Aml;
- AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart);
-
- /*
- * Allocate resources up-front. We don't want to have to delete a new
- * node from the namespace if we cannot allocate memory.
- */
- AmlBuffer = ACPI_ALLOCATE (AmlLength);
- if (!AmlBuffer)
- {
- return (AE_NO_MEMORY);
- }
-
- MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
- if (!MethodObj)
- {
- ACPI_FREE (AmlBuffer);
- return (AE_NO_MEMORY);
- }
-
- /* Lock namespace for AcpiNsLookup, we may be creating a new node */
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- goto ErrorExit;
- }
-
- /* The lookup either returns an existing node or creates a new one */
-
- Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1,
- ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node);
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-
- if (ACPI_FAILURE (Status)) /* NsLookup */
- {
- if (Status != AE_ALREADY_EXISTS)
- {
- goto ErrorExit;
- }
-
- /* Node existed previously, make sure it is a method node */
-
- if (Node->Type != ACPI_TYPE_METHOD)
- {
- Status = AE_TYPE;
- goto ErrorExit;
- }
- }
-
- /* Copy the method AML to the local buffer */
-
- ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength);
-
- /* Initialize the method object with the new method's information */
-
- MethodObj->Method.AmlStart = AmlBuffer;
- MethodObj->Method.AmlLength = AmlLength;
-
- MethodObj->Method.ParamCount = (UINT8)
- (MethodFlags & AML_METHOD_ARG_COUNT);
-
- if (MethodFlags & AML_METHOD_SERIALIZED)
- {
- MethodObj->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
-
- MethodObj->Method.SyncLevel = (UINT8)
- ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
- }
-
- /*
- * Now that it is complete, we can attach the new method object to
- * the method Node (detaches/deletes any existing object)
- */
- Status = AcpiNsAttachObject (Node, MethodObj, ACPI_TYPE_METHOD);
-
- /*
- * Flag indicates AML buffer is dynamic, must be deleted later.
- * Must be set only after attach above.
- */
- Node->Flags |= ANOBJ_ALLOCATED_BUFFER;
-
- /* Remove local reference to the method object */
-
- AcpiUtRemoveReference (MethodObj);
- return (Status);
-
-
-ErrorExit:
-
- ACPI_FREE (AmlBuffer);
- ACPI_FREE (MethodObj);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInstallMethod)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/namespace/nsxfobj.c
--- a/head/sys/contrib/dev/acpica/namespace/nsxfobj.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,285 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
- * ACPI Object oriented 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.
- */
-
-
-#define __NSXFOBJ_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_NAMESPACE
- ACPI_MODULE_NAME ("nsxfobj")
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetType
- *
- * PARAMETERS: Handle - Handle of object whose type is desired
- * RetType - Where the type will be placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: This routine returns the type associatd with a particular handle
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetType (
- ACPI_HANDLE Handle,
- ACPI_OBJECT_TYPE *RetType)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
-
-
- /* Parameter Validation */
-
- if (!RetType)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * Special case for the predefined Root Node
- * (return type ANY)
- */
- if (Handle == ACPI_ROOT_OBJECT)
- {
- *RetType = ACPI_TYPE_ANY;
- return (AE_OK);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Convert and validate the handle */
-
- Node = AcpiNsValidateHandle (Handle);
- if (!Node)
- {
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (AE_BAD_PARAMETER);
- }
-
- *RetType = Node->Type;
-
-
- Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetType)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetParent
- *
- * PARAMETERS: Handle - Handle of object whose parent is desired
- * RetHandle - Where the parent handle will be placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: Returns a handle to the parent of the object represented by
- * Handle.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetParent (
- ACPI_HANDLE Handle,
- ACPI_HANDLE *RetHandle)
-{
- ACPI_NAMESPACE_NODE *Node;
- ACPI_NAMESPACE_NODE *ParentNode;
- ACPI_STATUS Status;
-
-
- if (!RetHandle)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Special case for the predefined Root Node (no parent) */
-
- if (Handle == ACPI_ROOT_OBJECT)
- {
- return (AE_NULL_ENTRY);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Convert and validate the handle */
-
- Node = AcpiNsValidateHandle (Handle);
- if (!Node)
- {
- Status = AE_BAD_PARAMETER;
- goto UnlockAndExit;
- }
-
- /* Get the parent entry */
-
- ParentNode = Node->Parent;
- *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode);
-
- /* Return exception if parent is null */
-
- if (!ParentNode)
- {
- Status = AE_NULL_ENTRY;
- }
-
-
-UnlockAndExit:
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetParent)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetNextObject
- *
- * PARAMETERS: Type - Type of object to be searched for
- * Parent - Parent object whose children we are getting
- * LastChild - Previous child that was found.
- * The NEXT child will be returned
- * RetHandle - Where handle to the next object is placed
- *
- * RETURN: Status
- *
- * DESCRIPTION: Return the next peer object within the namespace. If Handle is
- * valid, Scope is ignored. Otherwise, the first object within
- * Scope is returned.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetNextObject (
- ACPI_OBJECT_TYPE Type,
- ACPI_HANDLE Parent,
- ACPI_HANDLE Child,
- ACPI_HANDLE *RetHandle)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_NAMESPACE_NODE *ParentNode = NULL;
- ACPI_NAMESPACE_NODE *ChildNode = NULL;
-
-
- /* Parameter validation */
-
- if (Type > ACPI_TYPE_EXTERNAL_MAX)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* If null handle, use the parent */
-
- if (!Child)
- {
- /* Start search at the beginning of the specified scope */
-
- ParentNode = AcpiNsValidateHandle (Parent);
- if (!ParentNode)
- {
- Status = AE_BAD_PARAMETER;
- goto UnlockAndExit;
- }
- }
- else
- {
- /* Non-null handle, ignore the parent */
- /* Convert and validate the handle */
-
- ChildNode = AcpiNsValidateHandle (Child);
- if (!ChildNode)
- {
- Status = AE_BAD_PARAMETER;
- goto UnlockAndExit;
- }
- }
-
- /* Internal function does the real work */
-
- Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode);
- if (!Node)
- {
- Status = AE_NOT_FOUND;
- goto UnlockAndExit;
- }
-
- if (RetHandle)
- {
- *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
- }
-
-
-UnlockAndExit:
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetNextObject)
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c
--- a/head/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c Fri Mar 02 17:09:07 2012 +0200
@@ -214,6 +214,33 @@
/******************************************************************************
*
+ * FUNCTION: AcpiOsPhysicalTableOverride
+ *
+ * PARAMETERS: ExistingTable - Header of current table (probably firmware)
+ * NewAddress - Where new table address is returned
+ * (Physical address)
+ * NewTableLength - Where new table length is returned
+ *
+ * RETURN: Status, address/length of new table. Null pointer returned
+ * if no table is available to override.
+ *
+ * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsPhysicalTableOverride (
+ ACPI_TABLE_HEADER *ExistingTable,
+ ACPI_PHYSICAL_ADDRESS *NewAddress,
+ UINT32 *NewTableLength)
+{
+
+ return (AE_SUPPORT);
+}
+
+
+/******************************************************************************
+ *
* FUNCTION: AcpiOsRedirectOutput
*
* PARAMETERS: Destination - An open file handle/pointer
@@ -1017,9 +1044,10 @@
*
* PARAMETERS: Address - Physical Memory Address to read
* Value - Where value is placed
- * Width - Number of bits
+ * Width - Number of bits (8,16,32, or 64)
*
- * RETURN: Value read from physical memory address
+ * RETURN: Value read from physical memory address. Always returned
+ * as a 64-bit integer, regardless of the read width.
*
* DESCRIPTION: Read data from a physical memory address
*
@@ -1028,7 +1056,7 @@
ACPI_STATUS
AcpiOsReadMemory (
ACPI_PHYSICAL_ADDRESS Address,
- UINT32 *Value,
+ UINT64 *Value,
UINT32 Width)
{
@@ -1037,6 +1065,7 @@
case 8:
case 16:
case 32:
+ case 64:
*Value = 0;
break;
@@ -1053,7 +1082,7 @@
*
* PARAMETERS: Address - Physical Memory Address to write
* Value - Value to write
- * Width - Number of bits
+ * Width - Number of bits (8,16,32, or 64)
*
* RETURN: None
*
@@ -1064,7 +1093,7 @@
ACPI_STATUS
AcpiOsWriteMemory (
ACPI_PHYSICAL_ADDRESS Address,
- UINT32 Value,
+ UINT64 Value,
UINT32 Width)
{
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/psargs.c
--- a/head/sys/contrib/dev/acpica/parser/psargs.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,940 +0,0 @@
-/******************************************************************************
- *
- * Module Name: psargs - Parse AML opcode arguments
- *
- *****************************************************************************/
-
-/*
- * 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 __PSARGS_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/acnamesp.h>
-#include <contrib/dev/acpica/include/acdispat.h>
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("psargs")
-
-/* Local prototypes */
-
-static UINT32
-AcpiPsGetNextPackageLength (
- ACPI_PARSE_STATE *ParserState);
-
-static ACPI_PARSE_OBJECT *
-AcpiPsGetNextField (
- ACPI_PARSE_STATE *ParserState);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetNextPackageLength
- *
- * PARAMETERS: ParserState - Current parser state object
- *
- * RETURN: Decoded package length. On completion, the AML pointer points
- * past the length byte or bytes.
- *
- * DESCRIPTION: Decode and return a package length field.
- * Note: Largest package length is 28 bits, from ACPI specification
- *
- ******************************************************************************/
-
-static UINT32
-AcpiPsGetNextPackageLength (
- ACPI_PARSE_STATE *ParserState)
-{
- UINT8 *Aml = ParserState->Aml;
- UINT32 PackageLength = 0;
- UINT32 ByteCount;
- UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */
-
-
- ACPI_FUNCTION_TRACE (PsGetNextPackageLength);
-
-
- /*
- * Byte 0 bits [6:7] contain the number of additional bytes
- * used to encode the package length, either 0,1,2, or 3
- */
- ByteCount = (Aml[0] >> 6);
- ParserState->Aml += ((ACPI_SIZE) ByteCount + 1);
-
- /* Get bytes 3, 2, 1 as needed */
-
- while (ByteCount)
- {
- /*
- * Final bit positions for the package length bytes:
- * Byte3->[20:27]
- * Byte2->[12:19]
- * Byte1->[04:11]
- * Byte0->[00:03]
- */
- PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4));
-
- ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */
- ByteCount--;
- }
-
- /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
-
- PackageLength |= (Aml[0] & ByteZeroMask);
- return_UINT32 (PackageLength);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetNextPackageEnd
- *
- * PARAMETERS: ParserState - Current parser state object
- *
- * RETURN: Pointer to end-of-package +1
- *
- * DESCRIPTION: Get next package length and return a pointer past the end of
- * the package. Consumes the package length field
- *
- ******************************************************************************/
-
-UINT8 *
-AcpiPsGetNextPackageEnd (
- ACPI_PARSE_STATE *ParserState)
-{
- UINT8 *Start = ParserState->Aml;
- UINT32 PackageLength;
-
-
- ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
-
-
- /* Function below updates ParserState->Aml */
-
- PackageLength = AcpiPsGetNextPackageLength (ParserState);
-
- return_PTR (Start + PackageLength); /* end of package */
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetNextNamestring
- *
- * PARAMETERS: ParserState - Current parser state object
- *
- * RETURN: Pointer to the start of the name string (pointer points into
- * the AML.
- *
- * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
- * prefix characters. Set parser state to point past the string.
- * (Name is consumed from the AML.)
- *
- ******************************************************************************/
-
-char *
-AcpiPsGetNextNamestring (
- ACPI_PARSE_STATE *ParserState)
-{
- UINT8 *Start = ParserState->Aml;
- UINT8 *End = ParserState->Aml;
-
-
- ACPI_FUNCTION_TRACE (PsGetNextNamestring);
-
-
- /* Point past any namestring prefix characters (backslash or carat) */
-
- while (AcpiPsIsPrefixChar (*End))
- {
- End++;
- }
-
- /* Decode the path prefix character */
-
- switch (*End)
- {
- case 0:
-
- /* NullName */
-
- if (End == Start)
- {
- Start = NULL;
- }
- End++;
- break;
-
- case AML_DUAL_NAME_PREFIX:
-
- /* Two name segments */
-
- End += 1 + (2 * ACPI_NAME_SIZE);
- break;
-
- case AML_MULTI_NAME_PREFIX_OP:
-
- /* Multiple name segments, 4 chars each, count in next byte */
-
- End += 2 + (*(End + 1) * ACPI_NAME_SIZE);
- break;
-
- default:
-
- /* Single name segment */
-
- End += ACPI_NAME_SIZE;
- break;
- }
-
- ParserState->Aml = End;
- return_PTR ((char *) Start);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetNextNamepath
- *
- * PARAMETERS: ParserState - Current parser state object
- * Arg - Where the namepath will be stored
- * ArgCount - If the namepath points to a control method
- * the method's argument is returned here.
- * PossibleMethodCall - Whether the namepath can possibly be the
- * start of a method call
- *
- * RETURN: Status
- *
- * DESCRIPTION: Get next name (if method call, return # of required args).
- * Names are looked up in the internal namespace to determine
- * if the name represents a control method. If a method
- * is found, the number of arguments to the method is returned.
- * This information is critical for parsing to continue correctly.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsGetNextNamepath (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_STATE *ParserState,
- ACPI_PARSE_OBJECT *Arg,
- BOOLEAN PossibleMethodCall)
-{
- ACPI_STATUS Status;
- char *Path;
- ACPI_PARSE_OBJECT *NameOp;
- ACPI_OPERAND_OBJECT *MethodDesc;
- ACPI_NAMESPACE_NODE *Node;
- UINT8 *Start = ParserState->Aml;
-
-
- ACPI_FUNCTION_TRACE (PsGetNextNamepath);
-
-
- Path = AcpiPsGetNextNamestring (ParserState);
- AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
-
- /* Null path case is allowed, just exit */
-
- if (!Path)
- {
- Arg->Common.Value.Name = Path;
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Lookup the name in the internal namespace, starting with the current
- * scope. We don't want to add anything new to the namespace here,
- * however, so we use MODE_EXECUTE.
- * Allow searching of the parent tree, but don't open a new scope -
- * we just want to lookup the object (must be mode EXECUTE to perform
- * the upsearch)
- */
- Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
- ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
- ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
-
- /*
- * If this name is a control method invocation, we must
- * setup the method call
- */
- if (ACPI_SUCCESS (Status) &&
- PossibleMethodCall &&
- (Node->Type == ACPI_TYPE_METHOD))
- {
- if (WalkState->Opcode == AML_UNLOAD_OP)
- {
- /*
- * AcpiPsGetNextNamestring has increased the AML pointer,
- * so we need to restore the saved AML pointer for method call.
- */
- WalkState->ParserState.Aml = Start;
- WalkState->ArgCount = 1;
- AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
- return_ACPI_STATUS (AE_OK);
- }
-
- /* This name is actually a control method invocation */
-
- MethodDesc = AcpiNsGetAttachedObject (Node);
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path));
-
- NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
- if (!NameOp)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Change Arg into a METHOD CALL and attach name to it */
-
- AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
- NameOp->Common.Value.Name = Path;
-
- /* Point METHODCALL/NAME to the METHOD Node */
-
- NameOp->Common.Node = Node;
- AcpiPsAppendArg (Arg, NameOp);
-
- if (!MethodDesc)
- {
- ACPI_ERROR ((AE_INFO,
- "Control Method %p has no attached object",
- Node));
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "Control Method - %p Args %X\n",
- Node, MethodDesc->Method.ParamCount));
-
- /* Get the number of arguments to expect */
-
- WalkState->ArgCount = MethodDesc->Method.ParamCount;
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Special handling if the name was not found during the lookup -
- * some NotFound cases are allowed
- */
- if (Status == AE_NOT_FOUND)
- {
- /* 1) NotFound is ok during load pass 1/2 (allow forward references) */
-
- if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
- ACPI_PARSE_EXECUTE)
- {
- Status = AE_OK;
- }
-
- /* 2) NotFound during a CondRefOf(x) is ok by definition */
-
- else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP)
- {
- Status = AE_OK;
- }
-
- /*
- * 3) NotFound while building a Package is ok at this point, we
- * may flag as an error later if slack mode is not enabled.
- * (Some ASL code depends on allowing this behavior)
- */
- else if ((Arg->Common.Parent) &&
- ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
- {
- Status = AE_OK;
- }
- }
-
- /* Final exception check (may have been changed from code above) */
-
- if (ACPI_FAILURE (Status))
- {
- ACPI_ERROR_NAMESPACE (Path, Status);
-
- if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
- ACPI_PARSE_EXECUTE)
- {
- /* Report a control method execution error */
-
- Status = AcpiDsMethodError (Status, WalkState);
- }
- }
-
- /* Save the namepath */
-
- Arg->Common.Value.Name = Path;
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetNextSimpleArg
- *
- * PARAMETERS: ParserState - Current parser state object
- * ArgType - The argument type (AML_*_ARG)
- * Arg - Where the argument is returned
- *
- * RETURN: None
- *
- * DESCRIPTION: Get the next simple argument (constant, string, or namestring)
- *
- ******************************************************************************/
-
-void
-AcpiPsGetNextSimpleArg (
- ACPI_PARSE_STATE *ParserState,
- UINT32 ArgType,
- ACPI_PARSE_OBJECT *Arg)
-{
- UINT32 Length;
- UINT16 Opcode;
- UINT8 *Aml = ParserState->Aml;
-
-
- ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
-
-
- switch (ArgType)
- {
- case ARGP_BYTEDATA:
-
- /* Get 1 byte from the AML stream */
-
- Opcode = AML_BYTE_OP;
- Arg->Common.Value.Integer = (UINT64) *Aml;
- Length = 1;
- break;
-
-
- case ARGP_WORDDATA:
-
- /* Get 2 bytes from the AML stream */
-
- Opcode = AML_WORD_OP;
- ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
- Length = 2;
- break;
-
-
- case ARGP_DWORDDATA:
-
- /* Get 4 bytes from the AML stream */
-
- Opcode = AML_DWORD_OP;
- ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
- Length = 4;
- break;
-
-
- case ARGP_QWORDDATA:
-
- /* Get 8 bytes from the AML stream */
-
- Opcode = AML_QWORD_OP;
- ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
- Length = 8;
- break;
-
-
- case ARGP_CHARLIST:
-
- /* Get a pointer to the string, point past the string */
-
- Opcode = AML_STRING_OP;
- Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
-
- /* Find the null terminator */
-
- Length = 0;
- while (Aml[Length])
- {
- Length++;
- }
- Length++;
- break;
-
-
- case ARGP_NAME:
- case ARGP_NAMESTRING:
-
- AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
- Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
- return_VOID;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
- return_VOID;
- }
-
- AcpiPsInitOp (Arg, Opcode);
- ParserState->Aml += Length;
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetNextField
- *
- * PARAMETERS: ParserState - Current parser state object
- *
- * RETURN: A newly allocated FIELD op
- *
- * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
- *
- ******************************************************************************/
-
-static ACPI_PARSE_OBJECT *
-AcpiPsGetNextField (
- ACPI_PARSE_STATE *ParserState)
-{
- UINT32 AmlOffset;
- ACPI_PARSE_OBJECT *Field;
- ACPI_PARSE_OBJECT *Arg = NULL;
- UINT16 Opcode;
- UINT32 Name;
- UINT8 AccessType;
- UINT8 AccessAttribute;
- UINT8 AccessLength;
- UINT32 PkgLength;
- UINT8 *PkgEnd;
- UINT32 BufferLength;
-
-
- ACPI_FUNCTION_TRACE (PsGetNextField);
-
-
- AmlOffset = (UINT32) ACPI_PTR_DIFF (
- ParserState->Aml, ParserState->AmlStart);
-
- /* Determine field type */
-
- switch (ACPI_GET8 (ParserState->Aml))
- {
- case AML_FIELD_OFFSET_OP:
-
- Opcode = AML_INT_RESERVEDFIELD_OP;
- ParserState->Aml++;
- break;
-
- case AML_FIELD_ACCESS_OP:
-
- Opcode = AML_INT_ACCESSFIELD_OP;
- ParserState->Aml++;
- break;
-
- case AML_FIELD_CONNECTION_OP:
-
- Opcode = AML_INT_CONNECTION_OP;
- ParserState->Aml++;
- break;
-
- case AML_FIELD_EXT_ACCESS_OP:
-
- Opcode = AML_INT_EXTACCESSFIELD_OP;
- ParserState->Aml++;
- break;
-
- default:
-
- Opcode = AML_INT_NAMEDFIELD_OP;
- break;
- }
-
- /* Allocate a new field op */
-
- Field = AcpiPsAllocOp (Opcode);
- if (!Field)
- {
- return_PTR (NULL);
- }
-
- Field->Common.AmlOffset = AmlOffset;
-
- /* Decode the field type */
-
- switch (Opcode)
- {
- case AML_INT_NAMEDFIELD_OP:
-
- /* Get the 4-character name */
-
- ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
- AcpiPsSetName (Field, Name);
- ParserState->Aml += ACPI_NAME_SIZE;
-
- /* Get the length which is encoded as a package length */
-
- Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
- break;
-
-
- case AML_INT_RESERVEDFIELD_OP:
-
- /* Get the length which is encoded as a package length */
-
- Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
- break;
-
-
- case AML_INT_ACCESSFIELD_OP:
- case AML_INT_EXTACCESSFIELD_OP:
-
- /*
- * Get AccessType and AccessAttrib and merge into the field Op
- * AccessType is first operand, AccessAttribute is second. stuff
- * these bytes into the node integer value for convenience.
- */
-
- /* Get the two bytes (Type/Attribute) */
-
- AccessType = ACPI_GET8 (ParserState->Aml);
- ParserState->Aml++;
- AccessAttribute = ACPI_GET8 (ParserState->Aml);
- ParserState->Aml++;
-
- Field->Common.Value.Integer = (UINT8) AccessType;
- Field->Common.Value.Integer |= (UINT16) (AccessAttribute << 8);
-
- /* This opcode has a third byte, AccessLength */
-
- if (Opcode == AML_INT_EXTACCESSFIELD_OP)
- {
- AccessLength = ACPI_GET8 (ParserState->Aml);
- ParserState->Aml++;
-
- Field->Common.Value.Integer |= (UINT32) (AccessLength << 16);
- }
- break;
-
-
- case AML_INT_CONNECTION_OP:
-
- /*
- * Argument for Connection operator can be either a Buffer
- * (resource descriptor), or a NameString.
- */
- if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP)
- {
- ParserState->Aml++;
-
- PkgEnd = ParserState->Aml;
- PkgLength = AcpiPsGetNextPackageLength (ParserState);
- PkgEnd += PkgLength;
-
- if (ParserState->Aml < PkgEnd)
- {
- /* Non-empty list */
-
- Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
- if (!Arg)
- {
- return_PTR (NULL);
- }
-
- /* Get the actual buffer length argument */
-
- Opcode = ACPI_GET8 (ParserState->Aml);
- ParserState->Aml++;
-
- switch (Opcode)
- {
- case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
- BufferLength = ACPI_GET8 (ParserState->Aml);
- ParserState->Aml += 1;
- break;
-
- case AML_WORD_OP: /* AML_WORDDATA_ARG */
- BufferLength = ACPI_GET16 (ParserState->Aml);
- ParserState->Aml += 2;
- break;
-
- case AML_DWORD_OP: /* AML_DWORDATA_ARG */
- BufferLength = ACPI_GET32 (ParserState->Aml);
- ParserState->Aml += 4;
- break;
-
- default:
- BufferLength = 0;
- break;
- }
-
- /* Fill in bytelist data */
-
- Arg->Named.Value.Size = BufferLength;
- Arg->Named.Data = ParserState->Aml;
- }
-
- /* Skip to End of byte data */
-
- ParserState->Aml = PkgEnd;
- }
- else
- {
- Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
- if (!Arg)
- {
- return_PTR (NULL);
- }
-
- /* Get the Namestring argument */
-
- Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
- }
-
- /* Link the buffer/namestring to parent (CONNECTION_OP) */
-
- AcpiPsAppendArg (Field, Arg);
- break;
-
-
- default:
-
- /* Opcode was set in previous switch */
- break;
- }
-
- return_PTR (Field);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetNextArg
- *
- * PARAMETERS: WalkState - Current state
- * ParserState - Current parser state object
- * ArgType - The argument type (AML_*_ARG)
- * ReturnArg - Where the next arg is returned
- *
- * RETURN: Status, and an op object containing the next argument.
- *
- * DESCRIPTION: Get next argument (including complex list arguments that require
- * pushing the parser stack)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsGetNextArg (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_STATE *ParserState,
- UINT32 ArgType,
- ACPI_PARSE_OBJECT **ReturnArg)
-{
- ACPI_PARSE_OBJECT *Arg = NULL;
- ACPI_PARSE_OBJECT *Prev = NULL;
- ACPI_PARSE_OBJECT *Field;
- UINT32 Subop;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
-
-
- switch (ArgType)
- {
- case ARGP_BYTEDATA:
- case ARGP_WORDDATA:
- case ARGP_DWORDDATA:
- case ARGP_CHARLIST:
- case ARGP_NAME:
- case ARGP_NAMESTRING:
-
- /* Constants, strings, and namestrings are all the same size */
-
- Arg = AcpiPsAllocOp (AML_BYTE_OP);
- if (!Arg)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
- AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
- break;
-
-
- case ARGP_PKGLENGTH:
-
- /* Package length, nothing returned */
-
- ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
- break;
-
-
- case ARGP_FIELDLIST:
-
- if (ParserState->Aml < ParserState->PkgEnd)
- {
- /* Non-empty list */
-
- while (ParserState->Aml < ParserState->PkgEnd)
- {
- Field = AcpiPsGetNextField (ParserState);
- if (!Field)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- if (Prev)
- {
- Prev->Common.Next = Field;
- }
- else
- {
- Arg = Field;
- }
- Prev = Field;
- }
-
- /* Skip to End of byte data */
-
- ParserState->Aml = ParserState->PkgEnd;
- }
- break;
-
-
- case ARGP_BYTELIST:
-
- if (ParserState->Aml < ParserState->PkgEnd)
- {
- /* Non-empty list */
-
- Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
- if (!Arg)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Fill in bytelist data */
-
- Arg->Common.Value.Size = (UINT32)
- ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
- Arg->Named.Data = ParserState->Aml;
-
- /* Skip to End of byte data */
-
- ParserState->Aml = ParserState->PkgEnd;
- }
- break;
-
-
- case ARGP_TARGET:
- case ARGP_SUPERNAME:
- case ARGP_SIMPLENAME:
-
- Subop = AcpiPsPeekOpcode (ParserState);
- if (Subop == 0 ||
- AcpiPsIsLeadingChar (Subop) ||
- AcpiPsIsPrefixChar (Subop))
- {
- /* NullName or NameString */
-
- Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
- if (!Arg)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* To support SuperName arg of Unload */
-
- if (WalkState->Opcode == AML_UNLOAD_OP)
- {
- Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
-
- /*
- * If the SuperName arg of Unload is a method call,
- * we have restored the AML pointer, just free this Arg
- */
- if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
- {
- AcpiPsFreeOp (Arg);
- Arg = NULL;
- }
- }
- else
- {
- Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
- }
- }
- else
- {
- /* Single complex argument, nothing returned */
-
- WalkState->ArgCount = 1;
- }
- break;
-
-
- case ARGP_DATAOBJ:
- case ARGP_TERMARG:
-
- /* Single complex argument, nothing returned */
-
- WalkState->ArgCount = 1;
- break;
-
-
- case ARGP_DATAOBJLIST:
- case ARGP_TERMLIST:
- case ARGP_OBJLIST:
-
- if (ParserState->Aml < ParserState->PkgEnd)
- {
- /* Non-empty list of variable arguments, nothing returned */
-
- WalkState->ArgCount = ACPI_VAR_ARGS;
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
- Status = AE_AML_OPERAND_TYPE;
- break;
- }
-
- *ReturnArg = Arg;
- return_ACPI_STATUS (Status);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/psloop.c
--- a/head/sys/contrib/dev/acpica/parser/psloop.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1268 +0,0 @@
-/******************************************************************************
- *
- * Module Name: psloop - Main AML parse loop
- *
- *****************************************************************************/
-
-/*
- * 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.
- */
-
-
-/*
- * Parse the AML and build an operation tree as most interpreters, (such as
- * Perl) do. Parsing is done by hand rather than with a YACC generated parser
- * to tightly constrain stack and dynamic memory usage. Parsing is kept
- * flexible and the code fairly compact by parsing based on a list of AML
- * opcode templates in AmlOpInfo[].
- */
-
-#include <contrib/dev/acpica/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/amlcode.h>
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("psloop")
-
-static UINT32 AcpiGbl_Depth = 0;
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiPsGetAmlOpcode (
- ACPI_WALK_STATE *WalkState);
-
-static ACPI_STATUS
-AcpiPsBuildNamedOp (
- ACPI_WALK_STATE *WalkState,
- UINT8 *AmlOpStart,
- ACPI_PARSE_OBJECT *UnnamedOp,
- ACPI_PARSE_OBJECT **Op);
-
-static ACPI_STATUS
-AcpiPsCreateOp (
- ACPI_WALK_STATE *WalkState,
- UINT8 *AmlOpStart,
- ACPI_PARSE_OBJECT **NewOp);
-
-static ACPI_STATUS
-AcpiPsGetArguments (
- ACPI_WALK_STATE *WalkState,
- UINT8 *AmlOpStart,
- ACPI_PARSE_OBJECT *Op);
-
-static ACPI_STATUS
-AcpiPsCompleteOp (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_OBJECT **Op,
- ACPI_STATUS Status);
-
-static ACPI_STATUS
-AcpiPsCompleteFinalOp (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_OBJECT *Op,
- ACPI_STATUS Status);
-
-static void
-AcpiPsLinkModuleCode (
- ACPI_PARSE_OBJECT *ParentOp,
- UINT8 *AmlStart,
- UINT32 AmlLength,
- ACPI_OWNER_ID OwnerId);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetAmlOpcode
- *
- * PARAMETERS: WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Extract the next AML opcode from the input stream.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiPsGetAmlOpcode (
- ACPI_WALK_STATE *WalkState)
-{
-
- ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
-
-
- WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
- WalkState->ParserState.AmlStart);
- WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState));
-
- /*
- * First cut to determine what we have found:
- * 1) A valid AML opcode
- * 2) A name string
- * 3) An unknown/invalid opcode
- */
- WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
-
- switch (WalkState->OpInfo->Class)
- {
- case AML_CLASS_ASCII:
- case AML_CLASS_PREFIX:
- /*
- * Starts with a valid prefix or ASCII char, this is a name
- * string. Convert the bare name string to a namepath.
- */
- WalkState->Opcode = AML_INT_NAMEPATH_OP;
- WalkState->ArgTypes = ARGP_NAMESTRING;
- break;
-
- case AML_CLASS_UNKNOWN:
-
- /* The opcode is unrecognized. Just skip unknown opcodes */
-
- ACPI_ERROR ((AE_INFO,
- "Found unknown opcode 0x%X at AML address %p offset 0x%X, ignoring",
- WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset));
-
- ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128);
-
- /* Assume one-byte bad opcode */
-
- WalkState->ParserState.Aml++;
- return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
-
- default:
-
- /* Found opcode info, this is a normal opcode */
-
- WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode);
- WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
- break;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsBuildNamedOp
- *
- * PARAMETERS: WalkState - Current state
- * AmlOpStart - Begin of named Op in AML
- * UnnamedOp - Early Op (not a named Op)
- * Op - Returned Op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Parse a named Op
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiPsBuildNamedOp (
- ACPI_WALK_STATE *WalkState,
- UINT8 *AmlOpStart,
- ACPI_PARSE_OBJECT *UnnamedOp,
- ACPI_PARSE_OBJECT **Op)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PARSE_OBJECT *Arg = NULL;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState);
-
-
- UnnamedOp->Common.Value.Arg = NULL;
- UnnamedOp->Common.ArgListLength = 0;
- UnnamedOp->Common.AmlOpcode = WalkState->Opcode;
-
- /*
- * Get and append arguments until we find the node that contains
- * the name (the type ARGP_NAME).
- */
- while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
- (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
- {
- Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
- GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- AcpiPsAppendArg (UnnamedOp, Arg);
- INCREMENT_ARG_LIST (WalkState->ArgTypes);
- }
-
- /*
- * Make sure that we found a NAME and didn't run out of arguments
- */
- if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
- {
- return_ACPI_STATUS (AE_AML_NO_OPERAND);
- }
-
- /* We know that this arg is a name, move to next arg */
-
- INCREMENT_ARG_LIST (WalkState->ArgTypes);
-
- /*
- * Find the object. This will either insert the object into
- * the namespace or simply look it up
- */
- WalkState->Op = NULL;
-
- Status = WalkState->DescendingCallback (WalkState, Op);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog"));
- return_ACPI_STATUS (Status);
- }
-
- if (!*Op)
- {
- return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
- }
-
- Status = AcpiPsNextParseState (WalkState, *Op, Status);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_CTRL_PENDING)
- {
- return_ACPI_STATUS (AE_CTRL_PARSE_PENDING);
- }
- return_ACPI_STATUS (Status);
- }
-
- AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
- AcpiGbl_Depth++;
-
- if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
- (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
- {
- /*
- * Defer final parsing of an OperationRegion body, because we don't
- * have enough info in the first pass to parse it correctly (i.e.,
- * there may be method calls within the TermArg elements of the body.)
- *
- * However, we must continue parsing because the opregion is not a
- * standalone package -- we don't know where the end is at this point.
- *
- * (Length is unknown until parse of the body complete)
- */
- (*Op)->Named.Data = AmlOpStart;
- (*Op)->Named.Length = 0;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsCreateOp
- *
- * PARAMETERS: WalkState - Current state
- * AmlOpStart - Op start in AML
- * NewOp - Returned Op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Get Op from AML
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiPsCreateOp (
- ACPI_WALK_STATE *WalkState,
- UINT8 *AmlOpStart,
- ACPI_PARSE_OBJECT **NewOp)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PARSE_OBJECT *Op;
- ACPI_PARSE_OBJECT *NamedOp = NULL;
- ACPI_PARSE_OBJECT *ParentScope;
- UINT8 ArgumentCount;
- const ACPI_OPCODE_INFO *OpInfo;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState);
-
-
- Status = AcpiPsGetAmlOpcode (WalkState);
- if (Status == AE_CTRL_PARSE_CONTINUE)
- {
- return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE);
- }
-
- /* Create Op structure and append to parent's argument list */
-
- WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
- Op = AcpiPsAllocOp (WalkState->Opcode);
- if (!Op)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- if (WalkState->OpInfo->Flags & AML_NAMED)
- {
- Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp);
- AcpiPsFreeOp (Op);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- *NewOp = NamedOp;
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Not a named opcode, just allocate Op and append to parent */
-
- if (WalkState->OpInfo->Flags & AML_CREATE)
- {
- /*
- * Backup to beginning of CreateXXXfield declaration
- * BodyLength is unknown until we parse the body
- */
- Op->Named.Data = AmlOpStart;
- Op->Named.Length = 0;
- }
-
- if (WalkState->Opcode == AML_BANK_FIELD_OP)
- {
- /*
- * Backup to beginning of BankField declaration
- * BodyLength is unknown until we parse the body
- */
- Op->Named.Data = AmlOpStart;
- Op->Named.Length = 0;
- }
-
- ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState));
- AcpiPsAppendArg (ParentScope, Op);
-
- if (ParentScope)
- {
- OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode);
- if (OpInfo->Flags & AML_HAS_TARGET)
- {
- ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type);
- if (ParentScope->Common.ArgListLength > ArgumentCount)
- {
- Op->Common.Flags |= ACPI_PARSEOP_TARGET;
- }
- }
- else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP)
- {
- Op->Common.Flags |= ACPI_PARSEOP_TARGET;
- }
- }
-
- if (WalkState->DescendingCallback != NULL)
- {
- /*
- * Find the object. This will either insert the object into
- * the namespace or simply look it up
- */
- WalkState->Op = *NewOp = Op;
-
- Status = WalkState->DescendingCallback (WalkState, &Op);
- Status = AcpiPsNextParseState (WalkState, Op, Status);
- if (Status == AE_CTRL_PENDING)
- {
- Status = AE_CTRL_PARSE_PENDING;
- }
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetArguments
- *
- * PARAMETERS: WalkState - Current state
- * AmlOpStart - Op start in AML
- * Op - Current Op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Get arguments for passed Op.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiPsGetArguments (
- ACPI_WALK_STATE *WalkState,
- UINT8 *AmlOpStart,
- ACPI_PARSE_OBJECT *Op)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PARSE_OBJECT *Arg = NULL;
- const ACPI_OPCODE_INFO *OpInfo;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState);
-
-
- switch (Op->Common.AmlOpcode)
- {
- case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
- case AML_WORD_OP: /* AML_WORDDATA_ARG */
- case AML_DWORD_OP: /* AML_DWORDATA_ARG */
- case AML_QWORD_OP: /* AML_QWORDATA_ARG */
- case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
-
- /* Fill in constant or string argument directly */
-
- AcpiPsGetNextSimpleArg (&(WalkState->ParserState),
- GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op);
- break;
-
- case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
-
- Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- WalkState->ArgTypes = 0;
- break;
-
- default:
- /*
- * Op is not a constant or string, append each argument to the Op
- */
- while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount)
- {
- WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml,
- WalkState->ParserState.AmlStart);
-
- Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
- GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (Arg)
- {
- Arg->Common.AmlOffset = WalkState->AmlOffset;
- AcpiPsAppendArg (Op, Arg);
- }
-
- INCREMENT_ARG_LIST (WalkState->ArgTypes);
- }
-
-
- /*
- * Handle executable code at "module-level". This refers to
- * executable opcodes that appear outside of any control method.
- */
- if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) &&
- ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0))
- {
- /*
- * We want to skip If/Else/While constructs during Pass1 because we
- * want to actually conditionally execute the code during Pass2.
- *
- * Except for disassembly, where we always want to walk the
- * If/Else/While packages
- */
- switch (Op->Common.AmlOpcode)
- {
- case AML_IF_OP:
- case AML_ELSE_OP:
- case AML_WHILE_OP:
-
- /*
- * Currently supported module-level opcodes are:
- * IF/ELSE/WHILE. These appear to be the most common,
- * and easiest to support since they open an AML
- * package.
- */
- if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1)
- {
- AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart,
- (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart),
- WalkState->OwnerId);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "Pass1: Skipping an If/Else/While body\n"));
-
- /* Skip body of if/else/while in pass 1 */
-
- WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
- WalkState->ArgCount = 0;
- break;
-
- default:
- /*
- * Check for an unsupported executable opcode at module
- * level. We must be in PASS1, the parent must be a SCOPE,
- * The opcode class must be EXECUTE, and the opcode must
- * not be an argument to another opcode.
- */
- if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) &&
- (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
- {
- OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
- if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
- (!Arg))
- {
- ACPI_WARNING ((AE_INFO,
- "Detected an unsupported executable opcode "
- "at module-level: [0x%.4X] at table offset 0x%.4X",
- Op->Common.AmlOpcode,
- (UINT32) (ACPI_PTR_DIFF (AmlOpStart,
- WalkState->ParserState.AmlStart) +
- sizeof (ACPI_TABLE_HEADER))));
- }
- }
- break;
- }
- }
-
- /* Special processing for certain opcodes */
-
- switch (Op->Common.AmlOpcode)
- {
- case AML_METHOD_OP:
- /*
- * Skip parsing of control method because we don't have enough
- * info in the first pass to parse it correctly.
- *
- * Save the length and address of the body
- */
- Op->Named.Data = WalkState->ParserState.Aml;
- Op->Named.Length = (UINT32)
- (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml);
-
- /* Skip body of method */
-
- WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
- WalkState->ArgCount = 0;
- break;
-
- case AML_BUFFER_OP:
- case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
-
- if ((Op->Common.Parent) &&
- (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
- (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
- {
- /*
- * Skip parsing of Buffers and Packages because we don't have
- * enough info in the first pass to parse them correctly.
- */
- Op->Named.Data = AmlOpStart;
- Op->Named.Length = (UINT32)
- (WalkState->ParserState.PkgEnd - AmlOpStart);
-
- /* Skip body */
-
- WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd;
- WalkState->ArgCount = 0;
- }
- break;
-
- case AML_WHILE_OP:
-
- if (WalkState->ControlState)
- {
- WalkState->ControlState->Control.PackageEnd =
- WalkState->ParserState.PkgEnd;
- }
- break;
-
- default:
-
- /* No action for all other opcodes */
- break;
- }
-
- break;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsLinkModuleCode
- *
- * PARAMETERS: ParentOp - Parent parser op
- * AmlStart - Pointer to the AML
- * AmlLength - Length of executable AML
- * OwnerId - OwnerId of module level code
- *
- * RETURN: None.
- *
- * DESCRIPTION: Wrap the module-level code with a method object and link the
- * object to the global list. Note, the mutex field of the method
- * object is used to link multiple module-level code objects.
- *
- ******************************************************************************/
-
-static void
-AcpiPsLinkModuleCode (
- ACPI_PARSE_OBJECT *ParentOp,
- UINT8 *AmlStart,
- UINT32 AmlLength,
- ACPI_OWNER_ID OwnerId)
-{
- ACPI_OPERAND_OBJECT *Prev;
- ACPI_OPERAND_OBJECT *Next;
- ACPI_OPERAND_OBJECT *MethodObj;
- ACPI_NAMESPACE_NODE *ParentNode;
-
-
- /* Get the tail of the list */
-
- Prev = Next = AcpiGbl_ModuleCodeList;
- while (Next)
- {
- Prev = Next;
- Next = Next->Method.Mutex;
- }
-
- /*
- * Insert the module level code into the list. Merge it if it is
- * adjacent to the previous element.
- */
- if (!Prev ||
- ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart))
- {
- /* Create, initialize, and link a new temporary method object */
-
- MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
- if (!MethodObj)
- {
- return;
- }
-
- if (ParentOp->Common.Node)
- {
- ParentNode = ParentOp->Common.Node;
- }
- else
- {
- ParentNode = AcpiGbl_RootNode;
- }
-
- MethodObj->Method.AmlStart = AmlStart;
- MethodObj->Method.AmlLength = AmlLength;
- MethodObj->Method.OwnerId = OwnerId;
- MethodObj->Method.InfoFlags |= ACPI_METHOD_MODULE_LEVEL;
-
- /*
- * Save the parent node in NextObject. This is cheating, but we
- * don't want to expand the method object.
- */
- MethodObj->Method.NextObject =
- ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode);
-
- if (!Prev)
- {
- AcpiGbl_ModuleCodeList = MethodObj;
- }
- else
- {
- Prev->Method.Mutex = MethodObj;
- }
- }
- else
- {
- Prev->Method.AmlLength += AmlLength;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsCompleteOp
- *
- * PARAMETERS: WalkState - Current state
- * Op - Returned Op
- * Status - Parse status before complete Op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Complete Op
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiPsCompleteOp (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_OBJECT **Op,
- ACPI_STATUS Status)
-{
- ACPI_STATUS Status2;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
-
-
- /*
- * Finished one argument of the containing scope
- */
- WalkState->ParserState.Scope->ParseScope.ArgCount--;
-
- /* Close this Op (will result in parse subtree deletion) */
-
- Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
- if (ACPI_FAILURE (Status2))
- {
- return_ACPI_STATUS (Status2);
- }
-
- *Op = NULL;
-
- switch (Status)
- {
- case AE_OK:
- break;
-
-
- case AE_CTRL_TRANSFER:
-
- /* We are about to transfer to a called method */
-
- WalkState->PrevOp = NULL;
- WalkState->PrevArgTypes = WalkState->ArgTypes;
- return_ACPI_STATUS (Status);
-
-
- case AE_CTRL_END:
-
- AcpiPsPopScope (&(WalkState->ParserState), Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
-
- if (*Op)
- {
- WalkState->Op = *Op;
- WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
- WalkState->Opcode = (*Op)->Common.AmlOpcode;
-
- Status = WalkState->AscendingCallback (WalkState);
- Status = AcpiPsNextParseState (WalkState, *Op, Status);
-
- Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
- if (ACPI_FAILURE (Status2))
- {
- return_ACPI_STATUS (Status2);
- }
- }
-
- Status = AE_OK;
- break;
-
-
- case AE_CTRL_BREAK:
- case AE_CTRL_CONTINUE:
-
- /* Pop off scopes until we find the While */
-
- while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
- {
- AcpiPsPopScope (&(WalkState->ParserState), Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
- }
-
- /* Close this iteration of the While loop */
-
- WalkState->Op = *Op;
- WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
- WalkState->Opcode = (*Op)->Common.AmlOpcode;
-
- Status = WalkState->AscendingCallback (WalkState);
- Status = AcpiPsNextParseState (WalkState, *Op, Status);
-
- Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
- if (ACPI_FAILURE (Status2))
- {
- return_ACPI_STATUS (Status2);
- }
-
- Status = AE_OK;
- break;
-
-
- case AE_CTRL_TERMINATE:
-
- /* Clean up */
- do
- {
- if (*Op)
- {
- Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
- if (ACPI_FAILURE (Status2))
- {
- return_ACPI_STATUS (Status2);
- }
-
- AcpiUtDeleteGenericState (
- AcpiUtPopGenericState (&WalkState->ControlState));
- }
-
- AcpiPsPopScope (&(WalkState->ParserState), Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
-
- } while (*Op);
-
- return_ACPI_STATUS (AE_OK);
-
-
- default: /* All other non-AE_OK status */
-
- do
- {
- if (*Op)
- {
- Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
- if (ACPI_FAILURE (Status2))
- {
- return_ACPI_STATUS (Status2);
- }
- }
-
- AcpiPsPopScope (&(WalkState->ParserState), Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
-
- } while (*Op);
-
-
-#if 0
- /*
- * TBD: Cleanup parse ops on error
- */
- if (*Op == NULL)
- {
- AcpiPsPopScope (ParserState, Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
- }
-#endif
- WalkState->PrevOp = NULL;
- WalkState->PrevArgTypes = WalkState->ArgTypes;
- return_ACPI_STATUS (Status);
- }
-
- /* This scope complete? */
-
- if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
- {
- AcpiPsPopScope (&(WalkState->ParserState), Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
- }
- else
- {
- *Op = NULL;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsCompleteFinalOp
- *
- * PARAMETERS: WalkState - Current state
- * Op - Current Op
- * Status - Current parse status before complete last
- * Op
- *
- * RETURN: Status
- *
- * DESCRIPTION: Complete last Op.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiPsCompleteFinalOp (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_OBJECT *Op,
- ACPI_STATUS Status)
-{
- ACPI_STATUS Status2;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState);
-
-
- /*
- * Complete the last Op (if not completed), and clear the scope stack.
- * It is easily possible to end an AML "package" with an unbounded number
- * of open scopes (such as when several ASL blocks are closed with
- * sequential closing braces). We want to terminate each one cleanly.
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
- do
- {
- if (Op)
- {
- if (WalkState->AscendingCallback != NULL)
- {
- WalkState->Op = Op;
- WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
- WalkState->Opcode = Op->Common.AmlOpcode;
-
- Status = WalkState->AscendingCallback (WalkState);
- Status = AcpiPsNextParseState (WalkState, Op, Status);
- if (Status == AE_CTRL_PENDING)
- {
- Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- if (Status == AE_CTRL_TERMINATE)
- {
- Status = AE_OK;
-
- /* Clean up */
- do
- {
- if (Op)
- {
- Status2 = AcpiPsCompleteThisOp (WalkState, Op);
- if (ACPI_FAILURE (Status2))
- {
- return_ACPI_STATUS (Status2);
- }
- }
-
- AcpiPsPopScope (&(WalkState->ParserState), &Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
-
- } while (Op);
-
- return_ACPI_STATUS (Status);
- }
-
- else if (ACPI_FAILURE (Status))
- {
- /* First error is most important */
-
- (void) AcpiPsCompleteThisOp (WalkState, Op);
- return_ACPI_STATUS (Status);
- }
- }
-
- Status2 = AcpiPsCompleteThisOp (WalkState, Op);
- if (ACPI_FAILURE (Status2))
- {
- return_ACPI_STATUS (Status2);
- }
- }
-
- AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes,
- &WalkState->ArgCount);
-
- } while (Op);
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsParseLoop
- *
- * PARAMETERS: WalkState - Current state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
- * a tree of ops.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsParseLoop (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PARSE_OBJECT *Op = NULL; /* current op */
- ACPI_PARSE_STATE *ParserState;
- UINT8 *AmlOpStart = NULL;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState);
-
-
- if (WalkState->DescendingCallback == NULL)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- ParserState = &WalkState->ParserState;
- WalkState->ArgTypes = 0;
-
-#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
-
- if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART)
- {
- /* We are restarting a preempted control method */
-
- if (AcpiPsHasCompletedScope (ParserState))
- {
- /*
- * We must check if a predicate to an IF or WHILE statement
- * was just completed
- */
- if ((ParserState->Scope->ParseScope.Op) &&
- ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) ||
- (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) &&
- (WalkState->ControlState) &&
- (WalkState->ControlState->Common.State ==
- ACPI_CONTROL_PREDICATE_EXECUTING))
- {
- /*
- * A predicate was just completed, get the value of the
- * predicate and branch based on that value
- */
- WalkState->Op = NULL;
- Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE));
- if (ACPI_FAILURE (Status) &&
- ((Status & AE_CODE_MASK) != AE_CODE_CONTROL))
- {
- if (Status == AE_AML_NO_RETURN_VALUE)
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Invoked method did not return a value"));
- }
-
- ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed"));
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiPsNextParseState (WalkState, Op, Status);
- }
-
- AcpiPsPopScope (ParserState, &Op,
- &WalkState->ArgTypes, &WalkState->ArgCount);
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
- }
- else if (WalkState->PrevOp)
- {
- /* We were in the middle of an op */
-
- Op = WalkState->PrevOp;
- WalkState->ArgTypes = WalkState->PrevArgTypes;
- }
- }
-#endif
-
- /* Iterative parsing loop, while there is more AML to process: */
-
- while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
- {
- AmlOpStart = ParserState->Aml;
- if (!Op)
- {
- Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_CTRL_PARSE_CONTINUE)
- {
- continue;
- }
-
- if (Status == AE_CTRL_PARSE_PENDING)
- {
- Status = AE_OK;
- }
-
- Status = AcpiPsCompleteOp (WalkState, &Op, Status);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- continue;
- }
-
- Op->Common.AmlOffset = WalkState->AmlOffset;
-
- if (WalkState->OpInfo)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
- (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name,
- Op, ParserState->Aml, Op->Common.AmlOffset));
- }
- }
-
-
- /*
- * Start ArgCount at zero because we don't know if there are
- * any args yet
- */
- WalkState->ArgCount = 0;
-
- /* Are there any arguments that must be processed? */
-
- if (WalkState->ArgTypes)
- {
- /* Get arguments */
-
- Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op);
- if (ACPI_FAILURE (Status))
- {
- Status = AcpiPsCompleteOp (WalkState, &Op, Status);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- continue;
- }
- }
-
- /* Check for arguments that need to be processed */
-
- if (WalkState->ArgCount)
- {
- /*
- * There are arguments (complex ones), push Op and
- * prepare for argument
- */
- Status = AcpiPsPushScope (ParserState, Op,
- WalkState->ArgTypes, WalkState->ArgCount);
- if (ACPI_FAILURE (Status))
- {
- Status = AcpiPsCompleteOp (WalkState, &Op, Status);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- continue;
- }
-
- Op = NULL;
- continue;
- }
-
- /*
- * All arguments have been processed -- Op is complete,
- * prepare for next
- */
- WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
- if (WalkState->OpInfo->Flags & AML_NAMED)
- {
- if (AcpiGbl_Depth)
- {
- AcpiGbl_Depth--;
- }
-
- if (Op->Common.AmlOpcode == AML_REGION_OP ||
- Op->Common.AmlOpcode == AML_DATA_REGION_OP)
- {
- /*
- * Skip parsing of control method or opregion body,
- * because we don't have enough info in the first pass
- * to parse them correctly.
- *
- * Completed parsing an OpRegion declaration, we now
- * know the length.
- */
- Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
- }
- }
-
- if (WalkState->OpInfo->Flags & AML_CREATE)
- {
- /*
- * Backup to beginning of CreateXXXfield declaration (1 for
- * Opcode)
- *
- * BodyLength is unknown until we parse the body
- */
- Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
- }
-
- if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
- {
- /*
- * Backup to beginning of BankField declaration
- *
- * BodyLength is unknown until we parse the body
- */
- Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
- }
-
- /* This op complete, notify the dispatcher */
-
- if (WalkState->AscendingCallback != NULL)
- {
- WalkState->Op = Op;
- WalkState->Opcode = Op->Common.AmlOpcode;
-
- Status = WalkState->AscendingCallback (WalkState);
- Status = AcpiPsNextParseState (WalkState, Op, Status);
- if (Status == AE_CTRL_PENDING)
- {
- Status = AE_OK;
- }
- }
-
- Status = AcpiPsCompleteOp (WalkState, &Op, Status);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- } /* while ParserState->Aml */
-
- Status = AcpiPsCompleteFinalOp (WalkState, Op, Status);
- return_ACPI_STATUS (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/psopcode.c
--- a/head/sys/contrib/dev/acpica/parser/psopcode.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,522 +0,0 @@
-/******************************************************************************
- *
- * Module Name: psopcode - Parser/Interpreter opcode information table
- *
- *****************************************************************************/
-
-/*
- * 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/acopcode.h>
-#include <contrib/dev/acpica/include/amlcode.h>
-
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("psopcode")
-
-
-static const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6};
-
-
-/*******************************************************************************
- *
- * NAME: AcpiGbl_AmlOpInfo
- *
- * DESCRIPTION: Opcode table. Each entry contains <opcode, type, name, operands>
- * The name is a simple ascii string, the operand specifier is an
- * ascii string with one letter per operand. The letter specifies
- * the operand type.
- *
- ******************************************************************************/
-
-/*
- * Summary of opcode types/flags
- *
-
- Opcodes that have associated namespace objects (AML_NSOBJECT flag)
-
- AML_SCOPE_OP
- AML_DEVICE_OP
- AML_THERMAL_ZONE_OP
- AML_METHOD_OP
- AML_POWER_RES_OP
- AML_PROCESSOR_OP
- AML_FIELD_OP
- AML_INDEX_FIELD_OP
- AML_BANK_FIELD_OP
- AML_NAME_OP
- AML_ALIAS_OP
- AML_MUTEX_OP
- AML_EVENT_OP
- AML_REGION_OP
- AML_CREATE_FIELD_OP
- AML_CREATE_BIT_FIELD_OP
- AML_CREATE_BYTE_FIELD_OP
- AML_CREATE_WORD_FIELD_OP
- AML_CREATE_DWORD_FIELD_OP
- AML_CREATE_QWORD_FIELD_OP
- AML_INT_NAMEDFIELD_OP
- AML_INT_METHODCALL_OP
- AML_INT_NAMEPATH_OP
-
- Opcodes that are "namespace" opcodes (AML_NSOPCODE flag)
-
- AML_SCOPE_OP
- AML_DEVICE_OP
- AML_THERMAL_ZONE_OP
- AML_METHOD_OP
- AML_POWER_RES_OP
- AML_PROCESSOR_OP
- AML_FIELD_OP
- AML_INDEX_FIELD_OP
- AML_BANK_FIELD_OP
- AML_NAME_OP
- AML_ALIAS_OP
- AML_MUTEX_OP
- AML_EVENT_OP
- AML_REGION_OP
- AML_INT_NAMEDFIELD_OP
-
- Opcodes that have an associated namespace node (AML_NSNODE flag)
-
- AML_SCOPE_OP
- AML_DEVICE_OP
- AML_THERMAL_ZONE_OP
- AML_METHOD_OP
- AML_POWER_RES_OP
- AML_PROCESSOR_OP
- AML_NAME_OP
- AML_ALIAS_OP
- AML_MUTEX_OP
- AML_EVENT_OP
- AML_REGION_OP
- AML_CREATE_FIELD_OP
- AML_CREATE_BIT_FIELD_OP
- AML_CREATE_BYTE_FIELD_OP
- AML_CREATE_WORD_FIELD_OP
- AML_CREATE_DWORD_FIELD_OP
- AML_CREATE_QWORD_FIELD_OP
- AML_INT_NAMEDFIELD_OP
- AML_INT_METHODCALL_OP
- AML_INT_NAMEPATH_OP
-
- Opcodes that define named ACPI objects (AML_NAMED flag)
-
- AML_SCOPE_OP
- AML_DEVICE_OP
- AML_THERMAL_ZONE_OP
- AML_METHOD_OP
- AML_POWER_RES_OP
- AML_PROCESSOR_OP
- AML_NAME_OP
- AML_ALIAS_OP
- AML_MUTEX_OP
- AML_EVENT_OP
- AML_REGION_OP
- AML_INT_NAMEDFIELD_OP
-
- Opcodes that contain executable AML as part of the definition that
- must be deferred until needed
-
- AML_METHOD_OP
- AML_VAR_PACKAGE_OP
- AML_CREATE_FIELD_OP
- AML_CREATE_BIT_FIELD_OP
- AML_CREATE_BYTE_FIELD_OP
- AML_CREATE_WORD_FIELD_OP
- AML_CREATE_DWORD_FIELD_OP
- AML_CREATE_QWORD_FIELD_OP
- AML_REGION_OP
- AML_BUFFER_OP
-
- Field opcodes
-
- AML_CREATE_FIELD_OP
- AML_FIELD_OP
- AML_INDEX_FIELD_OP
- AML_BANK_FIELD_OP
-
- Field "Create" opcodes
-
- AML_CREATE_FIELD_OP
- AML_CREATE_BIT_FIELD_OP
- AML_CREATE_BYTE_FIELD_OP
- AML_CREATE_WORD_FIELD_OP
- AML_CREATE_DWORD_FIELD_OP
- AML_CREATE_QWORD_FIELD_OP
-
- ******************************************************************************/
-
-
-/*
- * Master Opcode information table. A summary of everything we know about each
- * opcode, all in one place.
- */
-const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] =
-{
-/*! [Begin] no source code translation */
-/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */
-
-/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
-/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
-/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
-/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
-/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
-/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
-/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
-/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT),
-/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
-/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0),
-/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
-/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
-/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
-/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
-/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
-/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
-/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0),
-/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
-/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
-/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
-/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
-/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
-/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT),
-/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT),
-/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R),
-/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R),
-/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
-/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R),
-/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT),
-/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
-/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
-/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
-/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
-/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
-/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
-/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT),
-/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
-/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
-/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
-/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
-/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS),
-/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
-/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
-/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT),
-
-/* Prefixed opcodes (Two-byte opcodes with a prefix op) */
-
-/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
-/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
-/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE),
-/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R),
-/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
-/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
-/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
-/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
-/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R),
-/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
-/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
-/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R),
-/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
-/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0),
-/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R),
-/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
-/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
-/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED),
-/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD),
-/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | AML_DEFER),
-
-/* Internal opcodes that map to invalid AML opcodes */
-
-/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
-/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
-/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT),
-/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ),
-/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE),
-/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0),
-/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
-/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ),
-/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
-/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0),
-/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL),
-/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS),
-/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS),
-/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS),
-
-/* ACPI 2.0 opcodes */
-
-/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT),
-/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER),
-/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
-/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
-/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT),
-/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT),
-/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R),
-/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT),
-/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0),
-/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R),
-/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER),
-/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE),
-
-/* ACPI 3.0 opcodes */
-
-/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R),
-
-/* ACPI 5.0 opcodes */
-
-/* 7F */ ACPI_OP ("-ConnectField-", ARGP_CONNECTFIELD_OP, ARGI_CONNECTFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS),
-/* 80 */ ACPI_OP ("-ExtAccessField-", ARGP_CONNECTFIELD_OP, ARGI_CONNECTFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0)
-
-/*! [End] no source code translation !*/
-};
-
-/*
- * This table is directly indexed by the opcodes, and returns an
- * index into the table above
- */
-static const UINT8 AcpiGbl_ShortOpIndex[256] =
-{
-/* 0 1 2 3 4 5 6 7 */
-/* 8 9 A B C D E F */
-/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
-/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
-/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
-/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
-/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
-/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
-/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
-/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
-/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
-/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
-/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
-/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
-/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
-/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
-/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
-/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
-/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
-/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
-/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
-/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
-};
-
-/*
- * This table is indexed by the second opcode of the extended opcode
- * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo)
- */
-static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] =
-{
-/* 0 1 2 3 4 5 6 7 */
-/* 8 9 A B C D E F */
-/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
-/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
-/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
-/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
-/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
-/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
-/* 0x88 */ 0x7C,
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetOpcodeInfo
- *
- * PARAMETERS: Opcode - The AML opcode
- *
- * RETURN: A pointer to the info about the opcode.
- *
- * DESCRIPTION: Find AML opcode description based on the opcode.
- * NOTE: This procedure must ALWAYS return a valid pointer!
- *
- ******************************************************************************/
-
-const ACPI_OPCODE_INFO *
-AcpiPsGetOpcodeInfo (
- UINT16 Opcode)
-{
- ACPI_FUNCTION_NAME (PsGetOpcodeInfo);
-
-
- /*
- * Detect normal 8-bit opcode or extended 16-bit opcode
- */
- if (!(Opcode & 0xFF00))
- {
- /* Simple (8-bit) opcode: 0-255, can't index beyond table */
-
- return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]);
- }
-
- if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
- (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE))
- {
- /* Valid extended (16-bit) opcode */
-
- return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]);
- }
-
- /* Unknown AML opcode */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Unknown AML opcode [%4.4X]\n", Opcode));
-
- return (&AcpiGbl_AmlOpInfo [_UNK]);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetOpcodeName
- *
- * PARAMETERS: Opcode - The AML opcode
- *
- * RETURN: A pointer to the name of the opcode (ASCII String)
- * Note: Never returns NULL.
- *
- * DESCRIPTION: Translate an opcode into a human-readable string
- *
- ******************************************************************************/
-
-char *
-AcpiPsGetOpcodeName (
- UINT16 Opcode)
-{
-#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
-
- const ACPI_OPCODE_INFO *Op;
-
-
- Op = AcpiPsGetOpcodeInfo (Opcode);
-
- /* Always guaranteed to return a valid pointer */
-
- return (Op->Name);
-
-#else
- return ("OpcodeName unavailable");
-
-#endif
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetArgumentCount
- *
- * PARAMETERS: OpType - Type associated with the AML opcode
- *
- * RETURN: Argument count
- *
- * DESCRIPTION: Obtain the number of expected arguments for an AML opcode
- *
- ******************************************************************************/
-
-UINT8
-AcpiPsGetArgumentCount (
- UINT32 OpType)
-{
-
- if (OpType <= AML_TYPE_EXEC_6A_0T_1R)
- {
- return (AcpiGbl_ArgumentCount[OpType]);
- }
-
- return (0);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/psparse.c
--- a/head/sys/contrib/dev/acpica/parser/psparse.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,711 +0,0 @@
-/******************************************************************************
- *
- * Module Name: psparse - Parser top level AML parse 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.
- */
-
-
-/*
- * Parse the AML and build an operation tree as most interpreters,
- * like Perl, do. Parsing is done by hand rather than with a YACC
- * generated parser to tightly constrain stack and dynamic memory
- * usage. At the same time, parsing is kept flexible and the code
- * fairly compact by parsing based on a list of AML opcode
- * templates in AmlOpInfo[]
- */
-
-#include <contrib/dev/acpica/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/amlcode.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("psparse")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetOpcodeSize
- *
- * PARAMETERS: Opcode - An AML opcode
- *
- * RETURN: Size of the opcode, in bytes (1 or 2)
- *
- * DESCRIPTION: Get the size of the current opcode.
- *
- ******************************************************************************/
-
-UINT32
-AcpiPsGetOpcodeSize (
- UINT32 Opcode)
-{
-
- /* Extended (2-byte) opcode if > 255 */
-
- if (Opcode > 0x00FF)
- {
- return (2);
- }
-
- /* Otherwise, just a single byte opcode */
-
- return (1);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsPeekOpcode
- *
- * PARAMETERS: ParserState - A parser state object
- *
- * RETURN: Next AML opcode
- *
- * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
- *
- ******************************************************************************/
-
-UINT16
-AcpiPsPeekOpcode (
- ACPI_PARSE_STATE *ParserState)
-{
- UINT8 *Aml;
- UINT16 Opcode;
-
-
- Aml = ParserState->Aml;
- Opcode = (UINT16) ACPI_GET8 (Aml);
-
- if (Opcode == AML_EXTENDED_OP_PREFIX)
- {
- /* Extended opcode, get the second opcode byte */
-
- Aml++;
- Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
- }
-
- return (Opcode);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsCompleteThisOp
- *
- * PARAMETERS: WalkState - Current State
- * Op - Op to complete
- *
- * RETURN: Status
- *
- * DESCRIPTION: Perform any cleanup at the completion of an Op.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsCompleteThisOp (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_OBJECT *Op)
-{
- ACPI_PARSE_OBJECT *Prev;
- ACPI_PARSE_OBJECT *Next;
- const ACPI_OPCODE_INFO *ParentInfo;
- ACPI_PARSE_OBJECT *ReplacementOp = NULL;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
-
-
- /* Check for null Op, can happen if AML code is corrupt */
-
- if (!Op)
- {
- return_ACPI_STATUS (AE_OK); /* OK for now */
- }
-
- /* Delete this op and the subtree below it if asked to */
-
- if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
- (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Make sure that we only delete this subtree */
-
- if (Op->Common.Parent)
- {
- Prev = Op->Common.Parent->Common.Value.Arg;
- if (!Prev)
- {
- /* Nothing more to do */
-
- goto Cleanup;
- }
-
- /*
- * Check if we need to replace the operator and its subtree
- * with a return value op (placeholder op)
- */
- ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
-
- switch (ParentInfo->Class)
- {
- case AML_CLASS_CONTROL:
- break;
-
- case AML_CLASS_CREATE:
-
- /*
- * These opcodes contain TermArg operands. The current
- * op must be replaced by a placeholder return op
- */
- ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
- if (!ReplacementOp)
- {
- Status = AE_NO_MEMORY;
- }
- break;
-
- case AML_CLASS_NAMED_OBJECT:
-
- /*
- * These opcodes contain TermArg operands. The current
- * op must be replaced by a placeholder return op
- */
- if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
- {
- ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
- if (!ReplacementOp)
- {
- Status = AE_NO_MEMORY;
- }
- }
- else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
- (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
- {
- if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
- (Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
- {
- ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
- if (!ReplacementOp)
- {
- Status = AE_NO_MEMORY;
- }
- else
- {
- ReplacementOp->Named.Data = Op->Named.Data;
- ReplacementOp->Named.Length = Op->Named.Length;
- }
- }
- }
- break;
-
- default:
-
- ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
- if (!ReplacementOp)
- {
- Status = AE_NO_MEMORY;
- }
- }
-
- /* We must unlink this op from the parent tree */
-
- if (Prev == Op)
- {
- /* This op is the first in the list */
-
- if (ReplacementOp)
- {
- ReplacementOp->Common.Parent = Op->Common.Parent;
- ReplacementOp->Common.Value.Arg = NULL;
- ReplacementOp->Common.Node = Op->Common.Node;
- Op->Common.Parent->Common.Value.Arg = ReplacementOp;
- ReplacementOp->Common.Next = Op->Common.Next;
- }
- else
- {
- Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
- }
- }
-
- /* Search the parent list */
-
- else while (Prev)
- {
- /* Traverse all siblings in the parent's argument list */
-
- Next = Prev->Common.Next;
- if (Next == Op)
- {
- if (ReplacementOp)
- {
- ReplacementOp->Common.Parent = Op->Common.Parent;
- ReplacementOp->Common.Value.Arg = NULL;
- ReplacementOp->Common.Node = Op->Common.Node;
- Prev->Common.Next = ReplacementOp;
- ReplacementOp->Common.Next = Op->Common.Next;
- Next = NULL;
- }
- else
- {
- Prev->Common.Next = Op->Common.Next;
- Next = NULL;
- }
- }
- Prev = Next;
- }
- }
-
-
-Cleanup:
-
- /* Now we can actually delete the subtree rooted at Op */
-
- AcpiPsDeleteParseTree (Op);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsNextParseState
- *
- * PARAMETERS: WalkState - Current state
- * Op - Current parse op
- * CallbackStatus - Status from previous operation
- *
- * RETURN: Status
- *
- * DESCRIPTION: Update the parser state based upon the return exception from
- * the parser callback.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsNextParseState (
- ACPI_WALK_STATE *WalkState,
- ACPI_PARSE_OBJECT *Op,
- ACPI_STATUS CallbackStatus)
-{
- ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
- ACPI_STATUS Status = AE_CTRL_PENDING;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
-
-
- switch (CallbackStatus)
- {
- case AE_CTRL_TERMINATE:
- /*
- * A control method was terminated via a RETURN statement.
- * The walk of this method is complete.
- */
- ParserState->Aml = ParserState->AmlEnd;
- Status = AE_CTRL_TERMINATE;
- break;
-
-
- case AE_CTRL_BREAK:
-
- ParserState->Aml = WalkState->AmlLastWhile;
- WalkState->ControlState->Common.Value = FALSE;
- Status = AE_CTRL_BREAK;
- break;
-
-
- case AE_CTRL_CONTINUE:
-
- ParserState->Aml = WalkState->AmlLastWhile;
- Status = AE_CTRL_CONTINUE;
- break;
-
-
- case AE_CTRL_PENDING:
-
- ParserState->Aml = WalkState->AmlLastWhile;
- break;
-
-#if 0
- case AE_CTRL_SKIP:
-
- ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
- Status = AE_OK;
- break;
-#endif
-
- case AE_CTRL_TRUE:
- /*
- * Predicate of an IF was true, and we are at the matching ELSE.
- * Just close out this package
- */
- ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
- Status = AE_CTRL_PENDING;
- break;
-
-
- case AE_CTRL_FALSE:
- /*
- * Either an IF/WHILE Predicate was false or we encountered a BREAK
- * opcode. In both cases, we do not execute the rest of the
- * package; We simply close out the parent (finishing the walk of
- * this branch of the tree) and continue execution at the parent
- * level.
- */
- ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
-
- /* In the case of a BREAK, just force a predicate (if any) to FALSE */
-
- WalkState->ControlState->Common.Value = FALSE;
- Status = AE_CTRL_END;
- break;
-
-
- case AE_CTRL_TRANSFER:
-
- /* A method call (invocation) -- transfer control */
-
- Status = AE_CTRL_TRANSFER;
- WalkState->PrevOp = Op;
- WalkState->MethodCallOp = Op;
- WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
-
- /* Will return value (if any) be used by the caller? */
-
- WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
- break;
-
-
- default:
-
- Status = CallbackStatus;
- if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
- {
- Status = AE_OK;
- }
- break;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsParseAml
- *
- * PARAMETERS: WalkState - Current state
- *
- *
- * RETURN: Status
- *
- * DESCRIPTION: Parse raw AML and return a tree of ops
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsParseAml (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status;
- ACPI_THREAD_STATE *Thread;
- ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList;
- ACPI_WALK_STATE *PreviousWalkState;
-
-
- ACPI_FUNCTION_TRACE (PsParseAml);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "Entered with WalkState=%p Aml=%p size=%X\n",
- WalkState, WalkState->ParserState.Aml,
- WalkState->ParserState.AmlSize));
-
- if (!WalkState->ParserState.Aml)
- {
- return_ACPI_STATUS (AE_NULL_OBJECT);
- }
-
- /* Create and initialize a new thread state */
-
- Thread = AcpiUtCreateThreadState ();
- if (!Thread)
- {
- if (WalkState->MethodDesc)
- {
- /* Executing a control method - additional cleanup */
-
- AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
- }
-
- AcpiDsDeleteWalkState (WalkState);
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- WalkState->Thread = Thread;
-
- /*
- * If executing a method, the starting SyncLevel is this method's
- * SyncLevel
- */
- if (WalkState->MethodDesc)
- {
- WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel;
- }
-
- AcpiDsPushWalkState (WalkState, Thread);
-
- /*
- * This global allows the AML debugger to get a handle to the currently
- * executing control method.
- */
- AcpiGbl_CurrentWalkList = Thread;
-
- /*
- * Execute the walk loop as long as there is a valid Walk State. This
- * handles nested control method invocations without recursion.
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
-
- Status = AE_OK;
- while (WalkState)
- {
- if (ACPI_SUCCESS (Status))
- {
- /*
- * The ParseLoop executes AML until the method terminates
- * or calls another method.
- */
- Status = AcpiPsParseLoop (WalkState);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "Completed one call to walk loop, %s State=%p\n",
- AcpiFormatException (Status), WalkState));
-
- if (Status == AE_CTRL_TRANSFER)
- {
- /*
- * A method call was detected.
- * Transfer control to the called control method
- */
- Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
- if (ACPI_FAILURE (Status))
- {
- Status = AcpiDsMethodError (Status, WalkState);
- }
-
- /*
- * If the transfer to the new method method call worked, a new walk
- * state was created -- get it
- */
- WalkState = AcpiDsGetCurrentWalkState (Thread);
- continue;
- }
- else if (Status == AE_CTRL_TERMINATE)
- {
- Status = AE_OK;
- }
- else if ((Status != AE_OK) && (WalkState->MethodDesc))
- {
- /* Either the method parse or actual execution failed */
-
- ACPI_ERROR_METHOD ("Method parse/execution failed",
- WalkState->MethodNode, NULL, Status);
-
- /* Check for possible multi-thread reentrancy problem */
-
- if ((Status == AE_ALREADY_EXISTS) &&
- (!(WalkState->MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)))
- {
- /*
- * Method is not serialized and tried to create an object
- * twice. The probable cause is that the method cannot
- * handle reentrancy. Mark as "pending serialized" now, and
- * then mark "serialized" when the last thread exits.
- */
- WalkState->MethodDesc->Method.InfoFlags |=
- ACPI_METHOD_SERIALIZED_PENDING;
- }
- }
-
- /* We are done with this walk, move on to the parent if any */
-
- WalkState = AcpiDsPopWalkState (Thread);
-
- /* Reset the current scope to the beginning of scope stack */
-
- AcpiDsScopeStackClear (WalkState);
-
- /*
- * If we just returned from the execution of a control method or if we
- * encountered an error during the method parse phase, there's lots of
- * cleanup to do
- */
- if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) ||
- (ACPI_FAILURE (Status)))
- {
- AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
- }
-
- /* Delete this walk state and all linked control states */
-
- AcpiPsCleanupScope (&WalkState->ParserState);
- PreviousWalkState = WalkState;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "ReturnValue=%p, ImplicitValue=%p State=%p\n",
- WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
-
- /* Check if we have restarted a preempted walk */
-
- WalkState = AcpiDsGetCurrentWalkState (Thread);
- if (WalkState)
- {
- if (ACPI_SUCCESS (Status))
- {
- /*
- * There is another walk state, restart it.
- * If the method return value is not used by the parent,
- * The object is deleted
- */
- if (!PreviousWalkState->ReturnDesc)
- {
- /*
- * In slack mode execution, if there is no return value
- * we should implicitly return zero (0) as a default value.
- */
- if (AcpiGbl_EnableInterpreterSlack &&
- !PreviousWalkState->ImplicitReturnObj)
- {
- PreviousWalkState->ImplicitReturnObj =
- AcpiUtCreateIntegerObject ((UINT64) 0);
- if (!PreviousWalkState->ImplicitReturnObj)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
- }
-
- /* Restart the calling control method */
-
- Status = AcpiDsRestartControlMethod (WalkState,
- PreviousWalkState->ImplicitReturnObj);
- }
- else
- {
- /*
- * We have a valid return value, delete any implicit
- * return value.
- */
- AcpiDsClearImplicitReturn (PreviousWalkState);
-
- Status = AcpiDsRestartControlMethod (WalkState,
- PreviousWalkState->ReturnDesc);
- }
- if (ACPI_SUCCESS (Status))
- {
- WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
- }
- }
- else
- {
- /* On error, delete any return object or implicit return */
-
- AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
- AcpiDsClearImplicitReturn (PreviousWalkState);
- }
- }
-
- /*
- * Just completed a 1st-level method, save the final internal return
- * value (if any)
- */
- else if (PreviousWalkState->CallerReturnDesc)
- {
- if (PreviousWalkState->ImplicitReturnObj)
- {
- *(PreviousWalkState->CallerReturnDesc) =
- PreviousWalkState->ImplicitReturnObj;
- }
- else
- {
- /* NULL if no return value */
-
- *(PreviousWalkState->CallerReturnDesc) =
- PreviousWalkState->ReturnDesc;
- }
- }
- else
- {
- if (PreviousWalkState->ReturnDesc)
- {
- /* Caller doesn't want it, must delete it */
-
- AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
- }
- if (PreviousWalkState->ImplicitReturnObj)
- {
- /* Caller doesn't want it, must delete it */
-
- AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
- }
- }
-
- AcpiDsDeleteWalkState (PreviousWalkState);
- }
-
- /* Normal exit */
-
- AcpiExReleaseAllMutexes (Thread);
- AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
- AcpiGbl_CurrentWalkList = PrevWalkList;
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/psscope.c
--- a/head/sys/contrib/dev/acpica/parser/psscope.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,302 +0,0 @@
-/******************************************************************************
- *
- * Module Name: psscope - Parser scope stack 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.
- */
-
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acparser.h>
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("psscope")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetParentScope
- *
- * PARAMETERS: ParserState - Current parser state object
- *
- * RETURN: Pointer to an Op object
- *
- * DESCRIPTION: Get parent of current op being parsed
- *
- ******************************************************************************/
-
-ACPI_PARSE_OBJECT *
-AcpiPsGetParentScope (
- ACPI_PARSE_STATE *ParserState)
-{
-
- return (ParserState->Scope->ParseScope.Op);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsHasCompletedScope
- *
- * PARAMETERS: ParserState - Current parser state object
- *
- * RETURN: Boolean, TRUE = scope completed.
- *
- * DESCRIPTION: Is parsing of current argument complete? Determined by
- * 1) AML pointer is at or beyond the end of the scope
- * 2) The scope argument count has reached zero.
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiPsHasCompletedScope (
- ACPI_PARSE_STATE *ParserState)
-{
-
- return ((BOOLEAN)
- ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd ||
- !ParserState->Scope->ParseScope.ArgCount)));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsInitScope
- *
- * PARAMETERS: ParserState - Current parser state object
- * Root - the Root Node of this new scope
- *
- * RETURN: Status
- *
- * DESCRIPTION: Allocate and init a new scope object
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsInitScope (
- ACPI_PARSE_STATE *ParserState,
- ACPI_PARSE_OBJECT *RootOp)
-{
- ACPI_GENERIC_STATE *Scope;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp);
-
-
- Scope = AcpiUtCreateGenericState ();
- if (!Scope)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE;
- Scope->ParseScope.Op = RootOp;
- Scope->ParseScope.ArgCount = ACPI_VAR_ARGS;
- Scope->ParseScope.ArgEnd = ParserState->AmlEnd;
- Scope->ParseScope.PkgEnd = ParserState->AmlEnd;
-
- ParserState->Scope = Scope;
- ParserState->StartOp = RootOp;
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsPushScope
- *
- * PARAMETERS: ParserState - Current parser state object
- * Op - Current op to be pushed
- * RemainingArgs - List of args remaining
- * ArgCount - Fixed or variable number of args
- *
- * RETURN: Status
- *
- * DESCRIPTION: Push current op to begin parsing its argument
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsPushScope (
- ACPI_PARSE_STATE *ParserState,
- ACPI_PARSE_OBJECT *Op,
- UINT32 RemainingArgs,
- UINT32 ArgCount)
-{
- ACPI_GENERIC_STATE *Scope;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op);
-
-
- Scope = AcpiUtCreateGenericState ();
- if (!Scope)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE;
- Scope->ParseScope.Op = Op;
- Scope->ParseScope.ArgList = RemainingArgs;
- Scope->ParseScope.ArgCount = ArgCount;
- Scope->ParseScope.PkgEnd = ParserState->PkgEnd;
-
- /* Push onto scope stack */
-
- AcpiUtPushGenericState (&ParserState->Scope, Scope);
-
- if (ArgCount == ACPI_VAR_ARGS)
- {
- /* Multiple arguments */
-
- Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
- }
- else
- {
- /* Single argument */
-
- Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR);
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsPopScope
- *
- * PARAMETERS: ParserState - Current parser state object
- * Op - Where the popped op is returned
- * ArgList - Where the popped "next argument" is
- * returned
- * ArgCount - Count of objects in ArgList
- *
- * RETURN: Status
- *
- * DESCRIPTION: Return to parsing a previous op
- *
- ******************************************************************************/
-
-void
-AcpiPsPopScope (
- ACPI_PARSE_STATE *ParserState,
- ACPI_PARSE_OBJECT **Op,
- UINT32 *ArgList,
- UINT32 *ArgCount)
-{
- ACPI_GENERIC_STATE *Scope = ParserState->Scope;
-
-
- ACPI_FUNCTION_TRACE (PsPopScope);
-
-
- /* Only pop the scope if there is in fact a next scope */
-
- if (Scope->Common.Next)
- {
- Scope = AcpiUtPopGenericState (&ParserState->Scope);
-
- /* Return to parsing previous op */
-
- *Op = Scope->ParseScope.Op;
- *ArgList = Scope->ParseScope.ArgList;
- *ArgCount = Scope->ParseScope.ArgCount;
- ParserState->PkgEnd = Scope->ParseScope.PkgEnd;
-
- /* All done with this scope state structure */
-
- AcpiUtDeleteGenericState (Scope);
- }
- else
- {
- /* Empty parse stack, prepare to fetch next opcode */
-
- *Op = NULL;
- *ArgList = 0;
- *ArgCount = 0;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "Popped Op %p Args %X\n", *Op, *ArgCount));
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsCleanupScope
- *
- * PARAMETERS: ParserState - Current parser state object
- *
- * RETURN: None
- *
- * DESCRIPTION: Destroy available list, remaining stack levels, and return
- * root scope
- *
- ******************************************************************************/
-
-void
-AcpiPsCleanupScope (
- ACPI_PARSE_STATE *ParserState)
-{
- ACPI_GENERIC_STATE *Scope;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState);
-
-
- if (!ParserState)
- {
- return_VOID;
- }
-
- /* Delete anything on the scope stack */
-
- while (ParserState->Scope)
- {
- Scope = AcpiUtPopGenericState (&ParserState->Scope);
- AcpiUtDeleteGenericState (Scope);
- }
-
- return_VOID;
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/pstree.c
--- a/head/sys/contrib/dev/acpica/parser/pstree.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,360 +0,0 @@
-/******************************************************************************
- *
- * Module Name: pstree - Parser op tree manipulation/traversal/search
- *
- *****************************************************************************/
-
-/*
- * 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 __PSTREE_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>
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("pstree")
-
-/* Local prototypes */
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-ACPI_PARSE_OBJECT *
-AcpiPsGetChild (
- ACPI_PARSE_OBJECT *op);
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetArg
- *
- * PARAMETERS: Op - Get an argument for this op
- * Argn - Nth argument to get
- *
- * RETURN: The argument (as an Op object). NULL if argument does not exist
- *
- * DESCRIPTION: Get the specified op's argument.
- *
- ******************************************************************************/
-
-ACPI_PARSE_OBJECT *
-AcpiPsGetArg (
- ACPI_PARSE_OBJECT *Op,
- UINT32 Argn)
-{
- ACPI_PARSE_OBJECT *Arg = NULL;
- const ACPI_OPCODE_INFO *OpInfo;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-/*
- if (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)
- {
- return (Op->Common.Value.Arg);
- }
-*/
- /* Get the info structure for this opcode */
-
- OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
- if (OpInfo->Class == AML_CLASS_UNKNOWN)
- {
- /* Invalid opcode or ASCII character */
-
- return (NULL);
- }
-
- /* Check if this opcode requires argument sub-objects */
-
- if (!(OpInfo->Flags & AML_HAS_ARGS))
- {
- /* Has no linked argument objects */
-
- return (NULL);
- }
-
- /* Get the requested argument object */
-
- Arg = Op->Common.Value.Arg;
- while (Arg && Argn)
- {
- Argn--;
- Arg = Arg->Common.Next;
- }
-
- return (Arg);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsAppendArg
- *
- * PARAMETERS: Op - Append an argument to this Op.
- * Arg - Argument Op to append
- *
- * RETURN: None.
- *
- * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK)
- *
- ******************************************************************************/
-
-void
-AcpiPsAppendArg (
- ACPI_PARSE_OBJECT *Op,
- ACPI_PARSE_OBJECT *Arg)
-{
- ACPI_PARSE_OBJECT *PrevArg;
- const ACPI_OPCODE_INFO *OpInfo;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!Op)
- {
- return;
- }
-
- /* Get the info structure for this opcode */
-
- OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
- if (OpInfo->Class == AML_CLASS_UNKNOWN)
- {
- /* Invalid opcode */
-
- ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
- Op->Common.AmlOpcode));
- return;
- }
-
- /* Check if this opcode requires argument sub-objects */
-
- if (!(OpInfo->Flags & AML_HAS_ARGS))
- {
- /* Has no linked argument objects */
-
- return;
- }
-
- /* Append the argument to the linked argument list */
-
- if (Op->Common.Value.Arg)
- {
- /* Append to existing argument list */
-
- PrevArg = Op->Common.Value.Arg;
- while (PrevArg->Common.Next)
- {
- PrevArg = PrevArg->Common.Next;
- }
- PrevArg->Common.Next = Arg;
- }
- else
- {
- /* No argument list, this will be the first argument */
-
- Op->Common.Value.Arg = Arg;
- }
-
- /* Set the parent in this arg and any args linked after it */
-
- while (Arg)
- {
- Arg->Common.Parent = Op;
- Arg = Arg->Common.Next;
-
- Op->Common.ArgListLength++;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetDepthNext
- *
- * PARAMETERS: Origin - Root of subtree to search
- * Op - Last (previous) Op that was found
- *
- * RETURN: Next Op found in the search.
- *
- * DESCRIPTION: Get next op in tree (walking the tree in depth-first order)
- * Return NULL when reaching "origin" or when walking up from root
- *
- ******************************************************************************/
-
-ACPI_PARSE_OBJECT *
-AcpiPsGetDepthNext (
- ACPI_PARSE_OBJECT *Origin,
- ACPI_PARSE_OBJECT *Op)
-{
- ACPI_PARSE_OBJECT *Next = NULL;
- ACPI_PARSE_OBJECT *Parent;
- ACPI_PARSE_OBJECT *Arg;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!Op)
- {
- return (NULL);
- }
-
- /* Look for an argument or child */
-
- Next = AcpiPsGetArg (Op, 0);
- if (Next)
- {
- return (Next);
- }
-
- /* Look for a sibling */
-
- Next = Op->Common.Next;
- if (Next)
- {
- return (Next);
- }
-
- /* Look for a sibling of parent */
-
- Parent = Op->Common.Parent;
-
- while (Parent)
- {
- Arg = AcpiPsGetArg (Parent, 0);
- while (Arg && (Arg != Origin) && (Arg != Op))
- {
- Arg = Arg->Common.Next;
- }
-
- if (Arg == Origin)
- {
- /* Reached parent of origin, end search */
-
- return (NULL);
- }
-
- if (Parent->Common.Next)
- {
- /* Found sibling of parent */
-
- return (Parent->Common.Next);
- }
-
- Op = Parent;
- Parent = Parent->Common.Parent;
- }
-
- return (Next);
-}
-
-
-#ifdef ACPI_OBSOLETE_FUNCTIONS
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsGetChild
- *
- * PARAMETERS: Op - Get the child of this Op
- *
- * RETURN: Child Op, Null if none is found.
- *
- * DESCRIPTION: Get op's children or NULL if none
- *
- ******************************************************************************/
-
-ACPI_PARSE_OBJECT *
-AcpiPsGetChild (
- ACPI_PARSE_OBJECT *Op)
-{
- ACPI_PARSE_OBJECT *Child = NULL;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- switch (Op->Common.AmlOpcode)
- {
- case AML_SCOPE_OP:
- case AML_ELSE_OP:
- case AML_DEVICE_OP:
- case AML_THERMAL_ZONE_OP:
- case AML_INT_METHODCALL_OP:
-
- Child = AcpiPsGetArg (Op, 0);
- break;
-
-
- case AML_BUFFER_OP:
- case AML_PACKAGE_OP:
- case AML_METHOD_OP:
- case AML_IF_OP:
- case AML_WHILE_OP:
- case AML_FIELD_OP:
-
- Child = AcpiPsGetArg (Op, 1);
- break;
-
-
- case AML_POWER_RES_OP:
- case AML_INDEX_FIELD_OP:
-
- Child = AcpiPsGetArg (Op, 2);
- break;
-
-
- case AML_PROCESSOR_OP:
- case AML_BANK_FIELD_OP:
-
- Child = AcpiPsGetArg (Op, 3);
- break;
-
-
- default:
- /* All others have no children */
- break;
- }
-
- return (Child);
-}
-#endif
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/psutils.c
--- a/head/sys/contrib/dev/acpica/parser/psutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,290 +0,0 @@
-/******************************************************************************
- *
- * Module Name: psutils - Parser miscellaneous utilities (Parser only)
- *
- *****************************************************************************/
-
-/*
- * 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>
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("psutils")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsCreateScopeOp
- *
- * PARAMETERS: None
- *
- * RETURN: A new Scope object, null on failure
- *
- * DESCRIPTION: Create a Scope and associated namepath op with the root name
- *
- ******************************************************************************/
-
-ACPI_PARSE_OBJECT *
-AcpiPsCreateScopeOp (
- void)
-{
- ACPI_PARSE_OBJECT *ScopeOp;
-
-
- ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP);
- if (!ScopeOp)
- {
- return (NULL);
- }
-
- ScopeOp->Named.Name = ACPI_ROOT_NAME;
- return (ScopeOp);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsInitOp
- *
- * PARAMETERS: Op - A newly allocated Op object
- * Opcode - Opcode to store in the Op
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize a parse (Op) object
- *
- ******************************************************************************/
-
-void
-AcpiPsInitOp (
- ACPI_PARSE_OBJECT *Op,
- UINT16 Opcode)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER;
- Op->Common.AmlOpcode = Opcode;
-
- ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName,
- (AcpiPsGetOpcodeInfo (Opcode))->Name,
- sizeof (Op->Common.AmlOpName)));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsAllocOp
- *
- * PARAMETERS: Opcode - Opcode that will be stored in the new Op
- *
- * RETURN: Pointer to the new Op, null on failure
- *
- * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
- * opcode. A cache of opcodes is available for the pure
- * GENERIC_OP, since this is by far the most commonly used.
- *
- ******************************************************************************/
-
-ACPI_PARSE_OBJECT*
-AcpiPsAllocOp (
- UINT16 Opcode)
-{
- ACPI_PARSE_OBJECT *Op;
- const ACPI_OPCODE_INFO *OpInfo;
- UINT8 Flags = ACPI_PARSEOP_GENERIC;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- OpInfo = AcpiPsGetOpcodeInfo (Opcode);
-
- /* Determine type of ParseOp required */
-
- if (OpInfo->Flags & AML_DEFER)
- {
- Flags = ACPI_PARSEOP_DEFERRED;
- }
- else if (OpInfo->Flags & AML_NAMED)
- {
- Flags = ACPI_PARSEOP_NAMED;
- }
- else if (Opcode == AML_INT_BYTELIST_OP)
- {
- Flags = ACPI_PARSEOP_BYTELIST;
- }
-
- /* Allocate the minimum required size object */
-
- if (Flags == ACPI_PARSEOP_GENERIC)
- {
- /* The generic op (default) is by far the most common (16 to 1) */
-
- Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache);
- }
- else
- {
- /* Extended parseop */
-
- Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache);
- }
-
- /* Initialize the Op */
-
- if (Op)
- {
- AcpiPsInitOp (Op, Opcode);
- Op->Common.Flags = Flags;
- }
-
- return (Op);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsFreeOp
- *
- * PARAMETERS: Op - Op to be freed
- *
- * RETURN: None.
- *
- * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list
- * or actually free it.
- *
- ******************************************************************************/
-
-void
-AcpiPsFreeOp (
- ACPI_PARSE_OBJECT *Op)
-{
- ACPI_FUNCTION_NAME (PsFreeOp);
-
-
- if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op));
- }
-
- if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
- {
- (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op);
- }
- else
- {
- (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: Utility functions
- *
- * DESCRIPTION: Low level character and object functions
- *
- ******************************************************************************/
-
-
-/*
- * Is "c" a namestring lead character?
- */
-BOOLEAN
-AcpiPsIsLeadingChar (
- UINT32 c)
-{
- return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z')));
-}
-
-
-/*
- * Is "c" a namestring prefix character?
- */
-BOOLEAN
-AcpiPsIsPrefixChar (
- UINT32 c)
-{
- return ((BOOLEAN) (c == '\\' || c == '^'));
-}
-
-
-/*
- * Get op's name (4-byte name segment) or 0 if unnamed
- */
-UINT32
-AcpiPsGetName (
- ACPI_PARSE_OBJECT *Op)
-{
-
- /* The "generic" object has no name associated with it */
-
- if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
- {
- return (0);
- }
-
- /* Only the "Extended" parse objects have a name */
-
- return (Op->Named.Name);
-}
-
-
-/*
- * Set op's name
- */
-void
-AcpiPsSetName (
- ACPI_PARSE_OBJECT *Op,
- UINT32 name)
-{
-
- /* The "generic" object has no name associated with it */
-
- if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
- {
- return;
- }
-
- Op->Named.Name = name;
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/pswalk.c
--- a/head/sys/contrib/dev/acpica/parser/pswalk.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/******************************************************************************
- *
- * Module Name: pswalk - Parser routines to walk parsed op tree(s)
- *
- *****************************************************************************/
-
-/*
- * 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>
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("pswalk")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsDeleteParseTree
- *
- * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete a portion of or an entire parse tree.
- *
- ******************************************************************************/
-
-void
-AcpiPsDeleteParseTree (
- ACPI_PARSE_OBJECT *SubtreeRoot)
-{
- ACPI_PARSE_OBJECT *Op = SubtreeRoot;
- ACPI_PARSE_OBJECT *Next = NULL;
- ACPI_PARSE_OBJECT *Parent = NULL;
-
-
- ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot);
-
-
- /* Visit all nodes in the subtree */
-
- while (Op)
- {
- /* Check if we are not ascending */
-
- if (Op != Parent)
- {
- /* Look for an argument or child of the current op */
-
- Next = AcpiPsGetArg (Op, 0);
- if (Next)
- {
- /* Still going downward in tree (Op is not completed yet) */
-
- Op = Next;
- continue;
- }
- }
-
- /* No more children, this Op is complete. */
-
- Next = Op->Common.Next;
- Parent = Op->Common.Parent;
-
- AcpiPsFreeOp (Op);
-
- /* If we are back to the starting point, the walk is complete. */
-
- if (Op == SubtreeRoot)
- {
- return_VOID;
- }
- if (Next)
- {
- Op = Next;
- }
- else
- {
- Op = Parent;
- }
- }
-
- return_VOID;
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/parser/psxface.c
--- a/head/sys/contrib/dev/acpica/parser/psxface.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,442 +0,0 @@
-/******************************************************************************
- *
- * Module Name: psxface - Parser 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.
- */
-
-#define __PSXFACE_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/acinterp.h>
-#include <contrib/dev/acpica/include/actables.h>
-
-
-#define _COMPONENT ACPI_PARSER
- ACPI_MODULE_NAME ("psxface")
-
-/* Local Prototypes */
-
-static void
-AcpiPsStartTrace (
- ACPI_EVALUATE_INFO *Info);
-
-static void
-AcpiPsStopTrace (
- ACPI_EVALUATE_INFO *Info);
-
-static void
-AcpiPsUpdateParameterList (
- ACPI_EVALUATE_INFO *Info,
- UINT16 Action);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDebugTrace
- *
- * PARAMETERS: MethodName - Valid ACPI name string
- * DebugLevel - Optional level mask. 0 to use default
- * DebugLayer - Optional layer mask. 0 to use default
- * Flags - bit 1: one shot(1) or persistent(0)
- *
- * RETURN: Status
- *
- * DESCRIPTION: External interface to enable debug tracing during control
- * method execution
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiDebugTrace (
- char *Name,
- UINT32 DebugLevel,
- UINT32 DebugLayer,
- UINT32 Flags)
-{
- ACPI_STATUS Status;
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* TBDs: Validate name, allow full path or just nameseg */
-
- AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name);
- AcpiGbl_TraceFlags = Flags;
-
- if (DebugLevel)
- {
- AcpiGbl_TraceDbgLevel = DebugLevel;
- }
- if (DebugLayer)
- {
- AcpiGbl_TraceDbgLayer = DebugLayer;
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsStartTrace
- *
- * PARAMETERS: Info - Method info struct
- *
- * RETURN: None
- *
- * DESCRIPTION: Start control method execution trace
- *
- ******************************************************************************/
-
-static void
-AcpiPsStartTrace (
- ACPI_EVALUATE_INFO *Info)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return;
- }
-
- if ((!AcpiGbl_TraceMethodName) ||
- (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
- {
- goto Exit;
- }
-
- AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
- AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
-
- AcpiDbgLevel = 0x00FFFFFF;
- AcpiDbgLayer = ACPI_UINT32_MAX;
-
- if (AcpiGbl_TraceDbgLevel)
- {
- AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
- }
- if (AcpiGbl_TraceDbgLayer)
- {
- AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
- }
-
-
-Exit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsStopTrace
- *
- * PARAMETERS: Info - Method info struct
- *
- * RETURN: None
- *
- * DESCRIPTION: Stop control method execution trace
- *
- ******************************************************************************/
-
-static void
-AcpiPsStopTrace (
- ACPI_EVALUATE_INFO *Info)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return;
- }
-
- if ((!AcpiGbl_TraceMethodName) ||
- (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
- {
- goto Exit;
- }
-
- /* Disable further tracing if type is one-shot */
-
- if (AcpiGbl_TraceFlags & 1)
- {
- AcpiGbl_TraceMethodName = 0;
- AcpiGbl_TraceDbgLevel = 0;
- AcpiGbl_TraceDbgLayer = 0;
- }
-
- AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
- AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
-
-Exit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsExecuteMethod
- *
- * PARAMETERS: Info - Method info block, contains:
- * Node - Method Node to execute
- * ObjDesc - Method object
- * Parameters - List of parameters to pass to the method,
- * terminated by NULL. Params itself may be
- * NULL if no parameters are being passed.
- * ReturnObject - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * ParameterType - Type of Parameter list
- * ReturnObject - Where to put method's return value (if
- * any). If NULL, no value is returned.
- * PassNumber - Parse or execute pass
- *
- * RETURN: Status
- *
- * DESCRIPTION: Execute a control method
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiPsExecuteMethod (
- ACPI_EVALUATE_INFO *Info)
-{
- ACPI_STATUS Status;
- ACPI_PARSE_OBJECT *Op;
- ACPI_WALK_STATE *WalkState;
-
-
- ACPI_FUNCTION_TRACE (PsExecuteMethod);
-
-
- /* Quick validation of DSDT header */
-
- AcpiTbCheckDsdtHeader ();
-
- /* Validate the Info and method Node */
-
- if (!Info || !Info->ResolvedNode)
- {
- return_ACPI_STATUS (AE_NULL_ENTRY);
- }
-
- /* Init for new method, wait on concurrency semaphore */
-
- Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * The caller "owns" the parameters, so give each one an extra reference
- */
- AcpiPsUpdateParameterList (Info, REF_INCREMENT);
-
- /* Begin tracing if requested */
-
- AcpiPsStartTrace (Info);
-
- /*
- * Execute the method. Performs parse simultaneously
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
- "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
- Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc));
-
- /* Create and init a Root Node */
-
- Op = AcpiPsCreateScopeOp ();
- if (!Op)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Create and initialize a new walk state */
-
- Info->PassNumber = ACPI_IMODE_EXECUTE;
- WalkState = AcpiDsCreateWalkState (
- Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
- if (!WalkState)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode,
- Info->ObjDesc->Method.AmlStart,
- Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
- if (ACPI_FAILURE (Status))
- {
- AcpiDsDeleteWalkState (WalkState);
- goto Cleanup;
- }
-
- if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
- {
- WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
- }
-
- /* Invoke an internal method if necessary */
-
- if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
- {
- Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState);
- Info->ReturnObject = WalkState->ReturnDesc;
-
- /* Cleanup states */
-
- AcpiDsScopeStackClear (WalkState);
- AcpiPsCleanupScope (&WalkState->ParserState);
- AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
- AcpiDsDeleteWalkState (WalkState);
- goto Cleanup;
- }
-
- /*
- * Start method evaluation with an implicit return of zero. This is done
- * for Windows compatibility.
- */
- if (AcpiGbl_EnableInterpreterSlack)
- {
- WalkState->ImplicitReturnObj =
- AcpiUtCreateIntegerObject ((UINT64) 0);
- if (!WalkState->ImplicitReturnObj)
- {
- Status = AE_NO_MEMORY;
- AcpiDsDeleteWalkState (WalkState);
- goto Cleanup;
- }
- }
-
- /* Parse the AML */
-
- Status = AcpiPsParseAml (WalkState);
-
- /* WalkState was deleted by ParseAml */
-
-Cleanup:
- AcpiPsDeleteParseTree (Op);
-
- /* End optional tracing */
-
- AcpiPsStopTrace (Info);
-
- /* Take away the extra reference that we gave the parameters above */
-
- AcpiPsUpdateParameterList (Info, REF_DECREMENT);
-
- /* Exit now if error above */
-
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * If the method has returned an object, signal this to the caller with
- * a control exception code
- */
- if (Info->ReturnObject)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
- Info->ReturnObject));
- ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
-
- Status = AE_CTRL_RETURN_VALUE;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiPsUpdateParameterList
- *
- * PARAMETERS: Info - See ACPI_EVALUATE_INFO
- * (Used: ParameterType and Parameters)
- * Action - Add or Remove reference
- *
- * RETURN: Status
- *
- * DESCRIPTION: Update reference count on all method parameter objects
- *
- ******************************************************************************/
-
-static void
-AcpiPsUpdateParameterList (
- ACPI_EVALUATE_INFO *Info,
- UINT16 Action)
-{
- UINT32 i;
-
-
- if (Info->Parameters)
- {
- /* Update reference count for each parameter */
-
- for (i = 0; Info->Parameters[i]; i++)
- {
- /* Ignore errors, just do them all */
-
- (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action);
- }
- }
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsaddr.c
--- a/head/sys/contrib/dev/acpica/resources/rsaddr.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,407 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsaddr - Address resource descriptors (16/32/64)
- *
- ******************************************************************************/
-
-/*
- * 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 __RSADDR_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsaddr")
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertAddress16 - All WORD (16-bit) address resources
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
- ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
- sizeof (AML_RESOURCE_ADDRESS16),
- 0},
-
- /* Resource Type, General Flags, and Type-Specific Flags */
-
- {ACPI_RSC_ADDRESS, 0, 0, 0},
-
- /*
- * These fields are contiguous in both the source and destination:
- * Address Granularity
- * Address Range Minimum
- * Address Range Maximum
- * Address Translation Offset
- * Address Length
- */
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity),
- AML_OFFSET (Address16.Granularity),
- 5},
-
- /* Optional ResourceSource (Index and String) */
-
- {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource),
- 0,
- sizeof (AML_RESOURCE_ADDRESS16)}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
- ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
- sizeof (AML_RESOURCE_ADDRESS32),
- 0},
-
- /* Resource Type, General Flags, and Type-Specific Flags */
-
- {ACPI_RSC_ADDRESS, 0, 0, 0},
-
- /*
- * These fields are contiguous in both the source and destination:
- * Address Granularity
- * Address Range Minimum
- * Address Range Maximum
- * Address Translation Offset
- * Address Length
- */
- {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity),
- AML_OFFSET (Address32.Granularity),
- 5},
-
- /* Optional ResourceSource (Index and String) */
-
- {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource),
- 0,
- sizeof (AML_RESOURCE_ADDRESS32)}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
- ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
- sizeof (AML_RESOURCE_ADDRESS64),
- 0},
-
- /* Resource Type, General Flags, and Type-Specific Flags */
-
- {ACPI_RSC_ADDRESS, 0, 0, 0},
-
- /*
- * These fields are contiguous in both the source and destination:
- * Address Granularity
- * Address Range Minimum
- * Address Range Maximum
- * Address Translation Offset
- * Address Length
- */
- {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity),
- AML_OFFSET (Address64.Granularity),
- 5},
-
- /* Optional ResourceSource (Index and String) */
-
- {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource),
- 0,
- sizeof (AML_RESOURCE_ADDRESS64)}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
- ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
- sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),
- 0},
-
- /* Resource Type, General Flags, and Type-Specific Flags */
-
- {ACPI_RSC_ADDRESS, 0, 0, 0},
-
- /* Revision ID */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID),
- AML_OFFSET (ExtAddress64.RevisionID),
- 1},
- /*
- * These fields are contiguous in both the source and destination:
- * Address Granularity
- * Address Range Minimum
- * Address Range Maximum
- * Address Translation Offset
- * Address Length
- * Type-Specific Attribute
- */
- {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity),
- AML_OFFSET (ExtAddress64.Granularity),
- 6}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertGeneralFlags - Flags common to all address descriptors
- *
- ******************************************************************************/
-
-static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] =
-{
- {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)},
-
- /* Resource Type (Memory, Io, BusNumber, etc.) */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType),
- AML_OFFSET (Address.ResourceType),
- 1},
-
- /* General Flags - Consume, Decode, MinFixed, MaxFixed */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer),
- AML_OFFSET (Address.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode),
- AML_OFFSET (Address.Flags),
- 1},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed),
- AML_OFFSET (Address.Flags),
- 2},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed),
- AML_OFFSET (Address.Flags),
- 3}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertMemFlags - Flags common to Memory address descriptors
- *
- ******************************************************************************/
-
-static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] =
-{
- {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)},
-
- /* Memory-specific flags */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect),
- AML_OFFSET (Address.SpecificFlags),
- 0},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching),
- AML_OFFSET (Address.SpecificFlags),
- 1},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType),
- AML_OFFSET (Address.SpecificFlags),
- 3},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation),
- AML_OFFSET (Address.SpecificFlags),
- 5}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertIoFlags - Flags common to I/O address descriptors
- *
- ******************************************************************************/
-
-static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] =
-{
- {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)},
-
- /* I/O-specific flags */
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType),
- AML_OFFSET (Address.SpecificFlags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation),
- AML_OFFSET (Address.SpecificFlags),
- 4},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType),
- AML_OFFSET (Address.SpecificFlags),
- 5}
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetAddressCommon
- *
- * PARAMETERS: Resource - Pointer to the internal resource struct
- * Aml - Pointer to the AML resource descriptor
- *
- * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise
- *
- * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
- * to an internal resource descriptor
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiRsGetAddressCommon (
- ACPI_RESOURCE *Resource,
- AML_RESOURCE *Aml)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Validate the Resource Type */
-
- if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0))
- {
- return (FALSE);
- }
-
- /* Get the Resource Type and General Flags */
-
- (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags);
-
- /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
-
- if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
- {
- (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags);
- }
- else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
- {
- (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags);
- }
- else
- {
- /* Generic resource type, just grab the TypeSpecific byte */
-
- Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags;
- }
-
- return (TRUE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsSetAddressCommon
- *
- * PARAMETERS: Aml - Pointer to the AML resource descriptor
- * Resource - Pointer to the internal resource struct
- *
- * RETURN: None
- *
- * DESCRIPTION: Convert common flag fields from a resource descriptor to an
- * AML descriptor
- *
- ******************************************************************************/
-
-void
-AcpiRsSetAddressCommon (
- AML_RESOURCE *Aml,
- ACPI_RESOURCE *Resource)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Set the Resource Type and General Flags */
-
- (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags);
-
- /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
-
- if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
- {
- (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags);
- }
- else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
- {
- (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags);
- }
- else
- {
- /* Generic resource type, just copy the TypeSpecific byte */
-
- Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific;
- }
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rscalc.c
--- a/head/sys/contrib/dev/acpica/resources/rscalc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,730 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rscalc - Calculate stream and list lengths
- *
- ******************************************************************************/
-
-/*
- * 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 __RSCALC_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rscalc")
-
-
-/* Local prototypes */
-
-static UINT8
-AcpiRsCountSetBits (
- UINT16 BitField);
-
-static ACPI_RS_LENGTH
-AcpiRsStructOptionLength (
- ACPI_RESOURCE_SOURCE *ResourceSource);
-
-static UINT32
-AcpiRsStreamOptionLength (
- UINT32 ResourceLength,
- UINT32 MinimumTotalLength);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsCountSetBits
- *
- * PARAMETERS: BitField - Field in which to count bits
- *
- * RETURN: Number of bits set within the field
- *
- * DESCRIPTION: Count the number of bits set in a resource field. Used for
- * (Short descriptor) interrupt and DMA lists.
- *
- ******************************************************************************/
-
-static UINT8
-AcpiRsCountSetBits (
- UINT16 BitField)
-{
- UINT8 BitsSet;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- for (BitsSet = 0; BitField; BitsSet++)
- {
- /* Zero the least significant bit that is set */
-
- BitField &= (UINT16) (BitField - 1);
- }
-
- return (BitsSet);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsStructOptionLength
- *
- * PARAMETERS: ResourceSource - Pointer to optional descriptor field
- *
- * RETURN: Status
- *
- * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
- * ResourceSource fields in some Large descriptors. Used during
- * list-to-stream conversion
- *
- ******************************************************************************/
-
-static ACPI_RS_LENGTH
-AcpiRsStructOptionLength (
- ACPI_RESOURCE_SOURCE *ResourceSource)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * If the ResourceSource string is valid, return the size of the string
- * (StringLength includes the NULL terminator) plus the size of the
- * ResourceSourceIndex (1).
- */
- if (ResourceSource->StringPtr)
- {
- return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1));
- }
-
- return (0);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsStreamOptionLength
- *
- * PARAMETERS: ResourceLength - Length from the resource header
- * MinimumTotalLength - Minimum length of this resource, before
- * any optional fields. Includes header size
- *
- * RETURN: Length of optional string (0 if no string present)
- *
- * DESCRIPTION: Common code to handle optional ResourceSourceIndex and
- * ResourceSource fields in some Large descriptors. Used during
- * stream-to-list conversion
- *
- ******************************************************************************/
-
-static UINT32
-AcpiRsStreamOptionLength (
- UINT32 ResourceLength,
- UINT32 MinimumAmlResourceLength)
-{
- UINT32 StringLength = 0;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * The ResourceSourceIndex and ResourceSource are optional elements of some
- * Large-type resource descriptors.
- */
-
- /*
- * If the length of the actual resource descriptor is greater than the ACPI
- * spec-defined minimum length, it means that a ResourceSourceIndex exists
- * and is followed by a (required) null terminated string. The string length
- * (including the null terminator) is the resource length minus the minimum
- * length, minus one byte for the ResourceSourceIndex itself.
- */
- if (ResourceLength > MinimumAmlResourceLength)
- {
- /* Compute the length of the optional string */
-
- StringLength = ResourceLength - MinimumAmlResourceLength - 1;
- }
-
- /*
- * Round the length up to a multiple of the native word in order to
- * guarantee that the entire resource descriptor is native word aligned
- */
- return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetAmlLength
- *
- * PARAMETERS: Resource - Pointer to the resource linked list
- * SizeNeeded - Where the required size is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Takes a linked list of internal resource descriptors and
- * calculates the size buffer needed to hold the corresponding
- * external resource byte stream.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetAmlLength (
- ACPI_RESOURCE *Resource,
- ACPI_SIZE *SizeNeeded)
-{
- ACPI_SIZE AmlSizeNeeded = 0;
- ACPI_RS_LENGTH TotalSize;
-
-
- ACPI_FUNCTION_TRACE (RsGetAmlLength);
-
-
- /* Traverse entire list of internal resource descriptors */
-
- while (Resource)
- {
- /* Validate the descriptor type */
-
- if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
- {
- return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
- }
-
- /* Get the base size of the (external stream) resource descriptor */
-
- TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type];
-
- /*
- * Augment the base size for descriptors with optional and/or
- * variable-length fields
- */
- switch (Resource->Type)
- {
- case ACPI_RESOURCE_TYPE_IRQ:
-
- /* Length can be 3 or 2 */
-
- if (Resource->Data.Irq.DescriptorLength == 2)
- {
- TotalSize--;
- }
- break;
-
-
- case ACPI_RESOURCE_TYPE_START_DEPENDENT:
-
- /* Length can be 1 or 0 */
-
- if (Resource->Data.Irq.DescriptorLength == 0)
- {
- TotalSize--;
- }
- break;
-
-
- case ACPI_RESOURCE_TYPE_VENDOR:
- /*
- * Vendor Defined Resource:
- * For a Vendor Specific resource, if the Length is between 1 and 7
- * it will be created as a Small Resource data type, otherwise it
- * is a Large Resource data type.
- */
- if (Resource->Data.Vendor.ByteLength > 7)
- {
- /* Base size of a Large resource descriptor */
-
- TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER);
- }
-
- /* Add the size of the vendor-specific data */
-
- TotalSize = (ACPI_RS_LENGTH)
- (TotalSize + Resource->Data.Vendor.ByteLength);
- break;
-
-
- case ACPI_RESOURCE_TYPE_END_TAG:
- /*
- * End Tag:
- * We are done -- return the accumulated total size.
- */
- *SizeNeeded = AmlSizeNeeded + TotalSize;
-
- /* Normal exit */
-
- return_ACPI_STATUS (AE_OK);
-
-
- case ACPI_RESOURCE_TYPE_ADDRESS16:
- /*
- * 16-Bit Address Resource:
- * Add the size of the optional ResourceSource info
- */
- TotalSize = (ACPI_RS_LENGTH)
- (TotalSize + AcpiRsStructOptionLength (
- &Resource->Data.Address16.ResourceSource));
- break;
-
-
- case ACPI_RESOURCE_TYPE_ADDRESS32:
- /*
- * 32-Bit Address Resource:
- * Add the size of the optional ResourceSource info
- */
- TotalSize = (ACPI_RS_LENGTH)
- (TotalSize + AcpiRsStructOptionLength (
- &Resource->Data.Address32.ResourceSource));
- break;
-
-
- case ACPI_RESOURCE_TYPE_ADDRESS64:
- /*
- * 64-Bit Address Resource:
- * Add the size of the optional ResourceSource info
- */
- TotalSize = (ACPI_RS_LENGTH)
- (TotalSize + AcpiRsStructOptionLength (
- &Resource->Data.Address64.ResourceSource));
- break;
-
-
- case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
- /*
- * Extended IRQ Resource:
- * Add the size of each additional optional interrupt beyond the
- * required 1 (4 bytes for each UINT32 interrupt number)
- */
- TotalSize = (ACPI_RS_LENGTH)
- (TotalSize +
- ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +
-
- /* Add the size of the optional ResourceSource info */
-
- AcpiRsStructOptionLength (
- &Resource->Data.ExtendedIrq.ResourceSource));
- break;
-
-
- case ACPI_RESOURCE_TYPE_GPIO:
-
- TotalSize = (ACPI_RS_LENGTH) (TotalSize + (Resource->Data.Gpio.PinTableLength * 2) +
- Resource->Data.Gpio.ResourceSource.StringLength +
- Resource->Data.Gpio.VendorLength);
-
- break;
-
-
- case ACPI_RESOURCE_TYPE_SERIAL_BUS:
-
- TotalSize = AcpiGbl_AmlResourceSerialBusSizes [Resource->Data.CommonSerialBus.Type];
-
- TotalSize = (ACPI_RS_LENGTH) (TotalSize +
- Resource->Data.I2cSerialBus.ResourceSource.StringLength +
- Resource->Data.I2cSerialBus.VendorLength);
-
- break;
-
-
- default:
- break;
- }
-
- /* Update the total */
-
- AmlSizeNeeded += TotalSize;
-
- /* Point to the next object */
-
- Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
- }
-
- /* Did not find an EndTag resource descriptor */
-
- return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetListLength
- *
- * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
- * AmlBufferLength - Size of AmlBuffer
- * SizeNeeded - Where the size needed is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Takes an external resource byte stream and calculates the size
- * buffer needed to hold the corresponding internal resource
- * descriptor linked list.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetListLength (
- UINT8 *AmlBuffer,
- UINT32 AmlBufferLength,
- ACPI_SIZE *SizeNeeded)
-{
- ACPI_STATUS Status;
- UINT8 *EndAml;
- UINT8 *Buffer;
- UINT32 BufferSize;
- UINT16 Temp16;
- UINT16 ResourceLength;
- UINT32 ExtraStructBytes;
- UINT8 ResourceIndex;
- UINT8 MinimumAmlResourceLength;
- AML_RESOURCE *AmlResource;
-
-
- ACPI_FUNCTION_TRACE (RsGetListLength);
-
-
- *SizeNeeded = ACPI_RS_SIZE_MIN; /* Minimum size is one EndTag */
- EndAml = AmlBuffer + AmlBufferLength;
-
- /* Walk the list of AML resource descriptors */
-
- while (AmlBuffer < EndAml)
- {
- /* Validate the Resource Type and Resource Length */
-
- Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex);
- if (ACPI_FAILURE (Status))
- {
- /*
- * Exit on failure. Cannot continue because the descriptor length
- * may be bogus also.
- */
- return_ACPI_STATUS (Status);
- }
-
- AmlResource = (void *) AmlBuffer;
-
- /* Get the resource length and base (minimum) AML size */
-
- ResourceLength = AcpiUtGetResourceLength (AmlBuffer);
- MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
-
- /*
- * Augment the size for descriptors with optional
- * and/or variable length fields
- */
- ExtraStructBytes = 0;
- Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);
-
- switch (AcpiUtGetResourceType (AmlBuffer))
- {
- case ACPI_RESOURCE_NAME_IRQ:
- /*
- * IRQ Resource:
- * Get the number of bits set in the 16-bit IRQ mask
- */
- ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
- ExtraStructBytes = AcpiRsCountSetBits (Temp16);
- break;
-
-
- case ACPI_RESOURCE_NAME_DMA:
- /*
- * DMA Resource:
- * Get the number of bits set in the 8-bit DMA mask
- */
- ExtraStructBytes = AcpiRsCountSetBits (*Buffer);
- break;
-
-
- case ACPI_RESOURCE_NAME_VENDOR_SMALL:
- case ACPI_RESOURCE_NAME_VENDOR_LARGE:
- /*
- * Vendor Resource:
- * Get the number of vendor data bytes
- */
- ExtraStructBytes = ResourceLength;
- break;
-
-
- case ACPI_RESOURCE_NAME_END_TAG:
- /*
- * End Tag: This is the normal exit
- */
- return_ACPI_STATUS (AE_OK);
-
-
- case ACPI_RESOURCE_NAME_ADDRESS32:
- case ACPI_RESOURCE_NAME_ADDRESS16:
- case ACPI_RESOURCE_NAME_ADDRESS64:
- /*
- * Address Resource:
- * Add the size of the optional ResourceSource
- */
- ExtraStructBytes = AcpiRsStreamOptionLength (
- ResourceLength, MinimumAmlResourceLength);
- break;
-
-
- case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
- /*
- * Extended IRQ Resource:
- * Using the InterruptTableLength, add 4 bytes for each additional
- * interrupt. Note: at least one interrupt is required and is
- * included in the minimum descriptor size (reason for the -1)
- */
- ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);
-
- /* Add the size of the optional ResourceSource */
-
- ExtraStructBytes += AcpiRsStreamOptionLength (
- ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);
- break;
-
- case ACPI_RESOURCE_NAME_GPIO:
-
- /* Vendor data is optional */
-
- if (AmlResource->Gpio.VendorLength)
- {
- ExtraStructBytes += AmlResource->Gpio.VendorOffset -
- AmlResource->Gpio.PinTableOffset + AmlResource->Gpio.VendorLength;
- }
- else
- {
- ExtraStructBytes += AmlResource->LargeHeader.ResourceLength +
- sizeof (AML_RESOURCE_LARGE_HEADER) -
- AmlResource->Gpio.PinTableOffset;
- }
- break;
-
- case ACPI_RESOURCE_NAME_SERIAL_BUS:
-
- MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[
- AmlResource->CommonSerialBus.Type];
- ExtraStructBytes += AmlResource->CommonSerialBus.ResourceLength -
- MinimumAmlResourceLength;
- break;
-
- default:
- break;
- }
-
- /*
- * Update the required buffer size for the internal descriptor structs
- *
- * Important: Round the size up for the appropriate alignment. This
- * is a requirement on IA64.
- */
- if (AcpiUtGetResourceType (AmlBuffer) == ACPI_RESOURCE_NAME_SERIAL_BUS)
- {
- BufferSize = AcpiGbl_ResourceStructSerialBusSizes[
- AmlResource->CommonSerialBus.Type] + ExtraStructBytes;
- }
- else
- {
- BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +
- ExtraStructBytes;
- }
- BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize);
-
- *SizeNeeded += BufferSize;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
- "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
- AcpiUtGetResourceType (AmlBuffer),
- AcpiUtGetDescriptorLength (AmlBuffer), BufferSize));
-
- /*
- * Point to the next resource within the AML stream using the length
- * contained in the resource descriptor header
- */
- AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);
- }
-
- /* Did not find an EndTag resource descriptor */
-
- return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetPciRoutingTableLength
- *
- * PARAMETERS: PackageObject - Pointer to the package object
- * BufferSizeNeeded - UINT32 pointer of the size buffer
- * needed to properly return the
- * parsed data
- *
- * RETURN: Status
- *
- * DESCRIPTION: Given a package representing a PCI routing table, this
- * calculates the size of the corresponding linked list of
- * descriptions.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetPciRoutingTableLength (
- ACPI_OPERAND_OBJECT *PackageObject,
- ACPI_SIZE *BufferSizeNeeded)
-{
- UINT32 NumberOfElements;
- ACPI_SIZE TempSizeNeeded = 0;
- ACPI_OPERAND_OBJECT **TopObjectList;
- UINT32 Index;
- ACPI_OPERAND_OBJECT *PackageElement;
- ACPI_OPERAND_OBJECT **SubObjectList;
- BOOLEAN NameFound;
- UINT32 TableIndex;
-
-
- ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);
-
-
- NumberOfElements = PackageObject->Package.Count;
-
- /*
- * Calculate the size of the return buffer.
- * The base size is the number of elements * the sizes of the
- * structures. Additional space for the strings is added below.
- * The minus one is to subtract the size of the UINT8 Source[1]
- * member because it is added below.
- *
- * But each PRT_ENTRY structure has a pointer to a string and
- * the size of that string must be found.
- */
- TopObjectList = PackageObject->Package.Elements;
-
- for (Index = 0; Index < NumberOfElements; Index++)
- {
- /* Dereference the sub-package */
-
- PackageElement = *TopObjectList;
-
- /* We must have a valid Package object */
-
- if (!PackageElement ||
- (PackageElement->Common.Type != ACPI_TYPE_PACKAGE))
- {
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * The SubObjectList will now point to an array of the
- * four IRQ elements: Address, Pin, Source and SourceIndex
- */
- SubObjectList = PackageElement->Package.Elements;
-
- /* Scan the IrqTableElements for the Source Name String */
-
- NameFound = FALSE;
-
- for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++)
- {
- if (*SubObjectList && /* Null object allowed */
-
- ((ACPI_TYPE_STRING ==
- (*SubObjectList)->Common.Type) ||
-
- ((ACPI_TYPE_LOCAL_REFERENCE ==
- (*SubObjectList)->Common.Type) &&
-
- ((*SubObjectList)->Reference.Class ==
- ACPI_REFCLASS_NAME))))
- {
- NameFound = TRUE;
- }
- else
- {
- /* Look at the next element */
-
- SubObjectList++;
- }
- }
-
- TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
-
- /* Was a String type found? */
-
- if (NameFound)
- {
- if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING)
- {
- /*
- * The length String.Length field does not include the
- * terminating NULL, add 1
- */
- TempSizeNeeded += ((ACPI_SIZE)
- (*SubObjectList)->String.Length + 1);
- }
- else
- {
- TempSizeNeeded += AcpiNsGetPathnameLength (
- (*SubObjectList)->Reference.Node);
- }
- }
- else
- {
- /*
- * If no name was found, then this is a NULL, which is
- * translated as a UINT32 zero.
- */
- TempSizeNeeded += sizeof (UINT32);
- }
-
- /* Round up the size since each element must be aligned */
-
- TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);
-
- /* Point to the next ACPI_OPERAND_OBJECT */
-
- TopObjectList++;
- }
-
- /*
- * Add an extra element to the end of the list, essentially a
- * NULL terminator
- */
- *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);
- return_ACPI_STATUS (AE_OK);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rscreate.c
--- a/head/sys/contrib/dev/acpica/resources/rscreate.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,534 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rscreate - Create resource lists/tables
- *
- ******************************************************************************/
-
-/*
- * 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 __RSCREATE_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rscreate")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiBufferToResource
- *
- * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
- * AmlBufferLength - Length of the AmlBuffer
- * ResourcePtr - Where the converted resource is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert a raw AML buffer to a resource list
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiBufferToResource (
- UINT8 *AmlBuffer,
- UINT16 AmlBufferLength,
- ACPI_RESOURCE **ResourcePtr)
-{
- ACPI_STATUS Status;
- ACPI_SIZE ListSizeNeeded;
- void *Resource;
- void *CurrentResourcePtr;
-
- /*
- * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag
- * is not required here.
- */
-
- /* Get the required length for the converted resource */
-
- Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength,
- &ListSizeNeeded);
- if (Status == AE_AML_NO_RESOURCE_END_TAG)
- {
- Status = AE_OK;
- }
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Allocate a buffer for the converted resource */
-
- Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded);
- CurrentResourcePtr = Resource;
- if (!Resource)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Perform the AML-to-Resource conversion */
-
- Status = AcpiUtWalkAmlResources (AmlBuffer, AmlBufferLength,
- AcpiRsConvertAmlToResources, &CurrentResourcePtr);
- if (Status == AE_AML_NO_RESOURCE_END_TAG)
- {
- Status = AE_OK;
- }
- if (ACPI_FAILURE (Status))
- {
- ACPI_FREE (Resource);
- }
- else
- {
- *ResourcePtr = Resource;
- }
-
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsCreateResourceList
- *
- * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
- * OutputBuffer - Pointer to the user's buffer
- *
- * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code
- * If OutputBuffer is not large enough, OutputBufferLength
- * indicates how large OutputBuffer should be, else it
- * indicates how may UINT8 elements of OutputBuffer are valid.
- *
- * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
- * execution and parses the stream to create a linked list
- * of device resources.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsCreateResourceList (
- ACPI_OPERAND_OBJECT *AmlBuffer,
- ACPI_BUFFER *OutputBuffer)
-{
-
- ACPI_STATUS Status;
- UINT8 *AmlStart;
- ACPI_SIZE ListSizeNeeded = 0;
- UINT32 AmlBufferLength;
- void *Resource;
-
-
- ACPI_FUNCTION_TRACE (RsCreateResourceList);
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
- AmlBuffer));
-
- /* Params already validated, so we don't re-validate here */
-
- AmlBufferLength = AmlBuffer->Buffer.Length;
- AmlStart = AmlBuffer->Buffer.Pointer;
-
- /*
- * Pass the AmlBuffer into a module that can calculate
- * the buffer size needed for the linked list
- */
- Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
- &ListSizeNeeded);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
- Status, (UINT32) ListSizeNeeded));
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Do the conversion */
-
- Resource = OutputBuffer->Pointer;
- Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
- AcpiRsConvertAmlToResources, &Resource);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
- OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsCreatePciRoutingTable
- *
- * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT
- * package
- * OutputBuffer - Pointer to the user's buffer
- *
- * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
- * If the OutputBuffer is too small, the error will be
- * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
- * to the size buffer needed.
- *
- * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
- * linked list of PCI interrupt descriptions
- *
- * NOTE: It is the caller's responsibility to ensure that the start of the
- * output buffer is aligned properly (if necessary).
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsCreatePciRoutingTable (
- ACPI_OPERAND_OBJECT *PackageObject,
- ACPI_BUFFER *OutputBuffer)
-{
- UINT8 *Buffer;
- ACPI_OPERAND_OBJECT **TopObjectList;
- ACPI_OPERAND_OBJECT **SubObjectList;
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_SIZE BufferSizeNeeded = 0;
- UINT32 NumberOfElements;
- UINT32 Index;
- ACPI_PCI_ROUTING_TABLE *UserPrt;
- ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status;
- ACPI_BUFFER PathBuffer;
-
-
- ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
-
-
- /* Params already validated, so we don't re-validate here */
-
- /* Get the required buffer length */
-
- Status = AcpiRsGetPciRoutingTableLength (PackageObject,
- &BufferSizeNeeded);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
- (UINT32) BufferSizeNeeded));
-
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
- * package that in turn contains an UINT64 Address, a UINT8 Pin,
- * a Name, and a UINT8 SourceIndex.
- */
- TopObjectList = PackageObject->Package.Elements;
- NumberOfElements = PackageObject->Package.Count;
- Buffer = OutputBuffer->Pointer;
- UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
-
- for (Index = 0; Index < NumberOfElements; Index++)
- {
- /*
- * Point UserPrt past this current structure
- *
- * NOTE: On the first iteration, UserPrt->Length will
- * be zero because we cleared the return buffer earlier
- */
- Buffer += UserPrt->Length;
- UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
-
- /*
- * Fill in the Length field with the information we have at this point.
- * The minus four is to subtract the size of the UINT8 Source[4] member
- * because it is added below.
- */
- UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
-
- /* Each element of the top-level package must also be a package */
-
- if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE)
- {
- ACPI_ERROR ((AE_INFO,
- "(PRT[%u]) Need sub-package, found %s",
- Index, AcpiUtGetObjectTypeName (*TopObjectList)));
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /* Each sub-package must be of length 4 */
-
- if ((*TopObjectList)->Package.Count != 4)
- {
- ACPI_ERROR ((AE_INFO,
- "(PRT[%u]) Need package of length 4, found length %u",
- Index, (*TopObjectList)->Package.Count));
- return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
- }
-
- /*
- * Dereference the sub-package.
- * The SubObjectList will now point to an array of the four IRQ
- * elements: [Address, Pin, Source, SourceIndex]
- */
- SubObjectList = (*TopObjectList)->Package.Elements;
-
- /* 1) First subobject: Dereference the PRT.Address */
-
- ObjDesc = SubObjectList[0];
- if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
- {
- ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s",
- Index, AcpiUtGetObjectTypeName (ObjDesc)));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
-
- UserPrt->Address = ObjDesc->Integer.Value;
-
- /* 2) Second subobject: Dereference the PRT.Pin */
-
- ObjDesc = SubObjectList[1];
- if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
- {
- ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
- Index, AcpiUtGetObjectTypeName (ObjDesc)));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
-
- UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
-
- /*
- * If the BIOS has erroneously reversed the _PRT SourceName (index 2)
- * and the SourceIndex (index 3), fix it. _PRT is important enough to
- * workaround this BIOS error. This also provides compatibility with
- * other ACPI implementations.
- */
- ObjDesc = SubObjectList[3];
- if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
- {
- SubObjectList[3] = SubObjectList[2];
- SubObjectList[2] = ObjDesc;
-
- ACPI_WARNING ((AE_INFO,
- "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
- Index));
- }
-
- /*
- * 3) Third subobject: Dereference the PRT.SourceName
- * The name may be unresolved (slack mode), so allow a null object
- */
- ObjDesc = SubObjectList[2];
- if (ObjDesc)
- {
- switch (ObjDesc->Common.Type)
- {
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
- {
- ACPI_ERROR ((AE_INFO,
- "(PRT[%u].Source) Need name, found Reference Class 0x%X",
- Index, ObjDesc->Reference.Class));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
-
- Node = ObjDesc->Reference.Node;
-
- /* Use *remaining* length of the buffer as max for pathname */
-
- PathBuffer.Length = OutputBuffer->Length -
- (UINT32) ((UINT8 *) UserPrt->Source -
- (UINT8 *) OutputBuffer->Pointer);
- PathBuffer.Pointer = UserPrt->Source;
-
- Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
-
- /* +1 to include null terminator */
-
- UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
- break;
-
-
- case ACPI_TYPE_STRING:
-
- ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
-
- /*
- * Add to the Length field the length of the string
- * (add 1 for terminator)
- */
- UserPrt->Length += ObjDesc->String.Length + 1;
- break;
-
-
- case ACPI_TYPE_INTEGER:
- /*
- * If this is a number, then the Source Name is NULL, since the
- * entire buffer was zeroed out, we can leave this alone.
- *
- * Add to the Length field the length of the UINT32 NULL
- */
- UserPrt->Length += sizeof (UINT32);
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO,
- "(PRT[%u].Source) Need Ref/String/Integer, found %s",
- Index, AcpiUtGetObjectTypeName (ObjDesc)));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
- }
-
- /* Now align the current length */
-
- UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
-
- /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
-
- ObjDesc = SubObjectList[3];
- if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
- {
- ACPI_ERROR ((AE_INFO,
- "(PRT[%u].SourceIndex) Need Integer, found %s",
- Index, AcpiUtGetObjectTypeName (ObjDesc)));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
-
- UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
-
- /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
-
- TopObjectList++;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
- OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsCreateAmlResources
- *
- * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
- * OutputBuffer - Pointer to the user's buffer
- *
- * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
- * If the OutputBuffer is too small, the error will be
- * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
- * to the size buffer needed.
- *
- * DESCRIPTION: Takes the linked list of device resources and
- * creates a bytestream to be used as input for the
- * _SRS control method.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsCreateAmlResources (
- ACPI_RESOURCE *LinkedListBuffer,
- ACPI_BUFFER *OutputBuffer)
-{
- ACPI_STATUS Status;
- ACPI_SIZE AmlSizeNeeded = 0;
-
-
- ACPI_FUNCTION_TRACE (RsCreateAmlResources);
-
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
- LinkedListBuffer));
-
- /*
- * Params already validated, so we don't re-validate here
- *
- * Pass the LinkedListBuffer into a module that calculates
- * the buffer size needed for the byte stream.
- */
- Status = AcpiRsGetAmlLength (LinkedListBuffer,
- &AmlSizeNeeded);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
- (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Do the conversion */
-
- Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded,
- OutputBuffer->Pointer);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
- OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
- return_ACPI_STATUS (AE_OK);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsdump.c
--- a/head/sys/contrib/dev/acpica/resources/rsdump.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,946 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsdump - Functions to display the resource structures.
- *
- ******************************************************************************/
-
-/*
- * 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 __RSDUMP_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsdump")
-
-
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-
-/* Local prototypes */
-
-static void
-AcpiRsOutString (
- char *Title,
- char *Value);
-
-static void
-AcpiRsOutInteger8 (
- char *Title,
- UINT8 Value);
-
-static void
-AcpiRsOutInteger16 (
- char *Title,
- UINT16 Value);
-
-static void
-AcpiRsOutInteger32 (
- char *Title,
- UINT32 Value);
-
-static void
-AcpiRsOutInteger64 (
- char *Title,
- UINT64 Value);
-
-static void
-AcpiRsOutTitle (
- char *Title);
-
-static void
-AcpiRsDumpByteList (
- UINT16 Length,
- UINT8 *Data);
-
-static void
-AcpiRsDumpWordList (
- UINT16 Length,
- UINT16 *Data);
-
-static void
-AcpiRsDumpDwordList (
- UINT8 Length,
- UINT32 *Data);
-
-static void
-AcpiRsDumpShortByteList (
- UINT8 Length,
- UINT8 *Data);
-
-static void
-AcpiRsDumpResourceSource (
- ACPI_RESOURCE_SOURCE *ResourceSource);
-
-static void
-AcpiRsDumpAddressCommon (
- ACPI_RESOURCE_DATA *Resource);
-
-static void
-AcpiRsDumpDescriptor (
- void *Resource,
- ACPI_RSDUMP_INFO *Table);
-
-
-#define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f)
-#define ACPI_PRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f)
-#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_RSDUMP_INFO))
-
-
-/*******************************************************************************
- *
- * Resource Descriptor info tables
- *
- * Note: The first table entry must be a Title or Literal and must contain
- * the table length (number of table entries)
- *
- ******************************************************************************/
-
-ACPI_RSDUMP_INFO AcpiRsDumpIrq[7] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL},
- {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.DescriptorLength), "Descriptor Length", NULL},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HeDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LlDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_ShrDecode},
- {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL},
- {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpDma[6] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TypDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BmDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SizDecode},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL},
- {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[4] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf), "Start-Dependent-Functions",NULL},
- {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (StartDpf.DescriptorLength), "Descriptor Length", NULL},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority), "Compatibility Priority", AcpiGbl_ConfigDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness), "Performance/Robustness", AcpiGbl_ConfigDecode}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[1] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf), "End-Dependent-Functions", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpIo[6] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo), "I/O", NULL},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode), "Address Decoding", AcpiGbl_IoDecode},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Minimum), "Address Minimum", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Maximum), "Address Maximum", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.Alignment), "Alignment", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.AddressLength), "Address Length", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[3] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo), "Fixed I/O", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedIo.Address), "Address", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedIo.AddressLength), "Address Length", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpVendor[3] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor), "Vendor Specific", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Vendor.ByteLength), "Length", NULL},
- {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]), "Vendor Data", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag), "EndTag", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.AddressLength), "Address Length", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.AddressLength), "Address Length", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpAddress16[8] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16), "16-Bit WORD Address Space",NULL},
- {ACPI_RSD_ADDRESS, 0, NULL, NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Granularity), "Granularity", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Minimum), "Address Minimum", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Maximum), "Address Maximum", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.TranslationOffset), "Translation Offset", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.AddressLength), "Address Length", NULL},
- {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address16.ResourceSource), NULL, NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpAddress32[8] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32), "32-Bit DWORD Address Space", NULL},
- {ACPI_RSD_ADDRESS, 0, NULL, NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Granularity), "Granularity", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Minimum), "Address Minimum", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Maximum), "Address Maximum", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.TranslationOffset), "Translation Offset", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.AddressLength), "Address Length", NULL},
- {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address32.ResourceSource), NULL, NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpAddress64[8] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64), "64-Bit QWORD Address Space", NULL},
- {ACPI_RSD_ADDRESS, 0, NULL, NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Granularity), "Granularity", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Minimum), "Address Minimum", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Maximum), "Address Maximum", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.TranslationOffset), "Translation Offset", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.AddressLength), "Address Length", NULL},
- {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address64.ResourceSource), NULL, NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[8] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64), "64-Bit Extended Address Space", NULL},
- {ACPI_RSD_ADDRESS, 0, NULL, NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Granularity), "Granularity", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Minimum), "Address Minimum", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Maximum), "Address Maximum", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset), "Translation Offset", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.AddressLength), "Address Length", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific), "Type-Specific Attribute", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HeDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LlDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_ShrDecode},
- {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL},
- {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[6] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg), "Generic Register", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.SpaceId), "Space ID", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitWidth), "Bit Width", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitOffset), "Bit Offset", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.AccessSize), "Access Size", NULL},
- {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (GenericReg.Address), "Address", NULL}
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpGpio[16] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGpio), "GPIO", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Gpio.RevisionId), "RevisionId", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Gpio.ConnectionType), "ConnectionType", AcpiGbl_CtDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Gpio.ProducerConsumer), "ProducerConsumer", AcpiGbl_ConsumeDecode},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Gpio.PinConfig), "PinConfig", AcpiGbl_PpcDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Gpio.Sharable), "Sharable", AcpiGbl_ShrDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Gpio.IoRestriction), "IoRestriction", AcpiGbl_IorDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Gpio.Triggering), "Triggering", AcpiGbl_HeDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Gpio.Polarity), "Polarity", AcpiGbl_LlDecode},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.DriveStrength), "DriveStrength", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.DebounceTimeout), "DebounceTimeout", NULL},
- {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Gpio.ResourceSource), "ResourceSource", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.PinTableLength), "PinTableLength", NULL},
- {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET (Gpio.PinTable), "PinTable", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Gpio.VendorLength), "VendorLength", NULL},
- {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (Gpio.VendorData), "VendorData", NULL},
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpFixedDma[4] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedDma), "FixedDma", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedDma.RequestLines), "RequestLines", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedDma.Channels), "Channels", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedDma.Width), "TransferWidth", AcpiGbl_DtsDecode},
-};
-
-#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.RevisionId), "RevisionId", NULL}, \
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.Type), "Type", AcpiGbl_SbtDecode}, \
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (CommonSerialBus.ProducerConsumer), "ProducerConsumer", AcpiGbl_ConsumeDecode}, \
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (CommonSerialBus.SlaveMode), "SlaveMode", AcpiGbl_SmDecode}, \
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (CommonSerialBus.TypeRevisionId), "TypeRevisionId", NULL}, \
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (CommonSerialBus.TypeDataLength), "TypeDataLength", NULL}, \
- {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (CommonSerialBus.ResourceSource), "ResourceSource", NULL}, \
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (CommonSerialBus.VendorLength), "VendorLength", NULL}, \
- {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (CommonSerialBus.VendorData), "VendorData", NULL},
-
-ACPI_RSDUMP_INFO AcpiRsDumpCommonSerialBus[10] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpCommonSerialBus), "Common Serial Bus", NULL},
- ACPI_RS_DUMP_COMMON_SERIAL_BUS
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpI2cSerialBus[13] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpI2cSerialBus), "I2C Serial Bus", NULL},
- ACPI_RS_DUMP_COMMON_SERIAL_BUS
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (I2cSerialBus.AccessMode), "AccessMode", AcpiGbl_AmDecode},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (I2cSerialBus.ConnectionSpeed), "ConnectionSpeed", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (I2cSerialBus.SlaveAddress), "SlaveAddress", NULL},
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpSpiSerialBus[17] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpSpiSerialBus), "Spi Serial Bus", NULL},
- ACPI_RS_DUMP_COMMON_SERIAL_BUS
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (SpiSerialBus.WireMode), "WireMode", AcpiGbl_WmDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (SpiSerialBus.DevicePolarity), "DevicePolarity", AcpiGbl_DpDecode},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (SpiSerialBus.DataBitLength), "DataBitLength", NULL},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (SpiSerialBus.ClockPhase), "ClockPhase", AcpiGbl_CphDecode},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (SpiSerialBus.ClockPolarity), "ClockPolarity", AcpiGbl_CpoDecode},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (SpiSerialBus.DeviceSelection), "DeviceSelection", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (SpiSerialBus.ConnectionSpeed), "ConnectionSpeed", NULL},
-};
-
-ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[19] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpUartSerialBus), "Uart Serial Bus", NULL},
- ACPI_RS_DUMP_COMMON_SERIAL_BUS
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.FlowControl), "FlowControl", AcpiGbl_FcDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.StopBits), "StopBits", AcpiGbl_SbDecode},
- {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.DataBits), "DataBits", AcpiGbl_BpbDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (UartSerialBus.Endian), "Endian", AcpiGbl_EdDecode},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (UartSerialBus.Parity), "Parity", AcpiGbl_PtDecode},
- {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (UartSerialBus.LinesEnabled), "LinesEnabled", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (UartSerialBus.RxFifoSize), "RxFifoSize", NULL},
- {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (UartSerialBus.TxFifoSize), "TxFifoSize", NULL},
- {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (UartSerialBus.DefaultBaudRate), "ConnectionSpeed", NULL},
-};
-
-/*
- * Tables used for common address descriptor flag fields
- */
-static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DecDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode}
-};
-
-static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] =
-{
- {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", (void *) "Memory Range"},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MemDecode},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MtpDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TtpDecode}
-};
-
-static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] =
-{
- {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", (void *) "I/O Range"},
- {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RngDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TtpDecode},
- {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TrsDecode}
-};
-
-
-/*
- * Table used to dump _PRT contents
- */
-static ACPI_RSDUMP_INFO AcpiRsDumpPrt[5] =
-{
- {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt), NULL, NULL},
- {ACPI_RSD_UINT64, ACPI_PRT_OFFSET (Address), "Address", NULL},
- {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (Pin), "Pin", NULL},
- {ACPI_RSD_STRING, ACPI_PRT_OFFSET (Source[0]), "Source", NULL},
- {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (SourceIndex), "Source Index", NULL}
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsDumpDescriptor
- *
- * PARAMETERS: Resource
- *
- * RETURN: None
- *
- * DESCRIPTION:
- *
- ******************************************************************************/
-
-static void
-AcpiRsDumpDescriptor (
- void *Resource,
- ACPI_RSDUMP_INFO *Table)
-{
- UINT8 *Target = NULL;
- UINT8 *PreviousTarget;
- char *Name;
- UINT8 Count;
-
-
- /* First table entry must contain the table length (# of table entries) */
-
- Count = Table->Offset;
-
- while (Count)
- {
- PreviousTarget = Target;
- Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
- Name = Table->Name;
-
- switch (Table->Opcode)
- {
- case ACPI_RSD_TITLE:
- /*
- * Optional resource title
- */
- if (Table->Name)
- {
- AcpiOsPrintf ("%s Resource\n", Name);
- }
- break;
-
- /* Strings */
-
- case ACPI_RSD_LITERAL:
- AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
- break;
-
- case ACPI_RSD_STRING:
- AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
- break;
-
- /* Data items, 8/16/32/64 bit */
-
- case ACPI_RSD_UINT8:
- if (Table->Pointer)
- {
- AcpiRsOutString (Name, ACPI_CAST_PTR (char,
- Table->Pointer [*Target]));
- }
- else
- {
- AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
- }
- break;
-
- case ACPI_RSD_UINT16:
- AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
- break;
-
- case ACPI_RSD_UINT32:
- AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
- break;
-
- case ACPI_RSD_UINT64:
- AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
- break;
-
- /* Flags: 1-bit and 2-bit flags supported */
-
- case ACPI_RSD_1BITFLAG:
- AcpiRsOutString (Name, ACPI_CAST_PTR (char,
- Table->Pointer [*Target & 0x01]));
- break;
-
- case ACPI_RSD_2BITFLAG:
- AcpiRsOutString (Name, ACPI_CAST_PTR (char,
- Table->Pointer [*Target & 0x03]));
- break;
-
- case ACPI_RSD_3BITFLAG:
- AcpiRsOutString (Name, ACPI_CAST_PTR (char,
- Table->Pointer [*Target & 0x07]));
- break;
-
- case ACPI_RSD_SHORTLIST:
- /*
- * Short byte list (single line output) for DMA and IRQ resources
- * Note: The list length is obtained from the previous table entry
- */
- if (PreviousTarget)
- {
- AcpiRsOutTitle (Name);
- AcpiRsDumpShortByteList (*PreviousTarget, Target);
- }
- break;
-
- case ACPI_RSD_SHORTLISTX:
- /*
- * Short byte list (single line output) for GPIO vendor data
- * Note: The list length is obtained from the previous table entry
- */
- if (PreviousTarget)
- {
- AcpiRsOutTitle (Name);
- AcpiRsDumpShortByteList (*PreviousTarget,
- *(ACPI_CAST_INDIRECT_PTR (UINT8, Target)));
- }
- break;
-
- case ACPI_RSD_LONGLIST:
- /*
- * Long byte list for Vendor resource data
- * Note: The list length is obtained from the previous table entry
- */
- if (PreviousTarget)
- {
- AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
- }
- break;
-
- case ACPI_RSD_DWORDLIST:
- /*
- * Dword list for Extended Interrupt resources
- * Note: The list length is obtained from the previous table entry
- */
- if (PreviousTarget)
- {
- AcpiRsDumpDwordList (*PreviousTarget,
- ACPI_CAST_PTR (UINT32, Target));
- }
- break;
-
- case ACPI_RSD_WORDLIST:
- /*
- * Word list for GPIO Pin Table
- * Note: The list length is obtained from the previous table entry
- */
- if (PreviousTarget)
- {
- AcpiRsDumpWordList (*PreviousTarget,
- *(ACPI_CAST_INDIRECT_PTR (UINT16, Target)));
- }
- break;
-
- case ACPI_RSD_ADDRESS:
- /*
- * Common flags for all Address resources
- */
- AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
- break;
-
- case ACPI_RSD_SOURCE:
- /*
- * Optional ResourceSource for Address resources
- */
- AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
- break;
-
- default:
- AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
- Table->Opcode);
- return;
- }
-
- Table++;
- Count--;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsDumpResourceSource
- *
- * PARAMETERS: ResourceSource - Pointer to a Resource Source struct
- *
- * RETURN: None
- *
- * DESCRIPTION: Common routine for dumping the optional ResourceSource and the
- * corresponding ResourceSourceIndex.
- *
- ******************************************************************************/
-
-static void
-AcpiRsDumpResourceSource (
- ACPI_RESOURCE_SOURCE *ResourceSource)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- if (ResourceSource->Index == 0xFF)
- {
- return;
- }
-
- AcpiRsOutInteger8 ("Resource Source Index",
- ResourceSource->Index);
-
- AcpiRsOutString ("Resource Source",
- ResourceSource->StringPtr ?
- ResourceSource->StringPtr : "[Not Specified]");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsDumpAddressCommon
- *
- * PARAMETERS: Resource - Pointer to an internal resource descriptor
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump the fields that are common to all Address resource
- * descriptors
- *
- ******************************************************************************/
-
-static void
-AcpiRsDumpAddressCommon (
- ACPI_RESOURCE_DATA *Resource)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Decode the type-specific flags */
-
- switch (Resource->Address.ResourceType)
- {
- case ACPI_MEMORY_RANGE:
-
- AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
- break;
-
- case ACPI_IO_RANGE:
-
- AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
- break;
-
- case ACPI_BUS_NUMBER_RANGE:
-
- AcpiRsOutString ("Resource Type", "Bus Number Range");
- break;
-
- default:
-
- AcpiRsOutInteger8 ("Resource Type",
- (UINT8) Resource->Address.ResourceType);
- break;
- }
-
- /* Decode the general flags */
-
- AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsDumpResourceList
- *
- * PARAMETERS: ResourceList - Pointer to a resource descriptor list
- *
- * RETURN: None
- *
- * DESCRIPTION: Dispatches the structure to the correct dump routine.
- *
- ******************************************************************************/
-
-void
-AcpiRsDumpResourceList (
- ACPI_RESOURCE *ResourceList)
-{
- UINT32 Count = 0;
- UINT32 Type;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
- {
- return;
- }
-
- /* Walk list and dump all resource descriptors (END_TAG terminates) */
-
- do
- {
- AcpiOsPrintf ("\n[%02X] ", Count);
- Count++;
-
- /* Validate Type before dispatch */
-
- Type = ResourceList->Type;
- if (Type > ACPI_RESOURCE_TYPE_MAX)
- {
- AcpiOsPrintf (
- "Invalid descriptor type (%X) in resource list\n",
- ResourceList->Type);
- return;
- }
-
- /* Dump the resource descriptor */
-
- if (Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
- {
- AcpiRsDumpDescriptor (&ResourceList->Data,
- AcpiGbl_DumpSerialBusDispatch[ResourceList->Data.CommonSerialBus.Type]);
- }
- else
- {
- AcpiRsDumpDescriptor (&ResourceList->Data,
- AcpiGbl_DumpResourceDispatch[Type]);
- }
-
- /* Point to the next resource structure */
-
- ResourceList = ACPI_NEXT_RESOURCE (ResourceList);
-
- /* Exit when END_TAG descriptor is reached */
-
- } while (Type != ACPI_RESOURCE_TYPE_END_TAG);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsDumpIrqList
- *
- * PARAMETERS: RouteTable - Pointer to the routing table to dump.
- *
- * RETURN: None
- *
- * DESCRIPTION: Print IRQ routing table
- *
- ******************************************************************************/
-
-void
-AcpiRsDumpIrqList (
- UINT8 *RouteTable)
-{
- ACPI_PCI_ROUTING_TABLE *PrtElement;
- UINT8 Count;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
- {
- return;
- }
-
- PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
-
- /* Dump all table elements, Exit on zero length element */
-
- for (Count = 0; PrtElement->Length; Count++)
- {
- AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
- AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
-
- PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
- PrtElement, PrtElement->Length);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsOut*
- *
- * PARAMETERS: Title - Name of the resource field
- * Value - Value of the resource field
- *
- * RETURN: None
- *
- * DESCRIPTION: Miscellaneous helper functions to consistently format the
- * output of the resource dump routines
- *
- ******************************************************************************/
-
-static void
-AcpiRsOutString (
- char *Title,
- char *Value)
-{
- AcpiOsPrintf ("%27s : %s", Title, Value);
- if (!*Value)
- {
- AcpiOsPrintf ("[NULL NAMESTRING]");
- }
- AcpiOsPrintf ("\n");
-}
-
-static void
-AcpiRsOutInteger8 (
- char *Title,
- UINT8 Value)
-{
- AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
-}
-
-static void
-AcpiRsOutInteger16 (
- char *Title,
- UINT16 Value)
-{
- AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
-}
-
-static void
-AcpiRsOutInteger32 (
- char *Title,
- UINT32 Value)
-{
- AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
-}
-
-static void
-AcpiRsOutInteger64 (
- char *Title,
- UINT64 Value)
-{
- AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
- ACPI_FORMAT_UINT64 (Value));
-}
-
-static void
-AcpiRsOutTitle (
- char *Title)
-{
- AcpiOsPrintf ("%27s : ", Title);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsDump*List
- *
- * PARAMETERS: Length - Number of elements in the list
- * Data - Start of the list
- *
- * RETURN: None
- *
- * DESCRIPTION: Miscellaneous functions to dump lists of raw data
- *
- ******************************************************************************/
-
-static void
-AcpiRsDumpByteList (
- UINT16 Length,
- UINT8 *Data)
-{
- UINT8 i;
-
-
- for (i = 0; i < Length; i++)
- {
- AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
- "Byte", i, Data[i]);
- }
-}
-
-static void
-AcpiRsDumpShortByteList (
- UINT8 Length,
- UINT8 *Data)
-{
- UINT8 i;
-
-
- for (i = 0; i < Length; i++)
- {
- AcpiOsPrintf ("%X ", Data[i]);
- }
- AcpiOsPrintf ("\n");
-}
-
-static void
-AcpiRsDumpDwordList (
- UINT8 Length,
- UINT32 *Data)
-{
- UINT8 i;
-
-
- for (i = 0; i < Length; i++)
- {
- AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
- "Dword", i, Data[i]);
- }
-}
-
-static void
-AcpiRsDumpWordList (
- UINT16 Length,
- UINT16 *Data)
-{
- UINT16 i;
-
-
- for (i = 0; i < Length; i++)
- {
- AcpiOsPrintf ("%25s%2.2X : %4.4X\n",
- "Word", i, Data[i]);
- }
-}
-
-#endif
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsinfo.c
--- a/head/sys/contrib/dev/acpica/resources/rsinfo.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,265 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsinfo - Dispatch and Info tables
- *
- ******************************************************************************/
-
-/*
- * 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 __RSINFO_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsinfo")
-
-/*
- * Resource dispatch and information tables. Any new resource types (either
- * Large or Small) must be reflected in each of these tables, so they are here
- * in one place.
- *
- * The tables for Large descriptors are indexed by bits 6:0 of the AML
- * descriptor type byte. The tables for Small descriptors are indexed by
- * bits 6:3 of the descriptor byte. The tables for internal resource
- * descriptors are indexed by the ACPI_RESOURCE_TYPE field.
- */
-
-
-/* Dispatch table for resource-to-AML (Set Resource) conversion functions */
-
-ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[] =
-{
- AcpiRsSetIrq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
- AcpiRsConvertDma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
- AcpiRsSetStartDpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
- AcpiRsConvertEndDpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
- AcpiRsConvertIo, /* 0x04, ACPI_RESOURCE_TYPE_IO */
- AcpiRsConvertFixedIo, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
- AcpiRsSetVendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
- AcpiRsConvertEndTag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
- AcpiRsConvertMemory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
- AcpiRsConvertMemory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
- AcpiRsConvertFixedMemory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
- AcpiRsConvertAddress16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
- AcpiRsConvertAddress32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
- AcpiRsConvertAddress64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
- AcpiRsConvertExtAddress64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
- AcpiRsConvertExtIrq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
- AcpiRsConvertGenericReg, /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
- AcpiRsConvertGpio, /* 0x11, ACPI_RESOURCE_TYPE_GPIO */
- AcpiRsConvertFixedDma, /* 0x12, ACPI_RESOURCE_TYPE_FIXED_DMA */
- NULL, /* 0x13, ACPI_RESOURCE_TYPE_SERIAL_BUS - Use subtype table below */
-};
-
-/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
-
-ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[] =
-{
- /* Small descriptors */
-
- NULL, /* 0x00, Reserved */
- NULL, /* 0x01, Reserved */
- NULL, /* 0x02, Reserved */
- NULL, /* 0x03, Reserved */
- AcpiRsGetIrq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
- AcpiRsConvertDma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
- AcpiRsGetStartDpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
- AcpiRsConvertEndDpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
- AcpiRsConvertIo, /* 0x08, ACPI_RESOURCE_NAME_IO */
- AcpiRsConvertFixedIo, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
- AcpiRsConvertFixedDma, /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
- NULL, /* 0x0B, Reserved */
- NULL, /* 0x0C, Reserved */
- NULL, /* 0x0D, Reserved */
- AcpiRsGetVendorSmall, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
- AcpiRsConvertEndTag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
-
- /* Large descriptors */
-
- NULL, /* 0x00, Reserved */
- AcpiRsConvertMemory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
- AcpiRsConvertGenericReg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
- NULL, /* 0x03, Reserved */
- AcpiRsGetVendorLarge, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
- AcpiRsConvertMemory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
- AcpiRsConvertFixedMemory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
- AcpiRsConvertAddress32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
- AcpiRsConvertAddress16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
- AcpiRsConvertExtIrq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
- AcpiRsConvertAddress64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
- AcpiRsConvertExtAddress64, /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
- AcpiRsConvertGpio, /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
- NULL, /* 0x0D, Reserved */
- NULL, /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use subtype table below */
-};
-
-/* Subtype table for SerialBus -- I2C, SPI, and UART */
-
-ACPI_RSCONVERT_INFO *AcpiGbl_ConvertResourceSerialBusDispatch[] =
-{
- NULL,
- AcpiRsConvertI2cSerialBus,
- AcpiRsConvertSpiSerialBus,
- AcpiRsConvertUartSerialBus,
-};
-
-
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-
-/* Dispatch table for resource dump functions */
-
-ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[] =
-{
- AcpiRsDumpIrq, /* ACPI_RESOURCE_TYPE_IRQ */
- AcpiRsDumpDma, /* ACPI_RESOURCE_TYPE_DMA */
- AcpiRsDumpStartDpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
- AcpiRsDumpEndDpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
- AcpiRsDumpIo, /* ACPI_RESOURCE_TYPE_IO */
- AcpiRsDumpFixedIo, /* ACPI_RESOURCE_TYPE_FIXED_IO */
- AcpiRsDumpVendor, /* ACPI_RESOURCE_TYPE_VENDOR */
- AcpiRsDumpEndTag, /* ACPI_RESOURCE_TYPE_END_TAG */
- AcpiRsDumpMemory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */
- AcpiRsDumpMemory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */
- AcpiRsDumpFixedMemory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
- AcpiRsDumpAddress16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
- AcpiRsDumpAddress32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
- AcpiRsDumpAddress64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
- AcpiRsDumpExtAddress64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
- AcpiRsDumpExtIrq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
- AcpiRsDumpGenericReg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
- AcpiRsDumpGpio, /* ACPI_RESOURCE_TYPE_GPIO */
- AcpiRsDumpFixedDma, /* ACPI_RESOURCE_TYPE_FIXED_DMA */
- NULL, /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
-};
-
-ACPI_RSDUMP_INFO *AcpiGbl_DumpSerialBusDispatch[] =
-{
- NULL,
- AcpiRsDumpI2cSerialBus, /* AML_RESOURCE_I2C_BUS_TYPE */
- AcpiRsDumpSpiSerialBus, /* AML_RESOURCE_SPI_BUS_TYPE */
- AcpiRsDumpUartSerialBus, /* AML_RESOURCE_UART_BUS_TYPE */
-};
-#endif
-
-
-/*
- * Base sizes for external AML resource descriptors, indexed by internal type.
- * Includes size of the descriptor header (1 byte for small descriptors,
- * 3 bytes for large descriptors)
- */
-const UINT8 AcpiGbl_AmlResourceSizes[] =
-{
- sizeof (AML_RESOURCE_IRQ), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
- sizeof (AML_RESOURCE_DMA), /* ACPI_RESOURCE_TYPE_DMA */
- sizeof (AML_RESOURCE_START_DEPENDENT), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
- sizeof (AML_RESOURCE_END_DEPENDENT), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
- sizeof (AML_RESOURCE_IO), /* ACPI_RESOURCE_TYPE_IO */
- sizeof (AML_RESOURCE_FIXED_IO), /* ACPI_RESOURCE_TYPE_FIXED_IO */
- sizeof (AML_RESOURCE_VENDOR_SMALL), /* ACPI_RESOURCE_TYPE_VENDOR */
- sizeof (AML_RESOURCE_END_TAG), /* ACPI_RESOURCE_TYPE_END_TAG */
- sizeof (AML_RESOURCE_MEMORY24), /* ACPI_RESOURCE_TYPE_MEMORY24 */
- sizeof (AML_RESOURCE_MEMORY32), /* ACPI_RESOURCE_TYPE_MEMORY32 */
- sizeof (AML_RESOURCE_FIXED_MEMORY32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
- sizeof (AML_RESOURCE_ADDRESS16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */
- sizeof (AML_RESOURCE_ADDRESS32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */
- sizeof (AML_RESOURCE_ADDRESS64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
- sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
- sizeof (AML_RESOURCE_EXTENDED_IRQ), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
- sizeof (AML_RESOURCE_GENERIC_REGISTER), /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
- sizeof (AML_RESOURCE_GPIO), /* ACPI_RESOURCE_TYPE_GPIO */
- sizeof (AML_RESOURCE_FIXED_DMA), /* ACPI_RESOURCE_TYPE_FIXED_DMA */
- sizeof (AML_RESOURCE_COMMON_SERIALBUS), /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
-};
-
-
-const UINT8 AcpiGbl_ResourceStructSizes[] =
-{
- /* Small descriptors */
-
- 0,
- 0,
- 0,
- 0,
- ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
- ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
- ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
- ACPI_RS_SIZE_MIN,
- ACPI_RS_SIZE (ACPI_RESOURCE_IO),
- ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
- ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_DMA),
- 0,
- 0,
- 0,
- ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
- ACPI_RS_SIZE_MIN,
-
- /* Large descriptors */
-
- 0,
- ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
- ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
- 0,
- ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
- ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
- ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
- ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
- ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
- ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
- ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
- ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
- ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
- ACPI_RS_SIZE (ACPI_RESOURCE_COMMON_SERIALBUS)
-};
-
-const UINT8 AcpiGbl_AmlResourceSerialBusSizes[] =
-{
- 0,
- sizeof (AML_RESOURCE_I2C_SERIALBUS),
- sizeof (AML_RESOURCE_SPI_SERIALBUS),
- sizeof (AML_RESOURCE_UART_SERIALBUS),
-};
-
-const UINT8 AcpiGbl_ResourceStructSerialBusSizes[] =
-{
- 0,
- ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
- ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
- ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
-};
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsio.c
--- a/head/sys/contrib/dev/acpica/resources/rsio.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsio - IO and DMA resource descriptors
- *
- ******************************************************************************/
-
-/*
- * 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 __RSIO_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsio")
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertIo
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
- ACPI_RS_SIZE (ACPI_RESOURCE_IO),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
- sizeof (AML_RESOURCE_IO),
- 0},
-
- /* Decode flag */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode),
- AML_OFFSET (Io.Flags),
- 0},
- /*
- * These fields are contiguous in both the source and destination:
- * Address Alignment
- * Length
- * Minimum Base Address
- * Maximum Base Address
- */
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment),
- AML_OFFSET (Io.Alignment),
- 2},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum),
- AML_OFFSET (Io.Minimum),
- 2}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertFixedIo
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
- ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
- sizeof (AML_RESOURCE_FIXED_IO),
- 0},
- /*
- * These fields are contiguous in both the source and destination:
- * Base Address
- * Length
- */
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength),
- AML_OFFSET (FixedIo.AddressLength),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address),
- AML_OFFSET (FixedIo.Address),
- 1}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertGenericReg
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
- ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
- sizeof (AML_RESOURCE_GENERIC_REGISTER),
- 0},
- /*
- * These fields are contiguous in both the source and destination:
- * Address Space ID
- * Register Bit Width
- * Register Bit Offset
- * Access Size
- */
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId),
- AML_OFFSET (GenericReg.AddressSpaceId),
- 4},
-
- /* Get the Register Address */
-
- {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address),
- AML_OFFSET (GenericReg.Address),
- 1}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertEndDpf
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
- ACPI_RS_SIZE_MIN,
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
- sizeof (AML_RESOURCE_END_DEPENDENT),
- 0}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertEndTag
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
- ACPI_RS_SIZE_MIN,
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)},
-
- /*
- * Note: The checksum field is set to zero, meaning that the resource
- * data is treated as if the checksum operation succeeded.
- * (ACPI Spec 1.0b Section 6.4.2.8)
- */
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
- sizeof (AML_RESOURCE_END_TAG),
- 0}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsGetStartDpf
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
- ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
- ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)},
-
- /* Defaults for Compatibility and Performance priorities */
-
- {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
- ACPI_ACCEPTABLE_CONFIGURATION,
- 2},
-
- /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength),
- AML_OFFSET (StartDpf.DescriptorType),
- 0},
-
- /* All done if there is no flag byte present in the descriptor */
-
- {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
-
- /* Flag byte is present, get the flags */
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
- AML_OFFSET (StartDpf.Flags),
- 0},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
- AML_OFFSET (StartDpf.Flags),
- 2}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsSetStartDpf
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] =
-{
- /* Start with a default descriptor of length 1 */
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
- sizeof (AML_RESOURCE_START_DEPENDENT),
- ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)},
-
- /* Set the default flag values */
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
- AML_OFFSET (StartDpf.Flags),
- 0},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
- AML_OFFSET (StartDpf.Flags),
- 2},
- /*
- * All done if the output descriptor length is required to be 1
- * (i.e., optimization to 0 bytes cannot be attempted)
- */
- {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
- 1},
-
- /* Set length to 0 bytes (no flags byte) */
-
- {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)},
-
- /*
- * All done if the output descriptor length is required to be 0.
- *
- * TBD: Perhaps we should check for error if input flags are not
- * compatible with a 0-byte descriptor.
- */
- {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
- 0},
-
- /* Reset length to 1 byte (descriptor with flags byte) */
-
- {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)},
-
-
- /*
- * All done if flags byte is necessary -- if either priority value
- * is not ACPI_ACCEPTABLE_CONFIGURATION
- */
- {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
- ACPI_ACCEPTABLE_CONFIGURATION},
-
- {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
- ACPI_ACCEPTABLE_CONFIGURATION},
-
- /* Flag byte is not necessary */
-
- {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}
-};
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsirq.c
--- a/head/sys/contrib/dev/acpica/resources/rsirq.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,308 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsirq - IRQ resource descriptors
- *
- ******************************************************************************/
-
-/*
- * 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 __RSIRQ_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsirq")
-
-
-/*******************************************************************************
- *
- * AcpiRsGetIrq
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsGetIrq[8] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
- ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
- ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)},
-
- /* Get the IRQ mask (bytes 1:2) */
-
- {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
- AML_OFFSET (Irq.IrqMask),
- ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
-
- /* Set default flags (others are zero) */
-
- {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering),
- ACPI_EDGE_SENSITIVE,
- 1},
-
- /* Get the descriptor length (2 or 3 for IRQ descriptor) */
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength),
- AML_OFFSET (Irq.DescriptorType),
- 0},
-
- /* All done if no flag byte present in descriptor */
-
- {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
-
- /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
- AML_OFFSET (Irq.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
- AML_OFFSET (Irq.Flags),
- 3},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable),
- AML_OFFSET (Irq.Flags),
- 4}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsSetIrq
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsSetIrq[13] =
-{
- /* Start with a default descriptor of length 3 */
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
- sizeof (AML_RESOURCE_IRQ),
- ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)},
-
- /* Convert interrupt list to 16-bit IRQ bitmask */
-
- {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
- AML_OFFSET (Irq.IrqMask),
- ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
-
- /* Set the flags byte */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
- AML_OFFSET (Irq.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
- AML_OFFSET (Irq.Flags),
- 3},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable),
- AML_OFFSET (Irq.Flags),
- 4},
-
- /*
- * All done if the output descriptor length is required to be 3
- * (i.e., optimization to 2 bytes cannot be attempted)
- */
- {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
- 3},
-
- /* Set length to 2 bytes (no flags byte) */
-
- {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)},
-
- /*
- * All done if the output descriptor length is required to be 2.
- *
- * TBD: Perhaps we should check for error if input flags are not
- * compatible with a 2-byte descriptor.
- */
- {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
- 2},
-
- /* Reset length to 3 bytes (descriptor with flags byte) */
-
- {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)},
-
- /*
- * Check if the flags byte is necessary. Not needed if the flags are:
- * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
- */
- {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET (Data.Irq.Triggering),
- ACPI_EDGE_SENSITIVE},
-
- {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET (Data.Irq.Polarity),
- ACPI_ACTIVE_HIGH},
-
- {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
- ACPI_RS_OFFSET (Data.Irq.Sharable),
- ACPI_EXCLUSIVE},
-
- /* We can optimize to a 2-byte IrqNoFlags() descriptor */
-
- {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertExtIrq
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
- ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
- sizeof (AML_RESOURCE_EXTENDED_IRQ),
- 0},
-
- /* Flag bits */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer),
- AML_OFFSET (ExtendedIrq.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering),
- AML_OFFSET (ExtendedIrq.Flags),
- 1},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity),
- AML_OFFSET (ExtendedIrq.Flags),
- 2},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable),
- AML_OFFSET (ExtendedIrq.Flags),
- 3},
-
- /* IRQ Table length (Byte4) */
-
- {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount),
- AML_OFFSET (ExtendedIrq.InterruptCount),
- sizeof (UINT32)},
-
- /* Copy every IRQ in the table, each is 32 bits */
-
- {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
- AML_OFFSET (ExtendedIrq.Interrupts[0]),
- 0},
-
- /* Optional ResourceSource (Index and String) */
-
- {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource),
- ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
- sizeof (AML_RESOURCE_EXTENDED_IRQ)}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertDma
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
- ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
- sizeof (AML_RESOURCE_DMA),
- 0},
-
- /* Flags: transfer preference, bus mastering, channel speed */
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer),
- AML_OFFSET (Dma.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster),
- AML_OFFSET (Dma.Flags),
- 2},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type),
- AML_OFFSET (Dma.Flags),
- 5},
-
- /* DMA channel mask bits */
-
- {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]),
- AML_OFFSET (Dma.DmaChannelMask),
- ACPI_RS_OFFSET (Data.Dma.ChannelCount)}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertFixedDma
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma[4] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_DMA,
- ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_DMA),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedDma)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_DMA,
- sizeof (AML_RESOURCE_FIXED_DMA),
- 0},
-
- /*
- * These fields are contiguous in both the source and destination:
- * RequestLines
- * Channels
- */
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedDma.RequestLines),
- AML_OFFSET (FixedDma.RequestLines),
- 2},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedDma.Width),
- AML_OFFSET (FixedDma.Width),
- 1},
-
-};
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rslist.c
--- a/head/sys/contrib/dev/acpica/resources/rslist.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,275 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rslist - Linked list 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 __RSLIST_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rslist")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsConvertAmlToResources
- *
- * PARAMETERS: ACPI_WALK_AML_CALLBACK
- * ResourcePtr - Pointer to the buffer that will
- * contain the output structures
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert an AML resource to an internal representation of the
- * resource that is aligned and easier to access.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsConvertAmlToResources (
- UINT8 *Aml,
- UINT32 Length,
- UINT32 Offset,
- UINT8 ResourceIndex,
- void *Context)
-{
- ACPI_RESOURCE **ResourcePtr = ACPI_CAST_INDIRECT_PTR (
- ACPI_RESOURCE, Context);
- ACPI_RESOURCE *Resource;
- AML_RESOURCE *AmlResource;
- ACPI_RSCONVERT_INFO *ConversionTable;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (RsConvertAmlToResources);
-
-
- /*
- * Check that the input buffer and all subsequent pointers into it
- * are aligned on a native word boundary. Most important on IA64
- */
- Resource = *ResourcePtr;
- if (ACPI_IS_MISALIGNED (Resource))
- {
- ACPI_WARNING ((AE_INFO,
- "Misaligned resource pointer %p", Resource));
- }
-
- /* Get the appropriate conversion info table */
-
- AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
- if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_SERIAL_BUS)
- {
- if (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)
- {
- ConversionTable = NULL;
- }
- else
- {
- /* This is an I2C, SPI, or UART SerialBus descriptor */
-
- ConversionTable =
- AcpiGbl_ConvertResourceSerialBusDispatch[
- AmlResource->CommonSerialBus.Type];
- }
- }
- else
- {
- ConversionTable =
- AcpiGbl_GetResourceDispatch[ResourceIndex];
- }
-
- if (!ConversionTable)
- {
- ACPI_ERROR ((AE_INFO,
- "Invalid/unsupported resource descriptor: Type 0x%2.2X",
- ResourceIndex));
- return (AE_AML_INVALID_RESOURCE_TYPE);
- }
-
- /* Convert the AML byte stream resource to a local resource struct */
-
- Status = AcpiRsConvertAmlToResource (
- Resource, AmlResource, ConversionTable);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not convert AML resource (Type 0x%X)", *Aml));
- return_ACPI_STATUS (Status);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
- "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
- AcpiUtGetResourceType (Aml), Length,
- Resource->Length));
-
- /* Point to the next structure in the output buffer */
-
- *ResourcePtr = ACPI_NEXT_RESOURCE (Resource);
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsConvertResourcesToAml
- *
- * PARAMETERS: Resource - Pointer to the resource linked list
- * AmlSizeNeeded - Calculated size of the byte stream
- * needed from calling AcpiRsGetAmlLength()
- * The size of the OutputBuffer is
- * guaranteed to be >= AmlSizeNeeded
- * OutputBuffer - Pointer to the buffer that will
- * contain the byte stream
- *
- * RETURN: Status
- *
- * DESCRIPTION: Takes the resource linked list and parses it, creating a
- * byte stream of resources in the caller's output buffer
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsConvertResourcesToAml (
- ACPI_RESOURCE *Resource,
- ACPI_SIZE AmlSizeNeeded,
- UINT8 *OutputBuffer)
-{
- UINT8 *Aml = OutputBuffer;
- UINT8 *EndAml = OutputBuffer + AmlSizeNeeded;
- ACPI_RSCONVERT_INFO *ConversionTable;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (RsConvertResourcesToAml);
-
-
- /* Walk the resource descriptor list, convert each descriptor */
-
- while (Aml < EndAml)
- {
- /* Validate the (internal) Resource Type */
-
- if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
- {
- ACPI_ERROR ((AE_INFO,
- "Invalid descriptor type (0x%X) in resource list",
- Resource->Type));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
-
- /* Perform the conversion */
-
- if (Resource->Type == ACPI_RESOURCE_TYPE_SERIAL_BUS)
- {
- if (Resource->Data.CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)
- {
- ConversionTable = NULL;
- }
- else
- {
- /* This is an I2C, SPI, or UART SerialBus descriptor */
-
- ConversionTable = AcpiGbl_ConvertResourceSerialBusDispatch[
- Resource->Data.CommonSerialBus.Type];
- }
- }
- else
- {
- ConversionTable = AcpiGbl_SetResourceDispatch[Resource->Type];
- }
-
- if (!ConversionTable)
- {
- ACPI_ERROR ((AE_INFO,
- "Invalid/unsupported resource descriptor: Type 0x%2.2X",
- Resource->Type));
- return (AE_AML_INVALID_RESOURCE_TYPE);
- }
-
- Status = AcpiRsConvertResourceToAml (Resource,
- ACPI_CAST_PTR (AML_RESOURCE, Aml),
- ConversionTable);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not convert resource (type 0x%X) to AML",
- Resource->Type));
- return_ACPI_STATUS (Status);
- }
-
- /* Perform final sanity check on the new AML resource descriptor */
-
- Status = AcpiUtValidateResource (
- ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Check for end-of-list, normal exit */
-
- if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
- {
- /* An End Tag indicates the end of the input Resource Template */
-
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Extract the total length of the new descriptor and set the
- * Aml to point to the next (output) resource descriptor
- */
- Aml += AcpiUtGetDescriptorLength (Aml);
-
- /* Point to the next input resource descriptor */
-
- Resource = ACPI_NEXT_RESOURCE (Resource);
- }
-
- /* Completed buffer, but did not find an EndTag resource descriptor */
-
- return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsmemory.c
--- a/head/sys/contrib/dev/acpica/resources/rsmemory.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsmem24 - Memory resource descriptors
- *
- ******************************************************************************/
-
-/*
- * 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 __RSMEMORY_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsmemory")
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertMemory24
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[4] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
- ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
- sizeof (AML_RESOURCE_MEMORY24),
- 0},
-
- /* Read/Write bit */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect),
- AML_OFFSET (Memory24.Flags),
- 0},
- /*
- * These fields are contiguous in both the source and destination:
- * Minimum Base Address
- * Maximum Base Address
- * Address Base Alignment
- * Range Length
- */
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Memory24.Minimum),
- AML_OFFSET (Memory24.Minimum),
- 4}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertMemory32
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[4] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
- ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
- sizeof (AML_RESOURCE_MEMORY32),
- 0},
-
- /* Read/Write bit */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect),
- AML_OFFSET (Memory32.Flags),
- 0},
- /*
- * These fields are contiguous in both the source and destination:
- * Minimum Base Address
- * Maximum Base Address
- * Address Base Alignment
- * Range Length
- */
- {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Memory32.Minimum),
- AML_OFFSET (Memory32.Minimum),
- 4}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertFixedMemory32
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[4] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
- ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
- sizeof (AML_RESOURCE_FIXED_MEMORY32),
- 0},
-
- /* Read/Write bit */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect),
- AML_OFFSET (FixedMemory32.Flags),
- 0},
- /*
- * These fields are contiguous in both the source and destination:
- * Base Address
- * Range Length
- */
- {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.FixedMemory32.Address),
- AML_OFFSET (FixedMemory32.Address),
- 2}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsGetVendorSmall
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[3] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
- ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
- ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)},
-
- /* Length of the vendor data (byte count) */
-
- {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
- 0,
- sizeof (UINT8)},
-
- /* Vendor data */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
- sizeof (AML_RESOURCE_SMALL_HEADER),
- 0}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsGetVendorLarge
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[3] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
- ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
- ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)},
-
- /* Length of the vendor data (byte count) */
-
- {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
- 0,
- sizeof (UINT8)},
-
- /* Vendor data */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
- sizeof (AML_RESOURCE_LARGE_HEADER),
- 0}
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsSetVendor
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsSetVendor[7] =
-{
- /* Default is a small vendor descriptor */
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
- sizeof (AML_RESOURCE_SMALL_HEADER),
- ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)},
-
- /* Get the length and copy the data */
-
- {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
- 0,
- 0},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
- sizeof (AML_RESOURCE_SMALL_HEADER),
- 0},
-
- /*
- * All done if the Vendor byte length is 7 or less, meaning that it will
- * fit within a small descriptor
- */
- {ACPI_RSC_EXIT_LE, 0, 0, 7},
-
- /* Must create a large vendor descriptor */
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
- sizeof (AML_RESOURCE_LARGE_HEADER),
- 0},
-
- {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
- 0,
- 0},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
- sizeof (AML_RESOURCE_LARGE_HEADER),
- 0}
-};
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsmisc.c
--- a/head/sys/contrib/dev/acpica/resources/rsmisc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,869 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsmisc - Miscellaneous resource descriptors
- *
- ******************************************************************************/
-
-/*
- * 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 __RSMISC_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsmisc")
-
-
-#define INIT_RESOURCE_TYPE(i) i->ResourceOffset
-#define INIT_RESOURCE_LENGTH(i) i->AmlOffset
-#define INIT_TABLE_LENGTH(i) i->Value
-
-#define COMPARE_OPCODE(i) i->ResourceOffset
-#define COMPARE_TARGET(i) i->AmlOffset
-#define COMPARE_VALUE(i) i->Value
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsConvertAmlToResource
- *
- * PARAMETERS: Resource - Pointer to the resource descriptor
- * Aml - Where the AML descriptor is returned
- * Info - Pointer to appropriate conversion table
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
- * internal resource descriptor
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsConvertAmlToResource (
- ACPI_RESOURCE *Resource,
- AML_RESOURCE *Aml,
- ACPI_RSCONVERT_INFO *Info)
-{
- ACPI_RS_LENGTH AmlResourceLength;
- void *Source;
- void *Destination;
- char *Target;
- UINT8 Count;
- UINT8 FlagsMode = FALSE;
- UINT16 ItemCount = 0;
- UINT16 Temp16 = 0;
-
-
- ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
-
-
- if (!Info)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (((ACPI_SIZE) Resource) & 0x3)
- {
- /* Each internal resource struct is expected to be 32-bit aligned */
-
- ACPI_WARNING ((AE_INFO,
- "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
- Resource, Resource->Type, Resource->Length));
- }
-
- /* Extract the resource Length field (does not include header length) */
-
- AmlResourceLength = AcpiUtGetResourceLength (Aml);
-
- /*
- * First table entry must be ACPI_RSC_INITxxx and must contain the
- * table length (# of table entries)
- */
- Count = INIT_TABLE_LENGTH (Info);
- while (Count)
- {
- /*
- * Source is the external AML byte stream buffer,
- * destination is the internal resource descriptor
- */
- Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
- Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
-
- switch (Info->Opcode)
- {
- case ACPI_RSC_INITGET:
- /*
- * Get the resource type and the initial (minimum) length
- */
- ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
- Resource->Type = INIT_RESOURCE_TYPE (Info);
- Resource->Length = INIT_RESOURCE_LENGTH (Info);
- break;
-
-
- case ACPI_RSC_INITSET:
- break;
-
-
- case ACPI_RSC_FLAGINIT:
-
- FlagsMode = TRUE;
- break;
-
-
- case ACPI_RSC_1BITFLAG:
- /*
- * Mask and shift the flag bit
- */
- ACPI_SET8 (Destination) = (UINT8)
- ((ACPI_GET8 (Source) >> Info->Value) & 0x01);
- break;
-
-
- case ACPI_RSC_2BITFLAG:
- /*
- * Mask and shift the flag bits
- */
- ACPI_SET8 (Destination) = (UINT8)
- ((ACPI_GET8 (Source) >> Info->Value) & 0x03);
- break;
-
-
- case ACPI_RSC_3BITFLAG:
- /*
- * Mask and shift the flag bits
- */
- ACPI_SET8 (Destination) = (UINT8)
- ((ACPI_GET8 (Source) >> Info->Value) & 0x07);
- break;
-
-
- case ACPI_RSC_COUNT:
-
- ItemCount = ACPI_GET8 (Source);
- ACPI_SET8 (Destination) = (UINT8) ItemCount;
-
- Resource->Length = Resource->Length +
- (Info->Value * (ItemCount - 1));
- break;
-
-
- case ACPI_RSC_COUNT16:
-
- ItemCount = AmlResourceLength;
- ACPI_SET16 (Destination) = ItemCount;
-
- Resource->Length = Resource->Length +
- (Info->Value * (ItemCount - 1));
- break;
-
-
- case ACPI_RSC_COUNT_GPIO_PIN:
-
- Target = ACPI_ADD_PTR (void, Aml, Info->Value);
- ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
-
- Resource->Length = Resource->Length + ItemCount;
- ItemCount = ItemCount / 2;
- ACPI_SET16 (Destination) = ItemCount;
- break;
-
-
- case ACPI_RSC_COUNT_GPIO_VEN:
-
- ItemCount = ACPI_GET8 (Source);
- ACPI_SET8 (Destination) = (UINT8) ItemCount;
-
- Resource->Length = Resource->Length +
- (Info->Value * ItemCount);
- break;
-
-
- case ACPI_RSC_COUNT_GPIO_RES:
-
- /*
- * Vendor data is optional (length/offset may both be zero)
- * Examine vendor data length field first
- */
- Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2));
- if (ACPI_GET16 (Target))
- {
- /* Use vendor offset to get resource source length */
-
- Target = ACPI_ADD_PTR (void, Aml, Info->Value);
- ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
- }
- else
- {
- /* No vendor data to worry about */
-
- ItemCount = Aml->LargeHeader.ResourceLength +
- sizeof (AML_RESOURCE_LARGE_HEADER) -
- ACPI_GET16 (Source);
- }
-
- Resource->Length = Resource->Length + ItemCount;
- ACPI_SET16 (Destination) = ItemCount;
- break;
-
-
- case ACPI_RSC_COUNT_SERIAL_VEN:
-
- ItemCount = ACPI_GET16 (Source) - Info->Value;
-
- Resource->Length = Resource->Length + ItemCount;
- ACPI_SET16 (Destination) = ItemCount;
- break;
-
-
- case ACPI_RSC_COUNT_SERIAL_RES:
-
- ItemCount = (AmlResourceLength +
- sizeof (AML_RESOURCE_LARGE_HEADER)) -
- ACPI_GET16 (Source) - Info->Value;
-
- Resource->Length = Resource->Length + ItemCount;
- ACPI_SET16 (Destination) = ItemCount;
- break;
-
-
- case ACPI_RSC_LENGTH:
-
- Resource->Length = Resource->Length + Info->Value;
- break;
-
-
- case ACPI_RSC_MOVE8:
- case ACPI_RSC_MOVE16:
- case ACPI_RSC_MOVE32:
- case ACPI_RSC_MOVE64:
- /*
- * Raw data move. Use the Info value field unless ItemCount has
- * been previously initialized via a COUNT opcode
- */
- if (Info->Value)
- {
- ItemCount = Info->Value;
- }
- AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_GPIO_PIN:
-
- /* Generate and set the PIN data pointer */
-
- Target = (char *) ACPI_ADD_PTR (void, Resource,
- (Resource->Length - ItemCount * 2));
- *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target);
-
- /* Copy the PIN data */
-
- Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
- AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_GPIO_RES:
-
- /* Generate and set the ResourceSource string pointer */
-
- Target = (char *) ACPI_ADD_PTR (void, Resource,
- (Resource->Length - ItemCount));
- *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
-
- /* Copy the ResourceSource string */
-
- Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
- AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_SERIAL_VEN:
-
- /* Generate and set the Vendor Data pointer */
-
- Target = (char *) ACPI_ADD_PTR (void, Resource,
- (Resource->Length - ItemCount));
- *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
-
- /* Copy the Vendor Data */
-
- Source = ACPI_ADD_PTR (void, Aml, Info->Value);
- AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_SERIAL_RES:
-
- /* Generate and set the ResourceSource string pointer */
-
- Target = (char *) ACPI_ADD_PTR (void, Resource,
- (Resource->Length - ItemCount));
- *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
-
- /* Copy the ResourceSource string */
-
- Source = ACPI_ADD_PTR (void, Aml, (ACPI_GET16 (Source) + Info->Value));
- AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_SET8:
-
- ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
- break;
-
-
- case ACPI_RSC_DATA8:
-
- Target = ACPI_ADD_PTR (char, Resource, Info->Value);
- ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target));
- break;
-
-
- case ACPI_RSC_ADDRESS:
- /*
- * Common handler for address descriptor flags
- */
- if (!AcpiRsGetAddressCommon (Resource, Aml))
- {
- return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
- }
- break;
-
-
- case ACPI_RSC_SOURCE:
- /*
- * Optional ResourceSource (Index and String)
- */
- Resource->Length +=
- AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
- Destination, Aml, NULL);
- break;
-
-
- case ACPI_RSC_SOURCEX:
- /*
- * Optional ResourceSource (Index and String). This is the more
- * complicated case used by the Interrupt() macro
- */
- Target = ACPI_ADD_PTR (char, Resource,
- Info->AmlOffset + (ItemCount * 4));
-
- Resource->Length +=
- AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH)
- (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
- Destination, Aml, Target);
- break;
-
-
- case ACPI_RSC_BITMASK:
- /*
- * 8-bit encoded bitmask (DMA macro)
- */
- ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
- if (ItemCount)
- {
- Resource->Length += (ItemCount - 1);
- }
-
- Target = ACPI_ADD_PTR (char, Resource, Info->Value);
- ACPI_SET8 (Target) = (UINT8) ItemCount;
- break;
-
-
- case ACPI_RSC_BITMASK16:
- /*
- * 16-bit encoded bitmask (IRQ macro)
- */
- ACPI_MOVE_16_TO_16 (&Temp16, Source);
-
- ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
- if (ItemCount)
- {
- Resource->Length += (ItemCount - 1);
- }
-
- Target = ACPI_ADD_PTR (char, Resource, Info->Value);
- ACPI_SET8 (Target) = (UINT8) ItemCount;
- break;
-
-
- case ACPI_RSC_EXIT_NE:
- /*
- * Control - Exit conversion if not equal
- */
- switch (Info->ResourceOffset)
- {
- case ACPI_RSC_COMPARE_AML_LENGTH:
- if (AmlResourceLength != Info->Value)
- {
- goto Exit;
- }
- break;
-
- case ACPI_RSC_COMPARE_VALUE:
- if (ACPI_GET8 (Source) != Info->Value)
- {
- goto Exit;
- }
- break;
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- Count--;
- Info++;
- }
-
-Exit:
- if (!FlagsMode)
- {
- /* Round the resource struct length up to the next boundary (32 or 64) */
-
- Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
- }
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsConvertResourceToAml
- *
- * PARAMETERS: Resource - Pointer to the resource descriptor
- * Aml - Where the AML descriptor is returned
- * Info - Pointer to appropriate conversion table
- *
- * RETURN: Status
- *
- * DESCRIPTION: Convert an internal resource descriptor to the corresponding
- * external AML resource descriptor.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsConvertResourceToAml (
- ACPI_RESOURCE *Resource,
- AML_RESOURCE *Aml,
- ACPI_RSCONVERT_INFO *Info)
-{
- void *Source = NULL;
- void *Destination;
- char *Target;
- ACPI_RSDESC_SIZE AmlLength = 0;
- UINT8 Count;
- UINT16 Temp16 = 0;
- UINT16 ItemCount = 0;
-
-
- ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
-
-
- if (!Info)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /*
- * First table entry must be ACPI_RSC_INITxxx and must contain the
- * table length (# of table entries)
- */
- Count = INIT_TABLE_LENGTH (Info);
-
- while (Count)
- {
- /*
- * Source is the internal resource descriptor,
- * destination is the external AML byte stream buffer
- */
- Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
- Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
-
- switch (Info->Opcode)
- {
- case ACPI_RSC_INITSET:
-
- ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
- AmlLength = INIT_RESOURCE_LENGTH (Info);
- AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_INITGET:
- break;
-
-
- case ACPI_RSC_FLAGINIT:
- /*
- * Clear the flag byte
- */
- ACPI_SET8 (Destination) = 0;
- break;
-
-
- case ACPI_RSC_1BITFLAG:
- /*
- * Mask and shift the flag bit
- */
- ACPI_SET8 (Destination) |= (UINT8)
- ((ACPI_GET8 (Source) & 0x01) << Info->Value);
- break;
-
-
- case ACPI_RSC_2BITFLAG:
- /*
- * Mask and shift the flag bits
- */
- ACPI_SET8 (Destination) |= (UINT8)
- ((ACPI_GET8 (Source) & 0x03) << Info->Value);
- break;
-
-
- case ACPI_RSC_3BITFLAG:
- /*
- * Mask and shift the flag bits
- */
- ACPI_SET8 (Destination) |= (UINT8)
- ((ACPI_GET8 (Source) & 0x07) << Info->Value);
- break;
-
-
- case ACPI_RSC_COUNT:
-
- ItemCount = ACPI_GET8 (Source);
- ACPI_SET8 (Destination) = (UINT8) ItemCount;
-
- AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
- break;
-
-
- case ACPI_RSC_COUNT16:
-
- ItemCount = ACPI_GET16 (Source);
- AmlLength = (UINT16) (AmlLength + ItemCount);
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_COUNT_GPIO_PIN:
-
- ItemCount = ACPI_GET16 (Source);
- ACPI_SET16 (Destination) = (UINT16) AmlLength;
-
- AmlLength = (UINT16) (AmlLength + ItemCount * 2);
- Target = ACPI_ADD_PTR (void, Aml, Info->Value);
- ACPI_SET16 (Target) = (UINT16) AmlLength;
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_COUNT_GPIO_VEN:
-
- ItemCount = ACPI_GET16 (Source);
- ACPI_SET16 (Destination) = (UINT16) ItemCount;
-
- AmlLength = (UINT16) (AmlLength + (Info->Value * ItemCount));
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_COUNT_GPIO_RES:
-
- /* Set resource source string length */
-
- ItemCount = ACPI_GET16 (Source);
- ACPI_SET16 (Destination) = (UINT16) AmlLength;
-
- /* Compute offset for the Vendor Data */
-
- AmlLength = (UINT16) (AmlLength + ItemCount);
- Target = ACPI_ADD_PTR (void, Aml, Info->Value);
-
- /* Set vendor offset only if there is vendor data */
-
- if (Resource->Data.Gpio.VendorLength)
- {
- ACPI_SET16 (Target) = (UINT16) AmlLength;
- }
-
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_COUNT_SERIAL_VEN:
-
- ItemCount = ACPI_GET16 (Source);
- ACPI_SET16 (Destination) = ItemCount + Info->Value;
- AmlLength = (UINT16) (AmlLength + ItemCount);
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_COUNT_SERIAL_RES:
-
- ItemCount = ACPI_GET16 (Source);
- AmlLength = (UINT16) (AmlLength + ItemCount);
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_LENGTH:
-
- AcpiRsSetResourceLength (Info->Value, Aml);
- break;
-
-
- case ACPI_RSC_MOVE8:
- case ACPI_RSC_MOVE16:
- case ACPI_RSC_MOVE32:
- case ACPI_RSC_MOVE64:
-
- if (Info->Value)
- {
- ItemCount = Info->Value;
- }
- AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_GPIO_PIN:
-
- Destination = (char *) ACPI_ADD_PTR (void, Aml,
- ACPI_GET16 (Destination));
- Source = * (UINT16 **) Source;
- AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_GPIO_RES:
-
- /* Used for both ResourceSource string and VendorData */
-
- Destination = (char *) ACPI_ADD_PTR (void, Aml,
- ACPI_GET16 (Destination));
- Source = * (UINT8 **) Source;
- AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_SERIAL_VEN:
-
- Destination = (char *) ACPI_ADD_PTR (void, Aml,
- (AmlLength - ItemCount));
- Source = * (UINT8 **) Source;
- AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_MOVE_SERIAL_RES:
-
- Destination = (char *) ACPI_ADD_PTR (void, Aml,
- (AmlLength - ItemCount));
- Source = * (UINT8 **) Source;
- AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
- break;
-
-
- case ACPI_RSC_ADDRESS:
-
- /* Set the Resource Type, General Flags, and Type-Specific Flags */
-
- AcpiRsSetAddressCommon (Aml, Resource);
- break;
-
-
- case ACPI_RSC_SOURCEX:
- /*
- * Optional ResourceSource (Index and String)
- */
- AmlLength = AcpiRsSetResourceSource (
- Aml, (ACPI_RS_LENGTH) AmlLength, Source);
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_SOURCE:
- /*
- * Optional ResourceSource (Index and String). This is the more
- * complicated case used by the Interrupt() macro
- */
- AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
- AcpiRsSetResourceLength (AmlLength, Aml);
- break;
-
-
- case ACPI_RSC_BITMASK:
- /*
- * 8-bit encoded bitmask (DMA macro)
- */
- ACPI_SET8 (Destination) = (UINT8)
- AcpiRsEncodeBitmask (Source,
- *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
- break;
-
-
- case ACPI_RSC_BITMASK16:
- /*
- * 16-bit encoded bitmask (IRQ macro)
- */
- Temp16 = AcpiRsEncodeBitmask (Source,
- *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
- ACPI_MOVE_16_TO_16 (Destination, &Temp16);
- break;
-
-
- case ACPI_RSC_EXIT_LE:
- /*
- * Control - Exit conversion if less than or equal
- */
- if (ItemCount <= Info->Value)
- {
- goto Exit;
- }
- break;
-
-
- case ACPI_RSC_EXIT_NE:
- /*
- * Control - Exit conversion if not equal
- */
- switch (COMPARE_OPCODE (Info))
- {
- case ACPI_RSC_COMPARE_VALUE:
-
- if (*ACPI_ADD_PTR (UINT8, Resource,
- COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
- {
- goto Exit;
- }
- break;
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
- break;
-
-
- case ACPI_RSC_EXIT_EQ:
- /*
- * Control - Exit conversion if equal
- */
- if (*ACPI_ADD_PTR (UINT8, Resource,
- COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
- {
- goto Exit;
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- Count--;
- Info++;
- }
-
-Exit:
- return_ACPI_STATUS (AE_OK);
-}
-
-
-#if 0
-/* Previous resource validations */
-
- if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
- {
- return_ACPI_STATUS (AE_SUPPORT);
- }
-
- if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
- {
- return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
- }
-
- if (((Aml->Irq.Flags & 0x09) == 0x00) ||
- ((Aml->Irq.Flags & 0x09) == 0x09))
- {
- /*
- * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
- * polarity/trigger interrupts are allowed (ACPI spec, section
- * "IRQ Format"), so 0x00 and 0x09 are illegal.
- */
- ACPI_ERROR ((AE_INFO,
- "Invalid interrupt polarity/trigger in resource list, 0x%X",
- Aml->Irq.Flags));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
-
- Resource->Data.ExtendedIrq.InterruptCount = Temp8;
- if (Temp8 < 1)
- {
- /* Must have at least one IRQ */
-
- return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
- }
-
- if (Resource->Data.Dma.Transfer == 0x03)
- {
- ACPI_ERROR ((AE_INFO,
- "Invalid DMA.Transfer preference (3)"));
- return_ACPI_STATUS (AE_BAD_DATA);
- }
-#endif
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsserial.c
--- a/head/sys/contrib/dev/acpica/resources/rsserial.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,425 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsserial - GPIO/SerialBus resource descriptors
- *
- ******************************************************************************/
-
-/*
- * 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 __RSIRQ_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsserial")
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertGpio
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertGpio[17] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,
- ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertGpio)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO,
- sizeof (AML_RESOURCE_GPIO),
- 0},
-
- /*
- * These fields are contiguous in both the source and destination:
- * RevisionId
- * ConnectionType
- */
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.RevisionId),
- AML_OFFSET (Gpio.RevisionId),
- 2},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.ProducerConsumer),
- AML_OFFSET (Gpio.Flags),
- 0},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Sharable),
- AML_OFFSET (Gpio.IntFlags),
- 3},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.IoRestriction),
- AML_OFFSET (Gpio.IntFlags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Triggering),
- AML_OFFSET (Gpio.IntFlags),
- 0},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Polarity),
- AML_OFFSET (Gpio.IntFlags),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.PinConfig),
- AML_OFFSET (Gpio.PinConfig),
- 1},
-
- /*
- * These fields are contiguous in both the source and destination:
- * DriveStrength
- * DebounceTimeout
- */
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Gpio.DriveStrength),
- AML_OFFSET (Gpio.DriveStrength),
- 2},
-
- /* Pin Table */
-
- {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTableLength),
- AML_OFFSET (Gpio.PinTableOffset),
- AML_OFFSET (Gpio.ResSourceOffset)},
-
- {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTable),
- AML_OFFSET (Gpio.PinTableOffset),
- 0},
-
- /* Resource Source */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.Index),
- AML_OFFSET (Gpio.ResSourceIndex),
- 1},
-
- {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringLength),
- AML_OFFSET (Gpio.ResSourceOffset),
- AML_OFFSET (Gpio.VendorOffset)},
-
- {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringPtr),
- AML_OFFSET (Gpio.ResSourceOffset),
- 0},
-
- /* Vendor Data */
-
- {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET (Data.Gpio.VendorLength),
- AML_OFFSET (Gpio.VendorLength),
- 1},
-
- {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.VendorData),
- AML_OFFSET (Gpio.VendorOffset),
- 0},
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertI2cSerialBus
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
- ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
- sizeof (AML_RESOURCE_I2C_SERIALBUS),
- 0},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
- AML_OFFSET (CommonSerialBus.RevisionId),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
- AML_OFFSET (CommonSerialBus.Type),
- 1},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
- AML_OFFSET (CommonSerialBus.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
- AML_OFFSET (CommonSerialBus.Flags),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
- AML_OFFSET (CommonSerialBus.TypeRevisionId),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- 1},
-
- /* Vendor data */
-
- {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- AML_RESOURCE_I2C_MIN_DATA_LEN},
-
- {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
- 0,
- sizeof (AML_RESOURCE_I2C_SERIALBUS)},
-
- /* Resource Source */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
- AML_OFFSET (CommonSerialBus.ResSourceIndex),
- 1},
-
- {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
-
- {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
-
- /* I2C bus type specific */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode),
- AML_OFFSET (I2cSerialBus.TypeSpecificFlags),
- 0},
-
- {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed),
- AML_OFFSET (I2cSerialBus.ConnectionSpeed),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress),
- AML_OFFSET (I2cSerialBus.SlaveAddress),
- 1},
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertSpiSerialBus
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
- ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
- sizeof (AML_RESOURCE_SPI_SERIALBUS),
- 0},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
- AML_OFFSET (CommonSerialBus.RevisionId),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
- AML_OFFSET (CommonSerialBus.Type),
- 1},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
- AML_OFFSET (CommonSerialBus.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
- AML_OFFSET (CommonSerialBus.Flags),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
- AML_OFFSET (CommonSerialBus.TypeRevisionId),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- 1},
-
- /* Vendor data */
-
- {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- AML_RESOURCE_SPI_MIN_DATA_LEN},
-
- {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
- 0,
- sizeof (AML_RESOURCE_SPI_SERIALBUS)},
-
- /* Resource Source */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
- AML_OFFSET (CommonSerialBus.ResSourceIndex),
- 1},
-
- {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
-
- {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
-
- /* Spi bus type specific */
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode),
- AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity),
- AML_OFFSET (SpiSerialBus.TypeSpecificFlags),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength),
- AML_OFFSET (SpiSerialBus.DataBitLength),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase),
- AML_OFFSET (SpiSerialBus.ClockPhase),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity),
- AML_OFFSET (SpiSerialBus.ClockPolarity),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection),
- AML_OFFSET (SpiSerialBus.DeviceSelection),
- 1},
-
- {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed),
- AML_OFFSET (SpiSerialBus.ConnectionSpeed),
- 1},
-};
-
-
-/*******************************************************************************
- *
- * AcpiRsConvertUartSerialBus
- *
- ******************************************************************************/
-
-ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[22] =
-{
- {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
- ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
- ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)},
-
- {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
- sizeof (AML_RESOURCE_UART_SERIALBUS),
- 0},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId),
- AML_OFFSET (CommonSerialBus.RevisionId),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type),
- AML_OFFSET (CommonSerialBus.Type),
- 1},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode),
- AML_OFFSET (CommonSerialBus.Flags),
- 0},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer),
- AML_OFFSET (CommonSerialBus.Flags),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId),
- AML_OFFSET (CommonSerialBus.TypeRevisionId),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- 1},
-
- /* Vendor data */
-
- {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- AML_RESOURCE_UART_MIN_DATA_LEN},
-
- {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData),
- 0,
- sizeof (AML_RESOURCE_UART_SERIALBUS)},
-
- /* Resource Source */
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index),
- AML_OFFSET (CommonSerialBus.ResSourceIndex),
- 1},
-
- {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
-
- {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr),
- AML_OFFSET (CommonSerialBus.TypeDataLength),
- sizeof (AML_RESOURCE_COMMON_SERIALBUS)},
-
- /* Uart bus type specific */
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl),
- AML_OFFSET (UartSerialBus.TypeSpecificFlags),
- 0},
-
- {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits),
- AML_OFFSET (UartSerialBus.TypeSpecificFlags),
- 2},
-
- {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits),
- AML_OFFSET (UartSerialBus.TypeSpecificFlags),
- 4},
-
- {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian),
- AML_OFFSET (UartSerialBus.TypeSpecificFlags),
- 7},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.Parity),
- AML_OFFSET (UartSerialBus.Parity),
- 1},
-
- {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled),
- AML_OFFSET (UartSerialBus.LinesEnabled),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize),
- AML_OFFSET (UartSerialBus.RxFifoSize),
- 1},
-
- {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize),
- AML_OFFSET (UartSerialBus.TxFifoSize),
- 1},
-
- {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate),
- AML_OFFSET (UartSerialBus.DefaultBaudRate),
- 1},
-};
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsutils.c
--- a/head/sys/contrib/dev/acpica/resources/rsutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,861 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsutils - Utilities for the resource manager
- *
- ******************************************************************************/
-
-/*
- * 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 __RSUTILS_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/acresrc.h>
-
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsutils")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsDecodeBitmask
- *
- * PARAMETERS: Mask - Bitmask to decode
- * List - Where the converted list is returned
- *
- * RETURN: Count of bits set (length of list)
- *
- * DESCRIPTION: Convert a bit mask into a list of values
- *
- ******************************************************************************/
-
-UINT8
-AcpiRsDecodeBitmask (
- UINT16 Mask,
- UINT8 *List)
-{
- UINT8 i;
- UINT8 BitCount;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Decode the mask bits */
-
- for (i = 0, BitCount = 0; Mask; i++)
- {
- if (Mask & 0x0001)
- {
- List[BitCount] = i;
- BitCount++;
- }
-
- Mask >>= 1;
- }
-
- return (BitCount);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsEncodeBitmask
- *
- * PARAMETERS: List - List of values to encode
- * Count - Length of list
- *
- * RETURN: Encoded bitmask
- *
- * DESCRIPTION: Convert a list of values to an encoded bitmask
- *
- ******************************************************************************/
-
-UINT16
-AcpiRsEncodeBitmask (
- UINT8 *List,
- UINT8 Count)
-{
- UINT32 i;
- UINT16 Mask;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Encode the list into a single bitmask */
-
- for (i = 0, Mask = 0; i < Count; i++)
- {
- Mask |= (0x1 << List[i]);
- }
-
- return (Mask);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsMoveData
- *
- * PARAMETERS: Destination - Pointer to the destination descriptor
- * Source - Pointer to the source descriptor
- * ItemCount - How many items to move
- * MoveType - Byte width
- *
- * RETURN: None
- *
- * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
- * alignment issues and endian issues if necessary, as configured
- * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
- *
- ******************************************************************************/
-
-void
-AcpiRsMoveData (
- void *Destination,
- void *Source,
- UINT16 ItemCount,
- UINT8 MoveType)
-{
- UINT32 i;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* One move per item */
-
- for (i = 0; i < ItemCount; i++)
- {
- switch (MoveType)
- {
- /*
- * For the 8-bit case, we can perform the move all at once
- * since there are no alignment or endian issues
- */
- case ACPI_RSC_MOVE8:
- case ACPI_RSC_MOVE_GPIO_RES:
- case ACPI_RSC_MOVE_SERIAL_VEN:
- case ACPI_RSC_MOVE_SERIAL_RES:
- ACPI_MEMCPY (Destination, Source, ItemCount);
- return;
-
- /*
- * 16-, 32-, and 64-bit cases must use the move macros that perform
- * endian conversion and/or accomodate hardware that cannot perform
- * misaligned memory transfers
- */
- case ACPI_RSC_MOVE16:
- case ACPI_RSC_MOVE_GPIO_PIN:
- ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
- &ACPI_CAST_PTR (UINT16, Source)[i]);
- break;
-
- case ACPI_RSC_MOVE32:
- ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
- &ACPI_CAST_PTR (UINT32, Source)[i]);
- break;
-
- case ACPI_RSC_MOVE64:
- ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
- &ACPI_CAST_PTR (UINT64, Source)[i]);
- break;
-
- default:
- return;
- }
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsSetResourceLength
- *
- * PARAMETERS: TotalLength - Length of the AML descriptor, including
- * the header and length fields.
- * Aml - Pointer to the raw AML descriptor
- *
- * RETURN: None
- *
- * DESCRIPTION: Set the ResourceLength field of an AML
- * resource descriptor, both Large and Small descriptors are
- * supported automatically. Note: Descriptor Type field must
- * be valid.
- *
- ******************************************************************************/
-
-void
-AcpiRsSetResourceLength (
- ACPI_RSDESC_SIZE TotalLength,
- AML_RESOURCE *Aml)
-{
- ACPI_RS_LENGTH ResourceLength;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Length is the total descriptor length minus the header length */
-
- ResourceLength = (ACPI_RS_LENGTH)
- (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
-
- /* Length is stored differently for large and small descriptors */
-
- if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
- {
- /* Large descriptor -- bytes 1-2 contain the 16-bit length */
-
- ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
- }
- else
- {
- /* Small descriptor -- bits 2:0 of byte 0 contain the length */
-
- Aml->SmallHeader.DescriptorType = (UINT8)
-
- /* Clear any existing length, preserving descriptor type bits */
-
- ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
-
- | ResourceLength);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsSetResourceHeader
- *
- * PARAMETERS: DescriptorType - Byte to be inserted as the type
- * TotalLength - Length of the AML descriptor, including
- * the header and length fields.
- * Aml - Pointer to the raw AML descriptor
- *
- * RETURN: None
- *
- * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
- * resource descriptor, both Large and Small descriptors are
- * supported automatically
- *
- ******************************************************************************/
-
-void
-AcpiRsSetResourceHeader (
- UINT8 DescriptorType,
- ACPI_RSDESC_SIZE TotalLength,
- AML_RESOURCE *Aml)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Set the Resource Type */
-
- Aml->SmallHeader.DescriptorType = DescriptorType;
-
- /* Set the Resource Length */
-
- AcpiRsSetResourceLength (TotalLength, Aml);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsStrcpy
- *
- * PARAMETERS: Destination - Pointer to the destination string
- * Source - Pointer to the source string
- *
- * RETURN: String length, including NULL terminator
- *
- * DESCRIPTION: Local string copy that returns the string length, saving a
- * strcpy followed by a strlen.
- *
- ******************************************************************************/
-
-static UINT16
-AcpiRsStrcpy (
- char *Destination,
- char *Source)
-{
- UINT16 i;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- for (i = 0; Source[i]; i++)
- {
- Destination[i] = Source[i];
- }
-
- Destination[i] = 0;
-
- /* Return string length including the NULL terminator */
-
- return ((UINT16) (i + 1));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetResourceSource
- *
- * PARAMETERS: ResourceLength - Length field of the descriptor
- * MinimumLength - Minimum length of the descriptor (minus
- * any optional fields)
- * ResourceSource - Where the ResourceSource is returned
- * Aml - Pointer to the raw AML descriptor
- * StringPtr - (optional) where to store the actual
- * ResourceSource string
- *
- * RETURN: Length of the string plus NULL terminator, rounded up to native
- * word boundary
- *
- * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
- * to an internal resource descriptor
- *
- ******************************************************************************/
-
-ACPI_RS_LENGTH
-AcpiRsGetResourceSource (
- ACPI_RS_LENGTH ResourceLength,
- ACPI_RS_LENGTH MinimumLength,
- ACPI_RESOURCE_SOURCE *ResourceSource,
- AML_RESOURCE *Aml,
- char *StringPtr)
-{
- ACPI_RSDESC_SIZE TotalLength;
- UINT8 *AmlResourceSource;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
- AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
-
- /*
- * ResourceSource is present if the length of the descriptor is longer than
- * the minimum length.
- *
- * Note: Some resource descriptors will have an additional null, so
- * we add 1 to the minimum length.
- */
- if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
- {
- /* Get the ResourceSourceIndex */
-
- ResourceSource->Index = AmlResourceSource[0];
-
- ResourceSource->StringPtr = StringPtr;
- if (!StringPtr)
- {
- /*
- * String destination pointer is not specified; Set the String
- * pointer to the end of the current ResourceSource structure.
- */
- ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource,
- sizeof (ACPI_RESOURCE_SOURCE));
- }
-
- /*
- * In order for the Resource length to be a multiple of the native
- * word, calculate the length of the string (+1 for NULL terminator)
- * and expand to the next word multiple.
- *
- * Zero the entire area of the buffer.
- */
- TotalLength = (UINT32) ACPI_STRLEN (
- ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
- TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
-
- ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
-
- /* Copy the ResourceSource string to the destination */
-
- ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
- ACPI_CAST_PTR (char, &AmlResourceSource[1]));
-
- return ((ACPI_RS_LENGTH) TotalLength);
- }
-
- /* ResourceSource is not present */
-
- ResourceSource->Index = 0;
- ResourceSource->StringLength = 0;
- ResourceSource->StringPtr = NULL;
- return (0);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsSetResourceSource
- *
- * PARAMETERS: Aml - Pointer to the raw AML descriptor
- * MinimumLength - Minimum length of the descriptor (minus
- * any optional fields)
- * ResourceSource - Internal ResourceSource
-
- *
- * RETURN: Total length of the AML descriptor
- *
- * DESCRIPTION: Convert an optional ResourceSource from internal format to a
- * raw AML resource descriptor
- *
- ******************************************************************************/
-
-ACPI_RSDESC_SIZE
-AcpiRsSetResourceSource (
- AML_RESOURCE *Aml,
- ACPI_RS_LENGTH MinimumLength,
- ACPI_RESOURCE_SOURCE *ResourceSource)
-{
- UINT8 *AmlResourceSource;
- ACPI_RSDESC_SIZE DescriptorLength;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- DescriptorLength = MinimumLength;
-
- /* Non-zero string length indicates presence of a ResourceSource */
-
- if (ResourceSource->StringLength)
- {
- /* Point to the end of the AML descriptor */
-
- AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
-
- /* Copy the ResourceSourceIndex */
-
- AmlResourceSource[0] = (UINT8) ResourceSource->Index;
-
- /* Copy the ResourceSource string */
-
- ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
- ResourceSource->StringPtr);
-
- /*
- * Add the length of the string (+ 1 for null terminator) to the
- * final descriptor length
- */
- DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
- }
-
- /* Return the new total length of the AML descriptor */
-
- return (DescriptorLength);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetPrtMethodData
- *
- * PARAMETERS: Node - Device node
- * RetBuffer - Pointer to a buffer structure for the
- * results
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the _PRT value of an object
- * contained in an object specified by the handle passed in
- *
- * If the function fails an appropriate status will be returned
- * and the contents of the callers buffer is undefined.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetPrtMethodData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
-
-
- /* Parameters guaranteed valid by caller */
-
- /* Execute the method, no parameters */
-
- Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
- ACPI_BTYPE_PACKAGE, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Create a resource linked list from the byte stream buffer that comes
- * back from the _CRS method execution.
- */
- Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
-
- /* On exit, we must delete the object returned by EvaluateObject */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetCrsMethodData
- *
- * PARAMETERS: Node - Device node
- * RetBuffer - Pointer to a buffer structure for the
- * results
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the _CRS value of an object
- * contained in an object specified by the handle passed in
- *
- * If the function fails an appropriate status will be returned
- * and the contents of the callers buffer is undefined.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetCrsMethodData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
-
-
- /* Parameters guaranteed valid by caller */
-
- /* Execute the method, no parameters */
-
- Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
- ACPI_BTYPE_BUFFER, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Make the call to create a resource linked list from the
- * byte stream buffer that comes back from the _CRS method
- * execution.
- */
- Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
-
- /* On exit, we must delete the object returned by evaluateObject */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetPrsMethodData
- *
- * PARAMETERS: Node - Device node
- * RetBuffer - Pointer to a buffer structure for the
- * results
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the _PRS value of an object
- * contained in an object specified by the handle passed in
- *
- * If the function fails an appropriate status will be returned
- * and the contents of the callers buffer is undefined.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetPrsMethodData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
-
-
- /* Parameters guaranteed valid by caller */
-
- /* Execute the method, no parameters */
-
- Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
- ACPI_BTYPE_BUFFER, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Make the call to create a resource linked list from the
- * byte stream buffer that comes back from the _CRS method
- * execution.
- */
- Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
-
- /* On exit, we must delete the object returned by evaluateObject */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetAeiMethodData
- *
- * PARAMETERS: Node - Device node
- * RetBuffer - Pointer to a buffer structure for the
- * results
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the _AEI value of an object
- * contained in an object specified by the handle passed in
- *
- * If the function fails an appropriate status will be returned
- * and the contents of the callers buffer is undefined.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetAeiMethodData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
-
-
- /* Parameters guaranteed valid by caller */
-
- /* Execute the method, no parameters */
-
- Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI,
- ACPI_BTYPE_BUFFER, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Make the call to create a resource linked list from the
- * byte stream buffer that comes back from the _CRS method
- * execution.
- */
- Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
-
- /* On exit, we must delete the object returned by evaluateObject */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsGetMethodData
- *
- * PARAMETERS: Handle - Handle to the containing object
- * Path - Path to method, relative to Handle
- * RetBuffer - Pointer to a buffer structure for the
- * results
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
- * object contained in an object specified by the handle passed in
- *
- * If the function fails an appropriate status will be returned
- * and the contents of the callers buffer is undefined.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsGetMethodData (
- ACPI_HANDLE Handle,
- char *Path,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (RsGetMethodData);
-
-
- /* Parameters guaranteed valid by caller */
-
- /* Execute the method, no parameters */
-
- Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Make the call to create a resource linked list from the
- * byte stream buffer that comes back from the method
- * execution.
- */
- Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
-
- /* On exit, we must delete the object returned by EvaluateObject */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsSetSrsMethodData
- *
- * PARAMETERS: Node - Device node
- * InBuffer - Pointer to a buffer structure of the
- * parameter
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to set the _SRS of an object contained
- * in an object specified by the handle passed in
- *
- * If the function fails an appropriate status will be returned
- * and the contents of the callers buffer is undefined.
- *
- * Note: Parameters guaranteed valid by caller
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRsSetSrsMethodData (
- ACPI_NAMESPACE_NODE *Node,
- ACPI_BUFFER *InBuffer)
-{
- ACPI_EVALUATE_INFO *Info;
- ACPI_OPERAND_OBJECT *Args[2];
- ACPI_STATUS Status;
- ACPI_BUFFER Buffer;
-
-
- ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
-
-
- /* 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 = Node;
- Info->Pathname = METHOD_NAME__SRS;
- Info->Parameters = Args;
- Info->Flags = ACPI_IGNORE_RETURN_VALUE;
-
- /*
- * The InBuffer parameter will point to a linked list of
- * resource parameters. It needs to be formatted into a
- * byte stream to be sent in as an input parameter to _SRS
- *
- * Convert the linked list into a byte stream
- */
- Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
- Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer);
- if (ACPI_FAILURE (Status))
- {
- goto Cleanup;
- }
-
- /* Create and initialize the method parameter object */
-
- Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
- if (!Args[0])
- {
- /*
- * Must free the buffer allocated above (otherwise it is freed
- * later)
- */
- ACPI_FREE (Buffer.Pointer);
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- Args[0]->Buffer.Length = (UINT32) Buffer.Length;
- Args[0]->Buffer.Pointer = Buffer.Pointer;
- Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
- Args[1] = NULL;
-
- /* Execute the method, no return value is expected */
-
- Status = AcpiNsEvaluate (Info);
-
- /* Clean up and return the status from AcpiNsEvaluate */
-
- AcpiUtRemoveReference (Args[0]);
-
-Cleanup:
- ACPI_FREE (Info);
- return_ACPI_STATUS (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/resources/rsxface.c
--- a/head/sys/contrib/dev/acpica/resources/rsxface.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,689 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: rsxface - Public interfaces to the resource manager
- *
- ******************************************************************************/
-
-/*
- * 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 __RSXFACE_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-#define _COMPONENT ACPI_RESOURCES
- ACPI_MODULE_NAME ("rsxface")
-
-/* Local macros for 16,32-bit to 64-bit conversion */
-
-#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field)
-#define ACPI_COPY_ADDRESS(Out, In) \
- ACPI_COPY_FIELD(Out, In, ResourceType); \
- ACPI_COPY_FIELD(Out, In, ProducerConsumer); \
- ACPI_COPY_FIELD(Out, In, Decode); \
- ACPI_COPY_FIELD(Out, In, MinAddressFixed); \
- ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \
- ACPI_COPY_FIELD(Out, In, Info); \
- ACPI_COPY_FIELD(Out, In, Granularity); \
- ACPI_COPY_FIELD(Out, In, Minimum); \
- ACPI_COPY_FIELD(Out, In, Maximum); \
- ACPI_COPY_FIELD(Out, In, TranslationOffset); \
- ACPI_COPY_FIELD(Out, In, AddressLength); \
- ACPI_COPY_FIELD(Out, In, ResourceSource);
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiRsMatchVendorResource (
- ACPI_RESOURCE *Resource,
- void *Context);
-
-static ACPI_STATUS
-AcpiRsValidateParameters (
- ACPI_HANDLE DeviceHandle,
- ACPI_BUFFER *Buffer,
- ACPI_NAMESPACE_NODE **ReturnNode);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsValidateParameters
- *
- * PARAMETERS: DeviceHandle - Handle to a device
- * Buffer - Pointer to a data buffer
- * ReturnNode - Pointer to where the device node is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Common parameter validation for resource interfaces
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiRsValidateParameters (
- ACPI_HANDLE DeviceHandle,
- ACPI_BUFFER *Buffer,
- ACPI_NAMESPACE_NODE **ReturnNode)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (RsValidateParameters);
-
-
- /*
- * Must have a valid handle to an ACPI device
- */
- if (!DeviceHandle)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- Node = AcpiNsValidateHandle (DeviceHandle);
- if (!Node)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (Node->Type != ACPI_TYPE_DEVICE)
- {
- return_ACPI_STATUS (AE_TYPE);
- }
-
- /*
- * Validate the user buffer object
- *
- * if there is a non-zero buffer length we also need a valid pointer in
- * the buffer. If it's a zero buffer length, we'll be returning the
- * needed buffer size (later), so keep going.
- */
- Status = AcpiUtValidateBuffer (Buffer);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- *ReturnNode = Node;
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetIrqRoutingTable
- *
- * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying
- * RetBuffer - Pointer to a buffer to receive the
- * current resources for the device
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the IRQ routing table for a
- * specific bus. The caller must first acquire a handle for the
- * desired bus. The routine table is placed in the buffer pointed
- * to by the RetBuffer variable parameter.
- *
- * If the function fails an appropriate status will be returned
- * and the value of RetBuffer is undefined.
- *
- * This function attempts to execute the _PRT method contained in
- * the object indicated by the passed DeviceHandle.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetIrqRoutingTable (
- ACPI_HANDLE DeviceHandle,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
-
-
- /* Validate parameters then dispatch to internal routine */
-
- Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetCurrentResources
- *
- * PARAMETERS: DeviceHandle - Handle to the device object for the
- * device we are querying
- * RetBuffer - Pointer to a buffer to receive the
- * current resources for the device
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the current resources for a
- * specific device. The caller must first acquire a handle for
- * the desired device. The resource data is placed in the buffer
- * pointed to by the RetBuffer variable parameter.
- *
- * If the function fails an appropriate status will be returned
- * and the value of RetBuffer is undefined.
- *
- * This function attempts to execute the _CRS method contained in
- * the object indicated by the passed DeviceHandle.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetCurrentResources (
- ACPI_HANDLE DeviceHandle,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
-
-
- /* Validate parameters then dispatch to internal routine */
-
- Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetPossibleResources
- *
- * PARAMETERS: DeviceHandle - Handle to the device object for the
- * device we are querying
- * RetBuffer - Pointer to a buffer to receive the
- * resources for the device
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get a list of the possible resources
- * for a specific device. The caller must first acquire a handle
- * for the desired device. The resource data is placed in the
- * buffer pointed to by the RetBuffer variable.
- *
- * If the function fails an appropriate status will be returned
- * and the value of RetBuffer is undefined.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetPossibleResources (
- ACPI_HANDLE DeviceHandle,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
-
-
- /* Validate parameters then dispatch to internal routine */
-
- Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiSetCurrentResources
- *
- * PARAMETERS: DeviceHandle - Handle to the device object for the
- * device we are setting resources
- * InBuffer - Pointer to a buffer containing the
- * resources to be set for the device
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to set the current resources for a
- * specific device. The caller must first acquire a handle for
- * the desired device. The resource data is passed to the routine
- * the buffer pointed to by the InBuffer variable.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiSetCurrentResources (
- ACPI_HANDLE DeviceHandle,
- ACPI_BUFFER *InBuffer)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
-
-
- /* Validate the buffer, don't allow zero length */
-
- if ((!InBuffer) ||
- (!InBuffer->Pointer) ||
- (!InBuffer->Length))
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Validate parameters then dispatch to internal routine */
-
- Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiRsSetSrsMethodData (Node, InBuffer);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetEventResources
- *
- * PARAMETERS: DeviceHandle - Handle to the device object for the
- * device we are getting resources
- * InBuffer - Pointer to a buffer containing the
- * resources to be set for the device
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to get the event resources for a
- * specific device. The caller must first acquire a handle for
- * the desired device. The resource data is passed to the routine
- * the buffer pointed to by the InBuffer variable. Uses the
- * _AEI method.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetEventResources (
- ACPI_HANDLE DeviceHandle,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetEventResources);
-
-
- /* Validate parameters then dispatch to internal routine */
-
- Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiRsGetAeiMethodData (Node, RetBuffer);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetEventResources)
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiResourceToAddress64
- *
- * PARAMETERS: Resource - Pointer to a resource
- * Out - Pointer to the users's return buffer
- * (a struct acpi_resource_address64)
- *
- * RETURN: Status
- *
- * DESCRIPTION: If the resource is an address16, address32, or address64,
- * copy it to the address64 return buffer. This saves the
- * caller from having to duplicate code for different-sized
- * addresses.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiResourceToAddress64 (
- ACPI_RESOURCE *Resource,
- ACPI_RESOURCE_ADDRESS64 *Out)
-{
- ACPI_RESOURCE_ADDRESS16 *Address16;
- ACPI_RESOURCE_ADDRESS32 *Address32;
-
-
- if (!Resource || !Out)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Convert 16 or 32 address descriptor to 64 */
-
- switch (Resource->Type)
- {
- case ACPI_RESOURCE_TYPE_ADDRESS16:
-
- Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data);
- ACPI_COPY_ADDRESS (Out, Address16);
- break;
-
- case ACPI_RESOURCE_TYPE_ADDRESS32:
-
- Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data);
- ACPI_COPY_ADDRESS (Out, Address32);
- break;
-
- case ACPI_RESOURCE_TYPE_ADDRESS64:
-
- /* Simple copy for 64 bit source */
-
- ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
- break;
-
- default:
- return (AE_BAD_PARAMETER);
- }
-
- return (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetVendorResource
- *
- * PARAMETERS: DeviceHandle - Handle for the parent device object
- * Name - Method name for the parent resource
- * (METHOD_NAME__CRS or METHOD_NAME__PRS)
- * Uuid - Pointer to the UUID to be matched.
- * includes both subtype and 16-byte UUID
- * RetBuffer - Where the vendor resource is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Walk a resource template for the specified evice to find a
- * vendor-defined resource that matches the supplied UUID and
- * UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetVendorResource (
- ACPI_HANDLE DeviceHandle,
- char *Name,
- ACPI_VENDOR_UUID *Uuid,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_VENDOR_WALK_INFO Info;
- ACPI_STATUS Status;
-
-
- /* Other parameters are validated by AcpiWalkResources */
-
- if (!Uuid || !RetBuffer)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Info.Uuid = Uuid;
- Info.Buffer = RetBuffer;
- Info.Status = AE_NOT_EXIST;
-
- /* Walk the _CRS or _PRS resource list for this device */
-
- Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource,
- &Info);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- return (Info.Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetVendorResource)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRsMatchVendorResource
- *
- * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
- *
- * RETURN: Status
- *
- * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiRsMatchVendorResource (
- ACPI_RESOURCE *Resource,
- void *Context)
-{
- ACPI_VENDOR_WALK_INFO *Info = Context;
- ACPI_RESOURCE_VENDOR_TYPED *Vendor;
- ACPI_BUFFER *Buffer;
- ACPI_STATUS Status;
-
-
- /* Ignore all descriptors except Vendor */
-
- if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
- {
- return (AE_OK);
- }
-
- Vendor = &Resource->Data.VendorTyped;
-
- /*
- * For a valid match, these conditions must hold:
- *
- * 1) Length of descriptor data must be at least as long as a UUID struct
- * 2) The UUID subtypes must match
- * 3) The UUID data must match
- */
- if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
- (Vendor->UuidSubtype != Info->Uuid->Subtype) ||
- (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
- {
- return (AE_OK);
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- Buffer = Info->Buffer;
- Status = AcpiUtInitializeBuffer (Buffer, Resource->Length);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Found the correct resource, copy and return it */
-
- ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length);
- Buffer->Length = Resource->Length;
-
- /* Found the desired descriptor, terminate resource walk */
-
- Info->Status = AE_OK;
- return (AE_CTRL_TERMINATE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiWalkResources
- *
- * PARAMETERS: DeviceHandle - Handle to the device object for the
- * device we are querying
- * Name - Method name of the resources we want.
- * (METHOD_NAME__CRS, METHOD_NAME__PRS, or
- * METHOD_NAME__AEI)
- * UserFunction - Called for each resource
- * Context - Passed to UserFunction
- *
- * RETURN: Status
- *
- * DESCRIPTION: Retrieves the current or possible resource list for the
- * specified device. The UserFunction is called once for
- * each resource in the list.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiWalkResources (
- ACPI_HANDLE DeviceHandle,
- char *Name,
- ACPI_WALK_RESOURCE_CALLBACK UserFunction,
- void *Context)
-{
- ACPI_STATUS Status;
- ACPI_BUFFER Buffer;
- ACPI_RESOURCE *Resource;
- ACPI_RESOURCE *ResourceEnd;
-
-
- ACPI_FUNCTION_TRACE (AcpiWalkResources);
-
-
- /* Parameter validation */
-
- if (!DeviceHandle || !UserFunction || !Name ||
- (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
- !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS) &&
- !ACPI_COMPARE_NAME (Name, METHOD_NAME__AEI)))
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Get the _CRS/_PRS/_AEI resource list */
-
- Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
- Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Buffer now contains the resource list */
-
- Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer);
- ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length);
-
- /* Walk the resource list until the EndTag is found (or buffer end) */
-
- while (Resource < ResourceEnd)
- {
- /* Sanity check the resource */
-
- if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
- {
- Status = AE_AML_INVALID_RESOURCE_TYPE;
- break;
- }
-
- /* Invoke the user function, abort on any error returned */
-
- Status = UserFunction (Resource, Context);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_CTRL_TERMINATE)
- {
- /* This is an OK termination by the user function */
-
- Status = AE_OK;
- }
- break;
- }
-
- /* EndTag indicates end-of-list */
-
- if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
- {
- break;
- }
-
- /* Get the next resource descriptor */
-
- Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
- }
-
- ACPI_FREE (Buffer.Pointer);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiWalkResources)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/tables/tbfadt.c
--- a/head/sys/contrib/dev/acpica/tables/tbfadt.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,704 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tbfadt - FADT table 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 __TBFADT_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_TABLES
- ACPI_MODULE_NAME ("tbfadt")
-
-/* Local prototypes */
-
-static ACPI_INLINE void
-AcpiTbInitGenericAddress (
- ACPI_GENERIC_ADDRESS *GenericAddress,
- UINT8 SpaceId,
- UINT8 ByteWidth,
- UINT64 Address);
-
-static void
-AcpiTbConvertFadt (
- void);
-
-static void
-AcpiTbValidateFadt (
- void);
-
-static void
-AcpiTbSetupFadtRegisters (
- void);
-
-
-/* Table for conversion of FADT to common internal format and FADT validation */
-
-typedef struct acpi_fadt_info
-{
- char *Name;
- UINT16 Address64;
- UINT16 Address32;
- UINT16 Length;
- UINT8 DefaultLength;
- UINT8 Type;
-
-} ACPI_FADT_INFO;
-
-#define ACPI_FADT_OPTIONAL 0
-#define ACPI_FADT_REQUIRED 1
-#define ACPI_FADT_SEPARATE_LENGTH 2
-
-static ACPI_FADT_INFO FadtInfoTable[] =
-{
- {"Pm1aEventBlock",
- ACPI_FADT_OFFSET (XPm1aEventBlock),
- ACPI_FADT_OFFSET (Pm1aEventBlock),
- ACPI_FADT_OFFSET (Pm1EventLength),
- ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
- ACPI_FADT_REQUIRED},
-
- {"Pm1bEventBlock",
- ACPI_FADT_OFFSET (XPm1bEventBlock),
- ACPI_FADT_OFFSET (Pm1bEventBlock),
- ACPI_FADT_OFFSET (Pm1EventLength),
- ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
- ACPI_FADT_OPTIONAL},
-
- {"Pm1aControlBlock",
- ACPI_FADT_OFFSET (XPm1aControlBlock),
- ACPI_FADT_OFFSET (Pm1aControlBlock),
- ACPI_FADT_OFFSET (Pm1ControlLength),
- ACPI_PM1_REGISTER_WIDTH,
- ACPI_FADT_REQUIRED},
-
- {"Pm1bControlBlock",
- ACPI_FADT_OFFSET (XPm1bControlBlock),
- ACPI_FADT_OFFSET (Pm1bControlBlock),
- ACPI_FADT_OFFSET (Pm1ControlLength),
- ACPI_PM1_REGISTER_WIDTH,
- ACPI_FADT_OPTIONAL},
-
- {"Pm2ControlBlock",
- ACPI_FADT_OFFSET (XPm2ControlBlock),
- ACPI_FADT_OFFSET (Pm2ControlBlock),
- ACPI_FADT_OFFSET (Pm2ControlLength),
- ACPI_PM2_REGISTER_WIDTH,
- ACPI_FADT_SEPARATE_LENGTH},
-
- {"PmTimerBlock",
- ACPI_FADT_OFFSET (XPmTimerBlock),
- ACPI_FADT_OFFSET (PmTimerBlock),
- ACPI_FADT_OFFSET (PmTimerLength),
- ACPI_PM_TIMER_WIDTH,
- ACPI_FADT_REQUIRED},
-
- {"Gpe0Block",
- ACPI_FADT_OFFSET (XGpe0Block),
- ACPI_FADT_OFFSET (Gpe0Block),
- ACPI_FADT_OFFSET (Gpe0BlockLength),
- 0,
- ACPI_FADT_SEPARATE_LENGTH},
-
- {"Gpe1Block",
- ACPI_FADT_OFFSET (XGpe1Block),
- ACPI_FADT_OFFSET (Gpe1Block),
- ACPI_FADT_OFFSET (Gpe1BlockLength),
- 0,
- ACPI_FADT_SEPARATE_LENGTH}
-};
-
-#define ACPI_FADT_INFO_ENTRIES \
- (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
-
-
-/* Table used to split Event Blocks into separate status/enable registers */
-
-typedef struct acpi_fadt_pm_info
-{
- ACPI_GENERIC_ADDRESS *Target;
- UINT16 Source;
- UINT8 RegisterNum;
-
-} ACPI_FADT_PM_INFO;
-
-static ACPI_FADT_PM_INFO FadtPmInfoTable[] =
-{
- {&AcpiGbl_XPm1aStatus,
- ACPI_FADT_OFFSET (XPm1aEventBlock),
- 0},
-
- {&AcpiGbl_XPm1aEnable,
- ACPI_FADT_OFFSET (XPm1aEventBlock),
- 1},
-
- {&AcpiGbl_XPm1bStatus,
- ACPI_FADT_OFFSET (XPm1bEventBlock),
- 0},
-
- {&AcpiGbl_XPm1bEnable,
- ACPI_FADT_OFFSET (XPm1bEventBlock),
- 1}
-};
-
-#define ACPI_FADT_PM_INFO_ENTRIES \
- (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbInitGenericAddress
- *
- * PARAMETERS: GenericAddress - GAS struct to be initialized
- * SpaceId - ACPI Space ID for this register
- * ByteWidth - Width of this register, in bytes
- * Address - Address of the register
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize a Generic Address Structure (GAS)
- * See the ACPI specification for a full description and
- * definition of this structure.
- *
- ******************************************************************************/
-
-static ACPI_INLINE void
-AcpiTbInitGenericAddress (
- ACPI_GENERIC_ADDRESS *GenericAddress,
- UINT8 SpaceId,
- UINT8 ByteWidth,
- UINT64 Address)
-{
-
- /*
- * The 64-bit Address field is non-aligned in the byte packed
- * GAS struct.
- */
- ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address);
-
- /* All other fields are byte-wide */
-
- GenericAddress->SpaceId = SpaceId;
- GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth);
- GenericAddress->BitOffset = 0;
- GenericAddress->AccessWidth = 0; /* Access width ANY */
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbParseFadt
- *
- * PARAMETERS: TableIndex - Index for the FADT
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
- * (FADT contains the addresses of the DSDT and FACS)
- *
- ******************************************************************************/
-
-void
-AcpiTbParseFadt (
- UINT32 TableIndex)
-{
- UINT32 Length;
- ACPI_TABLE_HEADER *Table;
-
-
- /*
- * The FADT has multiple versions with different lengths,
- * and it contains pointers to both the DSDT and FACS tables.
- *
- * Get a local copy of the FADT and convert it to a common format
- * Map entire FADT, assumed to be smaller than one page.
- */
- Length = AcpiGbl_RootTableList.Tables[TableIndex].Length;
-
- Table = AcpiOsMapMemory (
- AcpiGbl_RootTableList.Tables[TableIndex].Address, Length);
- if (!Table)
- {
- return;
- }
-
- /*
- * Validate the FADT checksum before we copy the table. Ignore
- * checksum error as we want to try to get the DSDT and FACS.
- */
- (void) AcpiTbVerifyChecksum (Table, Length);
-
- /* Create a local copy of the FADT in common ACPI 2.0+ format */
-
- AcpiTbCreateLocalFadt (Table, Length);
-
- /* All done with the real FADT, unmap it */
-
- AcpiOsUnmapMemory (Table, Length);
-
- /* Obtain the DSDT and FACS tables via their addresses within the FADT */
-
- AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
- ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
-
- /* If Hardware Reduced flag is set, there is no FACS */
-
- if (!AcpiGbl_ReducedHardware)
- {
- AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
- ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbCreateLocalFadt
- *
- * PARAMETERS: Table - Pointer to BIOS FADT
- * Length - Length of the table
- *
- * RETURN: None
- *
- * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
- * Performs validation on some important FADT fields.
- *
- * NOTE: We create a local copy of the FADT regardless of the version.
- *
- ******************************************************************************/
-
-void
-AcpiTbCreateLocalFadt (
- ACPI_TABLE_HEADER *Table,
- UINT32 Length)
-{
-
- /*
- * Check if the FADT is larger than the largest table that we expect
- * (the ACPI 5.0 version). If so, truncate the table, and issue
- * a warning.
- */
- if (Length > sizeof (ACPI_TABLE_FADT))
- {
- ACPI_WARNING ((AE_INFO,
- "FADT (revision %u) is longer than ACPI 5.0 version, "
- "truncating length %u to %u",
- Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT)));
- }
-
- /* Clear the entire local FADT */
-
- ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
-
- /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
-
- ACPI_MEMCPY (&AcpiGbl_FADT, Table,
- ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
-
- /* Take a copy of the Hardware Reduced flag */
-
- AcpiGbl_ReducedHardware = FALSE;
- if (AcpiGbl_FADT.Flags & ACPI_FADT_HW_REDUCED)
- {
- AcpiGbl_ReducedHardware = TRUE;
- }
-
- /* Convert the local copy of the FADT to the common internal format */
-
- AcpiTbConvertFadt ();
-
- /* Validate FADT values now, before we make any changes */
-
- AcpiTbValidateFadt ();
-
- /* Initialize the global ACPI register structures */
-
- AcpiTbSetupFadtRegisters ();
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbConvertFadt
- *
- * PARAMETERS: None, uses AcpiGbl_FADT
- *
- * RETURN: None
- *
- * DESCRIPTION: Converts all versions of the FADT to a common internal format.
- * Expand 32-bit addresses to 64-bit as necessary.
- *
- * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT),
- * and must contain a copy of the actual FADT.
- *
- * Notes on 64-bit register addresses:
- *
- * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
- * fields of the FADT for all ACPI register addresses.
- *
- * The 64-bit "X" fields are optional extensions to the original 32-bit FADT
- * V1.0 fields. Even if they are present in the FADT, they are optional and
- * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
- * 32-bit V1.0 fields if the corresponding X field is zero.
- *
- * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
- * corresponding "X" fields in the internal FADT.
- *
- * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
- * to the corresponding 64-bit X fields. For compatibility with other ACPI
- * implementations, we ignore the 64-bit field if the 32-bit field is valid,
- * regardless of whether the host OS is 32-bit or 64-bit.
- *
- ******************************************************************************/
-
-static void
-AcpiTbConvertFadt (
- void)
-{
- ACPI_GENERIC_ADDRESS *Address64;
- UINT32 Address32;
- UINT32 i;
-
-
- /* Update the local FADT table header length */
-
- AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
-
- /*
- * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
- * Later code will always use the X 64-bit field.
- */
- if (!AcpiGbl_FADT.XFacs)
- {
- AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
- }
- if (!AcpiGbl_FADT.XDsdt)
- {
- AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
- }
-
- /*
- * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
- * should be zero are indeed zero. This will workaround BIOSs that
- * inadvertently place values in these fields.
- *
- * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
- * at offset 45, 55, 95, and the word located at offset 109, 110.
- *
- * Note: The FADT revision value is unreliable. Only the length can be
- * trusted.
- */
- if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
- {
- AcpiGbl_FADT.PreferredProfile = 0;
- AcpiGbl_FADT.PstateControl = 0;
- AcpiGbl_FADT.CstControl = 0;
- AcpiGbl_FADT.BootFlags = 0;
- }
-
- /*
- * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
- * generic address structures as necessary. Later code will always use
- * the 64-bit address structures.
- *
- * March 2009:
- * We now always use the 32-bit address if it is valid (non-null). This
- * is not in accordance with the ACPI specification which states that
- * the 64-bit address supersedes the 32-bit version, but we do this for
- * compatibility with other ACPI implementations. Most notably, in the
- * case where both the 32 and 64 versions are non-null, we use the 32-bit
- * version. This is the only address that is guaranteed to have been
- * tested by the BIOS manufacturer.
- */
- for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
- {
- Address32 = *ACPI_ADD_PTR (UINT32,
- &AcpiGbl_FADT, FadtInfoTable[i].Address32);
-
- Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
- &AcpiGbl_FADT, FadtInfoTable[i].Address64);
-
- /*
- * If both 32- and 64-bit addresses are valid (non-zero),
- * they must match.
- */
- if (Address64->Address && Address32 &&
- (Address64->Address != (UINT64) Address32))
- {
- ACPI_ERROR ((AE_INFO,
- "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32",
- FadtInfoTable[i].Name, Address32,
- ACPI_FORMAT_UINT64 (Address64->Address)));
- }
-
- /* Always use 32-bit address if it is valid (non-null) */
-
- if (Address32)
- {
- /*
- * Copy the 32-bit address to the 64-bit GAS structure. The
- * Space ID is always I/O for 32-bit legacy address fields
- */
- AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO,
- *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length),
- (UINT64) Address32);
- }
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbValidateFadt
- *
- * PARAMETERS: Table - Pointer to the FADT to be validated
- *
- * RETURN: None
- *
- * DESCRIPTION: Validate various important fields within the FADT. If a problem
- * is found, issue a message, but no status is returned.
- * Used by both the table manager and the disassembler.
- *
- * Possible additional checks:
- * (AcpiGbl_FADT.Pm1EventLength >= 4)
- * (AcpiGbl_FADT.Pm1ControlLength >= 2)
- * (AcpiGbl_FADT.PmTimerLength >= 4)
- * Gpe block lengths must be multiple of 2
- *
- ******************************************************************************/
-
-static void
-AcpiTbValidateFadt (
- void)
-{
- char *Name;
- ACPI_GENERIC_ADDRESS *Address64;
- UINT8 Length;
- UINT32 i;
-
-
- /*
- * Check for FACS and DSDT address mismatches. An address mismatch between
- * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
- * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
- */
- if (AcpiGbl_FADT.Facs &&
- (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs))
- {
- ACPI_WARNING ((AE_INFO,
- "32/64X FACS address mismatch in FADT - "
- "0x%8.8X/0x%8.8X%8.8X, using 32",
- AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs)));
-
- AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
- }
-
- if (AcpiGbl_FADT.Dsdt &&
- (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt))
- {
- ACPI_WARNING ((AE_INFO,
- "32/64X DSDT address mismatch in FADT - "
- "0x%8.8X/0x%8.8X%8.8X, using 32",
- AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt)));
-
- AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
- }
-
- /* If Hardware Reduced flag is set, we are all done */
-
- if (AcpiGbl_ReducedHardware)
- {
- return;
- }
-
- /* Examine all of the 64-bit extended address fields (X fields) */
-
- for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
- {
- /*
- * Generate pointer to the 64-bit address, get the register
- * length (width) and the register name
- */
- Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
- &AcpiGbl_FADT, FadtInfoTable[i].Address64);
- Length = *ACPI_ADD_PTR (UINT8,
- &AcpiGbl_FADT, FadtInfoTable[i].Length);
- Name = FadtInfoTable[i].Name;
-
- /*
- * For each extended field, check for length mismatch between the
- * legacy length field and the corresponding 64-bit X length field.
- */
- if (Address64->Address &&
- (Address64->BitWidth != ACPI_MUL_8 (Length)))
- {
- ACPI_WARNING ((AE_INFO,
- "32/64X length mismatch in %s: %u/%u",
- Name, ACPI_MUL_8 (Length), Address64->BitWidth));
- }
-
- if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED)
- {
- /*
- * Field is required (PM1aEvent, PM1aControl, PmTimer).
- * Both the address and length must be non-zero.
- */
- if (!Address64->Address || !Length)
- {
- ACPI_ERROR ((AE_INFO,
- "Required field %s has zero address and/or length:"
- " 0x%8.8X%8.8X/0x%X",
- Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
- }
- }
- else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH)
- {
- /*
- * Field is optional (PM2Control, GPE0, GPE1) AND has its own
- * length field. If present, both the address and length must
- * be valid.
- */
- if ((Address64->Address && !Length) ||
- (!Address64->Address && Length))
- {
- ACPI_WARNING ((AE_INFO,
- "Optional field %s has zero address or length: "
- "0x%8.8X%8.8X/0x%X",
- Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
- }
- }
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbSetupFadtRegisters
- *
- * PARAMETERS: None, uses AcpiGbl_FADT.
- *
- * RETURN: None
- *
- * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
- * force FADT register definitions to their default lengths.
- *
- ******************************************************************************/
-
-static void
-AcpiTbSetupFadtRegisters (
- void)
-{
- ACPI_GENERIC_ADDRESS *Target64;
- ACPI_GENERIC_ADDRESS *Source64;
- UINT8 Pm1RegisterByteWidth;
- UINT32 i;
-
-
- /*
- * Optionally check all register lengths against the default values and
- * update them if they are incorrect.
- */
- if (AcpiGbl_UseDefaultRegisterWidths)
- {
- for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
- {
- Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
- FadtInfoTable[i].Address64);
-
- /*
- * If a valid register (Address != 0) and the (DefaultLength > 0)
- * (Not a GPE register), then check the width against the default.
- */
- if ((Target64->Address) &&
- (FadtInfoTable[i].DefaultLength > 0) &&
- (FadtInfoTable[i].DefaultLength != Target64->BitWidth))
- {
- ACPI_WARNING ((AE_INFO,
- "Invalid length for %s: %u, using default %u",
- FadtInfoTable[i].Name, Target64->BitWidth,
- FadtInfoTable[i].DefaultLength));
-
- /* Incorrect size, set width to the default */
-
- Target64->BitWidth = FadtInfoTable[i].DefaultLength;
- }
- }
- }
-
- /*
- * Get the length of the individual PM1 registers (enable and status).
- * Each register is defined to be (event block length / 2). Extra divide
- * by 8 converts bits to bytes.
- */
- Pm1RegisterByteWidth = (UINT8)
- ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth);
-
- /*
- * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
- * registers. These addresses do not appear (directly) in the FADT, so it
- * is useful to pre-calculate them from the PM1 Event Block definitions.
- *
- * The PM event blocks are split into two register blocks, first is the
- * PM Status Register block, followed immediately by the PM Enable
- * Register block. Each is of length (Pm1EventLength/2)
- *
- * Note: The PM1A event block is required by the ACPI specification.
- * However, the PM1B event block is optional and is rarely, if ever,
- * used.
- */
-
- for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++)
- {
- Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
- FadtPmInfoTable[i].Source);
-
- if (Source64->Address)
- {
- AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
- Source64->SpaceId, Pm1RegisterByteWidth,
- Source64->Address +
- (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth));
- }
- }
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/tables/tbfind.c
--- a/head/sys/contrib/dev/acpica/tables/tbfind.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tbfind - find table
- *
- *****************************************************************************/
-
-/*
- * 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 __TBFIND_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_TABLES
- ACPI_MODULE_NAME ("tbfind")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbFindTable
- *
- * PARAMETERS: Signature - String with ACPI table signature
- * OemId - String with the table OEM ID
- * OemTableId - String with the OEM Table ID
- * TableIndex - Where the table index is returned
- *
- * RETURN: Status and table index
- *
- * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
- * Signature, OEM ID and OEM Table ID. Returns an index that can
- * be used to get the table header or entire table.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbFindTable (
- char *Signature,
- char *OemId,
- char *OemTableId,
- UINT32 *TableIndex)
-{
- UINT32 i;
- ACPI_STATUS Status;
- ACPI_TABLE_HEADER Header;
-
-
- ACPI_FUNCTION_TRACE (TbFindTable);
-
-
- /* Normalize the input strings */
-
- ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER));
- ACPI_STRNCPY (Header.Signature, Signature, ACPI_NAME_SIZE);
- ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE);
- ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE);
-
- /* Search for the table */
-
- for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
- {
- if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature),
- Header.Signature, ACPI_NAME_SIZE))
- {
- /* Not the requested table */
-
- continue;
- }
-
- /* Table with matching signature has been found */
-
- if (!AcpiGbl_RootTableList.Tables[i].Pointer)
- {
- /* Table is not currently mapped, map it */
-
- Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (!AcpiGbl_RootTableList.Tables[i].Pointer)
- {
- continue;
- }
- }
-
- /* Check for table match on all IDs */
-
- if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature,
- Header.Signature, ACPI_NAME_SIZE) &&
- (!OemId[0] ||
- !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId,
- Header.OemId, ACPI_OEM_ID_SIZE)) &&
- (!OemTableId[0] ||
- !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId,
- Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE)))
- {
- *TableIndex = i;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
- Header.Signature));
- return_ACPI_STATUS (AE_OK);
- }
- }
-
- return_ACPI_STATUS (AE_NOT_FOUND);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/tables/tbinstal.c
--- a/head/sys/contrib/dev/acpica/tables/tbinstal.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,731 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tbinstal - ACPI table installation and removal
- *
- *****************************************************************************/
-
-/*
- * 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 __TBINSTAL_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/actables.h>
-
-
-#define _COMPONENT ACPI_TABLES
- ACPI_MODULE_NAME ("tbinstal")
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiTbVerifyTable
- *
- * PARAMETERS: TableDesc - table
- *
- * RETURN: Status
- *
- * DESCRIPTION: this function is called to verify and map table
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiTbVerifyTable (
- ACPI_TABLE_DESC *TableDesc)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (TbVerifyTable);
-
-
- /* Map the table if necessary */
-
- if (!TableDesc->Pointer)
- {
- if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
- ACPI_TABLE_ORIGIN_MAPPED)
- {
- TableDesc->Pointer = AcpiOsMapMemory (
- TableDesc->Address, TableDesc->Length);
- }
-
- if (!TableDesc->Pointer)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
- }
-
- /* FACS is the odd table, has no standard ACPI header and no checksum */
-
- if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
- {
- /* Always calculate checksum, ignore bad checksum if requested */
-
- Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbAddTable
- *
- * PARAMETERS: TableDesc - Table descriptor
- * TableIndex - Where the table index is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to add an ACPI table. It is used to
- * dynamically load tables via the Load and LoadTable AML
- * operators.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbAddTable (
- ACPI_TABLE_DESC *TableDesc,
- UINT32 *TableIndex)
-{
- UINT32 i;
- ACPI_STATUS Status = AE_OK;
- ACPI_TABLE_HEADER *OverrideTable = NULL;
-
-
- ACPI_FUNCTION_TRACE (TbAddTable);
-
-
- if (!TableDesc->Pointer)
- {
- Status = AcpiTbVerifyTable (TableDesc);
- if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Validate the incoming table signature.
- *
- * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
- * 2) We added support for OEMx tables, signature "OEM".
- * 3) Valid tables were encountered with a null signature, so we just
- * gave up on validating the signature, (05/2008).
- * 4) We encountered non-AML tables such as the MADT, which caused
- * interpreter errors and kernel faults. So now, we once again allow
- * only "SSDT", "OEMx", and now, also a null signature. (05/2011).
- */
- if ((TableDesc->Pointer->Signature[0] != 0x00) &&
- (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
- (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
- {
- ACPI_ERROR ((AE_INFO,
- "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
- AcpiUtValidAcpiName (*(UINT32 *) TableDesc->Pointer->Signature) ?
- TableDesc->Pointer->Signature : "????",
- *(UINT32 *) TableDesc->Pointer->Signature));
-
- return_ACPI_STATUS (AE_BAD_SIGNATURE);
- }
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
-
- /* Check if table is already registered */
-
- for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
- {
- if (!AcpiGbl_RootTableList.Tables[i].Pointer)
- {
- Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
- if (ACPI_FAILURE (Status) ||
- !AcpiGbl_RootTableList.Tables[i].Pointer)
- {
- continue;
- }
- }
-
- /*
- * Check for a table match on the entire table length,
- * not just the header.
- */
- if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length)
- {
- continue;
- }
-
- if (ACPI_MEMCMP (TableDesc->Pointer,
- AcpiGbl_RootTableList.Tables[i].Pointer,
- AcpiGbl_RootTableList.Tables[i].Length))
- {
- continue;
- }
-
- /*
- * Note: the current mechanism does not unregister a table if it is
- * dynamically unloaded. The related namespace entries are deleted,
- * but the table remains in the root table list.
- *
- * The assumption here is that the number of different tables that
- * will be loaded is actually small, and there is minimal overhead
- * in just keeping the table in case it is needed again.
- *
- * If this assumption changes in the future (perhaps on large
- * machines with many table load/unload operations), tables will
- * need to be unregistered when they are unloaded, and slots in the
- * root table list should be reused when empty.
- */
-
- /*
- * Table is already registered.
- * We can delete the table that was passed as a parameter.
- */
- AcpiTbDeleteTable (TableDesc);
- *TableIndex = i;
-
- if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
- {
- /* Table is still loaded, this is an error */
-
- Status = AE_ALREADY_EXISTS;
- goto Release;
- }
- else
- {
- /* Table was unloaded, allow it to be reloaded */
-
- TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
- TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
- Status = AE_OK;
- goto PrintHeader;
- }
- }
-
- /*
- * ACPI Table Override:
- * Allow the host to override dynamically loaded tables.
- */
- Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable);
- if (ACPI_SUCCESS (Status) && OverrideTable)
- {
- ACPI_INFO ((AE_INFO,
- "%4.4s @ 0x%p Table override, replaced with:",
- TableDesc->Pointer->Signature,
- ACPI_CAST_PTR (void, TableDesc->Address)));
-
- /* We can delete the table that was passed as a parameter */
-
- AcpiTbDeleteTable (TableDesc);
-
- /* Setup descriptor for the new table */
-
- TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable);
- TableDesc->Pointer = OverrideTable;
- TableDesc->Length = OverrideTable->Length;
- TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE;
- }
-
- /* Add the table to the global root table list */
-
- Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
- TableDesc->Length, TableDesc->Flags, TableIndex);
- if (ACPI_FAILURE (Status))
- {
- goto Release;
- }
-
-PrintHeader:
- AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
-
-Release:
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbResizeRootTableList
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Expand the size of global table array
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbResizeRootTableList (
- void)
-{
- ACPI_TABLE_DESC *Tables;
-
-
- ACPI_FUNCTION_TRACE (TbResizeRootTableList);
-
-
- /* AllowResize flag is a parameter to AcpiInitializeTables */
-
- if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
- {
- ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
- return_ACPI_STATUS (AE_SUPPORT);
- }
-
- /* Increase the Table Array size */
-
- Tables = ACPI_ALLOCATE_ZEROED (
- ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
- ACPI_ROOT_TABLE_SIZE_INCREMENT) *
- sizeof (ACPI_TABLE_DESC));
- if (!Tables)
- {
- ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Copy and free the previous table array */
-
- if (AcpiGbl_RootTableList.Tables)
- {
- ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
- (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
-
- if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
- {
- ACPI_FREE (AcpiGbl_RootTableList.Tables);
- }
- }
-
- AcpiGbl_RootTableList.Tables = Tables;
- AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
- AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbStoreTable
- *
- * PARAMETERS: Address - Table address
- * Table - Table header
- * Length - Table length
- * Flags - flags
- *
- * RETURN: Status and table index.
- *
- * DESCRIPTION: Add an ACPI table to the global table list
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbStoreTable (
- ACPI_PHYSICAL_ADDRESS Address,
- ACPI_TABLE_HEADER *Table,
- UINT32 Length,
- UINT8 Flags,
- UINT32 *TableIndex)
-{
- ACPI_STATUS Status;
- ACPI_TABLE_DESC *NewTable;
-
-
- /* Ensure that there is room for the table in the Root Table List */
-
- if (AcpiGbl_RootTableList.CurrentTableCount >=
- AcpiGbl_RootTableList.MaxTableCount)
- {
- Status = AcpiTbResizeRootTableList();
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount];
-
- /* Initialize added table */
-
- NewTable->Address = Address;
- NewTable->Pointer = Table;
- NewTable->Length = Length;
- NewTable->OwnerId = 0;
- NewTable->Flags = Flags;
-
- ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature);
-
- *TableIndex = AcpiGbl_RootTableList.CurrentTableCount;
- AcpiGbl_RootTableList.CurrentTableCount++;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbDeleteTable
- *
- * PARAMETERS: TableIndex - Table index
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete one internal ACPI table
- *
- ******************************************************************************/
-
-void
-AcpiTbDeleteTable (
- ACPI_TABLE_DESC *TableDesc)
-{
-
- /* Table must be mapped or allocated */
-
- if (!TableDesc->Pointer)
- {
- return;
- }
-
- switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
- {
- case ACPI_TABLE_ORIGIN_MAPPED:
- AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
- break;
-
- case ACPI_TABLE_ORIGIN_ALLOCATED:
- ACPI_FREE (TableDesc->Pointer);
- break;
-
- default:
- break;
- }
-
- TableDesc->Pointer = NULL;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbTerminate
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete all internal ACPI tables
- *
- ******************************************************************************/
-
-void
-AcpiTbTerminate (
- void)
-{
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (TbTerminate);
-
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
-
- /* Delete the individual tables */
-
- for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
- {
- AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
- }
-
- /*
- * Delete the root table array if allocated locally. Array cannot be
- * mapped, so we don't need to check for that flag.
- */
- if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
- {
- ACPI_FREE (AcpiGbl_RootTableList.Tables);
- }
-
- AcpiGbl_RootTableList.Tables = NULL;
- AcpiGbl_RootTableList.Flags = 0;
- AcpiGbl_RootTableList.CurrentTableCount = 0;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbDeleteNamespaceByOwner
- *
- * PARAMETERS: TableIndex - Table index
- *
- * RETURN: Status
- *
- * DESCRIPTION: Delete all namespace objects created when this table was loaded.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbDeleteNamespaceByOwner (
- UINT32 TableIndex)
-{
- ACPI_OWNER_ID OwnerId;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
- {
- /* The table index does not exist */
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (AE_NOT_EXIST);
- }
-
- /* Get the owner ID for this table, used to delete namespace nodes */
-
- OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
-
- /*
- * Need to acquire the namespace writer lock to prevent interference
- * with any concurrent namespace walks. The interpreter must be
- * released during the deletion since the acquisition of the deletion
- * lock may block, and also since the execution of a namespace walk
- * must be allowed to use the interpreter.
- */
- (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
- Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
-
- AcpiNsDeleteNamespaceByOwner (OwnerId);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbAllocateOwnerId
- *
- * PARAMETERS: TableIndex - Table index
- *
- * RETURN: Status
- *
- * DESCRIPTION: Allocates OwnerId in TableDesc
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbAllocateOwnerId (
- UINT32 TableIndex)
-{
- ACPI_STATUS Status = AE_BAD_PARAMETER;
-
-
- ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
-
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
- {
- Status = AcpiUtAllocateOwnerId
- (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbReleaseOwnerId
- *
- * PARAMETERS: TableIndex - Table index
- *
- * RETURN: Status
- *
- * DESCRIPTION: Releases OwnerId in TableDesc
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbReleaseOwnerId (
- UINT32 TableIndex)
-{
- ACPI_STATUS Status = AE_BAD_PARAMETER;
-
-
- ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
-
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
- {
- AcpiUtReleaseOwnerId (
- &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
- Status = AE_OK;
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbGetOwnerId
- *
- * PARAMETERS: TableIndex - Table index
- * OwnerId - Where the table OwnerId is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: returns OwnerId for the ACPI table
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbGetOwnerId (
- UINT32 TableIndex,
- ACPI_OWNER_ID *OwnerId)
-{
- ACPI_STATUS Status = AE_BAD_PARAMETER;
-
-
- ACPI_FUNCTION_TRACE (TbGetOwnerId);
-
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
- {
- *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
- Status = AE_OK;
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbIsTableLoaded
- *
- * PARAMETERS: TableIndex - Table index
- *
- * RETURN: Table Loaded Flag
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiTbIsTableLoaded (
- UINT32 TableIndex)
-{
- BOOLEAN IsLoaded = FALSE;
-
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
- {
- IsLoaded = (BOOLEAN)
- (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
- ACPI_TABLE_IS_LOADED);
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return (IsLoaded);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbSetTableLoadedFlag
- *
- * PARAMETERS: TableIndex - Table index
- * IsLoaded - TRUE if table is loaded, FALSE otherwise
- *
- * RETURN: None
- *
- * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
- *
- ******************************************************************************/
-
-void
-AcpiTbSetTableLoadedFlag (
- UINT32 TableIndex,
- BOOLEAN IsLoaded)
-{
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
- {
- if (IsLoaded)
- {
- AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
- ACPI_TABLE_IS_LOADED;
- }
- else
- {
- AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
- ~ACPI_TABLE_IS_LOADED;
- }
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/tables/tbutils.c
--- a/head/sys/contrib/dev/acpica/tables/tbutils.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,775 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tbutils - table 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 __TBUTILS_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_TABLES
- ACPI_MODULE_NAME ("tbutils")
-
-/* Local prototypes */
-
-static void
-AcpiTbFixString (
- char *String,
- ACPI_SIZE Length);
-
-static void
-AcpiTbCleanupTableHeader (
- ACPI_TABLE_HEADER *OutHeader,
- ACPI_TABLE_HEADER *Header);
-
-static ACPI_PHYSICAL_ADDRESS
-AcpiTbGetRootTableEntry (
- UINT8 *TableEntry,
- UINT32 TableEntrySize);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbInitializeFacs
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
- * for accessing the Global Lock and Firmware Waking Vector
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbInitializeFacs (
- void)
-{
- ACPI_STATUS Status;
-
-
- /* If Hardware Reduced flag is set, there is no FACS */
-
- if (AcpiGbl_ReducedHardware)
- {
- AcpiGbl_FACS = NULL;
- return (AE_OK);
- }
-
- Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS,
- ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS));
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbTablesLoaded
- *
- * PARAMETERS: None
- *
- * RETURN: TRUE if required ACPI tables are loaded
- *
- * DESCRIPTION: Determine if the minimum required ACPI tables are present
- * (FADT, FACS, DSDT)
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiTbTablesLoaded (
- void)
-{
-
- if (AcpiGbl_RootTableList.CurrentTableCount >= 3)
- {
- return (TRUE);
- }
-
- return (FALSE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbFixString
- *
- * PARAMETERS: String - String to be repaired
- * Length - Maximum length
- *
- * RETURN: None
- *
- * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
- * with a question mark '?'.
- *
- ******************************************************************************/
-
-static void
-AcpiTbFixString (
- char *String,
- ACPI_SIZE Length)
-{
-
- while (Length && *String)
- {
- if (!ACPI_IS_PRINT (*String))
- {
- *String = '?';
- }
- String++;
- Length--;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbCleanupTableHeader
- *
- * PARAMETERS: OutHeader - Where the cleaned header is returned
- * Header - Input ACPI table header
- *
- * RETURN: Returns the cleaned header in OutHeader
- *
- * DESCRIPTION: Copy the table header and ensure that all "string" fields in
- * the header consist of printable characters.
- *
- ******************************************************************************/
-
-static void
-AcpiTbCleanupTableHeader (
- ACPI_TABLE_HEADER *OutHeader,
- ACPI_TABLE_HEADER *Header)
-{
-
- ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER));
-
- AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE);
- AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE);
- AcpiTbFixString (OutHeader->OemTableId, ACPI_OEM_TABLE_ID_SIZE);
- AcpiTbFixString (OutHeader->AslCompilerId, ACPI_NAME_SIZE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbPrintTableHeader
- *
- * PARAMETERS: Address - Table physical address
- * Header - Table header
- *
- * RETURN: None
- *
- * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
- *
- ******************************************************************************/
-
-void
-AcpiTbPrintTableHeader (
- ACPI_PHYSICAL_ADDRESS Address,
- ACPI_TABLE_HEADER *Header)
-{
- ACPI_TABLE_HEADER LocalHeader;
-
-
- /*
- * The reason that the Address is cast to a void pointer is so that we
- * can use %p which will work properly on both 32-bit and 64-bit hosts.
- */
- if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS))
- {
- /* FACS only has signature and length fields */
-
- ACPI_INFO ((AE_INFO, "%4.4s %p %05X",
- Header->Signature, ACPI_CAST_PTR (void, Address),
- Header->Length));
- }
- else if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_RSDP))
- {
- /* RSDP has no common fields */
-
- ACPI_MEMCPY (LocalHeader.OemId,
- ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE);
- AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE);
-
- ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)",
- ACPI_CAST_PTR (void, Address),
- (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ?
- ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20,
- ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision,
- LocalHeader.OemId));
- }
- else
- {
- /* Standard ACPI table with full common header */
-
- AcpiTbCleanupTableHeader (&LocalHeader, Header);
-
- ACPI_INFO ((AE_INFO,
- "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
- LocalHeader.Signature, ACPI_CAST_PTR (void, Address),
- LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId,
- LocalHeader.OemTableId, LocalHeader.OemRevision,
- LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision));
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbValidateChecksum
- *
- * PARAMETERS: Table - ACPI table to verify
- * Length - Length of entire table
- *
- * RETURN: Status
- *
- * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
- * exception on bad checksum.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbVerifyChecksum (
- ACPI_TABLE_HEADER *Table,
- UINT32 Length)
-{
- UINT8 Checksum;
-
-
- /* Compute the checksum on the table */
-
- Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length);
-
- /* Checksum ok? (should be zero) */
-
- if (Checksum)
- {
- ACPI_WARNING ((AE_INFO,
- "Incorrect checksum in table [%4.4s] - 0x%2.2X, should be 0x%2.2X",
- Table->Signature, Table->Checksum,
- (UINT8) (Table->Checksum - Checksum)));
-
-#if (ACPI_CHECKSUM_ABORT)
- return (AE_BAD_CHECKSUM);
-#endif
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbChecksum
- *
- * PARAMETERS: Buffer - Pointer to memory region to be checked
- * Length - Length of this memory region
- *
- * RETURN: Checksum (UINT8)
- *
- * DESCRIPTION: Calculates circular checksum of memory region.
- *
- ******************************************************************************/
-
-UINT8
-AcpiTbChecksum (
- UINT8 *Buffer,
- UINT32 Length)
-{
- UINT8 Sum = 0;
- UINT8 *End = Buffer + Length;
-
-
- while (Buffer < End)
- {
- Sum = (UINT8) (Sum + *(Buffer++));
- }
-
- return Sum;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbCheckDsdtHeader
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Quick compare to check validity of the DSDT. This will detect
- * if the DSDT has been replaced from outside the OS and/or if
- * the DSDT header has been corrupted.
- *
- ******************************************************************************/
-
-void
-AcpiTbCheckDsdtHeader (
- void)
-{
-
- /* Compare original length and checksum to current values */
-
- if (AcpiGbl_OriginalDsdtHeader.Length != AcpiGbl_DSDT->Length ||
- AcpiGbl_OriginalDsdtHeader.Checksum != AcpiGbl_DSDT->Checksum)
- {
- ACPI_ERROR ((AE_INFO,
- "The DSDT has been corrupted or replaced - old, new headers below"));
- AcpiTbPrintTableHeader (0, &AcpiGbl_OriginalDsdtHeader);
- AcpiTbPrintTableHeader (0, AcpiGbl_DSDT);
-
- /* Disable further error messages */
-
- AcpiGbl_OriginalDsdtHeader.Length = AcpiGbl_DSDT->Length;
- AcpiGbl_OriginalDsdtHeader.Checksum = AcpiGbl_DSDT->Checksum;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbCopyDsdt
- *
- * PARAMETERS: TableDesc - Installed table to copy
- *
- * RETURN: None
- *
- * DESCRIPTION: Implements a subsystem option to copy the DSDT to local memory.
- * Some very bad BIOSs are known to either corrupt the DSDT or
- * install a new, bad DSDT. This copy works around the problem.
- *
- ******************************************************************************/
-
-ACPI_TABLE_HEADER *
-AcpiTbCopyDsdt (
- UINT32 TableIndex)
-{
- ACPI_TABLE_HEADER *NewTable;
- ACPI_TABLE_DESC *TableDesc;
-
-
- TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex];
-
- NewTable = ACPI_ALLOCATE (TableDesc->Length);
- if (!NewTable)
- {
- ACPI_ERROR ((AE_INFO, "Could not copy DSDT of length 0x%X",
- TableDesc->Length));
- return (NULL);
- }
-
- ACPI_MEMCPY (NewTable, TableDesc->Pointer, TableDesc->Length);
- AcpiTbDeleteTable (TableDesc);
- TableDesc->Pointer = NewTable;
- TableDesc->Flags = ACPI_TABLE_ORIGIN_ALLOCATED;
-
- ACPI_INFO ((AE_INFO,
- "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
- NewTable->Length));
-
- return (NewTable);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbInstallTable
- *
- * PARAMETERS: Address - Physical address of DSDT or FACS
- * Signature - Table signature, NULL if no need to
- * match
- * TableIndex - Index into root table array
- *
- * RETURN: None
- *
- * DESCRIPTION: Install an ACPI table into the global data structure. The
- * table override mechanism is implemented here to allow the host
- * OS to replace any table before it is installed in the root
- * table array.
- *
- ******************************************************************************/
-
-void
-AcpiTbInstallTable (
- ACPI_PHYSICAL_ADDRESS Address,
- char *Signature,
- UINT32 TableIndex)
-{
- UINT8 Flags;
- ACPI_STATUS Status;
- ACPI_TABLE_HEADER *TableToInstall;
- ACPI_TABLE_HEADER *MappedTable;
- ACPI_TABLE_HEADER *OverrideTable = NULL;
-
-
- if (!Address)
- {
- ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]",
- Signature));
- return;
- }
-
- /* Map just the table header */
-
- MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
- if (!MappedTable)
- {
- return;
- }
-
- /* Skip SSDT when DSDT is overriden */
-
- if (ACPI_COMPARE_NAME (MappedTable->Signature, ACPI_SIG_SSDT) &&
- (AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags &
- ACPI_TABLE_ORIGIN_OVERRIDE))
- {
- ACPI_INFO ((AE_INFO,
- "%4.4s @ 0x%p Table override, replaced with:", ACPI_SIG_SSDT,
- ACPI_CAST_PTR (void, Address)));
- AcpiTbPrintTableHeader (
- AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Address,
- AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer);
- goto UnmapAndExit;
- }
-
- /* If a particular signature is expected (DSDT/FACS), it must match */
-
- if (Signature &&
- !ACPI_COMPARE_NAME (MappedTable->Signature, Signature))
- {
- ACPI_ERROR ((AE_INFO,
- "Invalid signature 0x%X for ACPI table, expected [%s]",
- *ACPI_CAST_PTR (UINT32, MappedTable->Signature), Signature));
- goto UnmapAndExit;
- }
-
- /*
- * ACPI Table Override:
- *
- * Before we install the table, let the host OS override it with a new
- * one if desired. Any table within the RSDT/XSDT can be replaced,
- * including the DSDT which is pointed to by the FADT.
- */
- Status = AcpiOsTableOverride (MappedTable, &OverrideTable);
- if (ACPI_SUCCESS (Status) && OverrideTable)
- {
- ACPI_INFO ((AE_INFO,
- "%4.4s @ 0x%p Table override, replaced with:",
- MappedTable->Signature, ACPI_CAST_PTR (void, Address)));
-
- AcpiGbl_RootTableList.Tables[TableIndex].Pointer = OverrideTable;
- Address = ACPI_PTR_TO_PHYSADDR (OverrideTable);
-
- TableToInstall = OverrideTable;
- Flags = ACPI_TABLE_ORIGIN_OVERRIDE;
- }
- else
- {
- TableToInstall = MappedTable;
- Flags = ACPI_TABLE_ORIGIN_MAPPED;
- }
-
- /* Initialize the table entry */
-
- AcpiGbl_RootTableList.Tables[TableIndex].Address = Address;
- AcpiGbl_RootTableList.Tables[TableIndex].Length = TableToInstall->Length;
- AcpiGbl_RootTableList.Tables[TableIndex].Flags = Flags;
-
- ACPI_MOVE_32_TO_32 (
- &(AcpiGbl_RootTableList.Tables[TableIndex].Signature),
- TableToInstall->Signature);
-
- AcpiTbPrintTableHeader (Address, TableToInstall);
-
- if (TableIndex == ACPI_TABLE_INDEX_DSDT)
- {
- /* Global integer width is based upon revision of the DSDT */
-
- AcpiUtSetIntegerWidth (TableToInstall->Revision);
- }
-
-UnmapAndExit:
- AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbGetRootTableEntry
- *
- * PARAMETERS: TableEntry - Pointer to the RSDT/XSDT table entry
- * TableEntrySize - sizeof 32 or 64 (RSDT or XSDT)
- *
- * RETURN: Physical address extracted from the root table
- *
- * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on
- * both 32-bit and 64-bit platforms
- *
- * NOTE: ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on
- * 64-bit platforms.
- *
- ******************************************************************************/
-
-static ACPI_PHYSICAL_ADDRESS
-AcpiTbGetRootTableEntry (
- UINT8 *TableEntry,
- UINT32 TableEntrySize)
-{
- UINT64 Address64;
-
-
- /*
- * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
- * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
- */
- if (TableEntrySize == sizeof (UINT32))
- {
- /*
- * 32-bit platform, RSDT: Return 32-bit table entry
- * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
- */
- return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (UINT32, TableEntry)));
- }
- else
- {
- /*
- * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
- * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
- * return 64-bit
- */
- ACPI_MOVE_64_TO_64 (&Address64, TableEntry);
-
-#if ACPI_MACHINE_WIDTH == 32
- if (Address64 > ACPI_UINT32_MAX)
- {
- /* Will truncate 64-bit address to 32 bits, issue warning */
-
- ACPI_WARNING ((AE_INFO,
- "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X),"
- " truncating",
- ACPI_FORMAT_UINT64 (Address64)));
- }
-#endif
- return ((ACPI_PHYSICAL_ADDRESS) (Address64));
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbParseRootTable
- *
- * PARAMETERS: Rsdp - Pointer to the RSDP
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to parse the Root System Description
- * Table (RSDT or XSDT)
- *
- * NOTE: Tables are mapped (not copied) for efficiency. The FACS must
- * be mapped and cannot be copied because it contains the actual
- * memory location of the ACPI Global Lock.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbParseRootTable (
- ACPI_PHYSICAL_ADDRESS RsdpAddress)
-{
- ACPI_TABLE_RSDP *Rsdp;
- UINT32 TableEntrySize;
- UINT32 i;
- UINT32 TableCount;
- ACPI_TABLE_HEADER *Table;
- ACPI_PHYSICAL_ADDRESS Address;
- UINT32 Length;
- UINT8 *TableEntry;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (TbParseRootTable);
-
-
- /*
- * Map the entire RSDP and extract the address of the RSDT or XSDT
- */
- Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP));
- if (!Rsdp)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- AcpiTbPrintTableHeader (RsdpAddress,
- ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp));
-
- /* Differentiate between RSDT and XSDT root tables */
-
- if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress)
- {
- /*
- * Root table is an XSDT (64-bit physical addresses). We must use the
- * XSDT if the revision is > 1 and the XSDT pointer is present, as per
- * the ACPI specification.
- */
- Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress;
- TableEntrySize = sizeof (UINT64);
- }
- else
- {
- /* Root table is an RSDT (32-bit physical addresses) */
-
- Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress;
- TableEntrySize = sizeof (UINT32);
- }
-
- /*
- * It is not possible to map more than one entry in some environments,
- * so unmap the RSDP here before mapping other tables
- */
- AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP));
-
-
- /* Map the RSDT/XSDT table header to get the full table length */
-
- Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
- if (!Table)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- AcpiTbPrintTableHeader (Address, Table);
-
- /* Get the length of the full table, verify length and map entire table */
-
- Length = Table->Length;
- AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER));
-
- if (Length < sizeof (ACPI_TABLE_HEADER))
- {
- ACPI_ERROR ((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", Length));
- return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
- }
-
- Table = AcpiOsMapMemory (Address, Length);
- if (!Table)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Validate the root table checksum */
-
- Status = AcpiTbVerifyChecksum (Table, Length);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsUnmapMemory (Table, Length);
- return_ACPI_STATUS (Status);
- }
-
- /* Calculate the number of tables described in the root table */
-
- TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) /
- TableEntrySize);
-
- /*
- * First two entries in the table array are reserved for the DSDT
- * and FACS, which are not actually present in the RSDT/XSDT - they
- * come from the FADT
- */
- TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER);
- AcpiGbl_RootTableList.CurrentTableCount = 2;
-
- /*
- * Initialize the root table array from the RSDT/XSDT
- */
- for (i = 0; i < TableCount; i++)
- {
- if (AcpiGbl_RootTableList.CurrentTableCount >=
- AcpiGbl_RootTableList.MaxTableCount)
- {
- /* There is no more room in the root table array, attempt resize */
-
- Status = AcpiTbResizeRootTableList ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_WARNING ((AE_INFO, "Truncating %u table entries!",
- (unsigned) (TableCount -
- (AcpiGbl_RootTableList.CurrentTableCount - 2))));
- break;
- }
- }
-
- /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
-
- AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount].Address =
- AcpiTbGetRootTableEntry (TableEntry, TableEntrySize);
-
- TableEntry += TableEntrySize;
- AcpiGbl_RootTableList.CurrentTableCount++;
- }
-
- /*
- * It is not possible to map more than one entry in some environments,
- * so unmap the root table here before mapping other tables
- */
- AcpiOsUnmapMemory (Table, Length);
-
- /*
- * Complete the initialization of the root table array by examining
- * the header of each table
- */
- for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
- {
- AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address,
- NULL, i);
-
- /* Special case for FADT - get the DSDT and FACS */
-
- if (ACPI_COMPARE_NAME (
- &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT))
- {
- AcpiTbParseFadt (i);
- }
- }
-
- return_ACPI_STATUS (AE_OK);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/tables/tbxface.c
--- a/head/sys/contrib/dev/acpica/tables/tbxface.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,722 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tbxface - Public interfaces to the ACPI subsystem
- * ACPI table oriented 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.
- */
-
-#define __TBXFACE_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/actables.h>
-
-#define _COMPONENT ACPI_TABLES
- ACPI_MODULE_NAME ("tbxface")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiTbLoadNamespace (
- void);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiAllocateRootTable
- *
- * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of
- * ACPI_TABLE_DESC structures
- *
- * RETURN: Status
- *
- * DESCRIPTION: Allocate a root table array. Used by iASL compiler and
- * AcpiInitializeTables.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiAllocateRootTable (
- UINT32 InitialTableCount)
-{
-
- AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
- AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE;
-
- return (AcpiTbResizeRootTableList ());
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiInitializeTables
- *
- * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated
- * ACPI_TABLE_DESC structures. If NULL, the
- * array is dynamically allocated.
- * InitialTableCount - Size of InitialTableArray, in number of
- * ACPI_TABLE_DESC structures
- * AllowRealloc - Flag to tell Table Manager if resize of
- * pre-allocated array is allowed. Ignored
- * if InitialTableArray is NULL.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
- *
- * NOTE: Allows static allocation of the initial table array in order
- * to avoid the use of dynamic memory in confined environments
- * such as the kernel boot sequence where it may not be available.
- *
- * If the host OS memory managers are initialized, use NULL for
- * InitialTableArray, and the table will be dynamically allocated.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiInitializeTables (
- ACPI_TABLE_DESC *InitialTableArray,
- UINT32 InitialTableCount,
- BOOLEAN AllowResize)
-{
- ACPI_PHYSICAL_ADDRESS RsdpAddress;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiInitializeTables);
-
-
- /*
- * Set up the Root Table Array
- * Allocate the table array if requested
- */
- if (!InitialTableArray)
- {
- Status = AcpiAllocateRootTable (InitialTableCount);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
- else
- {
- /* Root Table Array has been statically allocated by the host */
-
- ACPI_MEMSET (InitialTableArray, 0,
- (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
-
- AcpiGbl_RootTableList.Tables = InitialTableArray;
- AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
- AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN;
- if (AllowResize)
- {
- AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;
- }
- }
-
- /* Get the address of the RSDP */
-
- RsdpAddress = AcpiOsGetRootPointer ();
- if (!RsdpAddress)
- {
- return_ACPI_STATUS (AE_NOT_FOUND);
- }
-
- /*
- * Get the root table (RSDT or XSDT) and extract all entries to the local
- * Root Table Array. This array contains the information of the RSDT/XSDT
- * in a common, more useable format.
- */
- Status = AcpiTbParseRootTable (RsdpAddress);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInitializeTables)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiReallocateRootTable
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
- * root list from the previously provided scratch area. Should
- * be called once dynamic memory allocation is available in the
- * kernel
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiReallocateRootTable (
- void)
-{
- ACPI_TABLE_DESC *Tables;
- ACPI_SIZE NewSize;
- ACPI_SIZE CurrentSize;
-
-
- ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
-
-
- /*
- * Only reallocate the root table if the host provided a static buffer
- * for the table array in the call to AcpiInitializeTables.
- */
- if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
- {
- return_ACPI_STATUS (AE_SUPPORT);
- }
-
- /*
- * Get the current size of the root table and add the default
- * increment to create the new table size.
- */
- CurrentSize = (ACPI_SIZE)
- AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC);
-
- NewSize = CurrentSize +
- (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC));
-
- /* Create new array and copy the old array */
-
- Tables = ACPI_ALLOCATE_ZEROED (NewSize);
- if (!Tables)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize);
-
- /*
- * Update the root table descriptor. The new size will be the current
- * number of tables plus the increment, independent of the reserved
- * size of the original table list.
- */
- AcpiGbl_RootTableList.Tables = Tables;
- AcpiGbl_RootTableList.MaxTableCount =
- AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
- AcpiGbl_RootTableList.Flags =
- ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetTableHeader
- *
- * PARAMETERS: Signature - ACPI signature of needed table
- * Instance - Which instance (for SSDTs)
- * OutTableHeader - The pointer to the table header to fill
- *
- * RETURN: Status and pointer to mapped table header
- *
- * DESCRIPTION: Finds an ACPI table header.
- *
- * NOTE: Caller is responsible in unmapping the header with
- * AcpiOsUnmapMemory
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetTableHeader (
- char *Signature,
- UINT32 Instance,
- ACPI_TABLE_HEADER *OutTableHeader)
-{
- UINT32 i;
- UINT32 j;
- ACPI_TABLE_HEADER *Header;
-
-
- /* Parameter validation */
-
- if (!Signature || !OutTableHeader)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Walk the root table list */
-
- for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
- {
- if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
- Signature))
- {
- continue;
- }
-
- if (++j < Instance)
- {
- continue;
- }
-
- if (!AcpiGbl_RootTableList.Tables[i].Pointer)
- {
- if ((AcpiGbl_RootTableList.Tables[i].Flags &
- ACPI_TABLE_ORIGIN_MASK) ==
- ACPI_TABLE_ORIGIN_MAPPED)
- {
- Header = AcpiOsMapMemory (
- AcpiGbl_RootTableList.Tables[i].Address,
- sizeof (ACPI_TABLE_HEADER));
- if (!Header)
- {
- return AE_NO_MEMORY;
- }
-
- ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
- AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
- }
- else
- {
- return AE_NOT_FOUND;
- }
- }
- else
- {
- ACPI_MEMCPY (OutTableHeader,
- AcpiGbl_RootTableList.Tables[i].Pointer,
- sizeof(ACPI_TABLE_HEADER));
- }
-
- return (AE_OK);
- }
-
- return (AE_NOT_FOUND);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetTable
- *
- * PARAMETERS: Signature - ACPI signature of needed table
- * Instance - Which instance (for SSDTs)
- * OutTable - Where the pointer to the table is returned
- *
- * RETURN: Status and pointer to table
- *
- * DESCRIPTION: Finds and verifies an ACPI table.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetTable (
- char *Signature,
- UINT32 Instance,
- ACPI_TABLE_HEADER **OutTable)
-{
- UINT32 i;
- UINT32 j;
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!Signature || !OutTable)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Walk the root table list */
-
- for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
- {
- if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
- Signature))
- {
- continue;
- }
-
- if (++j < Instance)
- {
- continue;
- }
-
- Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
- if (ACPI_SUCCESS (Status))
- {
- *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
- }
-
- return (Status);
- }
-
- return (AE_NOT_FOUND);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetTable)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetTableByIndex
- *
- * PARAMETERS: TableIndex - Table index
- * Table - Where the pointer to the table is returned
- *
- * RETURN: Status and pointer to the table
- *
- * DESCRIPTION: Obtain a table by an index into the global table list.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetTableByIndex (
- UINT32 TableIndex,
- ACPI_TABLE_HEADER **Table)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
-
-
- /* Parameter validation */
-
- if (!Table)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
-
- /* Validate index */
-
- if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
- {
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
- {
- /* Table is not mapped, map it */
-
- Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
- if (ACPI_FAILURE (Status))
- {
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (Status);
- }
- }
-
- *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbLoadNamespace
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
- * the RSDT/XSDT.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiTbLoadNamespace (
- void)
-{
- ACPI_STATUS Status;
- UINT32 i;
- ACPI_TABLE_HEADER *NewDsdt;
-
-
- ACPI_FUNCTION_TRACE (TbLoadNamespace);
-
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
-
- /*
- * Load the namespace. The DSDT is required, but any SSDT and
- * PSDT tables are optional. Verify the DSDT.
- */
- if (!AcpiGbl_RootTableList.CurrentTableCount ||
- !ACPI_COMPARE_NAME (
- &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
- ACPI_SIG_DSDT) ||
- ACPI_FAILURE (AcpiTbVerifyTable (
- &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
- {
- Status = AE_NO_ACPI_TABLES;
- goto UnlockAndExit;
- }
-
- /*
- * Save the DSDT pointer for simple access. This is the mapped memory
- * address. We must take care here because the address of the .Tables
- * array can change dynamically as tables are loaded at run-time. Note:
- * .Pointer field is not validated until after call to AcpiTbVerifyTable.
- */
- AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
-
- /*
- * Optionally copy the entire DSDT to local memory (instead of simply
- * mapping it.) There are some BIOSs that corrupt or replace the original
- * DSDT, creating the need for this option. Default is FALSE, do not copy
- * the DSDT.
- */
- if (AcpiGbl_CopyDsdtLocally)
- {
- NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
- if (NewDsdt)
- {
- AcpiGbl_DSDT = NewDsdt;
- }
- }
-
- /*
- * Save the original DSDT header for detection of table corruption
- * and/or replacement of the DSDT from outside the OS.
- */
- ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
- sizeof (ACPI_TABLE_HEADER));
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
-
- /* Load and parse tables */
-
- Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
-
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
- {
- if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
- ACPI_SIG_SSDT) &&
- !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
- ACPI_SIG_PSDT)) ||
- ACPI_FAILURE (AcpiTbVerifyTable (
- &AcpiGbl_RootTableList.Tables[i])))
- {
- continue;
- }
-
- /* Skip SSDT when DSDT is overriden */
-
- if (ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
- ACPI_SIG_SSDT) &&
- (AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags &
- ACPI_TABLE_ORIGIN_OVERRIDE))
- {
- continue;
- }
-
- /* Ignore errors while loading tables, get as many as possible */
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
- (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
-
-UnlockAndExit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiLoadTables
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiLoadTables (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiLoadTables);
-
-
- /* Load the namespace from the tables */
-
- Status = AcpiTbLoadNamespace ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "While loading namespace from ACPI tables"));
- }
-
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiLoadTables)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiInstallTableHandler
- *
- * PARAMETERS: Handler - Table event handler
- * Context - Value passed to the handler on each event
- *
- * RETURN: Status
- *
- * DESCRIPTION: Install table event handler
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiInstallTableHandler (
- ACPI_TABLE_HANDLER Handler,
- void *Context)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
-
-
- if (!Handler)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Don't allow more than one handler */
-
- if (AcpiGbl_TableHandler)
- {
- Status = AE_ALREADY_EXISTS;
- goto Cleanup;
- }
-
- /* Install the handler */
-
- AcpiGbl_TableHandler = Handler;
- AcpiGbl_TableHandlerContext = Context;
-
-Cleanup:
- (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiRemoveTableHandler
- *
- * PARAMETERS: Handler - Table event handler that was installed
- * previously.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Remove table event handler
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiRemoveTableHandler (
- ACPI_TABLE_HANDLER Handler)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Make sure that the installed handler is the same */
-
- if (!Handler ||
- Handler != AcpiGbl_TableHandler)
- {
- Status = AE_BAD_PARAMETER;
- goto Cleanup;
- }
-
- /* Remove the handler */
-
- AcpiGbl_TableHandler = NULL;
-
-Cleanup:
- (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/tables/tbxfroot.c
--- a/head/sys/contrib/dev/acpica/tables/tbxfroot.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,299 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tbxfroot - Find the root ACPI table (RSDT)
- *
- *****************************************************************************/
-
-/*
- * 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 __TBXFROOT_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_TABLES
- ACPI_MODULE_NAME ("tbxfroot")
-
-/* Local prototypes */
-
-static UINT8 *
-AcpiTbScanMemoryForRsdp (
- UINT8 *StartAddress,
- UINT32 Length);
-
-static ACPI_STATUS
-AcpiTbValidateRsdp (
- ACPI_TABLE_RSDP *Rsdp);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbValidateRsdp
- *
- * PARAMETERS: Rsdp - Pointer to unvalidated RSDP
- *
- * RETURN: Status
- *
- * DESCRIPTION: Validate the RSDP (ptr)
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiTbValidateRsdp (
- ACPI_TABLE_RSDP *Rsdp)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * The signature and checksum must both be correct
- *
- * Note: Sometimes there exists more than one RSDP in memory; the valid
- * RSDP has a valid checksum, all others have an invalid checksum.
- */
- if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP,
- sizeof (ACPI_SIG_RSDP)-1) != 0)
- {
- /* Nope, BAD Signature */
-
- return (AE_BAD_SIGNATURE);
- }
-
- /* Check the standard checksum */
-
- if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
- {
- return (AE_BAD_CHECKSUM);
- }
-
- /* Check extended checksum if table version >= 2 */
-
- if ((Rsdp->Revision >= 2) &&
- (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
- {
- return (AE_BAD_CHECKSUM);
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiFindRootPointer
- *
- * PARAMETERS: TableAddress - Where the table pointer is returned
- *
- * RETURN: Status, RSDP physical address
- *
- * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
- * pointer structure. If it is found, set *RSDP to point to it.
- *
- * NOTE1: The RSDP must be either in the first 1K of the Extended
- * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
- * Only a 32-bit physical address is necessary.
- *
- * NOTE2: This function is always available, regardless of the
- * initialization state of the rest of ACPI.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiFindRootPointer (
- ACPI_SIZE *TableAddress)
-{
- UINT8 *TablePtr;
- UINT8 *MemRover;
- UINT32 PhysicalAddress;
-
-
- ACPI_FUNCTION_TRACE (AcpiFindRootPointer);
-
-
- /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
-
- TablePtr = AcpiOsMapMemory (
- (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
- ACPI_EBDA_PTR_LENGTH);
- if (!TablePtr)
- {
- ACPI_ERROR ((AE_INFO,
- "Could not map memory at 0x%8.8X for length %u",
- ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
-
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
-
- /* Convert segment part to physical address */
-
- PhysicalAddress <<= 4;
- AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
-
- /* EBDA present? */
-
- if (PhysicalAddress > 0x400)
- {
- /*
- * 1b) Search EBDA paragraphs (EBDA is required to be a
- * minimum of 1K length)
- */
- TablePtr = AcpiOsMapMemory (
- (ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
- ACPI_EBDA_WINDOW_SIZE);
- if (!TablePtr)
- {
- ACPI_ERROR ((AE_INFO,
- "Could not map memory at 0x%8.8X for length %u",
- PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
-
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE);
- AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
-
- if (MemRover)
- {
- /* Return the physical address */
-
- PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr);
-
- *TableAddress = PhysicalAddress;
- return_ACPI_STATUS (AE_OK);
- }
- }
-
- /*
- * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
- */
- TablePtr = AcpiOsMapMemory (
- (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
- ACPI_HI_RSDP_WINDOW_SIZE);
-
- if (!TablePtr)
- {
- ACPI_ERROR ((AE_INFO,
- "Could not map memory at 0x%8.8X for length %u",
- ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
-
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
- AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
-
- if (MemRover)
- {
- /* Return the physical address */
-
- PhysicalAddress = (UINT32)
- (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
-
- *TableAddress = PhysicalAddress;
- return_ACPI_STATUS (AE_OK);
- }
-
- /* A valid RSDP was not found */
-
- ACPI_ERROR ((AE_INFO, "A valid RSDP was not found"));
- return_ACPI_STATUS (AE_NOT_FOUND);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbScanMemoryForRsdp
- *
- * PARAMETERS: StartAddress - Starting pointer for search
- * Length - Maximum length to search
- *
- * RETURN: Pointer to the RSDP if found, otherwise NULL.
- *
- * DESCRIPTION: Search a block of memory for the RSDP signature
- *
- ******************************************************************************/
-
-static UINT8 *
-AcpiTbScanMemoryForRsdp (
- UINT8 *StartAddress,
- UINT32 Length)
-{
- ACPI_STATUS Status;
- UINT8 *MemRover;
- UINT8 *EndAddress;
-
-
- ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
-
-
- EndAddress = StartAddress + Length;
-
- /* Search from given start address for the requested length */
-
- for (MemRover = StartAddress; MemRover < EndAddress;
- MemRover += ACPI_RSDP_SCAN_STEP)
- {
- /* The RSDP signature and checksum must both be correct */
-
- Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover));
- if (ACPI_SUCCESS (Status))
- {
- /* Sig and checksum valid, we have found a real RSDP */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "RSDP located at physical address %p\n", MemRover));
- return_PTR (MemRover);
- }
-
- /* No sig match or bad checksum, keep searching */
- }
-
- /* Searched entire block, no RSDP was found */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Searched entire block from %p, valid RSDP was not found\n",
- StartAddress));
- return_PTR (NULL);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utaddress.c
--- a/head/sys/contrib/dev/acpica/utilities/utaddress.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,322 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utaddress - OpRegion address range check
- *
- *****************************************************************************/
-
-/*
- * 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 __UTADDRESS_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utaddress")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAddAddressRange
- *
- * PARAMETERS: SpaceId - Address space ID
- * Address - OpRegion start address
- * Length - OpRegion length
- * RegionNode - OpRegion namespace node
- *
- * RETURN: Status
- *
- * DESCRIPTION: Add the Operation Region address range to the global list.
- * The only supported Space IDs are Memory and I/O. Called when
- * the OpRegion address/length operands are fully evaluated.
- *
- * MUTEX: Locks the namespace
- *
- * NOTE: Because this interface is only called when an OpRegion argument
- * list is evaluated, there cannot be any duplicate RegionNodes.
- * Duplicate Address/Length values are allowed, however, so that multiple
- * address conflicts can be detected.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtAddAddressRange (
- ACPI_ADR_SPACE_TYPE SpaceId,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 Length,
- ACPI_NAMESPACE_NODE *RegionNode)
-{
- ACPI_ADDRESS_RANGE *RangeInfo;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtAddAddressRange);
-
-
- if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
- (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Allocate/init a new info block, add it to the appropriate list */
-
- RangeInfo = ACPI_ALLOCATE (sizeof (ACPI_ADDRESS_RANGE));
- if (!RangeInfo)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- RangeInfo->StartAddress = Address;
- RangeInfo->EndAddress = (Address + Length - 1);
- RangeInfo->RegionNode = RegionNode;
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- ACPI_FREE (RangeInfo);
- return_ACPI_STATUS (Status);
- }
-
- RangeInfo->Next = AcpiGbl_AddressRangeList[SpaceId];
- AcpiGbl_AddressRangeList[SpaceId] = RangeInfo;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "\nAdded [%4.4s] address range: 0x%p-0x%p\n",
- AcpiUtGetNodeName (RangeInfo->RegionNode),
- ACPI_CAST_PTR (void, Address),
- ACPI_CAST_PTR (void, RangeInfo->EndAddress)));
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtRemoveAddressRange
- *
- * PARAMETERS: SpaceId - Address space ID
- * RegionNode - OpRegion namespace node
- *
- * RETURN: None
- *
- * DESCRIPTION: Remove the Operation Region from the global list. The only
- * supported Space IDs are Memory and I/O. Called when an
- * OpRegion is deleted.
- *
- * MUTEX: Assumes the namespace is locked
- *
- ******************************************************************************/
-
-void
-AcpiUtRemoveAddressRange (
- ACPI_ADR_SPACE_TYPE SpaceId,
- ACPI_NAMESPACE_NODE *RegionNode)
-{
- ACPI_ADDRESS_RANGE *RangeInfo;
- ACPI_ADDRESS_RANGE *Prev;
-
-
- ACPI_FUNCTION_TRACE (UtRemoveAddressRange);
-
-
- if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
- (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
- {
- return_VOID;
- }
-
- /* Get the appropriate list head and check the list */
-
- RangeInfo = Prev = AcpiGbl_AddressRangeList[SpaceId];
- while (RangeInfo)
- {
- if (RangeInfo->RegionNode == RegionNode)
- {
- if (RangeInfo == Prev) /* Found at list head */
- {
- AcpiGbl_AddressRangeList[SpaceId] = RangeInfo->Next;
- }
- else
- {
- Prev->Next = RangeInfo->Next;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "\nRemoved [%4.4s] address range: 0x%p-0x%p\n",
- AcpiUtGetNodeName (RangeInfo->RegionNode),
- ACPI_CAST_PTR (void, RangeInfo->StartAddress),
- ACPI_CAST_PTR (void, RangeInfo->EndAddress)));
-
- ACPI_FREE (RangeInfo);
- return_VOID;
- }
-
- Prev = RangeInfo;
- RangeInfo = RangeInfo->Next;
- }
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCheckAddressRange
- *
- * PARAMETERS: SpaceId - Address space ID
- * Address - Start address
- * Length - Length of address range
- * Warn - TRUE if warning on overlap desired
- *
- * RETURN: Count of the number of conflicts detected. Zero is always
- * returned for Space IDs other than Memory or I/O.
- *
- * DESCRIPTION: Check if the input address range overlaps any of the
- * ASL operation region address ranges. The only supported
- * Space IDs are Memory and I/O.
- *
- * MUTEX: Assumes the namespace is locked.
- *
- ******************************************************************************/
-
-UINT32
-AcpiUtCheckAddressRange (
- ACPI_ADR_SPACE_TYPE SpaceId,
- ACPI_PHYSICAL_ADDRESS Address,
- UINT32 Length,
- BOOLEAN Warn)
-{
- ACPI_ADDRESS_RANGE *RangeInfo;
- ACPI_PHYSICAL_ADDRESS EndAddress;
- char *Pathname;
- UINT32 OverlapCount = 0;
-
-
- ACPI_FUNCTION_TRACE (UtCheckAddressRange);
-
-
- if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
- (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO))
- {
- return_UINT32 (0);
- }
-
- RangeInfo = AcpiGbl_AddressRangeList[SpaceId];
- EndAddress = Address + Length - 1;
-
- /* Check entire list for all possible conflicts */
-
- while (RangeInfo)
- {
- /*
- * Check if the requested Address/Length overlaps this AddressRange.
- * Four cases to consider:
- *
- * 1) Input address/length is contained completely in the address range
- * 2) Input address/length overlaps range at the range start
- * 3) Input address/length overlaps range at the range end
- * 4) Input address/length completely encompasses the range
- */
- if ((Address <= RangeInfo->EndAddress) &&
- (EndAddress >= RangeInfo->StartAddress))
- {
- /* Found an address range overlap */
-
- OverlapCount++;
- if (Warn) /* Optional warning message */
- {
- Pathname = AcpiNsGetExternalPathname (RangeInfo->RegionNode);
-
- ACPI_WARNING ((AE_INFO,
- "0x%p-0x%p %s conflicts with Region %s %d",
- ACPI_CAST_PTR (void, Address),
- ACPI_CAST_PTR (void, EndAddress),
- AcpiUtGetRegionName (SpaceId), Pathname, OverlapCount));
- ACPI_FREE (Pathname);
- }
- }
-
- RangeInfo = RangeInfo->Next;
- }
-
- return_UINT32 (OverlapCount);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDeleteAddressLists
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete all global address range lists (called during
- * subsystem shutdown).
- *
- ******************************************************************************/
-
-void
-AcpiUtDeleteAddressLists (
- void)
-{
- ACPI_ADDRESS_RANGE *Next;
- ACPI_ADDRESS_RANGE *RangeInfo;
- int i;
-
-
- /* Delete all elements in all address range lists */
-
- for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
- {
- Next = AcpiGbl_AddressRangeList[i];
-
- while (Next)
- {
- RangeInfo = Next;
- Next = RangeInfo->Next;
- ACPI_FREE (RangeInfo);
- }
-
- AcpiGbl_AddressRangeList[i] = NULL;
- }
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utalloc.c
--- a/head/sys/contrib/dev/acpica/utilities/utalloc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,416 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utalloc - local memory allocation 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 __UTALLOC_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acdebug.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utalloc")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateCaches
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create all local caches
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCreateCaches (
- void)
-{
- ACPI_STATUS Status;
-
-
- /* Object Caches, for frequently used objects */
-
- Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE),
- ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE),
- ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON),
- ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED),
- ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT),
- ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
- /* Memory allocation lists */
-
- Status = AcpiUtCreateList ("Acpi-Global", 0,
- &AcpiGbl_GlobalList);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE),
- &AcpiGbl_NsNodeList);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-#endif
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDeleteCaches
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Purge and delete all local caches
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtDeleteCaches (
- void)
-{
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- char Buffer[7];
-
- if (AcpiGbl_DisplayFinalMemStats)
- {
- ACPI_STRCPY (Buffer, "MEMORY");
- (void) AcpiDbDisplayStatistics (Buffer);
- }
-#endif
-
- (void) AcpiOsDeleteCache (AcpiGbl_NamespaceCache);
- AcpiGbl_NamespaceCache = NULL;
-
- (void) AcpiOsDeleteCache (AcpiGbl_StateCache);
- AcpiGbl_StateCache = NULL;
-
- (void) AcpiOsDeleteCache (AcpiGbl_OperandCache);
- AcpiGbl_OperandCache = NULL;
-
- (void) AcpiOsDeleteCache (AcpiGbl_PsNodeCache);
- AcpiGbl_PsNodeCache = NULL;
-
- (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache);
- AcpiGbl_PsNodeExtCache = NULL;
-
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
- /* Debug only - display leftover memory allocation, if any */
-
- AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL);
-
- /* Free memory lists */
-
- AcpiOsFree (AcpiGbl_GlobalList);
- AcpiGbl_GlobalList = NULL;
-
- AcpiOsFree (AcpiGbl_NsNodeList);
- AcpiGbl_NsNodeList = NULL;
-#endif
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValidateBuffer
- *
- * PARAMETERS: Buffer - Buffer descriptor to be validated
- *
- * RETURN: Status
- *
- * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtValidateBuffer (
- ACPI_BUFFER *Buffer)
-{
-
- /* Obviously, the structure pointer must be valid */
-
- if (!Buffer)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Special semantics for the length */
-
- if ((Buffer->Length == ACPI_NO_BUFFER) ||
- (Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
- (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
- {
- return (AE_OK);
- }
-
- /* Length is valid, the buffer pointer must be also */
-
- if (!Buffer->Pointer)
- {
- return (AE_BAD_PARAMETER);
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtInitializeBuffer
- *
- * PARAMETERS: Buffer - Buffer to be validated
- * RequiredLength - Length needed
- *
- * RETURN: Status
- *
- * DESCRIPTION: Validate that the buffer is of the required length or
- * allocate a new buffer. Returned buffer is always zeroed.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtInitializeBuffer (
- ACPI_BUFFER *Buffer,
- ACPI_SIZE RequiredLength)
-{
- ACPI_SIZE InputBufferLength;
-
-
- /* Parameter validation */
-
- if (!Buffer || !RequiredLength)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * Buffer->Length is used as both an input and output parameter. Get the
- * input actual length and set the output required buffer length.
- */
- InputBufferLength = Buffer->Length;
- Buffer->Length = RequiredLength;
-
- /*
- * The input buffer length contains the actual buffer length, or the type
- * of buffer to be allocated by this routine.
- */
- switch (InputBufferLength)
- {
- case ACPI_NO_BUFFER:
-
- /* Return the exception (and the required buffer length) */
-
- return (AE_BUFFER_OVERFLOW);
-
- case ACPI_ALLOCATE_BUFFER:
-
- /* Allocate a new buffer */
-
- Buffer->Pointer = AcpiOsAllocate (RequiredLength);
- break;
-
- case ACPI_ALLOCATE_LOCAL_BUFFER:
-
- /* Allocate a new buffer with local interface to allow tracking */
-
- Buffer->Pointer = ACPI_ALLOCATE (RequiredLength);
- break;
-
- default:
-
- /* Existing buffer: Validate the size of the buffer */
-
- if (InputBufferLength < RequiredLength)
- {
- return (AE_BUFFER_OVERFLOW);
- }
- break;
- }
-
- /* Validate allocation from above or input buffer pointer */
-
- if (!Buffer->Pointer)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Have a valid buffer, clear it */
-
- ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocate
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of malloc.
- *
- ******************************************************************************/
-
-void *
-AcpiUtAllocate (
- ACPI_SIZE Size,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- void *Allocation;
-
-
- ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size);
-
-
- /* Check for an inadvertent size of zero bytes */
-
- if (!Size)
- {
- ACPI_WARNING ((Module, Line,
- "Attempt to allocate zero bytes, allocating 1 byte"));
- Size = 1;
- }
-
- Allocation = AcpiOsAllocate (Size);
- if (!Allocation)
- {
- /* Report allocation error */
-
- ACPI_WARNING ((Module, Line,
- "Could not allocate size %u", (UINT32) Size));
-
- return_PTR (NULL);
- }
-
- return_PTR (Allocation);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocateZeroed
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
- *
- ******************************************************************************/
-
-void *
-AcpiUtAllocateZeroed (
- ACPI_SIZE Size,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- void *Allocation;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- Allocation = AcpiUtAllocate (Size, Component, Module, Line);
- if (Allocation)
- {
- /* Clear the memory block */
-
- ACPI_MEMSET (Allocation, 0, Size);
- }
-
- return (Allocation);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utcache.c
--- a/head/sys/contrib/dev/acpica/utilities/utcache.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,361 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utcache - local cache allocation 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 __UTCACHE_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utcache")
-
-
-#ifdef ACPI_USE_LOCAL_CACHE
-/*******************************************************************************
- *
- * FUNCTION: AcpiOsCreateCache
- *
- * PARAMETERS: CacheName - Ascii name for the cache
- * ObjectSize - Size of each cached object
- * MaxDepth - Maximum depth of the cache (in objects)
- * ReturnCache - Where the new cache object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a cache object
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiOsCreateCache (
- char *CacheName,
- UINT16 ObjectSize,
- UINT16 MaxDepth,
- ACPI_MEMORY_LIST **ReturnCache)
-{
- ACPI_MEMORY_LIST *Cache;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!CacheName || !ReturnCache || (ObjectSize < 16))
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Create the cache object */
-
- Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
- if (!Cache)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Populate the cache object and return it */
-
- ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
- Cache->LinkOffset = 8;
- Cache->ListName = CacheName;
- Cache->ObjectSize = ObjectSize;
- Cache->MaxDepth = MaxDepth;
-
- *ReturnCache = Cache;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiOsPurgeCache
- *
- * PARAMETERS: Cache - Handle to cache object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Free all objects within the requested cache.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiOsPurgeCache (
- ACPI_MEMORY_LIST *Cache)
-{
- char *Next;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!Cache)
- {
- return (AE_BAD_PARAMETER);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Walk the list of objects in this cache */
-
- while (Cache->ListHead)
- {
- /* Delete and unlink one cached state object */
-
- Next = *(ACPI_CAST_INDIRECT_PTR (char,
- &(((char *) Cache->ListHead)[Cache->LinkOffset])));
- ACPI_FREE (Cache->ListHead);
-
- Cache->ListHead = Next;
- Cache->CurrentDepth--;
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiOsDeleteCache
- *
- * PARAMETERS: Cache - Handle to cache object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Free all objects within the requested cache and delete the
- * cache object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiOsDeleteCache (
- ACPI_MEMORY_LIST *Cache)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Purge all objects in the cache */
-
- Status = AcpiOsPurgeCache (Cache);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Now we can delete the cache object */
-
- AcpiOsFree (Cache);
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiOsReleaseObject
- *
- * PARAMETERS: Cache - Handle to cache object
- * Object - The object to be released
- *
- * RETURN: None
- *
- * DESCRIPTION: Release an object to the specified cache. If cache is full,
- * the object is deleted.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiOsReleaseObject (
- ACPI_MEMORY_LIST *Cache,
- void *Object)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!Cache || !Object)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* If cache is full, just free this object */
-
- if (Cache->CurrentDepth >= Cache->MaxDepth)
- {
- ACPI_FREE (Object);
- ACPI_MEM_TRACKING (Cache->TotalFreed++);
- }
-
- /* Otherwise put this object back into the cache */
-
- else
- {
- Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Mark the object as cached */
-
- ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize);
- ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
-
- /* Put the object at the head of the cache list */
-
- * (ACPI_CAST_INDIRECT_PTR (char,
- &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead;
- Cache->ListHead = Object;
- Cache->CurrentDepth++;
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiOsAcquireObject
- *
- * PARAMETERS: Cache - Handle to cache object
- *
- * RETURN: the acquired object. NULL on error
- *
- * DESCRIPTION: Get an object from the specified cache. If cache is empty,
- * the object is allocated.
- *
- ******************************************************************************/
-
-void *
-AcpiOsAcquireObject (
- ACPI_MEMORY_LIST *Cache)
-{
- ACPI_STATUS Status;
- void *Object;
-
-
- ACPI_FUNCTION_NAME (OsAcquireObject);
-
-
- if (!Cache)
- {
- return (NULL);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (Status))
- {
- return (NULL);
- }
-
- ACPI_MEM_TRACKING (Cache->Requests++);
-
- /* Check the cache first */
-
- if (Cache->ListHead)
- {
- /* There is an object available, use it */
-
- Object = Cache->ListHead;
- Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char,
- &(((char *) Object)[Cache->LinkOffset])));
-
- Cache->CurrentDepth--;
-
- ACPI_MEM_TRACKING (Cache->Hits++);
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Object %p from %s cache\n", Object, Cache->ListName));
-
- Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (Status))
- {
- return (NULL);
- }
-
- /* Clear (zero) the previously used Object */
-
- ACPI_MEMSET (Object, 0, Cache->ObjectSize);
- }
- else
- {
- /* The cache is empty, create a new object */
-
- ACPI_MEM_TRACKING (Cache->TotalAllocated++);
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied)
- {
- Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed;
- }
-#endif
-
- /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */
-
- Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (Status))
- {
- return (NULL);
- }
-
- Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize);
- if (!Object)
- {
- return (NULL);
- }
- }
-
- return (Object);
-}
-#endif /* ACPI_USE_LOCAL_CACHE */
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utcopy.c
--- a/head/sys/contrib/dev/acpica/utilities/utcopy.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1078 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utcopy - Internal to external object translation 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 __UTCOPY_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utcopy")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiUtCopyIsimpleToEsimple (
- ACPI_OPERAND_OBJECT *InternalObject,
- ACPI_OBJECT *ExternalObject,
- UINT8 *DataSpace,
- ACPI_SIZE *BufferSpaceUsed);
-
-static ACPI_STATUS
-AcpiUtCopyIelementToIelement (
- UINT8 ObjectType,
- ACPI_OPERAND_OBJECT *SourceObject,
- ACPI_GENERIC_STATE *State,
- void *Context);
-
-static ACPI_STATUS
-AcpiUtCopyIpackageToEpackage (
- ACPI_OPERAND_OBJECT *InternalObject,
- UINT8 *Buffer,
- ACPI_SIZE *SpaceUsed);
-
-static ACPI_STATUS
-AcpiUtCopyEsimpleToIsimple(
- ACPI_OBJECT *UserObj,
- ACPI_OPERAND_OBJECT **ReturnObj);
-
-static ACPI_STATUS
-AcpiUtCopyEpackageToIpackage (
- ACPI_OBJECT *ExternalObject,
- ACPI_OPERAND_OBJECT **InternalObject);
-
-static ACPI_STATUS
-AcpiUtCopySimpleObject (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *DestDesc);
-
-static ACPI_STATUS
-AcpiUtCopyIelementToEelement (
- UINT8 ObjectType,
- ACPI_OPERAND_OBJECT *SourceObject,
- ACPI_GENERIC_STATE *State,
- void *Context);
-
-static ACPI_STATUS
-AcpiUtCopyIpackageToIpackage (
- ACPI_OPERAND_OBJECT *SourceObj,
- ACPI_OPERAND_OBJECT *DestObj,
- ACPI_WALK_STATE *WalkState);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyIsimpleToEsimple
- *
- * PARAMETERS: InternalObject - Source object to be copied
- * ExternalObject - Where to return the copied object
- * DataSpace - Where object data is returned (such as
- * buffer and string data)
- * BufferSpaceUsed - Length of DataSpace that was used
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to copy a simple internal object to
- * an external object.
- *
- * The DataSpace buffer is assumed to have sufficient space for
- * the object.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopyIsimpleToEsimple (
- ACPI_OPERAND_OBJECT *InternalObject,
- ACPI_OBJECT *ExternalObject,
- UINT8 *DataSpace,
- ACPI_SIZE *BufferSpaceUsed)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple);
-
-
- *BufferSpaceUsed = 0;
-
- /*
- * Check for NULL object case (could be an uninitialized
- * package element)
- */
- if (!InternalObject)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Always clear the external object */
-
- ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT));
-
- /*
- * In general, the external object will be the same type as
- * the internal object
- */
- ExternalObject->Type = InternalObject->Common.Type;
-
- /* However, only a limited number of external types are supported */
-
- switch (InternalObject->Common.Type)
- {
- case ACPI_TYPE_STRING:
-
- ExternalObject->String.Pointer = (char *) DataSpace;
- ExternalObject->String.Length = InternalObject->String.Length;
- *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (
- (ACPI_SIZE) InternalObject->String.Length + 1);
-
- ACPI_MEMCPY ((void *) DataSpace,
- (void *) InternalObject->String.Pointer,
- (ACPI_SIZE) InternalObject->String.Length + 1);
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- ExternalObject->Buffer.Pointer = DataSpace;
- ExternalObject->Buffer.Length = InternalObject->Buffer.Length;
- *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (
- InternalObject->String.Length);
-
- ACPI_MEMCPY ((void *) DataSpace,
- (void *) InternalObject->Buffer.Pointer,
- InternalObject->Buffer.Length);
- break;
-
-
- case ACPI_TYPE_INTEGER:
-
- ExternalObject->Integer.Value = InternalObject->Integer.Value;
- break;
-
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- /* This is an object reference. */
-
- switch (InternalObject->Reference.Class)
- {
- case ACPI_REFCLASS_NAME:
-
- /*
- * For namepath, return the object handle ("reference")
- * We are referring to the namespace node
- */
- ExternalObject->Reference.Handle =
- InternalObject->Reference.Node;
- ExternalObject->Reference.ActualType =
- AcpiNsGetType (InternalObject->Reference.Node);
- break;
-
- default:
-
- /* All other reference types are unsupported */
-
- return_ACPI_STATUS (AE_TYPE);
- }
- break;
-
-
- case ACPI_TYPE_PROCESSOR:
-
- ExternalObject->Processor.ProcId =
- InternalObject->Processor.ProcId;
- ExternalObject->Processor.PblkAddress =
- InternalObject->Processor.Address;
- ExternalObject->Processor.PblkLength =
- InternalObject->Processor.Length;
- break;
-
-
- case ACPI_TYPE_POWER:
-
- ExternalObject->PowerResource.SystemLevel =
- InternalObject->PowerResource.SystemLevel;
-
- ExternalObject->PowerResource.ResourceOrder =
- InternalObject->PowerResource.ResourceOrder;
- break;
-
-
- default:
- /*
- * There is no corresponding external object type
- */
- ACPI_ERROR ((AE_INFO,
- "Unsupported object type, cannot convert to external object: %s",
- AcpiUtGetTypeName (InternalObject->Common.Type)));
-
- return_ACPI_STATUS (AE_SUPPORT);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyIelementToEelement
- *
- * PARAMETERS: ACPI_PKG_CALLBACK
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy one package element to another package element
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopyIelementToEelement (
- UINT8 ObjectType,
- ACPI_OPERAND_OBJECT *SourceObject,
- ACPI_GENERIC_STATE *State,
- void *Context)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
- ACPI_SIZE ObjectSpace;
- UINT32 ThisIndex;
- ACPI_OBJECT *TargetObject;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- ThisIndex = State->Pkg.Index;
- TargetObject = (ACPI_OBJECT *)
- &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex];
-
- switch (ObjectType)
- {
- case ACPI_COPY_TYPE_SIMPLE:
-
- /*
- * This is a simple or null object
- */
- Status = AcpiUtCopyIsimpleToEsimple (SourceObject,
- TargetObject, Info->FreeSpace, &ObjectSpace);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
-
- case ACPI_COPY_TYPE_PACKAGE:
-
- /*
- * Build the package object
- */
- TargetObject->Type = ACPI_TYPE_PACKAGE;
- TargetObject->Package.Count = SourceObject->Package.Count;
- TargetObject->Package.Elements =
- ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace);
-
- /*
- * Pass the new package object back to the package walk routine
- */
- State->Pkg.ThisTargetObj = TargetObject;
-
- /*
- * Save space for the array of objects (Package elements)
- * update the buffer length counter
- */
- ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD (
- (ACPI_SIZE) TargetObject->Package.Count *
- sizeof (ACPI_OBJECT));
- break;
-
-
- default:
- return (AE_BAD_PARAMETER);
- }
-
- Info->FreeSpace += ObjectSpace;
- Info->Length += ObjectSpace;
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyIpackageToEpackage
- *
- * PARAMETERS: InternalObject - Pointer to the object we are returning
- * Buffer - Where the object is returned
- * SpaceUsed - Where the object length is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to place a package object in a user
- * buffer. A package object by definition contains other objects.
- *
- * The buffer is assumed to have sufficient space for the object.
- * The caller must have verified the buffer length needed using
- * the AcpiUtGetObjectSize function before calling this function.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopyIpackageToEpackage (
- ACPI_OPERAND_OBJECT *InternalObject,
- UINT8 *Buffer,
- ACPI_SIZE *SpaceUsed)
-{
- ACPI_OBJECT *ExternalObject;
- ACPI_STATUS Status;
- ACPI_PKG_INFO Info;
-
-
- ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage);
-
-
- /*
- * First package at head of the buffer
- */
- ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer);
-
- /*
- * Free space begins right after the first package
- */
- Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
- Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (
- sizeof (ACPI_OBJECT));
- Info.ObjectSpace = 0;
- Info.NumPackages = 1;
-
- ExternalObject->Type = InternalObject->Common.Type;
- ExternalObject->Package.Count = InternalObject->Package.Count;
- ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT,
- Info.FreeSpace);
-
- /*
- * Leave room for an array of ACPI_OBJECTS in the buffer
- * and move the free space past it
- */
- Info.Length += (ACPI_SIZE) ExternalObject->Package.Count *
- ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
- Info.FreeSpace += ExternalObject->Package.Count *
- ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
-
- Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject,
- AcpiUtCopyIelementToEelement, &Info);
-
- *SpaceUsed = Info.Length;
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyIobjectToEobject
- *
- * PARAMETERS: InternalObject - The internal object to be converted
- * RetBuffer - Where the object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to build an API object to be returned
- * to the caller.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCopyIobjectToEobject (
- ACPI_OPERAND_OBJECT *InternalObject,
- ACPI_BUFFER *RetBuffer)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject);
-
-
- if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)
- {
- /*
- * Package object: Copy all subobjects (including
- * nested packages)
- */
- Status = AcpiUtCopyIpackageToEpackage (InternalObject,
- RetBuffer->Pointer, &RetBuffer->Length);
- }
- else
- {
- /*
- * Build a simple object (no nested objects)
- */
- Status = AcpiUtCopyIsimpleToEsimple (InternalObject,
- ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer),
- ACPI_ADD_PTR (UINT8, RetBuffer->Pointer,
- ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))),
- &RetBuffer->Length);
- /*
- * build simple does not include the object size in the length
- * so we add it in here
- */
- RetBuffer->Length += sizeof (ACPI_OBJECT);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyEsimpleToIsimple
- *
- * PARAMETERS: ExternalObject - The external object to be converted
- * RetInternalObject - Where the internal object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function copies an external object to an internal one.
- * NOTE: Pointers can be copied, we don't need to copy data.
- * (The pointers have to be valid in our address space no matter
- * what we do with them!)
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopyEsimpleToIsimple (
- ACPI_OBJECT *ExternalObject,
- ACPI_OPERAND_OBJECT **RetInternalObject)
-{
- ACPI_OPERAND_OBJECT *InternalObject;
-
-
- ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple);
-
-
- /*
- * Simple types supported are: String, Buffer, Integer
- */
- switch (ExternalObject->Type)
- {
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- InternalObject = AcpiUtCreateInternalObject (
- (UINT8) ExternalObject->Type);
- if (!InternalObject)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
- break;
-
- case ACPI_TYPE_ANY: /* This is the case for a NULL object */
-
- *RetInternalObject = NULL;
- return_ACPI_STATUS (AE_OK);
-
- default:
- /* All other types are not supported */
-
- ACPI_ERROR ((AE_INFO,
- "Unsupported object type, cannot convert to internal object: %s",
- AcpiUtGetTypeName (ExternalObject->Type)));
-
- return_ACPI_STATUS (AE_SUPPORT);
- }
-
-
- /* Must COPY string and buffer contents */
-
- switch (ExternalObject->Type)
- {
- case ACPI_TYPE_STRING:
-
- InternalObject->String.Pointer =
- ACPI_ALLOCATE_ZEROED ((ACPI_SIZE)
- ExternalObject->String.Length + 1);
-
- if (!InternalObject->String.Pointer)
- {
- goto ErrorExit;
- }
-
- ACPI_MEMCPY (InternalObject->String.Pointer,
- ExternalObject->String.Pointer,
- ExternalObject->String.Length);
-
- InternalObject->String.Length = ExternalObject->String.Length;
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- InternalObject->Buffer.Pointer =
- ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length);
- if (!InternalObject->Buffer.Pointer)
- {
- goto ErrorExit;
- }
-
- ACPI_MEMCPY (InternalObject->Buffer.Pointer,
- ExternalObject->Buffer.Pointer,
- ExternalObject->Buffer.Length);
-
- InternalObject->Buffer.Length = ExternalObject->Buffer.Length;
-
- /* Mark buffer data valid */
-
- InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID;
- break;
-
-
- case ACPI_TYPE_INTEGER:
-
- InternalObject->Integer.Value = ExternalObject->Integer.Value;
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- /* TBD: should validate incoming handle */
-
- InternalObject->Reference.Class = ACPI_REFCLASS_NAME;
- InternalObject->Reference.Node = ExternalObject->Reference.Handle;
- break;
-
- default:
- /* Other types can't get here */
- break;
- }
-
- *RetInternalObject = InternalObject;
- return_ACPI_STATUS (AE_OK);
-
-
-ErrorExit:
- AcpiUtRemoveReference (InternalObject);
- return_ACPI_STATUS (AE_NO_MEMORY);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyEpackageToIpackage
- *
- * PARAMETERS: ExternalObject - The external object to be converted
- * InternalObject - Where the internal object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy an external package object to an internal package.
- * Handles nested packages.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopyEpackageToIpackage (
- ACPI_OBJECT *ExternalObject,
- ACPI_OPERAND_OBJECT **InternalObject)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_OPERAND_OBJECT *PackageObject;
- ACPI_OPERAND_OBJECT **PackageElements;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage);
-
-
- /* Create the package object */
-
- PackageObject = AcpiUtCreatePackageObject (ExternalObject->Package.Count);
- if (!PackageObject)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- PackageElements = PackageObject->Package.Elements;
-
- /*
- * Recursive implementation. Probably ok, since nested external packages
- * as parameters should be very rare.
- */
- for (i = 0; i < ExternalObject->Package.Count; i++)
- {
- Status = AcpiUtCopyEobjectToIobject (
- &ExternalObject->Package.Elements[i],
- &PackageElements[i]);
- if (ACPI_FAILURE (Status))
- {
- /* Truncate package and delete it */
-
- PackageObject->Package.Count = i;
- PackageElements[i] = NULL;
- AcpiUtRemoveReference (PackageObject);
- return_ACPI_STATUS (Status);
- }
- }
-
- /* Mark package data valid */
-
- PackageObject->Package.Flags |= AOPOBJ_DATA_VALID;
-
- *InternalObject = PackageObject;
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyEobjectToIobject
- *
- * PARAMETERS: ExternalObject - The external object to be converted
- * InternalObject - Where the internal object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Converts an external object to an internal object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCopyEobjectToIobject (
- ACPI_OBJECT *ExternalObject,
- ACPI_OPERAND_OBJECT **InternalObject)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject);
-
-
- if (ExternalObject->Type == ACPI_TYPE_PACKAGE)
- {
- Status = AcpiUtCopyEpackageToIpackage (ExternalObject, InternalObject);
- }
- else
- {
- /*
- * Build a simple object (no nested objects)
- */
- Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopySimpleObject
- *
- * PARAMETERS: SourceDesc - The internal object to be copied
- * DestDesc - New target object
- *
- * RETURN: Status
- *
- * DESCRIPTION: Simple copy of one internal object to another. Reference count
- * of the destination object is preserved.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopySimpleObject (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT *DestDesc)
-{
- UINT16 ReferenceCount;
- ACPI_OPERAND_OBJECT *NextObject;
- ACPI_STATUS Status;
- ACPI_SIZE CopySize;
-
-
- /* Save fields from destination that we don't want to overwrite */
-
- ReferenceCount = DestDesc->Common.ReferenceCount;
- NextObject = DestDesc->Common.NextObject;
-
- /*
- * Copy the entire source object over the destination object.
- * Note: Source can be either an operand object or namespace node.
- */
- CopySize = sizeof (ACPI_OPERAND_OBJECT);
- if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
- {
- CopySize = sizeof (ACPI_NAMESPACE_NODE);
- }
-
- ACPI_MEMCPY (ACPI_CAST_PTR (char, DestDesc),
- ACPI_CAST_PTR (char, SourceDesc), CopySize);
-
- /* Restore the saved fields */
-
- DestDesc->Common.ReferenceCount = ReferenceCount;
- DestDesc->Common.NextObject = NextObject;
-
- /* New object is not static, regardless of source */
-
- DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
-
- /* Handle the objects with extra data */
-
- switch (DestDesc->Common.Type)
- {
- case ACPI_TYPE_BUFFER:
- /*
- * Allocate and copy the actual buffer if and only if:
- * 1) There is a valid buffer pointer
- * 2) The buffer has a length > 0
- */
- if ((SourceDesc->Buffer.Pointer) &&
- (SourceDesc->Buffer.Length))
- {
- DestDesc->Buffer.Pointer =
- ACPI_ALLOCATE (SourceDesc->Buffer.Length);
- if (!DestDesc->Buffer.Pointer)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Copy the actual buffer data */
-
- ACPI_MEMCPY (DestDesc->Buffer.Pointer,
- SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length);
- }
- break;
-
- case ACPI_TYPE_STRING:
- /*
- * Allocate and copy the actual string if and only if:
- * 1) There is a valid string pointer
- * (Pointer to a NULL string is allowed)
- */
- if (SourceDesc->String.Pointer)
- {
- DestDesc->String.Pointer =
- ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1);
- if (!DestDesc->String.Pointer)
- {
- return (AE_NO_MEMORY);
- }
-
- /* Copy the actual string data */
-
- ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer,
- (ACPI_SIZE) SourceDesc->String.Length + 1);
- }
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
- /*
- * We copied the reference object, so we now must add a reference
- * to the object pointed to by the reference
- *
- * DDBHandle reference (from Load/LoadTable) is a special reference,
- * it does not have a Reference.Object, so does not need to
- * increase the reference count
- */
- if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
- {
- break;
- }
-
- AcpiUtAddReference (SourceDesc->Reference.Object);
- break;
-
- case ACPI_TYPE_REGION:
- /*
- * We copied the Region Handler, so we now must add a reference
- */
- if (DestDesc->Region.Handler)
- {
- AcpiUtAddReference (DestDesc->Region.Handler);
- }
- break;
-
- /*
- * For Mutex and Event objects, we cannot simply copy the underlying
- * OS object. We must create a new one.
- */
- case ACPI_TYPE_MUTEX:
-
- Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
- case ACPI_TYPE_EVENT:
-
- Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
- &DestDesc->Event.OsSemaphore);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
-
- default:
- /* Nothing to do for other simple objects */
- break;
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyIelementToIelement
- *
- * PARAMETERS: ACPI_PKG_CALLBACK
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy one package element to another package element
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopyIelementToIelement (
- UINT8 ObjectType,
- ACPI_OPERAND_OBJECT *SourceObject,
- ACPI_GENERIC_STATE *State,
- void *Context)
-{
- ACPI_STATUS Status = AE_OK;
- UINT32 ThisIndex;
- ACPI_OPERAND_OBJECT **ThisTargetPtr;
- ACPI_OPERAND_OBJECT *TargetObject;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- ThisIndex = State->Pkg.Index;
- ThisTargetPtr = (ACPI_OPERAND_OBJECT **)
- &State->Pkg.DestObject->Package.Elements[ThisIndex];
-
- switch (ObjectType)
- {
- case ACPI_COPY_TYPE_SIMPLE:
-
- /* A null source object indicates a (legal) null package element */
-
- if (SourceObject)
- {
- /*
- * This is a simple object, just copy it
- */
- TargetObject = AcpiUtCreateInternalObject (
- SourceObject->Common.Type);
- if (!TargetObject)
- {
- return (AE_NO_MEMORY);
- }
-
- Status = AcpiUtCopySimpleObject (SourceObject, TargetObject);
- if (ACPI_FAILURE (Status))
- {
- goto ErrorExit;
- }
-
- *ThisTargetPtr = TargetObject;
- }
- else
- {
- /* Pass through a null element */
-
- *ThisTargetPtr = NULL;
- }
- break;
-
-
- case ACPI_COPY_TYPE_PACKAGE:
-
- /*
- * This object is a package - go down another nesting level
- * Create and build the package object
- */
- TargetObject = AcpiUtCreatePackageObject (SourceObject->Package.Count);
- if (!TargetObject)
- {
- return (AE_NO_MEMORY);
- }
-
- TargetObject->Common.Flags = SourceObject->Common.Flags;
-
- /* Pass the new package object back to the package walk routine */
-
- State->Pkg.ThisTargetObj = TargetObject;
-
- /* Store the object pointer in the parent package object */
-
- *ThisTargetPtr = TargetObject;
- break;
-
-
- default:
- return (AE_BAD_PARAMETER);
- }
-
- return (Status);
-
-ErrorExit:
- AcpiUtRemoveReference (TargetObject);
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyIpackageToIpackage
- *
- * PARAMETERS: SourceObj - Pointer to the source package object
- * DestObj - Where the internal object is returned
- * WalkState - Current Walk state descriptor
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to copy an internal package object
- * into another internal package object.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCopyIpackageToIpackage (
- ACPI_OPERAND_OBJECT *SourceObj,
- ACPI_OPERAND_OBJECT *DestObj,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage);
-
-
- DestObj->Common.Type = SourceObj->Common.Type;
- DestObj->Common.Flags = SourceObj->Common.Flags;
- DestObj->Package.Count = SourceObj->Package.Count;
-
- /*
- * Create the object array and walk the source package tree
- */
- DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED (
- ((ACPI_SIZE) SourceObj->Package.Count + 1) *
- sizeof (void *));
- if (!DestObj->Package.Elements)
- {
- ACPI_ERROR ((AE_INFO, "Package allocation failure"));
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /*
- * Copy the package element-by-element by walking the package "tree".
- * This handles nested packages of arbitrary depth.
- */
- Status = AcpiUtWalkPackageTree (SourceObj, DestObj,
- AcpiUtCopyIelementToIelement, WalkState);
- if (ACPI_FAILURE (Status))
- {
- /* On failure, delete the destination package object */
-
- AcpiUtRemoveReference (DestObj);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCopyIobjectToIobject
- *
- * PARAMETERS: SourceDesc - The internal object to be copied
- * DestDesc - Where the copied object is returned
- * WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy an internal object to a new internal object
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCopyIobjectToIobject (
- ACPI_OPERAND_OBJECT *SourceDesc,
- ACPI_OPERAND_OBJECT **DestDesc,
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject);
-
-
- /* Create the top level object */
-
- *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type);
- if (!*DestDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Copy the object and possible subobjects */
-
- if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE)
- {
- Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc,
- WalkState);
- }
- else
- {
- Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utdebug.c
--- a/head/sys/contrib/dev/acpica/utilities/utdebug.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,741 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utdebug - Debug print 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 __UTDEBUG_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utdebug")
-
-
-#ifdef ACPI_DEBUG_OUTPUT
-
-static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF;
-static char *AcpiGbl_FnEntryStr = "----Entry";
-static char *AcpiGbl_FnExitStr = "----Exit-";
-
-/* Local prototypes */
-
-static const char *
-AcpiUtTrimFunctionName (
- const char *FunctionName);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtInitStackPtrTrace
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
- *
- ******************************************************************************/
-
-void
-AcpiUtInitStackPtrTrace (
- void)
-{
- ACPI_SIZE CurrentSp;
-
-
- AcpiGbl_EntryStackPointer = &CurrentSp;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtTrackStackPtr
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Save the current CPU stack pointer
- *
- ******************************************************************************/
-
-void
-AcpiUtTrackStackPtr (
- void)
-{
- ACPI_SIZE CurrentSp;
-
-
- if (&CurrentSp < AcpiGbl_LowestStackPointer)
- {
- AcpiGbl_LowestStackPointer = &CurrentSp;
- }
-
- if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
- {
- AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtTrimFunctionName
- *
- * PARAMETERS: FunctionName - Ascii string containing a procedure name
- *
- * RETURN: Updated pointer to the function name
- *
- * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
- * This allows compiler macros such as __FUNCTION__ to be used
- * with no change to the debug output.
- *
- ******************************************************************************/
-
-static const char *
-AcpiUtTrimFunctionName (
- const char *FunctionName)
-{
-
- /* All Function names are longer than 4 chars, check is safe */
-
- if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED)
- {
- /* This is the case where the original source has not been modified */
-
- return (FunctionName + 4);
- }
-
- if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER)
- {
- /* This is the case where the source has been 'linuxized' */
-
- return (FunctionName + 5);
- }
-
- return (FunctionName);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDebugPrint
- *
- * PARAMETERS: RequestedDebugLevel - Requested debug print level
- * LineNumber - Caller's line number (for error output)
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * Format - Printf format field
- * ... - Optional printf arguments
- *
- * RETURN: None
- *
- * DESCRIPTION: Print error message with prefix consisting of the module name,
- * line number, and component ID.
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiDebugPrint (
- UINT32 RequestedDebugLevel,
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- const char *Format,
- ...)
-{
- ACPI_THREAD_ID ThreadId;
- va_list args;
-
-
- /*
- * Stay silent if the debug level or component ID is disabled
- */
- if (!(RequestedDebugLevel & AcpiDbgLevel) ||
- !(ComponentId & AcpiDbgLayer))
- {
- return;
- }
-
- /*
- * Thread tracking and context switch notification
- */
- ThreadId = AcpiOsGetThreadId ();
- if (ThreadId != AcpiGbl_PrevThreadId)
- {
- if (ACPI_LV_THREADS & AcpiDbgLevel)
- {
- AcpiOsPrintf (
- "\n**** Context Switch from TID %u to TID %u ****\n\n",
- (UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId);
- }
-
- AcpiGbl_PrevThreadId = ThreadId;
- }
-
- /*
- * Display the module name, current line number, thread ID (if requested),
- * current procedure nesting level, and the current procedure name
- */
- AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber);
-
- if (ACPI_LV_THREADS & AcpiDbgLevel)
- {
- AcpiOsPrintf ("[%u] ", (UINT32) ThreadId);
- }
-
- AcpiOsPrintf ("[%02ld] %-22.22s: ",
- AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName));
-
- va_start (args, Format);
- AcpiOsVprintf (Format, args);
- va_end (args);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiDebugPrint)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiDebugPrintRaw
- *
- * PARAMETERS: RequestedDebugLevel - Requested debug print level
- * LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * Format - Printf format field
- * ... - Optional printf arguments
- *
- * RETURN: None
- *
- * DESCRIPTION: Print message with no headers. Has same interface as
- * DebugPrint so that the same macros can be used.
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiDebugPrintRaw (
- UINT32 RequestedDebugLevel,
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- const char *Format,
- ...)
-{
- va_list args;
-
-
- if (!(RequestedDebugLevel & AcpiDbgLevel) ||
- !(ComponentId & AcpiDbgLayer))
- {
- return;
- }
-
- va_start (args, Format);
- AcpiOsVprintf (Format, args);
- va_end (args);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtTrace
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- *
- * RETURN: None
- *
- * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel
- *
- ******************************************************************************/
-
-void
-AcpiUtTrace (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId)
-{
-
- AcpiGbl_NestingLevel++;
- AcpiUtTrackStackPtr ();
-
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s\n", AcpiGbl_FnEntryStr);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiUtTrace)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtTracePtr
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * Pointer - Pointer to display
- *
- * RETURN: None
- *
- * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel
- *
- ******************************************************************************/
-
-void
-AcpiUtTracePtr (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- void *Pointer)
-{
- AcpiGbl_NestingLevel++;
- AcpiUtTrackStackPtr ();
-
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s %p\n", AcpiGbl_FnEntryStr, Pointer);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtTraceStr
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * String - Additional string to display
- *
- * RETURN: None
- *
- * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel
- *
- ******************************************************************************/
-
-void
-AcpiUtTraceStr (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- char *String)
-{
-
- AcpiGbl_NestingLevel++;
- AcpiUtTrackStackPtr ();
-
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s %s\n", AcpiGbl_FnEntryStr, String);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtTraceU32
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * Integer - Integer to display
- *
- * RETURN: None
- *
- * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel
- *
- ******************************************************************************/
-
-void
-AcpiUtTraceU32 (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- UINT32 Integer)
-{
-
- AcpiGbl_NestingLevel++;
- AcpiUtTrackStackPtr ();
-
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s %08X\n", AcpiGbl_FnEntryStr, Integer);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtExit
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- *
- * RETURN: None
- *
- * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel
- *
- ******************************************************************************/
-
-void
-AcpiUtExit (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId)
-{
-
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s\n", AcpiGbl_FnExitStr);
-
- AcpiGbl_NestingLevel--;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiUtExit)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtStatusExit
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * Status - Exit status code
- *
- * RETURN: None
- *
- * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel. Prints exit status also.
- *
- ******************************************************************************/
-
-void
-AcpiUtStatusExit (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- ACPI_STATUS Status)
-{
-
- if (ACPI_SUCCESS (Status))
- {
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s %s\n", AcpiGbl_FnExitStr,
- AcpiFormatException (Status));
- }
- else
- {
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s ****Exception****: %s\n", AcpiGbl_FnExitStr,
- AcpiFormatException (Status));
- }
-
- AcpiGbl_NestingLevel--;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiUtStatusExit)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValueExit
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * Value - Value to be printed with exit msg
- *
- * RETURN: None
- *
- * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel. Prints exit value also.
- *
- ******************************************************************************/
-
-void
-AcpiUtValueExit (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- UINT64 Value)
-{
-
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr,
- ACPI_FORMAT_UINT64 (Value));
-
- AcpiGbl_NestingLevel--;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiUtValueExit)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtPtrExit
- *
- * PARAMETERS: LineNumber - Caller's line number
- * FunctionName - Caller's procedure name
- * ModuleName - Caller's module name
- * ComponentId - Caller's component ID
- * Ptr - Pointer to display
- *
- * RETURN: None
- *
- * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
- * set in DebugLevel. Prints exit value also.
- *
- ******************************************************************************/
-
-void
-AcpiUtPtrExit (
- UINT32 LineNumber,
- const char *FunctionName,
- const char *ModuleName,
- UINT32 ComponentId,
- UINT8 *Ptr)
-{
-
- AcpiDebugPrint (ACPI_LV_FUNCTIONS,
- LineNumber, FunctionName, ModuleName, ComponentId,
- "%s %p\n", AcpiGbl_FnExitStr, Ptr);
-
- AcpiGbl_NestingLevel--;
-}
-
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDumpBuffer
- *
- * PARAMETERS: Buffer - Buffer to dump
- * Count - Amount to dump, in bytes
- * Display - BYTE, WORD, DWORD, or QWORD display
- * ComponentID - Caller's component ID
- *
- * RETURN: None
- *
- * DESCRIPTION: Generic dump buffer in both hex and ascii.
- *
- ******************************************************************************/
-
-void
-AcpiUtDumpBuffer2 (
- UINT8 *Buffer,
- UINT32 Count,
- UINT32 Display)
-{
- UINT32 i = 0;
- UINT32 j;
- UINT32 Temp32;
- UINT8 BufChar;
-
-
- if (!Buffer)
- {
- AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
- return;
- }
-
- if ((Count < 4) || (Count & 0x01))
- {
- Display = DB_BYTE_DISPLAY;
- }
-
- /* Nasty little dump buffer routine! */
-
- while (i < Count)
- {
- /* Print current offset */
-
- AcpiOsPrintf ("%6.4X: ", i);
-
- /* Print 16 hex chars */
-
- for (j = 0; j < 16;)
- {
- if (i + j >= Count)
- {
- /* Dump fill spaces */
-
- AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
- j += Display;
- continue;
- }
-
- switch (Display)
- {
- case DB_BYTE_DISPLAY:
- default: /* Default is BYTE display */
-
- AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]);
- break;
-
-
- case DB_WORD_DISPLAY:
-
- ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
- AcpiOsPrintf ("%04X ", Temp32);
- break;
-
-
- case DB_DWORD_DISPLAY:
-
- ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
- AcpiOsPrintf ("%08X ", Temp32);
- break;
-
-
- case DB_QWORD_DISPLAY:
-
- ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
- AcpiOsPrintf ("%08X", Temp32);
-
- ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
- AcpiOsPrintf ("%08X ", Temp32);
- break;
- }
-
- j += Display;
- }
-
- /*
- * Print the ASCII equivalent characters but watch out for the bad
- * unprintable ones (printable chars are 0x20 through 0x7E)
- */
- AcpiOsPrintf (" ");
- for (j = 0; j < 16; j++)
- {
- if (i + j >= Count)
- {
- AcpiOsPrintf ("\n");
- return;
- }
-
- BufChar = Buffer[(ACPI_SIZE) i + j];
- if (ACPI_IS_PRINT (BufChar))
- {
- AcpiOsPrintf ("%c", BufChar);
- }
- else
- {
- AcpiOsPrintf (".");
- }
- }
-
- /* Done with that line. */
-
- AcpiOsPrintf ("\n");
- i += 16;
- }
-
- return;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDumpBuffer
- *
- * PARAMETERS: Buffer - Buffer to dump
- * Count - Amount to dump, in bytes
- * Display - BYTE, WORD, DWORD, or QWORD display
- * ComponentID - Caller's component ID
- *
- * RETURN: None
- *
- * DESCRIPTION: Generic dump buffer in both hex and ascii.
- *
- ******************************************************************************/
-
-void
-AcpiUtDumpBuffer (
- UINT8 *Buffer,
- UINT32 Count,
- UINT32 Display,
- UINT32 ComponentId)
-{
-
- /* Only dump the buffer if tracing is enabled */
-
- if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
- (ComponentId & AcpiDbgLayer)))
- {
- return;
- }
-
- AcpiUtDumpBuffer2 (Buffer, Count, Display);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utdecode.c
--- a/head/sys/contrib/dev/acpica/utilities/utdecode.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,632 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utdecode - Utility decoding routines (value-to-string)
- *
- *****************************************************************************/
-
-/*
- * 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 __UTDECODE_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utdecode")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiFormatException
- *
- * PARAMETERS: Status - The ACPI_STATUS code to be formatted
- *
- * RETURN: A string containing the exception text. A valid pointer is
- * always returned.
- *
- * DESCRIPTION: This function translates an ACPI exception into an ASCII string
- * It is here instead of utxface.c so it is always present.
- *
- ******************************************************************************/
-
-const char *
-AcpiFormatException (
- ACPI_STATUS Status)
-{
- const char *Exception = NULL;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- Exception = AcpiUtValidateException (Status);
- if (!Exception)
- {
- /* Exception code was not recognized */
-
- ACPI_ERROR ((AE_INFO,
- "Unknown exception code: 0x%8.8X", Status));
-
- Exception = "UNKNOWN_STATUS_CODE";
- }
-
- return (ACPI_CAST_PTR (const char, Exception));
-}
-
-ACPI_EXPORT_SYMBOL (AcpiFormatException)
-
-
-/*
- * Properties of the ACPI Object Types, both internal and external.
- * The table is indexed by values of ACPI_OBJECT_TYPE
- */
-const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
-{
- ACPI_NS_NORMAL, /* 00 Any */
- ACPI_NS_NORMAL, /* 01 Number */
- ACPI_NS_NORMAL, /* 02 String */
- ACPI_NS_NORMAL, /* 03 Buffer */
- ACPI_NS_NORMAL, /* 04 Package */
- ACPI_NS_NORMAL, /* 05 FieldUnit */
- ACPI_NS_NEWSCOPE, /* 06 Device */
- ACPI_NS_NORMAL, /* 07 Event */
- ACPI_NS_NEWSCOPE, /* 08 Method */
- ACPI_NS_NORMAL, /* 09 Mutex */
- ACPI_NS_NORMAL, /* 10 Region */
- ACPI_NS_NEWSCOPE, /* 11 Power */
- ACPI_NS_NEWSCOPE, /* 12 Processor */
- ACPI_NS_NEWSCOPE, /* 13 Thermal */
- ACPI_NS_NORMAL, /* 14 BufferField */
- ACPI_NS_NORMAL, /* 15 DdbHandle */
- ACPI_NS_NORMAL, /* 16 Debug Object */
- ACPI_NS_NORMAL, /* 17 DefField */
- ACPI_NS_NORMAL, /* 18 BankField */
- ACPI_NS_NORMAL, /* 19 IndexField */
- ACPI_NS_NORMAL, /* 20 Reference */
- ACPI_NS_NORMAL, /* 21 Alias */
- ACPI_NS_NORMAL, /* 22 MethodAlias */
- ACPI_NS_NORMAL, /* 23 Notify */
- ACPI_NS_NORMAL, /* 24 Address Handler */
- ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
- ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
- ACPI_NS_NEWSCOPE, /* 27 Scope */
- ACPI_NS_NORMAL, /* 28 Extra */
- ACPI_NS_NORMAL, /* 29 Data */
- ACPI_NS_NORMAL /* 30 Invalid */
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtHexToAsciiChar
- *
- * PARAMETERS: Integer - Contains the hex digit
- * Position - bit position of the digit within the
- * integer (multiple of 4)
- *
- * RETURN: The converted Ascii character
- *
- * DESCRIPTION: Convert a hex digit to an Ascii character
- *
- ******************************************************************************/
-
-/* Hex to ASCII conversion table */
-
-static const char AcpiGbl_HexToAscii[] =
-{
- '0','1','2','3','4','5','6','7',
- '8','9','A','B','C','D','E','F'
-};
-
-char
-AcpiUtHexToAsciiChar (
- UINT64 Integer,
- UINT32 Position)
-{
-
- return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetRegionName
- *
- * PARAMETERS: Space ID - ID for the region
- *
- * RETURN: Decoded region SpaceId name
- *
- * DESCRIPTION: Translate a Space ID into a name string (Debug only)
- *
- ******************************************************************************/
-
-/* Region type decoding */
-
-const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
-{
- "SystemMemory",
- "SystemIO",
- "PCI_Config",
- "EmbeddedControl",
- "SMBus",
- "SystemCMOS",
- "PCIBARTarget",
- "IPMI",
- "GeneralPurposeIo",
- "GenericSerialBus"
-};
-
-
-char *
-AcpiUtGetRegionName (
- UINT8 SpaceId)
-{
-
- if (SpaceId >= ACPI_USER_REGION_BEGIN)
- {
- return ("UserDefinedRegion");
- }
- else if (SpaceId == ACPI_ADR_SPACE_DATA_TABLE)
- {
- return ("DataTable");
- }
- else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
- {
- return ("FunctionalFixedHW");
- }
- else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
- {
- return ("InvalidSpaceId");
- }
-
- return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetEventName
- *
- * PARAMETERS: EventId - Fixed event ID
- *
- * RETURN: Decoded event ID name
- *
- * DESCRIPTION: Translate a Event ID into a name string (Debug only)
- *
- ******************************************************************************/
-
-/* Event type decoding */
-
-static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
-{
- "PM_Timer",
- "GlobalLock",
- "PowerButton",
- "SleepButton",
- "RealTimeClock",
-};
-
-
-char *
-AcpiUtGetEventName (
- UINT32 EventId)
-{
-
- if (EventId > ACPI_EVENT_MAX)
- {
- return ("InvalidEventID");
- }
-
- return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetTypeName
- *
- * PARAMETERS: Type - An ACPI object type
- *
- * RETURN: Decoded ACPI object type name
- *
- * DESCRIPTION: Translate a Type ID into a name string (Debug only)
- *
- ******************************************************************************/
-
-/*
- * Elements of AcpiGbl_NsTypeNames below must match
- * one-to-one with values of ACPI_OBJECT_TYPE
- *
- * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
- * when stored in a table it really means that we have thus far seen no
- * evidence to indicate what type is actually going to be stored for this entry.
- */
-static const char AcpiGbl_BadType[] = "UNDEFINED";
-
-/* Printable names of the ACPI object types */
-
-static const char *AcpiGbl_NsTypeNames[] =
-{
- /* 00 */ "Untyped",
- /* 01 */ "Integer",
- /* 02 */ "String",
- /* 03 */ "Buffer",
- /* 04 */ "Package",
- /* 05 */ "FieldUnit",
- /* 06 */ "Device",
- /* 07 */ "Event",
- /* 08 */ "Method",
- /* 09 */ "Mutex",
- /* 10 */ "Region",
- /* 11 */ "Power",
- /* 12 */ "Processor",
- /* 13 */ "Thermal",
- /* 14 */ "BufferField",
- /* 15 */ "DdbHandle",
- /* 16 */ "DebugObject",
- /* 17 */ "RegionField",
- /* 18 */ "BankField",
- /* 19 */ "IndexField",
- /* 20 */ "Reference",
- /* 21 */ "Alias",
- /* 22 */ "MethodAlias",
- /* 23 */ "Notify",
- /* 24 */ "AddrHandler",
- /* 25 */ "ResourceDesc",
- /* 26 */ "ResourceFld",
- /* 27 */ "Scope",
- /* 28 */ "Extra",
- /* 29 */ "Data",
- /* 30 */ "Invalid"
-};
-
-
-char *
-AcpiUtGetTypeName (
- ACPI_OBJECT_TYPE Type)
-{
-
- if (Type > ACPI_TYPE_INVALID)
- {
- return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
- }
-
- return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
-}
-
-
-char *
-AcpiUtGetObjectTypeName (
- ACPI_OPERAND_OBJECT *ObjDesc)
-{
-
- if (!ObjDesc)
- {
- return ("[NULL Object Descriptor]");
- }
-
- return (AcpiUtGetTypeName (ObjDesc->Common.Type));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetNodeName
- *
- * PARAMETERS: Object - A namespace node
- *
- * RETURN: ASCII name of the node
- *
- * DESCRIPTION: Validate the node and return the node's ACPI name.
- *
- ******************************************************************************/
-
-char *
-AcpiUtGetNodeName (
- void *Object)
-{
- ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
-
-
- /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
-
- if (!Object)
- {
- return ("NULL");
- }
-
- /* Check for Root node */
-
- if ((Object == ACPI_ROOT_OBJECT) ||
- (Object == AcpiGbl_RootNode))
- {
- return ("\"\\\" ");
- }
-
- /* Descriptor must be a namespace node */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
- {
- return ("####");
- }
-
- /*
- * Ensure name is valid. The name was validated/repaired when the node
- * was created, but make sure it has not been corrupted.
- */
- AcpiUtRepairName (Node->Name.Ascii);
-
- /* Return the name */
-
- return (Node->Name.Ascii);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetDescriptorName
- *
- * PARAMETERS: Object - An ACPI object
- *
- * RETURN: Decoded name of the descriptor type
- *
- * DESCRIPTION: Validate object and return the descriptor type
- *
- ******************************************************************************/
-
-/* Printable names of object descriptor types */
-
-static const char *AcpiGbl_DescTypeNames[] =
-{
- /* 00 */ "Not a Descriptor",
- /* 01 */ "Cached",
- /* 02 */ "State-Generic",
- /* 03 */ "State-Update",
- /* 04 */ "State-Package",
- /* 05 */ "State-Control",
- /* 06 */ "State-RootParseScope",
- /* 07 */ "State-ParseScope",
- /* 08 */ "State-WalkScope",
- /* 09 */ "State-Result",
- /* 10 */ "State-Notify",
- /* 11 */ "State-Thread",
- /* 12 */ "Walk",
- /* 13 */ "Parser",
- /* 14 */ "Operand",
- /* 15 */ "Node"
-};
-
-
-char *
-AcpiUtGetDescriptorName (
- void *Object)
-{
-
- if (!Object)
- {
- return ("NULL OBJECT");
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
- {
- return ("Not a Descriptor");
- }
-
- return (ACPI_CAST_PTR (char,
- AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
-
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetReferenceName
- *
- * PARAMETERS: Object - An ACPI reference object
- *
- * RETURN: Decoded name of the type of reference
- *
- * DESCRIPTION: Decode a reference object sub-type to a string.
- *
- ******************************************************************************/
-
-/* Printable names of reference object sub-types */
-
-static const char *AcpiGbl_RefClassNames[] =
-{
- /* 00 */ "Local",
- /* 01 */ "Argument",
- /* 02 */ "RefOf",
- /* 03 */ "Index",
- /* 04 */ "DdbHandle",
- /* 05 */ "Named Object",
- /* 06 */ "Debug"
-};
-
-const char *
-AcpiUtGetReferenceName (
- ACPI_OPERAND_OBJECT *Object)
-{
-
- if (!Object)
- {
- return ("NULL Object");
- }
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
- {
- return ("Not an Operand object");
- }
-
- if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
- {
- return ("Not a Reference object");
- }
-
- if (Object->Reference.Class > ACPI_REFCLASS_MAX)
- {
- return ("Unknown Reference class");
- }
-
- return (AcpiGbl_RefClassNames[Object->Reference.Class]);
-}
-
-
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-/*
- * Strings and procedures used for debug only
- */
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetMutexName
- *
- * PARAMETERS: MutexId - The predefined ID for this mutex.
- *
- * RETURN: Decoded name of the internal mutex
- *
- * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
- *
- ******************************************************************************/
-
-/* Names for internal mutex objects, used for debug output */
-
-static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
-{
- "ACPI_MTX_Interpreter",
- "ACPI_MTX_Namespace",
- "ACPI_MTX_Tables",
- "ACPI_MTX_Events",
- "ACPI_MTX_Caches",
- "ACPI_MTX_Memory",
- "ACPI_MTX_CommandComplete",
- "ACPI_MTX_CommandReady"
-};
-
-char *
-AcpiUtGetMutexName (
- UINT32 MutexId)
-{
-
- if (MutexId > ACPI_MAX_MUTEX)
- {
- return ("Invalid Mutex ID");
- }
-
- return (AcpiGbl_MutexNames[MutexId]);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetNotifyName
- *
- * PARAMETERS: NotifyValue - Value from the Notify() request
- *
- * RETURN: Decoded name for the notify value
- *
- * DESCRIPTION: Translate a Notify Value to a notify namestring.
- *
- ******************************************************************************/
-
-/* Names for Notify() values, used for debug output */
-
-static const char *AcpiGbl_NotifyValueNames[] =
-{
- "Bus Check",
- "Device Check",
- "Device Wake",
- "Eject Request",
- "Device Check Light",
- "Frequency Mismatch",
- "Bus Mode Mismatch",
- "Power Fault",
- "Capabilities Check",
- "Device PLD Check",
- "Reserved",
- "System Locality Update"
-};
-
-const char *
-AcpiUtGetNotifyName (
- UINT32 NotifyValue)
-{
-
- if (NotifyValue <= ACPI_NOTIFY_MAX)
- {
- return (AcpiGbl_NotifyValueNames[NotifyValue]);
- }
- else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
- {
- return ("Reserved");
- }
- else /* Greater or equal to 0x80 */
- {
- return ("**Device Specific**");
- }
-}
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValidObjectType
- *
- * PARAMETERS: Type - Object type to be validated
- *
- * RETURN: TRUE if valid object type, FALSE otherwise
- *
- * DESCRIPTION: Validate an object type
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiUtValidObjectType (
- ACPI_OBJECT_TYPE Type)
-{
-
- if (Type > ACPI_TYPE_LOCAL_MAX)
- {
- /* Note: Assumes all TYPEs are contiguous (external/local) */
-
- return (FALSE);
- }
-
- return (TRUE);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utdelete.c
--- a/head/sys/contrib/dev/acpica/utilities/utdelete.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,766 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utdelete - object deletion and reference count 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 __UTDELETE_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/acevents.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utdelete")
-
-/* Local prototypes */
-
-static void
-AcpiUtDeleteInternalObj (
- ACPI_OPERAND_OBJECT *Object);
-
-static void
-AcpiUtUpdateRefCount (
- ACPI_OPERAND_OBJECT *Object,
- UINT32 Action);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDeleteInternalObj
- *
- * PARAMETERS: Object - Object to be deleted
- *
- * RETURN: None
- *
- * DESCRIPTION: Low level object deletion, after reference counts have been
- * updated (All reference counts, including sub-objects!)
- *
- ******************************************************************************/
-
-static void
-AcpiUtDeleteInternalObj (
- ACPI_OPERAND_OBJECT *Object)
-{
- void *ObjPointer = NULL;
- ACPI_OPERAND_OBJECT *HandlerDesc;
- ACPI_OPERAND_OBJECT *SecondDesc;
- ACPI_OPERAND_OBJECT *NextDesc;
- ACPI_OPERAND_OBJECT **LastObjPtr;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object);
-
-
- if (!Object)
- {
- return_VOID;
- }
-
- /*
- * Must delete or free any pointers within the object that are not
- * actual ACPI objects (for example, a raw buffer pointer).
- */
- switch (Object->Common.Type)
- {
- case ACPI_TYPE_STRING:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n",
- Object, Object->String.Pointer));
-
- /* Free the actual string buffer */
-
- if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
- {
- /* But only if it is NOT a pointer into an ACPI table */
-
- ObjPointer = Object->String.Pointer;
- }
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n",
- Object, Object->Buffer.Pointer));
-
- /* Free the actual buffer */
-
- if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
- {
- /* But only if it is NOT a pointer into an ACPI table */
-
- ObjPointer = Object->Buffer.Pointer;
- }
- break;
-
-
- case ACPI_TYPE_PACKAGE:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n",
- Object->Package.Count));
-
- /*
- * Elements of the package are not handled here, they are deleted
- * separately
- */
-
- /* Free the (variable length) element pointer array */
-
- ObjPointer = Object->Package.Elements;
- break;
-
-
- /*
- * These objects have a possible list of notify handlers.
- * Device object also may have a GPE block.
- */
- case ACPI_TYPE_DEVICE:
-
- if (Object->Device.GpeBlock)
- {
- (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock);
- }
-
- /*lint -fallthrough */
-
- case ACPI_TYPE_PROCESSOR:
- case ACPI_TYPE_THERMAL:
-
- /* Walk the notify handler list for this object */
-
- HandlerDesc = Object->CommonNotify.Handler;
- while (HandlerDesc)
- {
- NextDesc = HandlerDesc->AddressSpace.Next;
- AcpiUtRemoveReference (HandlerDesc);
- HandlerDesc = NextDesc;
- }
- break;
-
-
- case ACPI_TYPE_MUTEX:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "***** Mutex %p, OS Mutex %p\n",
- Object, Object->Mutex.OsMutex));
-
- if (Object == AcpiGbl_GlobalLockMutex)
- {
- /* Global Lock has extra semaphore */
-
- (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore);
- AcpiGbl_GlobalLockSemaphore = NULL;
-
- AcpiOsDeleteMutex (Object->Mutex.OsMutex);
- AcpiGbl_GlobalLockMutex = NULL;
- }
- else
- {
- AcpiExUnlinkMutex (Object);
- AcpiOsDeleteMutex (Object->Mutex.OsMutex);
- }
- break;
-
-
- case ACPI_TYPE_EVENT:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "***** Event %p, OS Semaphore %p\n",
- Object, Object->Event.OsSemaphore));
-
- (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore);
- Object->Event.OsSemaphore = NULL;
- break;
-
-
- case ACPI_TYPE_METHOD:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "***** Method %p\n", Object));
-
- /* Delete the method mutex if it exists */
-
- if (Object->Method.Mutex)
- {
- AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex);
- AcpiUtDeleteObjectDesc (Object->Method.Mutex);
- Object->Method.Mutex = NULL;
- }
- break;
-
-
- case ACPI_TYPE_REGION:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "***** Region %p\n", Object));
-
- /*
- * Update AddressRange list. However, only permanent regions
- * are installed in this list. (Not created within a method)
- */
- if (!(Object->Region.Node->Flags & ANOBJ_TEMPORARY))
- {
- AcpiUtRemoveAddressRange (Object->Region.SpaceId,
- Object->Region.Node);
- }
-
- SecondDesc = AcpiNsGetSecondaryObject (Object);
- if (SecondDesc)
- {
- /*
- * Free the RegionContext if and only if the handler is one of the
- * default handlers -- and therefore, we created the context object
- * locally, it was not created by an external caller.
- */
- HandlerDesc = Object->Region.Handler;
- if (HandlerDesc)
- {
- NextDesc = HandlerDesc->AddressSpace.RegionList;
- LastObjPtr = &HandlerDesc->AddressSpace.RegionList;
-
- /* Remove the region object from the handler's list */
-
- while (NextDesc)
- {
- if (NextDesc == Object)
- {
- *LastObjPtr = NextDesc->Region.Next;
- break;
- }
-
- /* Walk the linked list of handler */
-
- LastObjPtr = &NextDesc->Region.Next;
- NextDesc = NextDesc->Region.Next;
- }
-
- if (HandlerDesc->AddressSpace.HandlerFlags &
- ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
- {
- /* Deactivate region and free region context */
-
- if (HandlerDesc->AddressSpace.Setup)
- {
- (void) HandlerDesc->AddressSpace.Setup (Object,
- ACPI_REGION_DEACTIVATE,
- HandlerDesc->AddressSpace.Context,
- &SecondDesc->Extra.RegionContext);
- }
- }
-
- AcpiUtRemoveReference (HandlerDesc);
- }
-
- /* Now we can free the Extra object */
-
- AcpiUtDeleteObjectDesc (SecondDesc);
- }
- break;
-
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "***** Buffer Field %p\n", Object));
-
- SecondDesc = AcpiNsGetSecondaryObject (Object);
- if (SecondDesc)
- {
- AcpiUtDeleteObjectDesc (SecondDesc);
- }
- break;
-
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "***** Bank Field %p\n", Object));
-
- SecondDesc = AcpiNsGetSecondaryObject (Object);
- if (SecondDesc)
- {
- AcpiUtDeleteObjectDesc (SecondDesc);
- }
- break;
-
-
- default:
- break;
- }
-
- /* Free any allocated memory (pointer within the object) found above */
-
- if (ObjPointer)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n",
- ObjPointer));
- ACPI_FREE (ObjPointer);
- }
-
- /* Now the object can be safely deleted */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n",
- Object, AcpiUtGetObjectTypeName (Object)));
-
- AcpiUtDeleteObjectDesc (Object);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDeleteInternalObjectList
- *
- * PARAMETERS: ObjList - Pointer to the list to be deleted
- *
- * RETURN: None
- *
- * DESCRIPTION: This function deletes an internal object list, including both
- * simple objects and package objects
- *
- ******************************************************************************/
-
-void
-AcpiUtDeleteInternalObjectList (
- ACPI_OPERAND_OBJECT **ObjList)
-{
- ACPI_OPERAND_OBJECT **InternalObj;
-
-
- ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList);
-
-
- /* Walk the null-terminated internal list */
-
- for (InternalObj = ObjList; *InternalObj; InternalObj++)
- {
- AcpiUtRemoveReference (*InternalObj);
- }
-
- /* Free the combined parameter pointer list and object array */
-
- ACPI_FREE (ObjList);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtUpdateRefCount
- *
- * PARAMETERS: Object - Object whose ref count is to be updated
- * Action - What to do
- *
- * RETURN: New ref count
- *
- * DESCRIPTION: Modify the ref count and return it.
- *
- ******************************************************************************/
-
-static void
-AcpiUtUpdateRefCount (
- ACPI_OPERAND_OBJECT *Object,
- UINT32 Action)
-{
- UINT16 Count;
- UINT16 NewCount;
-
-
- ACPI_FUNCTION_NAME (UtUpdateRefCount);
-
-
- if (!Object)
- {
- return;
- }
-
- Count = Object->Common.ReferenceCount;
- NewCount = Count;
-
- /*
- * Perform the reference count action (increment, decrement, force delete)
- */
- switch (Action)
- {
- case REF_INCREMENT:
-
- NewCount++;
- Object->Common.ReferenceCount = NewCount;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Obj %p Refs=%X, [Incremented]\n",
- Object, NewCount));
- break;
-
- case REF_DECREMENT:
-
- if (Count < 1)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
- Object, NewCount));
-
- NewCount = 0;
- }
- else
- {
- NewCount--;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Obj %p Refs=%X, [Decremented]\n",
- Object, NewCount));
- }
-
- if (Object->Common.Type == ACPI_TYPE_METHOD)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount));
- }
-
- Object->Common.ReferenceCount = NewCount;
- if (NewCount == 0)
- {
- AcpiUtDeleteInternalObj (Object);
- }
- break;
-
- case REF_FORCE_DELETE:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count));
-
- NewCount = 0;
- Object->Common.ReferenceCount = NewCount;
- AcpiUtDeleteInternalObj (Object);
- break;
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Unknown action (0x%X)", Action));
- break;
- }
-
- /*
- * Sanity check the reference count, for debug purposes only.
- * (A deleted object will have a huge reference count)
- */
- if (Count > ACPI_MAX_REFERENCE_COUNT)
- {
- ACPI_WARNING ((AE_INFO,
- "Large Reference Count (0x%X) in object %p", Count, Object));
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtUpdateObjectReference
- *
- * PARAMETERS: Object - Increment ref count for this object
- * and all sub-objects
- * Action - Either REF_INCREMENT or REF_DECREMENT or
- * REF_FORCE_DELETE
- *
- * RETURN: Status
- *
- * DESCRIPTION: Increment the object reference count
- *
- * Object references are incremented when:
- * 1) An object is attached to a Node (namespace object)
- * 2) An object is copied (all subobjects must be incremented)
- *
- * Object references are decremented when:
- * 1) An object is detached from an Node
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtUpdateObjectReference (
- ACPI_OPERAND_OBJECT *Object,
- UINT16 Action)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_GENERIC_STATE *StateList = NULL;
- ACPI_OPERAND_OBJECT *NextObject = NULL;
- ACPI_GENERIC_STATE *State;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object);
-
-
- while (Object)
- {
- /* Make sure that this isn't a namespace handle */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Object %p is NS handle\n", Object));
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * All sub-objects must have their reference count incremented also.
- * Different object types have different subobjects.
- */
- switch (Object->Common.Type)
- {
- case ACPI_TYPE_DEVICE:
- case ACPI_TYPE_PROCESSOR:
- case ACPI_TYPE_POWER:
- case ACPI_TYPE_THERMAL:
-
- /* Update the notify objects for these types (if present) */
-
- AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action);
- AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action);
- break;
-
- case ACPI_TYPE_PACKAGE:
- /*
- * We must update all the sub-objects of the package,
- * each of whom may have their own sub-objects.
- */
- for (i = 0; i < Object->Package.Count; i++)
- {
- /*
- * Push each element onto the stack for later processing.
- * Note: There can be null elements within the package,
- * these are simply ignored
- */
- Status = AcpiUtCreateUpdateStateAndPush (
- Object->Package.Elements[i], Action, &StateList);
- if (ACPI_FAILURE (Status))
- {
- goto ErrorExit;
- }
- }
- break;
-
- case ACPI_TYPE_BUFFER_FIELD:
-
- NextObject = Object->BufferField.BufferObj;
- break;
-
- case ACPI_TYPE_LOCAL_REGION_FIELD:
-
- NextObject = Object->Field.RegionObj;
- break;
-
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- NextObject = Object->BankField.BankObj;
- Status = AcpiUtCreateUpdateStateAndPush (
- Object->BankField.RegionObj, Action, &StateList);
- if (ACPI_FAILURE (Status))
- {
- goto ErrorExit;
- }
- break;
-
- case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
- NextObject = Object->IndexField.IndexObj;
- Status = AcpiUtCreateUpdateStateAndPush (
- Object->IndexField.DataObj, Action, &StateList);
- if (ACPI_FAILURE (Status))
- {
- goto ErrorExit;
- }
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
- /*
- * The target of an Index (a package, string, or buffer) or a named
- * reference must track changes to the ref count of the index or
- * target object.
- */
- if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) ||
- (Object->Reference.Class== ACPI_REFCLASS_NAME))
- {
- NextObject = Object->Reference.Object;
- }
- break;
-
- case ACPI_TYPE_REGION:
- default:
- break; /* No subobjects for all other types */
- }
-
- /*
- * Now we can update the count in the main object. This can only
- * happen after we update the sub-objects in case this causes the
- * main object to be deleted.
- */
- AcpiUtUpdateRefCount (Object, Action);
- Object = NULL;
-
- /* Move on to the next object to be updated */
-
- if (NextObject)
- {
- Object = NextObject;
- NextObject = NULL;
- }
- else if (StateList)
- {
- State = AcpiUtPopGenericState (&StateList);
- Object = State->Update.Object;
- AcpiUtDeleteGenericState (State);
- }
- }
-
- return_ACPI_STATUS (AE_OK);
-
-
-ErrorExit:
-
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Could not update object reference count"));
-
- /* Free any stacked Update State objects */
-
- while (StateList)
- {
- State = AcpiUtPopGenericState (&StateList);
- AcpiUtDeleteGenericState (State);
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAddReference
- *
- * PARAMETERS: Object - Object whose reference count is to be
- * incremented
- *
- * RETURN: None
- *
- * DESCRIPTION: Add one reference to an ACPI object
- *
- ******************************************************************************/
-
-void
-AcpiUtAddReference (
- ACPI_OPERAND_OBJECT *Object)
-{
-
- ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object);
-
-
- /* Ensure that we have a valid object */
-
- if (!AcpiUtValidInternalObject (Object))
- {
- return_VOID;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Obj %p Current Refs=%X [To Be Incremented]\n",
- Object, Object->Common.ReferenceCount));
-
- /* Increment the reference count */
-
- (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtRemoveReference
- *
- * PARAMETERS: Object - Object whose ref count will be decremented
- *
- * RETURN: None
- *
- * DESCRIPTION: Decrement the reference count of an ACPI internal object
- *
- ******************************************************************************/
-
-void
-AcpiUtRemoveReference (
- ACPI_OPERAND_OBJECT *Object)
-{
-
- ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object);
-
-
- /*
- * Allow a NULL pointer to be passed in, just ignore it. This saves
- * each caller from having to check. Also, ignore NS nodes.
- *
- */
- if (!Object ||
- (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED))
-
- {
- return_VOID;
- }
-
- /* Ensure that we have a valid object */
-
- if (!AcpiUtValidInternalObject (Object))
- {
- return_VOID;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
- "Obj %p Current Refs=%X [To Be Decremented]\n",
- Object, Object->Common.ReferenceCount));
-
- /*
- * Decrement the reference count, and only actually delete the object
- * if the reference count becomes 0. (Must also decrement the ref count
- * of all subobjects!)
- */
- (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT);
- return_VOID;
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/uteval.c
--- a/head/sys/contrib/dev/acpica/utilities/uteval.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,370 +0,0 @@
-/******************************************************************************
- *
- * Module Name: uteval - Object evaluation
- *
- *****************************************************************************/
-
-/*
- * 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 __UTEVAL_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("uteval")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtEvaluateObject
- *
- * PARAMETERS: PrefixNode - Starting node
- * Path - Path to object from starting node
- * ExpectedReturnTypes - Bitmap of allowed return types
- * ReturnDesc - Where a return value is stored
- *
- * RETURN: Status
- *
- * DESCRIPTION: Evaluates a namespace object and verifies the type of the
- * return object. Common code that simplifies accessing objects
- * that have required return objects of fixed types.
- *
- * NOTE: Internal function, no parameter validation
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtEvaluateObject (
- ACPI_NAMESPACE_NODE *PrefixNode,
- char *Path,
- UINT32 ExpectedReturnBtypes,
- ACPI_OPERAND_OBJECT **ReturnDesc)
-{
- ACPI_EVALUATE_INFO *Info;
- ACPI_STATUS Status;
- UINT32 ReturnBtype;
-
-
- ACPI_FUNCTION_TRACE (UtEvaluateObject);
-
-
- /* Allocate the evaluation information block */
-
- Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
- if (!Info)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- Info->PrefixNode = PrefixNode;
- Info->Pathname = Path;
-
- /* Evaluate the object/method */
-
- Status = AcpiNsEvaluate (Info);
- if (ACPI_FAILURE (Status))
- {
- if (Status == AE_NOT_FOUND)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
- AcpiUtGetNodeName (PrefixNode), Path));
- }
- else
- {
- ACPI_ERROR_METHOD ("Method execution failed",
- PrefixNode, Path, Status);
- }
-
- goto Cleanup;
- }
-
- /* Did we get a return object? */
-
- if (!Info->ReturnObject)
- {
- if (ExpectedReturnBtypes)
- {
- ACPI_ERROR_METHOD ("No object was returned from",
- PrefixNode, Path, AE_NOT_EXIST);
-
- Status = AE_NOT_EXIST;
- }
-
- goto Cleanup;
- }
-
- /* Map the return object type to the bitmapped type */
-
- switch ((Info->ReturnObject)->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- ReturnBtype = ACPI_BTYPE_INTEGER;
- break;
-
- case ACPI_TYPE_BUFFER:
- ReturnBtype = ACPI_BTYPE_BUFFER;
- break;
-
- case ACPI_TYPE_STRING:
- ReturnBtype = ACPI_BTYPE_STRING;
- break;
-
- case ACPI_TYPE_PACKAGE:
- ReturnBtype = ACPI_BTYPE_PACKAGE;
- break;
-
- default:
- ReturnBtype = 0;
- break;
- }
-
- if ((AcpiGbl_EnableInterpreterSlack) &&
- (!ExpectedReturnBtypes))
- {
- /*
- * We received a return object, but one was not expected. This can
- * happen frequently if the "implicit return" feature is enabled.
- * Just delete the return object and return AE_OK.
- */
- AcpiUtRemoveReference (Info->ReturnObject);
- goto Cleanup;
- }
-
- /* Is the return object one of the expected types? */
-
- if (!(ExpectedReturnBtypes & ReturnBtype))
- {
- ACPI_ERROR_METHOD ("Return object type is incorrect",
- PrefixNode, Path, AE_TYPE);
-
- ACPI_ERROR ((AE_INFO,
- "Type returned from %s was incorrect: %s, expected Btypes: 0x%X",
- Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
- ExpectedReturnBtypes));
-
- /* On error exit, we must delete the return object */
-
- AcpiUtRemoveReference (Info->ReturnObject);
- Status = AE_TYPE;
- goto Cleanup;
- }
-
- /* Object type is OK, return it */
-
- *ReturnDesc = Info->ReturnObject;
-
-Cleanup:
- ACPI_FREE (Info);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtEvaluateNumericObject
- *
- * PARAMETERS: ObjectName - Object name to be evaluated
- * DeviceNode - Node for the device
- * Value - Where the value is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Evaluates a numeric namespace object for a selected device
- * and stores result in *Value.
- *
- * NOTE: Internal function, no parameter validation
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtEvaluateNumericObject (
- char *ObjectName,
- ACPI_NAMESPACE_NODE *DeviceNode,
- UINT64 *Value)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
-
-
- Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
- ACPI_BTYPE_INTEGER, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Get the returned Integer */
-
- *Value = ObjDesc->Integer.Value;
-
- /* On exit, we must delete the return object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtExecute_STA
- *
- * PARAMETERS: DeviceNode - Node for the device
- * Flags - Where the status flags are returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Executes _STA for selected device and stores results in
- * *Flags.
- *
- * NOTE: Internal function, no parameter validation
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtExecute_STA (
- ACPI_NAMESPACE_NODE *DeviceNode,
- UINT32 *Flags)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtExecute_STA);
-
-
- Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
- ACPI_BTYPE_INTEGER, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- if (AE_NOT_FOUND == Status)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "_STA on %4.4s was not found, assuming device is present\n",
- AcpiUtGetNodeName (DeviceNode)));
-
- *Flags = ACPI_UINT32_MAX;
- Status = AE_OK;
- }
-
- return_ACPI_STATUS (Status);
- }
-
- /* Extract the status flags */
-
- *Flags = (UINT32) ObjDesc->Integer.Value;
-
- /* On exit, we must delete the return object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtExecutePowerMethods
- *
- * PARAMETERS: DeviceNode - Node for the device
- * MethodNames - Array of power method names
- * MethodCount - Number of methods to execute
- * OutValues - Where the power method values are returned
- *
- * RETURN: Status, OutValues
- *
- * DESCRIPTION: Executes the specified power methods for the device and returns
- * the result(s).
- *
- * NOTE: Internal function, no parameter validation
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtExecutePowerMethods (
- ACPI_NAMESPACE_NODE *DeviceNode,
- const char **MethodNames,
- UINT8 MethodCount,
- UINT8 *OutValues)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_STATUS Status;
- ACPI_STATUS FinalStatus = AE_NOT_FOUND;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (UtExecutePowerMethods);
-
-
- for (i = 0; i < MethodCount; i++)
- {
- /*
- * Execute the power method (_SxD or _SxW). The only allowable
- * return type is an Integer.
- */
- Status = AcpiUtEvaluateObject (DeviceNode,
- ACPI_CAST_PTR (char, MethodNames[i]),
- ACPI_BTYPE_INTEGER, &ObjDesc);
- if (ACPI_SUCCESS (Status))
- {
- OutValues[i] = (UINT8) ObjDesc->Integer.Value;
-
- /* Delete the return object */
-
- AcpiUtRemoveReference (ObjDesc);
- FinalStatus = AE_OK; /* At least one value is valid */
- continue;
- }
-
- OutValues[i] = ACPI_UINT8_MAX;
- if (Status == AE_NOT_FOUND)
- {
- continue; /* Ignore if not found */
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n",
- ACPI_CAST_PTR (char, MethodNames[i]),
- AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status)));
- }
-
- return_ACPI_STATUS (FinalStatus);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utglobal.c
--- a/head/sys/contrib/dev/acpica/utilities/utglobal.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,358 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utglobal - Global variables for the ACPI subsystem
- *
- *****************************************************************************/
-
-/*
- * 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 __UTGLOBAL_C__
-#define DEFINE_ACPI_GLOBALS
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utglobal")
-
-
-/*******************************************************************************
- *
- * Static global variable initialization.
- *
- ******************************************************************************/
-
-/*
- * We want the debug switches statically initialized so they
- * are already set when the debugger is entered.
- */
-
-/* Debug switch - level and trace mask */
-
-#ifdef ACPI_DEBUG_OUTPUT
-UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
-#else
-UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
-#endif
-
-/* Debug switch - layer (component) mask */
-
-UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
-UINT32 AcpiGbl_NestingLevel = 0;
-
-/* Debugger globals */
-
-BOOLEAN AcpiGbl_DbTerminateThreads = FALSE;
-BOOLEAN AcpiGbl_AbortMethod = FALSE;
-BOOLEAN AcpiGbl_MethodExecuting = FALSE;
-
-/* System flags */
-
-UINT32 AcpiGbl_StartupFlags = 0;
-
-/* System starts uninitialized */
-
-BOOLEAN AcpiGbl_Shutdown = TRUE;
-
-const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] =
-{
- "\\_S0_",
- "\\_S1_",
- "\\_S2_",
- "\\_S3_",
- "\\_S4_",
- "\\_S5_"
-};
-
-const char *AcpiGbl_LowestDstateNames[ACPI_NUM_SxW_METHODS] =
-{
- "_S0W",
- "_S1W",
- "_S2W",
- "_S3W",
- "_S4W"
-};
-
-const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] =
-{
- "_S1D",
- "_S2D",
- "_S3D",
- "_S4D"
-};
-
-
-/*******************************************************************************
- *
- * Namespace globals
- *
- ******************************************************************************/
-
-/*
- * Predefined ACPI Names (Built-in to the Interpreter)
- *
- * NOTES:
- * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
- * during the initialization sequence.
- * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
- * perform a Notify() operation on it. 09/2010: Changed to type Device.
- * This still allows notifies, but does not confuse host code that
- * searches for valid ThermalZone objects.
- */
-const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] =
-{
- {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
- {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
- {"_SB_", ACPI_TYPE_DEVICE, NULL},
- {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
- {"_TZ_", ACPI_TYPE_DEVICE, NULL},
- {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL},
- {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
- {"_GL_", ACPI_TYPE_MUTEX, (char *) 1},
-
-#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
- {"_OSI", ACPI_TYPE_METHOD, (char *) 1},
-#endif
-
- /* Table terminator */
-
- {NULL, ACPI_TYPE_ANY, NULL}
-};
-
-
-/******************************************************************************
- *
- * Event and Hardware globals
- *
- ******************************************************************************/
-
-ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] =
-{
- /* Name Parent Register Register Bit Position Register Bit Mask */
-
- /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS},
- /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS},
- /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS},
- /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS},
- /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS},
- /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS},
- /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS},
- /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS},
-
- /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE},
- /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
- /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE},
- /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
- /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE},
- /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
-
- /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE},
- /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD},
- /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
- /* ACPI_BITREG_SLEEP_TYPE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE, ACPI_BITMASK_SLEEP_TYPE},
- /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE},
-
- /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE}
-};
-
-
-ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
-{
- /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE},
- /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
- /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE},
- /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
- /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtInitGlobals
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Init ACPICA globals. All globals that require specific
- * initialization should be initialized here!
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtInitGlobals (
- void)
-{
- ACPI_STATUS Status;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (UtInitGlobals);
-
-
- /* Create all memory caches */
-
- Status = AcpiUtCreateCaches ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Address Range lists */
-
- for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
- {
- AcpiGbl_AddressRangeList[i] = NULL;
- }
-
- /* Mutex locked flags */
-
- for (i = 0; i < ACPI_NUM_MUTEX; i++)
- {
- AcpiGbl_MutexInfo[i].Mutex = NULL;
- AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
- AcpiGbl_MutexInfo[i].UseCount = 0;
- }
-
- for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++)
- {
- AcpiGbl_OwnerIdMask[i] = 0;
- }
-
- /* Last OwnerID is never valid */
-
- AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
-
- /* Event counters */
-
- AcpiMethodCount = 0;
- AcpiSciCount = 0;
- AcpiGpeCount = 0;
-
- for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
- {
- AcpiFixedEventCount[i] = 0;
- }
-
- /* GPE support */
-
- AcpiGbl_AllGpesInitialized = FALSE;
- AcpiGbl_GpeXruptListHead = NULL;
- AcpiGbl_GpeFadtBlocks[0] = NULL;
- AcpiGbl_GpeFadtBlocks[1] = NULL;
- AcpiCurrentGpeCount = 0;
-
- /* Global handlers */
-
- AcpiGbl_SystemNotify.Handler = NULL;
- AcpiGbl_DeviceNotify.Handler = NULL;
- AcpiGbl_ExceptionHandler = NULL;
- AcpiGbl_InitHandler = NULL;
- AcpiGbl_TableHandler = NULL;
- AcpiGbl_InterfaceHandler = NULL;
- AcpiGbl_GlobalEventHandler = NULL;
-
- /* Global Lock support */
-
- AcpiGbl_GlobalLockSemaphore = NULL;
- AcpiGbl_GlobalLockMutex = NULL;
- AcpiGbl_GlobalLockAcquired = FALSE;
- AcpiGbl_GlobalLockHandle = 0;
- AcpiGbl_GlobalLockPresent = FALSE;
-
- /* Miscellaneous variables */
-
- AcpiGbl_DSDT = NULL;
- AcpiGbl_CmSingleStep = FALSE;
- AcpiGbl_DbTerminateThreads = FALSE;
- AcpiGbl_Shutdown = FALSE;
- AcpiGbl_NsLookupCount = 0;
- AcpiGbl_PsFindCount = 0;
- AcpiGbl_AcpiHardwarePresent = TRUE;
- AcpiGbl_LastOwnerIdIndex = 0;
- AcpiGbl_NextOwnerIdOffset = 0;
- AcpiGbl_TraceMethodName = 0;
- AcpiGbl_TraceDbgLevel = 0;
- AcpiGbl_TraceDbgLayer = 0;
- AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
- AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
- AcpiGbl_OsiData = 0;
- AcpiGbl_OsiMutex = NULL;
- AcpiGbl_RegMethodsExecuted = FALSE;
-
- /* Hardware oriented */
-
- AcpiGbl_EventsInitialized = FALSE;
- AcpiGbl_SystemAwakeAndRunning = TRUE;
-
- /* Namespace */
-
- AcpiGbl_ModuleCodeList = NULL;
- AcpiGbl_RootNode = NULL;
- AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
- AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
- AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
- AcpiGbl_RootNodeStruct.Parent = NULL;
- AcpiGbl_RootNodeStruct.Child = NULL;
- AcpiGbl_RootNodeStruct.Peer = NULL;
- AcpiGbl_RootNodeStruct.Object = NULL;
-
-
-#ifdef ACPI_DISASSEMBLER
- AcpiGbl_ExternalList = NULL;
-#endif
-
-#ifdef ACPI_DEBUG_OUTPUT
- AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX);
-#endif
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- AcpiGbl_DisplayFinalMemStats = FALSE;
- AcpiGbl_DisableMemTracking = FALSE;
-#endif
-
- return_ACPI_STATUS (AE_OK);
-}
-
-/* Public globals */
-
-ACPI_EXPORT_SYMBOL (AcpiGbl_FADT)
-ACPI_EXPORT_SYMBOL (AcpiDbgLevel)
-ACPI_EXPORT_SYMBOL (AcpiDbgLayer)
-ACPI_EXPORT_SYMBOL (AcpiGpeCount)
-ACPI_EXPORT_SYMBOL (AcpiCurrentGpeCount)
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utids.c
--- a/head/sys/contrib/dev/acpica/utilities/utids.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,380 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utids - support for device IDs - HID, UID, CID
- *
- *****************************************************************************/
-
-/*
- * 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 __UTIDS_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utids")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtExecute_HID
- *
- * PARAMETERS: DeviceNode - Node for the device
- * ReturnId - Where the string HID is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Executes the _HID control method that returns the hardware
- * ID of the device. The HID is either an 32-bit encoded EISAID
- * Integer or a String. A string is always returned. An EISAID
- * is converted to a string.
- *
- * NOTE: Internal function, no parameter validation
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtExecute_HID (
- ACPI_NAMESPACE_NODE *DeviceNode,
- ACPI_DEVICE_ID **ReturnId)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_DEVICE_ID *Hid;
- UINT32 Length;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtExecute_HID);
-
-
- Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
- ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Get the size of the String to be returned, includes null terminator */
-
- if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
- {
- Length = ACPI_EISAID_STRING_SIZE;
- }
- else
- {
- Length = ObjDesc->String.Length + 1;
- }
-
- /* Allocate a buffer for the HID */
-
- Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length);
- if (!Hid)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Area for the string starts after DEVICE_ID struct */
-
- Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_DEVICE_ID));
-
- /* Convert EISAID to a string or simply copy existing string */
-
- if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
- {
- AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value);
- }
- else
- {
- ACPI_STRCPY (Hid->String, ObjDesc->String.Pointer);
- }
-
- Hid->Length = Length;
- *ReturnId = Hid;
-
-
-Cleanup:
-
- /* On exit, we must delete the return object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtExecute_UID
- *
- * PARAMETERS: DeviceNode - Node for the device
- * ReturnId - Where the string UID is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Executes the _UID control method that returns the unique
- * ID of the device. The UID is either a 64-bit Integer (NOT an
- * EISAID) or a string. Always returns a string. A 64-bit integer
- * is converted to a decimal string.
- *
- * NOTE: Internal function, no parameter validation
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtExecute_UID (
- ACPI_NAMESPACE_NODE *DeviceNode,
- ACPI_DEVICE_ID **ReturnId)
-{
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_DEVICE_ID *Uid;
- UINT32 Length;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtExecute_UID);
-
-
- Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
- ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Get the size of the String to be returned, includes null terminator */
-
- if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
- {
- Length = ACPI_MAX64_DECIMAL_DIGITS + 1;
- }
- else
- {
- Length = ObjDesc->String.Length + 1;
- }
-
- /* Allocate a buffer for the UID */
-
- Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_ID) + (ACPI_SIZE) Length);
- if (!Uid)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Area for the string starts after DEVICE_ID struct */
-
- Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_DEVICE_ID));
-
- /* Convert an Integer to string, or just copy an existing string */
-
- if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
- {
- AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value);
- }
- else
- {
- ACPI_STRCPY (Uid->String, ObjDesc->String.Pointer);
- }
-
- Uid->Length = Length;
- *ReturnId = Uid;
-
-
-Cleanup:
-
- /* On exit, we must delete the return object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtExecute_CID
- *
- * PARAMETERS: DeviceNode - Node for the device
- * ReturnCidList - Where the CID list is returned
- *
- * RETURN: Status, list of CID strings
- *
- * DESCRIPTION: Executes the _CID control method that returns one or more
- * compatible hardware IDs for the device.
- *
- * NOTE: Internal function, no parameter validation
- *
- * A _CID method can return either a single compatible ID or a package of
- * compatible IDs. Each compatible ID can be one of the following:
- * 1) Integer (32 bit compressed EISA ID) or
- * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
- *
- * The Integer CIDs are converted to string format by this function.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtExecute_CID (
- ACPI_NAMESPACE_NODE *DeviceNode,
- ACPI_DEVICE_ID_LIST **ReturnCidList)
-{
- ACPI_OPERAND_OBJECT **CidObjects;
- ACPI_OPERAND_OBJECT *ObjDesc;
- ACPI_DEVICE_ID_LIST *CidList;
- char *NextIdString;
- UINT32 StringAreaSize;
- UINT32 Length;
- UINT32 CidListSize;
- ACPI_STATUS Status;
- UINT32 Count;
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (UtExecute_CID);
-
-
- /* Evaluate the _CID method for this device */
-
- Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
- ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
- &ObjDesc);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Get the count and size of the returned _CIDs. _CID can return either
- * a Package of Integers/Strings or a single Integer or String.
- * Note: This section also validates that all CID elements are of the
- * correct type (Integer or String).
- */
- if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
- {
- Count = ObjDesc->Package.Count;
- CidObjects = ObjDesc->Package.Elements;
- }
- else /* Single Integer or String CID */
- {
- Count = 1;
- CidObjects = &ObjDesc;
- }
-
- StringAreaSize = 0;
- for (i = 0; i < Count; i++)
- {
- /* String lengths include null terminator */
-
- switch (CidObjects[i]->Common.Type)
- {
- case ACPI_TYPE_INTEGER:
- StringAreaSize += ACPI_EISAID_STRING_SIZE;
- break;
-
- case ACPI_TYPE_STRING:
- StringAreaSize += CidObjects[i]->String.Length + 1;
- break;
-
- default:
- Status = AE_TYPE;
- goto Cleanup;
- }
- }
-
- /*
- * Now that we know the length of the CIDs, allocate return buffer:
- * 1) Size of the base structure +
- * 2) Size of the CID DEVICE_ID array +
- * 3) Size of the actual CID strings
- */
- CidListSize = sizeof (ACPI_DEVICE_ID_LIST) +
- ((Count - 1) * sizeof (ACPI_DEVICE_ID)) +
- StringAreaSize;
-
- CidList = ACPI_ALLOCATE_ZEROED (CidListSize);
- if (!CidList)
- {
- Status = AE_NO_MEMORY;
- goto Cleanup;
- }
-
- /* Area for CID strings starts after the CID DEVICE_ID array */
-
- NextIdString = ACPI_CAST_PTR (char, CidList->Ids) +
- ((ACPI_SIZE) Count * sizeof (ACPI_DEVICE_ID));
-
- /* Copy/convert the CIDs to the return buffer */
-
- for (i = 0; i < Count; i++)
- {
- if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER)
- {
- /* Convert the Integer (EISAID) CID to a string */
-
- AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value);
- Length = ACPI_EISAID_STRING_SIZE;
- }
- else /* ACPI_TYPE_STRING */
- {
- /* Copy the String CID from the returned object */
-
- ACPI_STRCPY (NextIdString, CidObjects[i]->String.Pointer);
- Length = CidObjects[i]->String.Length + 1;
- }
-
- CidList->Ids[i].String = NextIdString;
- CidList->Ids[i].Length = Length;
- NextIdString += Length;
- }
-
- /* Finish the CID list */
-
- CidList->Count = Count;
- CidList->ListSize = CidListSize;
- *ReturnCidList = CidList;
-
-
-Cleanup:
-
- /* On exit, we must delete the _CID return object */
-
- AcpiUtRemoveReference (ObjDesc);
- return_ACPI_STATUS (Status);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utinit.c
--- a/head/sys/contrib/dev/acpica/utilities/utinit.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utinit - Common ACPI subsystem 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.
- */
-
-
-#define __UTINIT_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/actables.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utinit")
-
-/* Local prototypes */
-
-static void AcpiUtTerminate (
- void);
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiUtTerminate
- *
- * PARAMETERS: none
- *
- * RETURN: none
- *
- * DESCRIPTION: Free global memory
- *
- ******************************************************************************/
-
-static void
-AcpiUtTerminate (
- void)
-{
- ACPI_GPE_BLOCK_INFO *GpeBlock;
- ACPI_GPE_BLOCK_INFO *NextGpeBlock;
- ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
- ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo;
-
-
- ACPI_FUNCTION_TRACE (UtTerminate);
-
-
- /* Free global GPE blocks and related info structures */
-
- GpeXruptInfo = AcpiGbl_GpeXruptListHead;
- while (GpeXruptInfo)
- {
- GpeBlock = GpeXruptInfo->GpeBlockListHead;
- while (GpeBlock)
- {
- NextGpeBlock = GpeBlock->Next;
- ACPI_FREE (GpeBlock->EventInfo);
- ACPI_FREE (GpeBlock->RegisterInfo);
- ACPI_FREE (GpeBlock);
-
- GpeBlock = NextGpeBlock;
- }
- NextGpeXruptInfo = GpeXruptInfo->Next;
- ACPI_FREE (GpeXruptInfo);
- GpeXruptInfo = NextGpeXruptInfo;
- }
-
- AcpiUtDeleteAddressLists ();
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtSubsystemShutdown
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Shutdown the various components. Do not delete the mutex
- * objects here, because the AML debugger may be still running.
- *
- ******************************************************************************/
-
-void
-AcpiUtSubsystemShutdown (
- void)
-{
- ACPI_FUNCTION_TRACE (UtSubsystemShutdown);
-
-
-#ifndef ACPI_ASL_COMPILER
-
- /* Close the AcpiEvent Handling */
-
- AcpiEvTerminate ();
-
- /* Delete any dynamic _OSI interfaces */
-
- AcpiUtInterfaceTerminate ();
-#endif
-
- /* Close the Namespace */
-
- AcpiNsTerminate ();
-
- /* Delete the ACPI tables */
-
- AcpiTbTerminate ();
-
- /* Close the globals */
-
- AcpiUtTerminate ();
-
- /* Purge the local caches */
-
- (void) AcpiUtDeleteCaches ();
- return_VOID;
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utlock.c
--- a/head/sys/contrib/dev/acpica/utilities/utlock.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utlock - Reader/Writer lock 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.
- */
-
-#define __UTLOCK_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utlock")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateRwLock
- * AcpiUtDeleteRwLock
- *
- * PARAMETERS: Lock - Pointer to a valid RW lock
- *
- * RETURN: Status
- *
- * DESCRIPTION: Reader/writer lock creation and deletion interfaces.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCreateRwLock (
- ACPI_RW_LOCK *Lock)
-{
- ACPI_STATUS Status;
-
-
- Lock->NumReaders = 0;
- Status = AcpiOsCreateMutex (&Lock->ReaderMutex);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Status = AcpiOsCreateMutex (&Lock->WriterMutex);
- return (Status);
-}
-
-
-void
-AcpiUtDeleteRwLock (
- ACPI_RW_LOCK *Lock)
-{
-
- AcpiOsDeleteMutex (Lock->ReaderMutex);
- AcpiOsDeleteMutex (Lock->WriterMutex);
-
- Lock->NumReaders = 0;
- Lock->ReaderMutex = NULL;
- Lock->WriterMutex = NULL;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAcquireReadLock
- * AcpiUtReleaseReadLock
- *
- * PARAMETERS: Lock - Pointer to a valid RW lock
- *
- * RETURN: Status
- *
- * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition,
- * only the first reader acquires the write mutex. On release,
- * only the last reader releases the write mutex. Although this
- * algorithm can in theory starve writers, this should not be a
- * problem with ACPICA since the subsystem is infrequently used
- * in comparison to (for example) an I/O system.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtAcquireReadLock (
- ACPI_RW_LOCK *Lock)
-{
- ACPI_STATUS Status;
-
-
- Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Acquire the write lock only for the first reader */
-
- Lock->NumReaders++;
- if (Lock->NumReaders == 1)
- {
- Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER);
- }
-
- AcpiOsReleaseMutex (Lock->ReaderMutex);
- return (Status);
-}
-
-
-ACPI_STATUS
-AcpiUtReleaseReadLock (
- ACPI_RW_LOCK *Lock)
-{
- ACPI_STATUS Status;
-
-
- Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Release the write lock only for the very last reader */
-
- Lock->NumReaders--;
- if (Lock->NumReaders == 0)
- {
- AcpiOsReleaseMutex (Lock->WriterMutex);
- }
-
- AcpiOsReleaseMutex (Lock->ReaderMutex);
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAcquireWriteLock
- * AcpiUtReleaseWriteLock
- *
- * PARAMETERS: Lock - Pointer to a valid RW lock
- *
- * RETURN: Status
- *
- * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or
- * release the writer mutex associated with the lock. Acquisition
- * of the lock is fully exclusive and will block all readers and
- * writers until it is released.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtAcquireWriteLock (
- ACPI_RW_LOCK *Lock)
-{
- ACPI_STATUS Status;
-
-
- Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER);
- return (Status);
-}
-
-
-void
-AcpiUtReleaseWriteLock (
- ACPI_RW_LOCK *Lock)
-{
-
- AcpiOsReleaseMutex (Lock->WriterMutex);
-}
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utmath.c
--- a/head/sys/contrib/dev/acpica/utilities/utmath.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,379 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utmath - Integer math support 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 __UTMATH_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utmath")
-
-/*
- * Optional support for 64-bit double-precision integer divide. This code
- * is configurable and is implemented in order to support 32-bit kernel
- * environments where a 64-bit double-precision math library is not available.
- *
- * Support for a more normal 64-bit divide/modulo (with check for a divide-
- * by-zero) appears after this optional section of code.
- */
-#ifndef ACPI_USE_NATIVE_DIVIDE
-
-/* Structures used only for 64-bit divide */
-
-typedef struct uint64_struct
-{
- UINT32 Lo;
- UINT32 Hi;
-
-} UINT64_STRUCT;
-
-typedef union uint64_overlay
-{
- UINT64 Full;
- UINT64_STRUCT Part;
-
-} UINT64_OVERLAY;
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtShortDivide
- *
- * PARAMETERS: Dividend - 64-bit dividend
- * Divisor - 32-bit divisor
- * OutQuotient - Pointer to where the quotient is returned
- * OutRemainder - Pointer to where the remainder is returned
- *
- * RETURN: Status (Checks for divide-by-zero)
- *
- * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
- * divide and modulo. The result is a 64-bit quotient and a
- * 32-bit remainder.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtShortDivide (
- UINT64 Dividend,
- UINT32 Divisor,
- UINT64 *OutQuotient,
- UINT32 *OutRemainder)
-{
- UINT64_OVERLAY DividendOvl;
- UINT64_OVERLAY Quotient;
- UINT32 Remainder32;
-
-
- ACPI_FUNCTION_TRACE (UtShortDivide);
-
-
- /* Always check for a zero divisor */
-
- if (Divisor == 0)
- {
- ACPI_ERROR ((AE_INFO, "Divide by zero"));
- return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
- }
-
- DividendOvl.Full = Dividend;
-
- /*
- * The quotient is 64 bits, the remainder is always 32 bits,
- * and is generated by the second divide.
- */
- ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor,
- Quotient.Part.Hi, Remainder32);
- ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor,
- Quotient.Part.Lo, Remainder32);
-
- /* Return only what was requested */
-
- if (OutQuotient)
- {
- *OutQuotient = Quotient.Full;
- }
- if (OutRemainder)
- {
- *OutRemainder = Remainder32;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDivide
- *
- * PARAMETERS: InDividend - Dividend
- * InDivisor - Divisor
- * OutQuotient - Pointer to where the quotient is returned
- * OutRemainder - Pointer to where the remainder is returned
- *
- * RETURN: Status (Checks for divide-by-zero)
- *
- * DESCRIPTION: Perform a divide and modulo.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtDivide (
- UINT64 InDividend,
- UINT64 InDivisor,
- UINT64 *OutQuotient,
- UINT64 *OutRemainder)
-{
- UINT64_OVERLAY Dividend;
- UINT64_OVERLAY Divisor;
- UINT64_OVERLAY Quotient;
- UINT64_OVERLAY Remainder;
- UINT64_OVERLAY NormalizedDividend;
- UINT64_OVERLAY NormalizedDivisor;
- UINT32 Partial1;
- UINT64_OVERLAY Partial2;
- UINT64_OVERLAY Partial3;
-
-
- ACPI_FUNCTION_TRACE (UtDivide);
-
-
- /* Always check for a zero divisor */
-
- if (InDivisor == 0)
- {
- ACPI_ERROR ((AE_INFO, "Divide by zero"));
- return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
- }
-
- Divisor.Full = InDivisor;
- Dividend.Full = InDividend;
- if (Divisor.Part.Hi == 0)
- {
- /*
- * 1) Simplest case is where the divisor is 32 bits, we can
- * just do two divides
- */
- Remainder.Part.Hi = 0;
-
- /*
- * The quotient is 64 bits, the remainder is always 32 bits,
- * and is generated by the second divide.
- */
- ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo,
- Quotient.Part.Hi, Partial1);
- ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo,
- Quotient.Part.Lo, Remainder.Part.Lo);
- }
-
- else
- {
- /*
- * 2) The general case where the divisor is a full 64 bits
- * is more difficult
- */
- Quotient.Part.Hi = 0;
- NormalizedDividend = Dividend;
- NormalizedDivisor = Divisor;
-
- /* Normalize the operands (shift until the divisor is < 32 bits) */
-
- do
- {
- ACPI_SHIFT_RIGHT_64 (NormalizedDivisor.Part.Hi,
- NormalizedDivisor.Part.Lo);
- ACPI_SHIFT_RIGHT_64 (NormalizedDividend.Part.Hi,
- NormalizedDividend.Part.Lo);
-
- } while (NormalizedDivisor.Part.Hi != 0);
-
- /* Partial divide */
-
- ACPI_DIV_64_BY_32 (NormalizedDividend.Part.Hi,
- NormalizedDividend.Part.Lo,
- NormalizedDivisor.Part.Lo,
- Quotient.Part.Lo, Partial1);
-
- /*
- * The quotient is always 32 bits, and simply requires adjustment.
- * The 64-bit remainder must be generated.
- */
- Partial1 = Quotient.Part.Lo * Divisor.Part.Hi;
- Partial2.Full = (UINT64) Quotient.Part.Lo * Divisor.Part.Lo;
- Partial3.Full = (UINT64) Partial2.Part.Hi + Partial1;
-
- Remainder.Part.Hi = Partial3.Part.Lo;
- Remainder.Part.Lo = Partial2.Part.Lo;
-
- if (Partial3.Part.Hi == 0)
- {
- if (Partial3.Part.Lo >= Dividend.Part.Hi)
- {
- if (Partial3.Part.Lo == Dividend.Part.Hi)
- {
- if (Partial2.Part.Lo > Dividend.Part.Lo)
- {
- Quotient.Part.Lo--;
- Remainder.Full -= Divisor.Full;
- }
- }
- else
- {
- Quotient.Part.Lo--;
- Remainder.Full -= Divisor.Full;
- }
- }
-
- Remainder.Full = Remainder.Full - Dividend.Full;
- Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi);
- Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo);
-
- if (Remainder.Part.Lo)
- {
- Remainder.Part.Hi--;
- }
- }
- }
-
- /* Return only what was requested */
-
- if (OutQuotient)
- {
- *OutQuotient = Quotient.Full;
- }
- if (OutRemainder)
- {
- *OutRemainder = Remainder.Full;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-#else
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtShortDivide, AcpiUtDivide
- *
- * PARAMETERS: See function headers above
- *
- * DESCRIPTION: Native versions of the UtDivide functions. Use these if either
- * 1) The target is a 64-bit platform and therefore 64-bit
- * integer math is supported directly by the machine.
- * 2) The target is a 32-bit or 16-bit platform, and the
- * double-precision integer math library is available to
- * perform the divide.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtShortDivide (
- UINT64 InDividend,
- UINT32 Divisor,
- UINT64 *OutQuotient,
- UINT32 *OutRemainder)
-{
-
- ACPI_FUNCTION_TRACE (UtShortDivide);
-
-
- /* Always check for a zero divisor */
-
- if (Divisor == 0)
- {
- ACPI_ERROR ((AE_INFO, "Divide by zero"));
- return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
- }
-
- /* Return only what was requested */
-
- if (OutQuotient)
- {
- *OutQuotient = InDividend / Divisor;
- }
- if (OutRemainder)
- {
- *OutRemainder = (UINT32) (InDividend % Divisor);
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_STATUS
-AcpiUtDivide (
- UINT64 InDividend,
- UINT64 InDivisor,
- UINT64 *OutQuotient,
- UINT64 *OutRemainder)
-{
- ACPI_FUNCTION_TRACE (UtDivide);
-
-
- /* Always check for a zero divisor */
-
- if (InDivisor == 0)
- {
- ACPI_ERROR ((AE_INFO, "Divide by zero"));
- return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
- }
-
-
- /* Return only what was requested */
-
- if (OutQuotient)
- {
- *OutQuotient = InDividend / InDivisor;
- }
- if (OutRemainder)
- {
- *OutRemainder = InDividend % InDivisor;
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-
-#endif
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utmisc.c
--- a/head/sys/contrib/dev/acpica/utilities/utmisc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1299 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utmisc - common utility procedures
- *
- ******************************************************************************/
-
-/*
- * 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 __UTMISC_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utmisc")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValidateException
- *
- * PARAMETERS: Status - The ACPI_STATUS code to be formatted
- *
- * RETURN: A string containing the exception text. NULL if exception is
- * not valid.
- *
- * DESCRIPTION: This function validates and translates an ACPI exception into
- * an ASCII string.
- *
- ******************************************************************************/
-
-const char *
-AcpiUtValidateException (
- ACPI_STATUS Status)
-{
- UINT32 SubStatus;
- const char *Exception = NULL;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * Status is composed of two parts, a "type" and an actual code
- */
- SubStatus = (Status & ~AE_CODE_MASK);
-
- switch (Status & AE_CODE_MASK)
- {
- case AE_CODE_ENVIRONMENTAL:
-
- if (SubStatus <= AE_CODE_ENV_MAX)
- {
- Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
- }
- break;
-
- case AE_CODE_PROGRAMMER:
-
- if (SubStatus <= AE_CODE_PGM_MAX)
- {
- Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus];
- }
- break;
-
- case AE_CODE_ACPI_TABLES:
-
- if (SubStatus <= AE_CODE_TBL_MAX)
- {
- Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus];
- }
- break;
-
- case AE_CODE_AML:
-
- if (SubStatus <= AE_CODE_AML_MAX)
- {
- Exception = AcpiGbl_ExceptionNames_Aml [SubStatus];
- }
- break;
-
- case AE_CODE_CONTROL:
-
- if (SubStatus <= AE_CODE_CTRL_MAX)
- {
- Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus];
- }
- break;
-
- default:
- break;
- }
-
- return (ACPI_CAST_PTR (const char, Exception));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtIsPciRootBridge
- *
- * PARAMETERS: Id - The HID/CID in string format
- *
- * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
- *
- * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiUtIsPciRootBridge (
- char *Id)
-{
-
- /*
- * Check if this is a PCI root bridge.
- * ACPI 3.0+: check for a PCI Express root also.
- */
- if (!(ACPI_STRCMP (Id,
- PCI_ROOT_HID_STRING)) ||
-
- !(ACPI_STRCMP (Id,
- PCI_EXPRESS_ROOT_HID_STRING)))
- {
- return (TRUE);
- }
-
- return (FALSE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtIsAmlTable
- *
- * PARAMETERS: Table - An ACPI table
- *
- * RETURN: TRUE if table contains executable AML; FALSE otherwise
- *
- * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
- * Currently, these are DSDT,SSDT,PSDT. All other table types are
- * data tables that do not contain AML code.
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiUtIsAmlTable (
- ACPI_TABLE_HEADER *Table)
-{
-
- /* These are the only tables that contain executable AML */
-
- if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
- ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
- ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
- {
- return (TRUE);
- }
-
- return (FALSE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocateOwnerId
- *
- * PARAMETERS: OwnerId - Where the new owner ID is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
- * track objects created by the table or method, to be deleted
- * when the method exits or the table is unloaded.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtAllocateOwnerId (
- ACPI_OWNER_ID *OwnerId)
-{
- UINT32 i;
- UINT32 j;
- UINT32 k;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
-
-
- /* Guard against multiple allocations of ID to the same location */
-
- if (*OwnerId)
- {
- ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId));
- return_ACPI_STATUS (AE_ALREADY_EXISTS);
- }
-
- /* Mutex for the global ID mask */
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Find a free owner ID, cycle through all possible IDs on repeated
- * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
- * to be scanned twice.
- */
- for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
- i < (ACPI_NUM_OWNERID_MASKS + 1);
- i++, j++)
- {
- if (j >= ACPI_NUM_OWNERID_MASKS)
- {
- j = 0; /* Wraparound to start of mask array */
- }
-
- for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
- {
- if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
- {
- /* There are no free IDs in this mask */
-
- break;
- }
-
- if (!(AcpiGbl_OwnerIdMask[j] & (1 << k)))
- {
- /*
- * Found a free ID. The actual ID is the bit index plus one,
- * making zero an invalid Owner ID. Save this as the last ID
- * allocated and update the global ID mask.
- */
- AcpiGbl_OwnerIdMask[j] |= (1 << k);
-
- AcpiGbl_LastOwnerIdIndex = (UINT8) j;
- AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
-
- /*
- * Construct encoded ID from the index and bit position
- *
- * Note: Last [j].k (bit 255) is never used and is marked
- * permanently allocated (prevents +1 overflow)
- */
- *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
-
- ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
- "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId));
- goto Exit;
- }
- }
-
- AcpiGbl_NextOwnerIdOffset = 0;
- }
-
- /*
- * All OwnerIds have been allocated. This typically should
- * not happen since the IDs are reused after deallocation. The IDs are
- * allocated upon table load (one per table) and method execution, and
- * they are released when a table is unloaded or a method completes
- * execution.
- *
- * If this error happens, there may be very deep nesting of invoked control
- * methods, or there may be a bug where the IDs are not released.
- */
- Status = AE_OWNER_ID_LIMIT;
- ACPI_ERROR ((AE_INFO,
- "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
-
-Exit:
- (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtReleaseOwnerId
- *
- * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID
- *
- * RETURN: None. No error is returned because we are either exiting a
- * control method or unloading a table. Either way, we would
- * ignore any error anyway.
- *
- * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
- *
- ******************************************************************************/
-
-void
-AcpiUtReleaseOwnerId (
- ACPI_OWNER_ID *OwnerIdPtr)
-{
- ACPI_OWNER_ID OwnerId = *OwnerIdPtr;
- ACPI_STATUS Status;
- UINT32 Index;
- UINT32 Bit;
-
-
- ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
-
-
- /* Always clear the input OwnerId (zero is an invalid ID) */
-
- *OwnerIdPtr = 0;
-
- /* Zero is not a valid OwnerID */
-
- if (OwnerId == 0)
- {
- ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%2.2X", OwnerId));
- return_VOID;
- }
-
- /* Mutex for the global ID mask */
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
- if (ACPI_FAILURE (Status))
- {
- return_VOID;
- }
-
- /* Normalize the ID to zero */
-
- OwnerId--;
-
- /* Decode ID to index/offset pair */
-
- Index = ACPI_DIV_32 (OwnerId);
- Bit = 1 << ACPI_MOD_32 (OwnerId);
-
- /* Free the owner ID only if it is valid */
-
- if (AcpiGbl_OwnerIdMask[Index] & Bit)
- {
- AcpiGbl_OwnerIdMask[Index] ^= Bit;
- }
- else
- {
- ACPI_ERROR ((AE_INFO,
- "Release of non-allocated OwnerId: 0x%2.2X", OwnerId + 1));
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtStrupr (strupr)
- *
- * PARAMETERS: SrcString - The source string to convert
- *
- * RETURN: None
- *
- * DESCRIPTION: Convert string to uppercase
- *
- * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
- *
- ******************************************************************************/
-
-void
-AcpiUtStrupr (
- char *SrcString)
-{
- char *String;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!SrcString)
- {
- return;
- }
-
- /* Walk entire string, uppercasing the letters */
-
- for (String = SrcString; *String; String++)
- {
- *String = (char) ACPI_TOUPPER (*String);
- }
-
- return;
-}
-
-
-#ifdef ACPI_ASL_COMPILER
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtStrlwr (strlwr)
- *
- * PARAMETERS: SrcString - The source string to convert
- *
- * RETURN: None
- *
- * DESCRIPTION: Convert string to lowercase
- *
- * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
- *
- ******************************************************************************/
-
-void
-AcpiUtStrlwr (
- char *SrcString)
-{
- char *String;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if (!SrcString)
- {
- return;
- }
-
- /* Walk entire string, lowercasing the letters */
-
- for (String = SrcString; *String; String++)
- {
- *String = (char) ACPI_TOLOWER (*String);
- }
-
- return;
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiUtStricmp
- *
- * PARAMETERS: String1 - first string to compare
- * String2 - second string to compare
- *
- * RETURN: int that signifies string relationship. Zero means strings
- * are equal.
- *
- * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
- * strings with no case sensitivity)
- *
- ******************************************************************************/
-
-int
-AcpiUtStricmp (
- char *String1,
- char *String2)
-{
- int c1;
- int c2;
-
-
- do
- {
- c1 = tolower ((int) *String1);
- c2 = tolower ((int) *String2);
-
- String1++;
- String2++;
- }
- while ((c1 == c2) && (c1));
-
- return (c1 - c2);
-}
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtPrintString
- *
- * PARAMETERS: String - Null terminated ASCII string
- * MaxLength - Maximum output length
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
- * sequences.
- *
- ******************************************************************************/
-
-void
-AcpiUtPrintString (
- char *String,
- UINT8 MaxLength)
-{
- UINT32 i;
-
-
- if (!String)
- {
- AcpiOsPrintf ("<\"NULL STRING PTR\">");
- return;
- }
-
- AcpiOsPrintf ("\"");
- for (i = 0; String[i] && (i < MaxLength); i++)
- {
- /* Escape sequences */
-
- switch (String[i])
- {
- case 0x07:
- AcpiOsPrintf ("\\a"); /* BELL */
- break;
-
- case 0x08:
- AcpiOsPrintf ("\\b"); /* BACKSPACE */
- break;
-
- case 0x0C:
- AcpiOsPrintf ("\\f"); /* FORMFEED */
- break;
-
- case 0x0A:
- AcpiOsPrintf ("\\n"); /* LINEFEED */
- break;
-
- case 0x0D:
- AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/
- break;
-
- case 0x09:
- AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */
- break;
-
- case 0x0B:
- AcpiOsPrintf ("\\v"); /* VERTICAL TAB */
- break;
-
- case '\'': /* Single Quote */
- case '\"': /* Double Quote */
- case '\\': /* Backslash */
- AcpiOsPrintf ("\\%c", (int) String[i]);
- break;
-
- default:
-
- /* Check for printable character or hex escape */
-
- if (ACPI_IS_PRINT (String[i]))
- {
- /* This is a normal character */
-
- AcpiOsPrintf ("%c", (int) String[i]);
- }
- else
- {
- /* All others will be Hex escapes */
-
- AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
- }
- break;
- }
- }
- AcpiOsPrintf ("\"");
-
- if (i == MaxLength && String[i])
- {
- AcpiOsPrintf ("...");
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDwordByteSwap
- *
- * PARAMETERS: Value - Value to be converted
- *
- * RETURN: UINT32 integer with bytes swapped
- *
- * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
- *
- ******************************************************************************/
-
-UINT32
-AcpiUtDwordByteSwap (
- UINT32 Value)
-{
- union
- {
- UINT32 Value;
- UINT8 Bytes[4];
- } Out;
- union
- {
- UINT32 Value;
- UINT8 Bytes[4];
- } In;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- In.Value = Value;
-
- Out.Bytes[0] = In.Bytes[3];
- Out.Bytes[1] = In.Bytes[2];
- Out.Bytes[2] = In.Bytes[1];
- Out.Bytes[3] = In.Bytes[0];
-
- return (Out.Value);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtSetIntegerWidth
- *
- * PARAMETERS: Revision From DSDT header
- *
- * RETURN: None
- *
- * DESCRIPTION: Set the global integer bit width based upon the revision
- * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
- * For Revision 2 and above, Integers are 64 bits. Yes, this
- * makes a difference.
- *
- ******************************************************************************/
-
-void
-AcpiUtSetIntegerWidth (
- UINT8 Revision)
-{
-
- if (Revision < 2)
- {
- /* 32-bit case */
-
- AcpiGbl_IntegerBitWidth = 32;
- AcpiGbl_IntegerNybbleWidth = 8;
- AcpiGbl_IntegerByteWidth = 4;
- }
- else
- {
- /* 64-bit case (ACPI 2.0+) */
-
- AcpiGbl_IntegerBitWidth = 64;
- AcpiGbl_IntegerNybbleWidth = 16;
- AcpiGbl_IntegerByteWidth = 8;
- }
-}
-
-
-#ifdef ACPI_DEBUG_OUTPUT
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDisplayInitPathname
- *
- * PARAMETERS: Type - Object type of the node
- * ObjHandle - Handle whose pathname will be displayed
- * Path - Additional path string to be appended.
- * (NULL if no extra path)
- *
- * RETURN: ACPI_STATUS
- *
- * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
- *
- ******************************************************************************/
-
-void
-AcpiUtDisplayInitPathname (
- UINT8 Type,
- ACPI_NAMESPACE_NODE *ObjHandle,
- char *Path)
-{
- ACPI_STATUS Status;
- ACPI_BUFFER Buffer;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Only print the path if the appropriate debug level is enabled */
-
- if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
- {
- return;
- }
-
- /* Get the full pathname to the node */
-
- Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
- Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
- if (ACPI_FAILURE (Status))
- {
- return;
- }
-
- /* Print what we're doing */
-
- switch (Type)
- {
- case ACPI_TYPE_METHOD:
- AcpiOsPrintf ("Executing ");
- break;
-
- default:
- AcpiOsPrintf ("Initializing ");
- break;
- }
-
- /* Print the object type and pathname */
-
- AcpiOsPrintf ("%-12s %s",
- AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
-
- /* Extra path is used to append names like _STA, _INI, etc. */
-
- if (Path)
- {
- AcpiOsPrintf (".%s", Path);
- }
- AcpiOsPrintf ("\n");
-
- ACPI_FREE (Buffer.Pointer);
-}
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValidAcpiChar
- *
- * PARAMETERS: Char - The character to be examined
- * Position - Byte position (0-3)
- *
- * RETURN: TRUE if the character is valid, FALSE otherwise
- *
- * DESCRIPTION: Check for a valid ACPI character. Must be one of:
- * 1) Upper case alpha
- * 2) numeric
- * 3) underscore
- *
- * We allow a '!' as the last character because of the ASF! table
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiUtValidAcpiChar (
- char Character,
- UINT32 Position)
-{
-
- if (!((Character >= 'A' && Character <= 'Z') ||
- (Character >= '0' && Character <= '9') ||
- (Character == '_')))
- {
- /* Allow a '!' in the last position */
-
- if (Character == '!' && Position == 3)
- {
- return (TRUE);
- }
-
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValidAcpiName
- *
- * PARAMETERS: Name - The name to be examined
- *
- * RETURN: TRUE if the name is valid, FALSE otherwise
- *
- * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
- * 1) Upper case alpha
- * 2) numeric
- * 3) underscore
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiUtValidAcpiName (
- UINT32 Name)
-{
- UINT32 i;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- for (i = 0; i < ACPI_NAME_SIZE; i++)
- {
- if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i))
- {
- return (FALSE);
- }
- }
-
- return (TRUE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtRepairName
- *
- * PARAMETERS: Name - The ACPI name to be repaired
- *
- * RETURN: Repaired version of the name
- *
- * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
- * return the new name. NOTE: the Name parameter must reside in
- * read/write memory, cannot be a const.
- *
- * An ACPI Name must consist of valid ACPI characters. We will repair the name
- * if necessary because we don't want to abort because of this, but we want
- * all namespace names to be printable. A warning message is appropriate.
- *
- * This issue came up because there are in fact machines that exhibit
- * this problem, and we want to be able to enable ACPI support for them,
- * even though there are a few bad names.
- *
- ******************************************************************************/
-
-void
-AcpiUtRepairName (
- char *Name)
-{
- UINT32 i;
- BOOLEAN FoundBadChar = FALSE;
-
-
- ACPI_FUNCTION_NAME (UtRepairName);
-
-
- /* Check each character in the name */
-
- for (i = 0; i < ACPI_NAME_SIZE; i++)
- {
- if (AcpiUtValidAcpiChar (Name[i], i))
- {
- continue;
- }
-
- /*
- * Replace a bad character with something printable, yet technically
- * still invalid. This prevents any collisions with existing "good"
- * names in the namespace.
- */
- Name[i] = '*';
- FoundBadChar = TRUE;
- }
-
- if (FoundBadChar)
- {
- /* Report warning only if in strict mode or debug mode */
-
- if (!AcpiGbl_EnableInterpreterSlack)
- {
- ACPI_WARNING ((AE_INFO,
- "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
- }
- else
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
- }
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtStrtoul64
- *
- * PARAMETERS: String - Null terminated string
- * Base - Radix of the string: 16 or ACPI_ANY_BASE;
- * ACPI_ANY_BASE means 'in behalf of ToInteger'
- * RetInteger - Where the converted integer is returned
- *
- * RETURN: Status and Converted value
- *
- * DESCRIPTION: Convert a string into an unsigned value. Performs either a
- * 32-bit or 64-bit conversion, depending on the current mode
- * of the interpreter.
- * NOTE: Does not support Octal strings, not needed.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtStrtoul64 (
- char *String,
- UINT32 Base,
- UINT64 *RetInteger)
-{
- UINT32 ThisDigit = 0;
- UINT64 ReturnValue = 0;
- UINT64 Quotient;
- UINT64 Dividend;
- UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE);
- UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4);
- UINT8 ValidDigits = 0;
- UINT8 SignOf0x = 0;
- UINT8 Term = 0;
-
-
- ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
-
-
- switch (Base)
- {
- case ACPI_ANY_BASE:
- case 16:
- break;
-
- default:
- /* Invalid Base */
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- if (!String)
- {
- goto ErrorExit;
- }
-
- /* Skip over any white space in the buffer */
-
- while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
- {
- String++;
- }
-
- if (ToIntegerOp)
- {
- /*
- * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
- * We need to determine if it is decimal or hexadecimal.
- */
- if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
- {
- SignOf0x = 1;
- Base = 16;
-
- /* Skip over the leading '0x' */
- String += 2;
- }
- else
- {
- Base = 10;
- }
- }
-
- /* Any string left? Check that '0x' is not followed by white space. */
-
- if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
- {
- if (ToIntegerOp)
- {
- goto ErrorExit;
- }
- else
- {
- goto AllDone;
- }
- }
-
- /*
- * Perform a 32-bit or 64-bit conversion, depending upon the current
- * execution mode of the interpreter
- */
- Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
-
- /* Main loop: convert the string to a 32- or 64-bit integer */
-
- while (*String)
- {
- if (ACPI_IS_DIGIT (*String))
- {
- /* Convert ASCII 0-9 to Decimal value */
-
- ThisDigit = ((UINT8) *String) - '0';
- }
- else if (Base == 10)
- {
- /* Digit is out of range; possible in ToInteger case only */
-
- Term = 1;
- }
- else
- {
- ThisDigit = (UINT8) ACPI_TOUPPER (*String);
- if (ACPI_IS_XDIGIT ((char) ThisDigit))
- {
- /* Convert ASCII Hex char to value */
-
- ThisDigit = ThisDigit - 'A' + 10;
- }
- else
- {
- Term = 1;
- }
- }
-
- if (Term)
- {
- if (ToIntegerOp)
- {
- goto ErrorExit;
- }
- else
- {
- break;
- }
- }
- else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x)
- {
- /* Skip zeros */
- String++;
- continue;
- }
-
- ValidDigits++;
-
- if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32)))
- {
- /*
- * This is ToInteger operation case.
- * No any restrictions for string-to-integer conversion,
- * see ACPI spec.
- */
- goto ErrorExit;
- }
-
- /* Divide the digit into the correct position */
-
- (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit),
- Base, &Quotient, NULL);
-
- if (ReturnValue > Quotient)
- {
- if (ToIntegerOp)
- {
- goto ErrorExit;
- }
- else
- {
- break;
- }
- }
-
- ReturnValue *= Base;
- ReturnValue += ThisDigit;
- String++;
- }
-
- /* All done, normal exit */
-
-AllDone:
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (ReturnValue)));
-
- *RetInteger = ReturnValue;
- return_ACPI_STATUS (AE_OK);
-
-
-ErrorExit:
- /* Base was set/validated above */
-
- if (Base == 10)
- {
- return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
- }
- else
- {
- return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateUpdateStateAndPush
- *
- * PARAMETERS: Object - Object to be added to the new state
- * Action - Increment/Decrement
- * StateList - List the state will be added to
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new state and push it
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCreateUpdateStateAndPush (
- ACPI_OPERAND_OBJECT *Object,
- UINT16 Action,
- ACPI_GENERIC_STATE **StateList)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Ignore null objects; these are expected */
-
- if (!Object)
- {
- return (AE_OK);
- }
-
- State = AcpiUtCreateUpdateState (Object, Action);
- if (!State)
- {
- return (AE_NO_MEMORY);
- }
-
- AcpiUtPushGenericState (StateList, State);
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtWalkPackageTree
- *
- * PARAMETERS: SourceObject - The package to walk
- * TargetObject - Target object (if package is being copied)
- * WalkCallback - Called once for each package element
- * Context - Passed to the callback function
- *
- * RETURN: Status
- *
- * DESCRIPTION: Walk through a package
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtWalkPackageTree (
- ACPI_OPERAND_OBJECT *SourceObject,
- void *TargetObject,
- ACPI_PKG_CALLBACK WalkCallback,
- void *Context)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_GENERIC_STATE *StateList = NULL;
- ACPI_GENERIC_STATE *State;
- UINT32 ThisIndex;
- ACPI_OPERAND_OBJECT *ThisSourceObj;
-
-
- ACPI_FUNCTION_TRACE (UtWalkPackageTree);
-
-
- State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
- if (!State)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- while (State)
- {
- /* Get one element of the package */
-
- ThisIndex = State->Pkg.Index;
- ThisSourceObj = (ACPI_OPERAND_OBJECT *)
- State->Pkg.SourceObject->Package.Elements[ThisIndex];
-
- /*
- * Check for:
- * 1) An uninitialized package element. It is completely
- * legal to declare a package and leave it uninitialized
- * 2) Not an internal object - can be a namespace node instead
- * 3) Any type other than a package. Packages are handled in else
- * case below.
- */
- if ((!ThisSourceObj) ||
- (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
- (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
- {
- Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
- State, Context);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- State->Pkg.Index++;
- while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
- {
- /*
- * We've handled all of the objects at this level, This means
- * that we have just completed a package. That package may
- * have contained one or more packages itself.
- *
- * Delete this state and pop the previous state (package).
- */
- AcpiUtDeleteGenericState (State);
- State = AcpiUtPopGenericState (&StateList);
-
- /* Finished when there are no more states */
-
- if (!State)
- {
- /*
- * We have handled all of the objects in the top level
- * package just add the length of the package objects
- * and exit
- */
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Go back up a level and move the index past the just
- * completed package object.
- */
- State->Pkg.Index++;
- }
- }
- else
- {
- /* This is a subobject of type package */
-
- Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
- State, Context);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Push the current state and create a new one
- * The callback above returned a new target package object.
- */
- AcpiUtPushGenericState (&StateList, State);
- State = AcpiUtCreatePkgState (ThisSourceObj,
- State->Pkg.ThisTargetObj, 0);
- if (!State)
- {
- /* Free any stacked Update State objects */
-
- while (StateList)
- {
- State = AcpiUtPopGenericState (&StateList);
- AcpiUtDeleteGenericState (State);
- }
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
- }
- }
-
- /* We should never get here */
-
- return_ACPI_STATUS (AE_AML_INTERNAL);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utmutex.c
--- a/head/sys/contrib/dev/acpica/utilities/utmutex.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,397 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utmutex - local mutex 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.
- */
-
-
-#define __UTMUTEX_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utmutex")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiUtCreateMutex (
- ACPI_MUTEX_HANDLE MutexId);
-
-static void
-AcpiUtDeleteMutex (
- ACPI_MUTEX_HANDLE MutexId);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtMutexInitialize
- *
- * PARAMETERS: None.
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create the system mutex objects. This includes mutexes,
- * spin locks, and reader/writer locks.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtMutexInitialize (
- void)
-{
- UINT32 i;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtMutexInitialize);
-
-
- /* Create each of the predefined mutex objects */
-
- for (i = 0; i < ACPI_NUM_MUTEX; i++)
- {
- Status = AcpiUtCreateMutex (i);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /* Create the spinlocks for use at interrupt level */
-
- Status = AcpiOsCreateLock (&AcpiGbl_GpeLock);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Mutex for _OSI support */
- Status = AcpiOsCreateMutex (&AcpiGbl_OsiMutex);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Create the reader/writer lock for namespace access */
-
- Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtMutexTerminate
- *
- * PARAMETERS: None.
- *
- * RETURN: None.
- *
- * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes,
- * spin locks, and reader/writer locks.
- *
- ******************************************************************************/
-
-void
-AcpiUtMutexTerminate (
- void)
-{
- UINT32 i;
-
-
- ACPI_FUNCTION_TRACE (UtMutexTerminate);
-
-
- /* Delete each predefined mutex object */
-
- for (i = 0; i < ACPI_NUM_MUTEX; i++)
- {
- AcpiUtDeleteMutex (i);
- }
-
- AcpiOsDeleteMutex (AcpiGbl_OsiMutex);
-
- /* Delete the spinlocks */
-
- AcpiOsDeleteLock (AcpiGbl_GpeLock);
- AcpiOsDeleteLock (AcpiGbl_HardwareLock);
-
- /* Delete the reader/writer lock */
-
- AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateMutex
- *
- * PARAMETERS: MutexID - ID of the mutex to be created
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a mutex object.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtCreateMutex (
- ACPI_MUTEX_HANDLE MutexId)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId);
-
-
- if (!AcpiGbl_MutexInfo[MutexId].Mutex)
- {
- Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex);
- AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
- AcpiGbl_MutexInfo[MutexId].UseCount = 0;
- }
-
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDeleteMutex
- *
- * PARAMETERS: MutexID - ID of the mutex to be deleted
- *
- * RETURN: Status
- *
- * DESCRIPTION: Delete a mutex object.
- *
- ******************************************************************************/
-
-static void
-AcpiUtDeleteMutex (
- ACPI_MUTEX_HANDLE MutexId)
-{
-
- ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId);
-
-
- AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
-
- AcpiGbl_MutexInfo[MutexId].Mutex = NULL;
- AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAcquireMutex
- *
- * PARAMETERS: MutexID - ID of the mutex to be acquired
- *
- * RETURN: Status
- *
- * DESCRIPTION: Acquire a mutex object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtAcquireMutex (
- ACPI_MUTEX_HANDLE MutexId)
-{
- ACPI_STATUS Status;
- ACPI_THREAD_ID ThisThreadId;
-
-
- ACPI_FUNCTION_NAME (UtAcquireMutex);
-
-
- if (MutexId > ACPI_MAX_MUTEX)
- {
- return (AE_BAD_PARAMETER);
- }
-
- ThisThreadId = AcpiOsGetThreadId ();
-
-#ifdef ACPI_MUTEX_DEBUG
- {
- UINT32 i;
- /*
- * Mutex debug code, for internal debugging only.
- *
- * Deadlock prevention. Check if this thread owns any mutexes of value
- * greater than or equal to this one. If so, the thread has violated
- * the mutex ordering rule. This indicates a coding error somewhere in
- * the ACPI subsystem code.
- */
- for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
- {
- if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId)
- {
- if (i == MutexId)
- {
- ACPI_ERROR ((AE_INFO,
- "Mutex [%s] already acquired by this thread [%u]",
- AcpiUtGetMutexName (MutexId),
- (UINT32) ThisThreadId));
-
- return (AE_ALREADY_ACQUIRED);
- }
-
- ACPI_ERROR ((AE_INFO,
- "Invalid acquire order: Thread %u owns [%s], wants [%s]",
- (UINT32) ThisThreadId, AcpiUtGetMutexName (i),
- AcpiUtGetMutexName (MutexId)));
-
- return (AE_ACQUIRE_DEADLOCK);
- }
- }
- }
-#endif
-
- ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
- "Thread %u attempting to acquire Mutex [%s]\n",
- (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
-
- Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex,
- ACPI_WAIT_FOREVER);
- if (ACPI_SUCCESS (Status))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u acquired Mutex [%s]\n",
- (UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
-
- AcpiGbl_MutexInfo[MutexId].UseCount++;
- AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId;
- }
- else
- {
- ACPI_EXCEPTION ((AE_INFO, Status,
- "Thread %u could not acquire Mutex [0x%X]",
- (UINT32) ThisThreadId, MutexId));
- }
-
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtReleaseMutex
- *
- * PARAMETERS: MutexID - ID of the mutex to be released
- *
- * RETURN: Status
- *
- * DESCRIPTION: Release a mutex object.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtReleaseMutex (
- ACPI_MUTEX_HANDLE MutexId)
-{
- ACPI_FUNCTION_NAME (UtReleaseMutex);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n",
- (UINT32) AcpiOsGetThreadId (), AcpiUtGetMutexName (MutexId)));
-
- if (MutexId > ACPI_MAX_MUTEX)
- {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * Mutex must be acquired in order to release it!
- */
- if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED)
- {
- ACPI_ERROR ((AE_INFO,
- "Mutex [0x%X] is not acquired, cannot release", MutexId));
-
- return (AE_NOT_ACQUIRED);
- }
-
-#ifdef ACPI_MUTEX_DEBUG
- {
- UINT32 i;
- /*
- * Mutex debug code, for internal debugging only.
- *
- * Deadlock prevention. Check if this thread owns any mutexes of value
- * greater than this one. If so, the thread has violated the mutex
- * ordering rule. This indicates a coding error somewhere in
- * the ACPI subsystem code.
- */
- for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
- {
- if (AcpiGbl_MutexInfo[i].ThreadId == AcpiOsGetThreadId ())
- {
- if (i == MutexId)
- {
- continue;
- }
-
- ACPI_ERROR ((AE_INFO,
- "Invalid release order: owns [%s], releasing [%s]",
- AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId)));
-
- return (AE_RELEASE_DEADLOCK);
- }
- }
- }
-#endif
-
- /* Mark unlocked FIRST */
-
- AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
-
- AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
- return (AE_OK);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utobject.c
--- a/head/sys/contrib/dev/acpica/utilities/utobject.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,787 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utobject - ACPI object create/delete/size/cache 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 __UTOBJECT_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utobject")
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiUtGetSimpleObjectSize (
- ACPI_OPERAND_OBJECT *Obj,
- ACPI_SIZE *ObjLength);
-
-static ACPI_STATUS
-AcpiUtGetPackageObjectSize (
- ACPI_OPERAND_OBJECT *Obj,
- ACPI_SIZE *ObjLength);
-
-static ACPI_STATUS
-AcpiUtGetElementLength (
- UINT8 ObjectType,
- ACPI_OPERAND_OBJECT *SourceObject,
- ACPI_GENERIC_STATE *State,
- void *Context);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateInternalObjectDbg
- *
- * PARAMETERS: ModuleName - Source file name of caller
- * LineNumber - Line number of caller
- * ComponentId - Component type of caller
- * Type - ACPI Type of the new object
- *
- * RETURN: A new internal object, null on failure
- *
- * DESCRIPTION: Create and initialize a new internal object.
- *
- * NOTE: We always allocate the worst-case object descriptor because
- * these objects are cached, and we want them to be
- * one-size-satisifies-any-request. This in itself may not be
- * the most memory efficient, but the efficiency of the object
- * cache should more than make up for this!
- *
- ******************************************************************************/
-
-ACPI_OPERAND_OBJECT *
-AcpiUtCreateInternalObjectDbg (
- const char *ModuleName,
- UINT32 LineNumber,
- UINT32 ComponentId,
- ACPI_OBJECT_TYPE Type)
-{
- ACPI_OPERAND_OBJECT *Object;
- ACPI_OPERAND_OBJECT *SecondObject;
-
-
- ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg,
- AcpiUtGetTypeName (Type));
-
-
- /* Allocate the raw object descriptor */
-
- Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId);
- if (!Object)
- {
- return_PTR (NULL);
- }
-
- switch (Type)
- {
- case ACPI_TYPE_REGION:
- case ACPI_TYPE_BUFFER_FIELD:
- case ACPI_TYPE_LOCAL_BANK_FIELD:
-
- /* These types require a secondary object */
-
- SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName,
- LineNumber, ComponentId);
- if (!SecondObject)
- {
- AcpiUtDeleteObjectDesc (Object);
- return_PTR (NULL);
- }
-
- SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;
- SecondObject->Common.ReferenceCount = 1;
-
- /* Link the second object to the first */
-
- Object->Common.NextObject = SecondObject;
- break;
-
- default:
- /* All others have no secondary object */
- break;
- }
-
- /* Save the object type in the object descriptor */
-
- Object->Common.Type = (UINT8) Type;
-
- /* Init the reference count */
-
- Object->Common.ReferenceCount = 1;
-
- /* Any per-type initialization should go here */
-
- return_PTR (Object);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreatePackageObject
- *
- * PARAMETERS: Count - Number of package elements
- *
- * RETURN: Pointer to a new Package object, null on failure
- *
- * DESCRIPTION: Create a fully initialized package object
- *
- ******************************************************************************/
-
-ACPI_OPERAND_OBJECT *
-AcpiUtCreatePackageObject (
- UINT32 Count)
-{
- ACPI_OPERAND_OBJECT *PackageDesc;
- ACPI_OPERAND_OBJECT **PackageElements;
-
-
- ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count);
-
-
- /* Create a new Package object */
-
- PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
- if (!PackageDesc)
- {
- return_PTR (NULL);
- }
-
- /*
- * Create the element array. Count+1 allows the array to be null
- * terminated.
- */
- PackageElements = ACPI_ALLOCATE_ZEROED (
- ((ACPI_SIZE) Count + 1) * sizeof (void *));
- if (!PackageElements)
- {
- ACPI_FREE (PackageDesc);
- return_PTR (NULL);
- }
-
- PackageDesc->Package.Count = Count;
- PackageDesc->Package.Elements = PackageElements;
- return_PTR (PackageDesc);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateIntegerObject
- *
- * PARAMETERS: InitialValue - Initial value for the integer
- *
- * RETURN: Pointer to a new Integer object, null on failure
- *
- * DESCRIPTION: Create an initialized integer object
- *
- ******************************************************************************/
-
-ACPI_OPERAND_OBJECT *
-AcpiUtCreateIntegerObject (
- UINT64 InitialValue)
-{
- ACPI_OPERAND_OBJECT *IntegerDesc;
-
-
- ACPI_FUNCTION_TRACE (UtCreateIntegerObject);
-
-
- /* Create and initialize a new integer object */
-
- IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!IntegerDesc)
- {
- return_PTR (NULL);
- }
-
- IntegerDesc->Integer.Value = InitialValue;
- return_PTR (IntegerDesc);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateBufferObject
- *
- * PARAMETERS: BufferSize - Size of buffer to be created
- *
- * RETURN: Pointer to a new Buffer object, null on failure
- *
- * DESCRIPTION: Create a fully initialized buffer object
- *
- ******************************************************************************/
-
-ACPI_OPERAND_OBJECT *
-AcpiUtCreateBufferObject (
- ACPI_SIZE BufferSize)
-{
- ACPI_OPERAND_OBJECT *BufferDesc;
- UINT8 *Buffer = NULL;
-
-
- ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize);
-
-
- /* Create a new Buffer object */
-
- BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
- if (!BufferDesc)
- {
- return_PTR (NULL);
- }
-
- /* Create an actual buffer only if size > 0 */
-
- if (BufferSize > 0)
- {
- /* Allocate the actual buffer */
-
- Buffer = ACPI_ALLOCATE_ZEROED (BufferSize);
- if (!Buffer)
- {
- ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
- (UINT32) BufferSize));
- AcpiUtRemoveReference (BufferDesc);
- return_PTR (NULL);
- }
- }
-
- /* Complete buffer object initialization */
-
- BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
- BufferDesc->Buffer.Pointer = Buffer;
- BufferDesc->Buffer.Length = (UINT32) BufferSize;
-
- /* Return the new buffer descriptor */
-
- return_PTR (BufferDesc);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateStringObject
- *
- * PARAMETERS: StringSize - Size of string to be created. Does not
- * include NULL terminator, this is added
- * automatically.
- *
- * RETURN: Pointer to a new String object
- *
- * DESCRIPTION: Create a fully initialized string object
- *
- ******************************************************************************/
-
-ACPI_OPERAND_OBJECT *
-AcpiUtCreateStringObject (
- ACPI_SIZE StringSize)
-{
- ACPI_OPERAND_OBJECT *StringDesc;
- char *String;
-
-
- ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize);
-
-
- /* Create a new String object */
-
- StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
- if (!StringDesc)
- {
- return_PTR (NULL);
- }
-
- /*
- * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
- * NOTE: Zero-length strings are NULL terminated
- */
- String = ACPI_ALLOCATE_ZEROED (StringSize + 1);
- if (!String)
- {
- ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
- (UINT32) StringSize));
- AcpiUtRemoveReference (StringDesc);
- return_PTR (NULL);
- }
-
- /* Complete string object initialization */
-
- StringDesc->String.Pointer = String;
- StringDesc->String.Length = (UINT32) StringSize;
-
- /* Return the new string descriptor */
-
- return_PTR (StringDesc);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValidInternalObject
- *
- * PARAMETERS: Object - Object to be validated
- *
- * RETURN: TRUE if object is valid, FALSE otherwise
- *
- * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT
- *
- ******************************************************************************/
-
-BOOLEAN
-AcpiUtValidInternalObject (
- void *Object)
-{
-
- ACPI_FUNCTION_NAME (UtValidInternalObject);
-
-
- /* Check for a null pointer */
-
- if (!Object)
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
- return (FALSE);
- }
-
- /* Check the descriptor type field */
-
- switch (ACPI_GET_DESCRIPTOR_TYPE (Object))
- {
- case ACPI_DESC_TYPE_OPERAND:
-
- /* The object appears to be a valid ACPI_OPERAND_OBJECT */
-
- return (TRUE);
-
- default:
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "%p is not not an ACPI operand obj [%s]\n",
- Object, AcpiUtGetDescriptorName (Object)));
- break;
- }
-
- return (FALSE);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocateObjectDescDbg
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * ComponentId - Caller's component ID (for error output)
- *
- * RETURN: Pointer to newly allocated object descriptor. Null on error
- *
- * DESCRIPTION: Allocate a new object descriptor. Gracefully handle
- * error conditions.
- *
- ******************************************************************************/
-
-void *
-AcpiUtAllocateObjectDescDbg (
- const char *ModuleName,
- UINT32 LineNumber,
- UINT32 ComponentId)
-{
- ACPI_OPERAND_OBJECT *Object;
-
-
- ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg);
-
-
- Object = AcpiOsAcquireObject (AcpiGbl_OperandCache);
- if (!Object)
- {
- ACPI_ERROR ((ModuleName, LineNumber,
- "Could not allocate an object descriptor"));
-
- return_PTR (NULL);
- }
-
- /* Mark the descriptor type */
-
- ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
- Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT)));
-
- return_PTR (Object);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDeleteObjectDesc
- *
- * PARAMETERS: Object - An Acpi internal object to be deleted
- *
- * RETURN: None.
- *
- * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
- *
- ******************************************************************************/
-
-void
-AcpiUtDeleteObjectDesc (
- ACPI_OPERAND_OBJECT *Object)
-{
- ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);
-
-
- /* Object must be an ACPI_OPERAND_OBJECT */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
- {
- ACPI_ERROR ((AE_INFO,
- "%p is not an ACPI Operand object [%s]", Object,
- AcpiUtGetDescriptorName (Object)));
- return_VOID;
- }
-
- (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetSimpleObjectSize
- *
- * PARAMETERS: InternalObject - An ACPI operand object
- * ObjLength - Where the length is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to determine the space required to
- * contain a simple object for return to an external user.
- *
- * The length includes the object structure plus any additional
- * needed space.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtGetSimpleObjectSize (
- ACPI_OPERAND_OBJECT *InternalObject,
- ACPI_SIZE *ObjLength)
-{
- ACPI_SIZE Length;
- ACPI_SIZE Size;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject);
-
-
- /* Start with the length of the (external) Acpi object */
-
- Length = sizeof (ACPI_OBJECT);
-
- /* A NULL object is allowed, can be a legal uninitialized package element */
-
- if (!InternalObject)
- {
- /*
- * Object is NULL, just return the length of ACPI_OBJECT
- * (A NULL ACPI_OBJECT is an object of all zeroes.)
- */
- *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
- return_ACPI_STATUS (AE_OK);
- }
-
- /* A Namespace Node should never appear here */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)
- {
- /* A namespace node should never get here */
-
- return_ACPI_STATUS (AE_AML_INTERNAL);
- }
-
- /*
- * The final length depends on the object type
- * Strings and Buffers are packed right up against the parent object and
- * must be accessed bytewise or there may be alignment problems on
- * certain processors
- */
- switch (InternalObject->Common.Type)
- {
- case ACPI_TYPE_STRING:
-
- Length += (ACPI_SIZE) InternalObject->String.Length + 1;
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- Length += (ACPI_SIZE) InternalObject->Buffer.Length;
- break;
-
-
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_PROCESSOR:
- case ACPI_TYPE_POWER:
-
- /* No extra data for these types */
-
- break;
-
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- switch (InternalObject->Reference.Class)
- {
- case ACPI_REFCLASS_NAME:
-
- /*
- * Get the actual length of the full pathname to this object.
- * The reference will be converted to the pathname to the object
- */
- Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);
- if (!Size)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);
- break;
-
- default:
-
- /*
- * No other reference opcodes are supported.
- * Notably, Locals and Args are not supported, but this may be
- * required eventually.
- */
- ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
- "unsupported Reference Class [%s] 0x%X in object %p",
- AcpiUtGetReferenceName (InternalObject),
- InternalObject->Reference.Class, InternalObject));
- Status = AE_TYPE;
- break;
- }
- break;
-
-
- default:
-
- ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
- "unsupported type [%s] 0x%X in object %p",
- AcpiUtGetObjectTypeName (InternalObject),
- InternalObject->Common.Type, InternalObject));
- Status = AE_TYPE;
- break;
- }
-
- /*
- * Account for the space required by the object rounded up to the next
- * multiple of the machine word size. This keeps each object aligned
- * on a machine word boundary. (preventing alignment faults on some
- * machines.)
- */
- *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetElementLength
- *
- * PARAMETERS: ACPI_PKG_CALLBACK
- *
- * RETURN: Status
- *
- * DESCRIPTION: Get the length of one package element.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtGetElementLength (
- UINT8 ObjectType,
- ACPI_OPERAND_OBJECT *SourceObject,
- ACPI_GENERIC_STATE *State,
- void *Context)
-{
- ACPI_STATUS Status = AE_OK;
- ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
- ACPI_SIZE ObjectSpace;
-
-
- switch (ObjectType)
- {
- case ACPI_COPY_TYPE_SIMPLE:
-
- /*
- * Simple object - just get the size (Null object/entry is handled
- * here also) and sum it into the running package length
- */
- Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- Info->Length += ObjectSpace;
- break;
-
-
- case ACPI_COPY_TYPE_PACKAGE:
-
- /* Package object - nothing much to do here, let the walk handle it */
-
- Info->NumPackages++;
- State->Pkg.ThisTargetObj = NULL;
- break;
-
-
- default:
-
- /* No other types allowed */
-
- return (AE_BAD_PARAMETER);
- }
-
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetPackageObjectSize
- *
- * PARAMETERS: InternalObject - An ACPI internal object
- * ObjLength - Where the length is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to determine the space required to
- * contain a package object for return to an external user.
- *
- * This is moderately complex since a package contains other
- * objects including packages.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtGetPackageObjectSize (
- ACPI_OPERAND_OBJECT *InternalObject,
- ACPI_SIZE *ObjLength)
-{
- ACPI_STATUS Status;
- ACPI_PKG_INFO Info;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject);
-
-
- Info.Length = 0;
- Info.ObjectSpace = 0;
- Info.NumPackages = 1;
-
- Status = AcpiUtWalkPackageTree (InternalObject, NULL,
- AcpiUtGetElementLength, &Info);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * We have handled all of the objects in all levels of the package.
- * just add the length of the package objects themselves.
- * Round up to the next machine word.
- */
- Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) *
- (ACPI_SIZE) Info.NumPackages;
-
- /* Return the total package length */
-
- *ObjLength = Info.Length;
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetObjectSize
- *
- * PARAMETERS: InternalObject - An ACPI internal object
- * ObjLength - Where the length will be returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to determine the space required to
- * contain an object for return to an API user.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtGetObjectSize (
- ACPI_OPERAND_OBJECT *InternalObject,
- ACPI_SIZE *ObjLength)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) &&
- (InternalObject->Common.Type == ACPI_TYPE_PACKAGE))
- {
- Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);
- }
- else
- {
- Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);
- }
-
- return (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utosi.c
--- a/head/sys/contrib/dev/acpica/utilities/utosi.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,422 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utosi - Support for the _OSI predefined control method
- *
- *****************************************************************************/
-
-/*
- * 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 __UTOSI_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utosi")
-
-/*
- * Strings supported by the _OSI predefined control method (which is
- * implemented internally within this module.)
- *
- * March 2009: Removed "Linux" as this host no longer wants to respond true
- * for this string. Basically, the only safe OS strings are windows-related
- * and in many or most cases represent the only test path within the
- * BIOS-provided ASL code.
- *
- * The last element of each entry is used to track the newest version of
- * Windows that the BIOS has requested.
- */
-static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] =
-{
- /* Operating System Vendor Strings */
-
- {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */
- {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */
- {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
- {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
- {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
- {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
- {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
- {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
- {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
- {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
- {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
-
- /* Feature Group Strings */
-
- {"Extended Address Space Descriptor", NULL, 0, 0}
-
- /*
- * All "optional" feature group strings (features that are implemented
- * by the host) should be dynamically added by the host via
- * AcpiInstallInterface and should not be manually added here.
- *
- * Examples of optional feature group strings:
- *
- * "Module Device"
- * "Processor Device"
- * "3.0 Thermal Model"
- * "3.0 _SCP Extensions"
- * "Processor Aggregator Device"
- */
-};
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtInitializeInterfaces
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Initialize the global _OSI supported interfaces list
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtInitializeInterfaces (
- void)
-{
- UINT32 i;
-
-
- (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
- AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
-
- /* Link the static list of supported interfaces */
-
- for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++)
- {
- AcpiDefaultSupportedInterfaces[i].Next =
- &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
- }
-
- AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtInterfaceTerminate
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete all interfaces in the global list. Sets
- * AcpiGbl_SupportedInterfaces to NULL.
- *
- ******************************************************************************/
-
-void
-AcpiUtInterfaceTerminate (
- void)
-{
- ACPI_INTERFACE_INFO *NextInterface;
-
-
- (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
- NextInterface = AcpiGbl_SupportedInterfaces;
-
- while (NextInterface)
- {
- AcpiGbl_SupportedInterfaces = NextInterface->Next;
-
- /* Only interfaces added at runtime can be freed */
-
- if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
- {
- ACPI_FREE (NextInterface->Name);
- ACPI_FREE (NextInterface);
- }
-
- NextInterface = AcpiGbl_SupportedInterfaces;
- }
-
- AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtInstallInterface
- *
- * PARAMETERS: InterfaceName - The interface to install
- *
- * RETURN: Status
- *
- * DESCRIPTION: Install the interface into the global interface list.
- * Caller MUST hold AcpiGbl_OsiMutex
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtInstallInterface (
- ACPI_STRING InterfaceName)
-{
- ACPI_INTERFACE_INFO *InterfaceInfo;
-
-
- /* Allocate info block and space for the name string */
-
- InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
- if (!InterfaceInfo)
- {
- return (AE_NO_MEMORY);
- }
-
- InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1);
- if (!InterfaceInfo->Name)
- {
- ACPI_FREE (InterfaceInfo);
- return (AE_NO_MEMORY);
- }
-
- /* Initialize new info and insert at the head of the global list */
-
- ACPI_STRCPY (InterfaceInfo->Name, InterfaceName);
- InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
- InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
-
- AcpiGbl_SupportedInterfaces = InterfaceInfo;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtRemoveInterface
- *
- * PARAMETERS: InterfaceName - The interface to remove
- *
- * RETURN: Status
- *
- * DESCRIPTION: Remove the interface from the global interface list.
- * Caller MUST hold AcpiGbl_OsiMutex
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtRemoveInterface (
- ACPI_STRING InterfaceName)
-{
- ACPI_INTERFACE_INFO *PreviousInterface;
- ACPI_INTERFACE_INFO *NextInterface;
-
-
- PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
- while (NextInterface)
- {
- if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
- {
- /* Found: name is in either the static list or was added at runtime */
-
- if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
- {
- /* Interface was added dynamically, remove and free it */
-
- if (PreviousInterface == NextInterface)
- {
- AcpiGbl_SupportedInterfaces = NextInterface->Next;
- }
- else
- {
- PreviousInterface->Next = NextInterface->Next;
- }
-
- ACPI_FREE (NextInterface->Name);
- ACPI_FREE (NextInterface);
- }
- else
- {
- /*
- * Interface is in static list. If marked invalid, then it
- * does not actually exist. Else, mark it invalid.
- */
- if (NextInterface->Flags & ACPI_OSI_INVALID)
- {
- return (AE_NOT_EXIST);
- }
-
- NextInterface->Flags |= ACPI_OSI_INVALID;
- }
-
- return (AE_OK);
- }
-
- PreviousInterface = NextInterface;
- NextInterface = NextInterface->Next;
- }
-
- /* Interface was not found */
-
- return (AE_NOT_EXIST);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetInterface
- *
- * PARAMETERS: InterfaceName - The interface to find
- *
- * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found.
- *
- * DESCRIPTION: Search for the specified interface name in the global list.
- * Caller MUST hold AcpiGbl_OsiMutex
- *
- ******************************************************************************/
-
-ACPI_INTERFACE_INFO *
-AcpiUtGetInterface (
- ACPI_STRING InterfaceName)
-{
- ACPI_INTERFACE_INFO *NextInterface;
-
-
- NextInterface = AcpiGbl_SupportedInterfaces;
- while (NextInterface)
- {
- if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
- {
- return (NextInterface);
- }
-
- NextInterface = NextInterface->Next;
- }
-
- return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtOsiImplementation
- *
- * PARAMETERS: WalkState - Current walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Implementation of the _OSI predefined control method. When
- * an invocation of _OSI is encountered in the system AML,
- * control is transferred to this function.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtOsiImplementation (
- ACPI_WALK_STATE *WalkState)
-{
- ACPI_OPERAND_OBJECT *StringDesc;
- ACPI_OPERAND_OBJECT *ReturnDesc;
- ACPI_INTERFACE_INFO *InterfaceInfo;
- ACPI_INTERFACE_HANDLER InterfaceHandler;
- UINT32 ReturnValue;
-
-
- ACPI_FUNCTION_TRACE (UtOsiImplementation);
-
-
- /* Validate the string input argument (from the AML caller) */
-
- StringDesc = WalkState->Arguments[0].Object;
- if (!StringDesc ||
- (StringDesc->Common.Type != ACPI_TYPE_STRING))
- {
- return_ACPI_STATUS (AE_TYPE);
- }
-
- /* Create a return object */
-
- ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!ReturnDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Default return value is 0, NOT SUPPORTED */
-
- ReturnValue = 0;
- (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
-
- /* Lookup the interface in the global _OSI list */
-
- InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
- if (InterfaceInfo &&
- !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
- {
- /*
- * The interface is supported.
- * Update the OsiData if necessary. We keep track of the latest
- * version of Windows that has been requested by the BIOS.
- */
- if (InterfaceInfo->Value > AcpiGbl_OsiData)
- {
- AcpiGbl_OsiData = InterfaceInfo->Value;
- }
-
- ReturnValue = ACPI_UINT32_MAX;
- }
-
- AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
-
- /*
- * Invoke an optional _OSI interface handler. The host OS may wish
- * to do some interface-specific handling. For example, warn about
- * certain interfaces or override the true/false support value.
- */
- InterfaceHandler = AcpiGbl_InterfaceHandler;
- if (InterfaceHandler)
- {
- ReturnValue = InterfaceHandler (
- StringDesc->String.Pointer, ReturnValue);
- }
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
- "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
- StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
-
- /* Complete the return object */
-
- ReturnDesc->Integer.Value = ReturnValue;
- WalkState->ReturnDesc = ReturnDesc;
- return_ACPI_STATUS (AE_OK);
-}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utresrc.c
--- a/head/sys/contrib/dev/acpica/utilities/utresrc.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,923 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utresrc - Resource managment 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 __UTRESRC_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acresrc.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utresrc")
-
-
-#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
-
-/*
- * Strings used to decode resource descriptors.
- * Used by both the disasssembler and the debugger resource dump routines
- */
-const char *AcpiGbl_BmDecode[] =
-{
- "NotBusMaster",
- "BusMaster"
-};
-
-const char *AcpiGbl_ConfigDecode[] =
-{
- "0 - Good Configuration",
- "1 - Acceptable Configuration",
- "2 - Suboptimal Configuration",
- "3 - ***Invalid Configuration***",
-};
-
-const char *AcpiGbl_ConsumeDecode[] =
-{
- "ResourceProducer",
- "ResourceConsumer"
-};
-
-const char *AcpiGbl_DecDecode[] =
-{
- "PosDecode",
- "SubDecode"
-};
-
-const char *AcpiGbl_HeDecode[] =
-{
- "Level",
- "Edge"
-};
-
-const char *AcpiGbl_IoDecode[] =
-{
- "Decode10",
- "Decode16"
-};
-
-const char *AcpiGbl_LlDecode[] =
-{
- "ActiveHigh",
- "ActiveLow"
-};
-
-const char *AcpiGbl_MaxDecode[] =
-{
- "MaxNotFixed",
- "MaxFixed"
-};
-
-const char *AcpiGbl_MemDecode[] =
-{
- "NonCacheable",
- "Cacheable",
- "WriteCombining",
- "Prefetchable"
-};
-
-const char *AcpiGbl_MinDecode[] =
-{
- "MinNotFixed",
- "MinFixed"
-};
-
-const char *AcpiGbl_MtpDecode[] =
-{
- "AddressRangeMemory",
- "AddressRangeReserved",
- "AddressRangeACPI",
- "AddressRangeNVS"
-};
-
-const char *AcpiGbl_RngDecode[] =
-{
- "InvalidRanges",
- "NonISAOnlyRanges",
- "ISAOnlyRanges",
- "EntireRange"
-};
-
-const char *AcpiGbl_RwDecode[] =
-{
- "ReadOnly",
- "ReadWrite"
-};
-
-const char *AcpiGbl_ShrDecode[] =
-{
- "Exclusive",
- "Shared"
-};
-
-const char *AcpiGbl_SizDecode[] =
-{
- "Transfer8",
- "Transfer8_16",
- "Transfer16",
- "InvalidSize"
-};
-
-const char *AcpiGbl_TrsDecode[] =
-{
- "DenseTranslation",
- "SparseTranslation"
-};
-
-const char *AcpiGbl_TtpDecode[] =
-{
- "TypeStatic",
- "TypeTranslation"
-};
-
-const char *AcpiGbl_TypDecode[] =
-{
- "Compatibility",
- "TypeA",
- "TypeB",
- "TypeF"
-};
-
-const char *AcpiGbl_PpcDecode[] =
-{
- "PullDefault",
- "PullUp",
- "PullDown",
- "PullNone"
-};
-
-const char *AcpiGbl_IorDecode[] =
-{
- "IoRestrictionNone",
- "IoRestrictionInputOnly",
- "IoRestrictionOutputOnly",
- "IoRestrictionNoneAndPreserve"
-};
-
-const char *AcpiGbl_DtsDecode[] =
-{
- "Width8bit",
- "Width16bit",
- "Width32bit",
- "Width64bit",
- "Width128bit",
- "Width256bit",
-};
-
-/* GPIO connection type */
-
-const char *AcpiGbl_CtDecode[] =
-{
- "Interrupt",
- "I/O"
-};
-
-/* Serial bus type */
-
-const char *AcpiGbl_SbtDecode[] =
-{
- "/* UNKNOWN serial bus type */",
- "I2C",
- "SPI",
- "UART"
-};
-
-/* I2C serial bus access mode */
-
-const char *AcpiGbl_AmDecode[] =
-{
- "AddressingMode7Bit",
- "AddressingMode10Bit"
-};
-
-/* I2C serial bus slave mode */
-
-const char *AcpiGbl_SmDecode[] =
-{
- "ControllerInitiated",
- "DeviceInitiated"
-};
-
-/* SPI serial bus wire mode */
-
-const char *AcpiGbl_WmDecode[] =
-{
- "FourWireMode",
- "ThreeWireMode"
-};
-
-/* SPI serial clock phase */
-
-const char *AcpiGbl_CphDecode[] =
-{
- "ClockPhaseFirst",
- "ClockPhaseSecond"
-};
-
-/* SPI serial bus clock polarity */
-
-const char *AcpiGbl_CpoDecode[] =
-{
- "ClockPolarityLow",
- "ClockPolarityHigh"
-};
-
-/* SPI serial bus device polarity */
-
-const char *AcpiGbl_DpDecode[] =
-{
- "PolarityLow",
- "PolarityHigh"
-};
-
-/* UART serial bus endian */
-
-const char *AcpiGbl_EdDecode[] =
-{
- "LittleEndian",
- "BigEndian"
-};
-
-/* UART serial bus bits per byte */
-
-const char *AcpiGbl_BpbDecode[] =
-{
- "DataBitsFive",
- "DataBitsSix",
- "DataBitsSeven",
- "DataBitsEight",
- "DataBitsNine",
- "/* UNKNOWN Bits per byte */",
- "/* UNKNOWN Bits per byte */",
- "/* UNKNOWN Bits per byte */"
-};
-
-/* UART serial bus stop bits */
-
-const char *AcpiGbl_SbDecode[] =
-{
- "StopBitsNone",
- "StopBitsOne",
- "StopBitsOnePlusHalf",
- "StopBitsTwo"
-};
-
-/* UART serial bus flow control */
-
-const char *AcpiGbl_FcDecode[] =
-{
- "FlowControlNone",
- "FlowControlHardware",
- "FlowControlXON",
- "/* UNKNOWN flow control keyword */"
-};
-
-/* UART serial bus parity type */
-
-const char *AcpiGbl_PtDecode[] =
-{
- "ParityTypeNone",
- "ParityTypeEven",
- "ParityTypeOdd",
- "ParityTypeMark",
- "ParityTypeSpace",
- "/* UNKNOWN parity keyword */",
- "/* UNKNOWN parity keyword */",
- "/* UNKNOWN parity keyword */"
-};
-
-#endif
-
-
-/*
- * Base sizes of the raw AML resource descriptors, indexed by resource type.
- * Zero indicates a reserved (and therefore invalid) resource type.
- */
-const UINT8 AcpiGbl_ResourceAmlSizes[] =
-{
- /* Small descriptors */
-
- 0,
- 0,
- 0,
- 0,
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ),
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA),
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT),
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT),
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO),
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO),
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_DMA),
- 0,
- 0,
- 0,
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL),
- ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG),
-
- /* Large descriptors */
-
- 0,
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER),
- 0,
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO),
- 0,
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_COMMON_SERIALBUS),
-};
-
-const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[] =
-{
- 0,
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS),
- ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS),
-};
-
-
-/*
- * Resource types, used to validate the resource length field.
- * The length of fixed-length types must match exactly, variable
- * lengths must meet the minimum required length, etc.
- * Zero indicates a reserved (and therefore invalid) resource type.
- */
-static const UINT8 AcpiGbl_ResourceTypes[] =
-{
- /* Small descriptors */
-
- 0,
- 0,
- 0,
- 0,
- ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */
- ACPI_FIXED_LENGTH, /* 05 DMA */
- ACPI_SMALL_VARIABLE_LENGTH, /* 06 StartDependentFunctions */
- ACPI_FIXED_LENGTH, /* 07 EndDependentFunctions */
- ACPI_FIXED_LENGTH, /* 08 IO */
- ACPI_FIXED_LENGTH, /* 09 FixedIO */
- ACPI_FIXED_LENGTH, /* 0A FixedDMA */
- 0,
- 0,
- 0,
- ACPI_VARIABLE_LENGTH, /* 0E VendorShort */
- ACPI_FIXED_LENGTH, /* 0F EndTag */
-
- /* Large descriptors */
-
- 0,
- ACPI_FIXED_LENGTH, /* 01 Memory24 */
- ACPI_FIXED_LENGTH, /* 02 GenericRegister */
- 0,
- ACPI_VARIABLE_LENGTH, /* 04 VendorLong */
- ACPI_FIXED_LENGTH, /* 05 Memory32 */
- ACPI_FIXED_LENGTH, /* 06 Memory32Fixed */
- ACPI_VARIABLE_LENGTH, /* 07 Dword* address */
- ACPI_VARIABLE_LENGTH, /* 08 Word* address */
- ACPI_VARIABLE_LENGTH, /* 09 ExtendedIRQ */
- ACPI_VARIABLE_LENGTH, /* 0A Qword* address */
- ACPI_FIXED_LENGTH, /* 0B Extended* address */
- ACPI_VARIABLE_LENGTH, /* 0C Gpio* */
- 0,
- ACPI_VARIABLE_LENGTH /* 0E *SerialBus */
-};
-
-/*
- * For the iASL compiler/disassembler, we don't want any error messages
- * because the disassembler uses the resource validation code to determine
- * if Buffer objects are actually Resource Templates.
- */
-#ifdef ACPI_ASL_COMPILER
-#define ACPI_RESOURCE_ERROR(plist)
-#else
-#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
-#endif
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtWalkAmlResources
- *
- * PARAMETERS: Aml - Pointer to the raw AML resource template
- * AmlLength - Length of the entire template
- * UserFunction - Called once for each descriptor found. If
- * NULL, a pointer to the EndTag is returned
- * Context - Passed to UserFunction
- *
- * RETURN: Status
- *
- * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
- * once for each resource found.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtWalkAmlResources (
- UINT8 *Aml,
- ACPI_SIZE AmlLength,
- ACPI_WALK_AML_CALLBACK UserFunction,
- void *Context)
-{
- ACPI_STATUS Status;
- UINT8 *EndAml;
- UINT8 ResourceIndex;
- UINT32 Length;
- UINT32 Offset = 0;
- UINT8 EndTag[2] = {0x79, 0x00};
-
-
- ACPI_FUNCTION_TRACE (UtWalkAmlResources);
-
-
- /* The absolute minimum resource template is one EndTag descriptor */
-
- if (AmlLength < sizeof (AML_RESOURCE_END_TAG))
- {
- return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
- }
-
- /* Point to the end of the resource template buffer */
-
- EndAml = Aml + AmlLength;
-
- /* Walk the byte list, abort on any invalid descriptor type or length */
-
- while (Aml < EndAml)
- {
- /* Validate the Resource Type and Resource Length */
-
- Status = AcpiUtValidateResource (Aml, &ResourceIndex);
- if (ACPI_FAILURE (Status))
- {
- /*
- * Exit on failure. Cannot continue because the descriptor length
- * may be bogus also.
- */
- return_ACPI_STATUS (Status);
- }
-
- /* Get the length of this descriptor */
-
- Length = AcpiUtGetDescriptorLength (Aml);
-
- /* Invoke the user function */
-
- if (UserFunction)
- {
- Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /* An EndTag descriptor terminates this resource template */
-
- if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG)
- {
- /*
- * There must be at least one more byte in the buffer for
- * the 2nd byte of the EndTag
- */
- if ((Aml + 1) >= EndAml)
- {
- return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
- }
-
- /* Return the pointer to the EndTag if requested */
-
- if (!UserFunction)
- {
- *(void **) Context = Aml;
- }
-
- /* Normal exit */
-
- return_ACPI_STATUS (AE_OK);
- }
-
- Aml += Length;
- Offset += Length;
- }
-
- /* Did not find an EndTag descriptor */
-
- if (UserFunction)
- {
- /* Insert an EndTag anyway. AcpiRsGetListLength always leaves room */
-
- (void) AcpiUtValidateResource (EndTag, &ResourceIndex);
- Status = UserFunction (EndTag, 2, Offset, ResourceIndex, Context);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtValidateResource
- *
- * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
- * ReturnIndex - Where the resource index is returned. NULL
- * if the index is not required.
- *
- * RETURN: Status, and optionally the Index into the global resource tables
- *
- * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
- * Type and Resource Length. Returns an index into the global
- * resource information/dispatch tables for later use.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtValidateResource (
- void *Aml,
- UINT8 *ReturnIndex)
-{
- AML_RESOURCE *AmlResource;
- UINT8 ResourceType;
- UINT8 ResourceIndex;
- ACPI_RS_LENGTH ResourceLength;
- ACPI_RS_LENGTH MinimumResourceLength;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * 1) Validate the ResourceType field (Byte 0)
- */
- ResourceType = ACPI_GET8 (Aml);
-
- /*
- * Byte 0 contains the descriptor name (Resource Type)
- * Examine the large/small bit in the resource header
- */
- if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
- {
- /* Verify the large resource type (name) against the max */
-
- if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
- {
- goto InvalidResource;
- }
-
- /*
- * Large Resource Type -- bits 6:0 contain the name
- * Translate range 0x80-0x8B to index range 0x10-0x1B
- */
- ResourceIndex = (UINT8) (ResourceType - 0x70);
- }
- else
- {
- /*
- * Small Resource Type -- bits 6:3 contain the name
- * Shift range to index range 0x00-0x0F
- */
- ResourceIndex = (UINT8)
- ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
- }
-
- /*
- * Check validity of the resource type, via AcpiGbl_ResourceTypes. Zero
- * indicates an invalid resource.
- */
- if (!AcpiGbl_ResourceTypes[ResourceIndex])
- {
- goto InvalidResource;
- }
-
- /*
- * Validate the ResourceLength field. This ensures that the length
- * is at least reasonable, and guarantees that it is non-zero.
- */
- ResourceLength = AcpiUtGetResourceLength (Aml);
- MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
-
- /* Validate based upon the type of resource - fixed length or variable */
-
- switch (AcpiGbl_ResourceTypes[ResourceIndex])
- {
- case ACPI_FIXED_LENGTH:
-
- /* Fixed length resource, length must match exactly */
-
- if (ResourceLength != MinimumResourceLength)
- {
- goto BadResourceLength;
- }
- break;
-
- case ACPI_VARIABLE_LENGTH:
-
- /* Variable length resource, length must be at least the minimum */
-
- if (ResourceLength < MinimumResourceLength)
- {
- goto BadResourceLength;
- }
- break;
-
- case ACPI_SMALL_VARIABLE_LENGTH:
-
- /* Small variable length resource, length can be (Min) or (Min-1) */
-
- if ((ResourceLength > MinimumResourceLength) ||
- (ResourceLength < (MinimumResourceLength - 1)))
- {
- goto BadResourceLength;
- }
- break;
-
- default:
-
- /* Shouldn't happen (because of validation earlier), but be sure */
-
- goto InvalidResource;
- }
-
- AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
- if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS)
- {
- /* Validate the BusType field */
-
- if ((AmlResource->CommonSerialBus.Type == 0) ||
- (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
- {
- ACPI_RESOURCE_ERROR ((AE_INFO,
- "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
- AmlResource->CommonSerialBus.Type));
- return (AE_AML_INVALID_RESOURCE_TYPE);
- }
- }
-
- /* Optionally return the resource table index */
-
- if (ReturnIndex)
- {
- *ReturnIndex = ResourceIndex;
- }
-
- return (AE_OK);
-
-
-InvalidResource:
-
- ACPI_RESOURCE_ERROR ((AE_INFO,
- "Invalid/unsupported resource descriptor: Type 0x%2.2X",
- ResourceType));
- return (AE_AML_INVALID_RESOURCE_TYPE);
-
-BadResourceLength:
-
- ACPI_RESOURCE_ERROR ((AE_INFO,
- "Invalid resource descriptor length: Type "
- "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
- ResourceType, ResourceLength, MinimumResourceLength));
- return (AE_AML_BAD_RESOURCE_LENGTH);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetResourceType
- *
- * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
- *
- * RETURN: The Resource Type with no extraneous bits (except the
- * Large/Small descriptor bit -- this is left alone)
- *
- * DESCRIPTION: Extract the Resource Type/Name from the first byte of
- * a resource descriptor.
- *
- ******************************************************************************/
-
-UINT8
-AcpiUtGetResourceType (
- void *Aml)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * Byte 0 contains the descriptor name (Resource Type)
- * Examine the large/small bit in the resource header
- */
- if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
- {
- /* Large Resource Type -- bits 6:0 contain the name */
-
- return (ACPI_GET8 (Aml));
- }
- else
- {
- /* Small Resource Type -- bits 6:3 contain the name */
-
- return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetResourceLength
- *
- * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
- *
- * RETURN: Byte Length
- *
- * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
- * definition, this does not include the size of the descriptor
- * header or the length field itself.
- *
- ******************************************************************************/
-
-UINT16
-AcpiUtGetResourceLength (
- void *Aml)
-{
- ACPI_RS_LENGTH ResourceLength;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * Byte 0 contains the descriptor name (Resource Type)
- * Examine the large/small bit in the resource header
- */
- if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
- {
- /* Large Resource type -- bytes 1-2 contain the 16-bit length */
-
- ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
-
- }
- else
- {
- /* Small Resource type -- bits 2:0 of byte 0 contain the length */
-
- ResourceLength = (UINT16) (ACPI_GET8 (Aml) &
- ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
- }
-
- return (ResourceLength);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetResourceHeaderLength
- *
- * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
- *
- * RETURN: Length of the AML header (depends on large/small descriptor)
- *
- * DESCRIPTION: Get the length of the header for this resource.
- *
- ******************************************************************************/
-
-UINT8
-AcpiUtGetResourceHeaderLength (
- void *Aml)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Examine the large/small bit in the resource header */
-
- if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
- {
- return (sizeof (AML_RESOURCE_LARGE_HEADER));
- }
- else
- {
- return (sizeof (AML_RESOURCE_SMALL_HEADER));
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetDescriptorLength
- *
- * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
- *
- * RETURN: Byte length
- *
- * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
- * length of the descriptor header and the length field itself.
- * Used to walk descriptor lists.
- *
- ******************************************************************************/
-
-UINT32
-AcpiUtGetDescriptorLength (
- void *Aml)
-{
- ACPI_FUNCTION_ENTRY ();
-
-
- /*
- * Get the Resource Length (does not include header length) and add
- * the header length (depends on if this is a small or large resource)
- */
- return (AcpiUtGetResourceLength (Aml) +
- AcpiUtGetResourceHeaderLength (Aml));
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetResourceEndTag
- *
- * PARAMETERS: ObjDesc - The resource template buffer object
- * EndTag - Where the pointer to the EndTag is returned
- *
- * RETURN: Status, pointer to the end tag
- *
- * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template
- * Note: allows a buffer length of zero.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtGetResourceEndTag (
- ACPI_OPERAND_OBJECT *ObjDesc,
- UINT8 **EndTag)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtGetResourceEndTag);
-
-
- /* Allow a buffer length of zero */
-
- if (!ObjDesc->Buffer.Length)
- {
- *EndTag = ObjDesc->Buffer.Pointer;
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Validate the template and get a pointer to the EndTag */
-
- Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer,
- ObjDesc->Buffer.Length, NULL, EndTag);
-
- return_ACPI_STATUS (Status);
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utstate.c
--- a/head/sys/contrib/dev/acpica/utilities/utstate.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,398 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utstate - state object support procedures
- *
- ******************************************************************************/
-
-/*
- * 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 __UTSTATE_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utstate")
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreatePkgStateAndPush
- *
- * PARAMETERS: Object - Object to be added to the new state
- * Action - Increment/Decrement
- * StateList - List the state will be added to
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a new state and push it
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCreatePkgStateAndPush (
- void *InternalObject,
- void *ExternalObject,
- UINT16 Index,
- ACPI_GENERIC_STATE **StateList)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index);
- if (!State)
- {
- return (AE_NO_MEMORY);
- }
-
- AcpiUtPushGenericState (StateList, State);
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtPushGenericState
- *
- * PARAMETERS: ListHead - Head of the state stack
- * State - State object to push
- *
- * RETURN: None
- *
- * DESCRIPTION: Push a state object onto a state stack
- *
- ******************************************************************************/
-
-void
-AcpiUtPushGenericState (
- ACPI_GENERIC_STATE **ListHead,
- ACPI_GENERIC_STATE *State)
-{
- ACPI_FUNCTION_TRACE (UtPushGenericState);
-
-
- /* Push the state object onto the front of the list (stack) */
-
- State->Common.Next = *ListHead;
- *ListHead = State;
-
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtPopGenericState
- *
- * PARAMETERS: ListHead - Head of the state stack
- *
- * RETURN: The popped state object
- *
- * DESCRIPTION: Pop a state object from a state stack
- *
- ******************************************************************************/
-
-ACPI_GENERIC_STATE *
-AcpiUtPopGenericState (
- ACPI_GENERIC_STATE **ListHead)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_TRACE (UtPopGenericState);
-
-
- /* Remove the state object at the head of the list (stack) */
-
- State = *ListHead;
- if (State)
- {
- /* Update the list head */
-
- *ListHead = State->Common.Next;
- }
-
- return_PTR (State);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateGenericState
- *
- * PARAMETERS: None
- *
- * RETURN: The new state object. NULL on failure.
- *
- * DESCRIPTION: Create a generic state object. Attempt to obtain one from
- * the global state cache; If none available, create a new one.
- *
- ******************************************************************************/
-
-ACPI_GENERIC_STATE *
-AcpiUtCreateGenericState (
- void)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- State = AcpiOsAcquireObject (AcpiGbl_StateCache);
- if (State)
- {
- /* Initialize */
- State->Common.DescriptorType = ACPI_DESC_TYPE_STATE;
- }
-
- return (State);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateThreadState
- *
- * PARAMETERS: None
- *
- * RETURN: New Thread State. NULL on failure
- *
- * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
- * to track per-thread info during method execution
- *
- ******************************************************************************/
-
-ACPI_THREAD_STATE *
-AcpiUtCreateThreadState (
- void)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_TRACE (UtCreateThreadState);
-
-
- /* Create the generic state object */
-
- State = AcpiUtCreateGenericState ();
- if (!State)
- {
- return_PTR (NULL);
- }
-
- /* Init fields specific to the update struct */
-
- State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_THREAD;
- State->Thread.ThreadId = AcpiOsGetThreadId ();
-
- /* Check for invalid thread ID - zero is very bad, it will break things */
-
- if (!State->Thread.ThreadId)
- {
- ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId"));
- State->Thread.ThreadId = (ACPI_THREAD_ID) 1;
- }
-
- return_PTR ((ACPI_THREAD_STATE *) State);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateUpdateState
- *
- * PARAMETERS: Object - Initial Object to be installed in the state
- * Action - Update action to be performed
- *
- * RETURN: New state object, null on failure
- *
- * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
- * to update reference counts and delete complex objects such
- * as packages.
- *
- ******************************************************************************/
-
-ACPI_GENERIC_STATE *
-AcpiUtCreateUpdateState (
- ACPI_OPERAND_OBJECT *Object,
- UINT16 Action)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtCreateUpdateState, Object);
-
-
- /* Create the generic state object */
-
- State = AcpiUtCreateGenericState ();
- if (!State)
- {
- return_PTR (NULL);
- }
-
- /* Init fields specific to the update struct */
-
- State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_UPDATE;
- State->Update.Object = Object;
- State->Update.Value = Action;
-
- return_PTR (State);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreatePkgState
- *
- * PARAMETERS: Object - Initial Object to be installed in the state
- * Action - Update action to be performed
- *
- * RETURN: New state object, null on failure
- *
- * DESCRIPTION: Create a "Package State"
- *
- ******************************************************************************/
-
-ACPI_GENERIC_STATE *
-AcpiUtCreatePkgState (
- void *InternalObject,
- void *ExternalObject,
- UINT16 Index)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtCreatePkgState, InternalObject);
-
-
- /* Create the generic state object */
-
- State = AcpiUtCreateGenericState ();
- if (!State)
- {
- return_PTR (NULL);
- }
-
- /* Init fields specific to the update struct */
-
- State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PACKAGE;
- State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject;
- State->Pkg.DestObject = ExternalObject;
- State->Pkg.Index= Index;
- State->Pkg.NumPackages = 1;
-
- return_PTR (State);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateControlState
- *
- * PARAMETERS: None
- *
- * RETURN: New state object, null on failure
- *
- * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
- * to support nested IF/WHILE constructs in the AML.
- *
- ******************************************************************************/
-
-ACPI_GENERIC_STATE *
-AcpiUtCreateControlState (
- void)
-{
- ACPI_GENERIC_STATE *State;
-
-
- ACPI_FUNCTION_TRACE (UtCreateControlState);
-
-
- /* Create the generic state object */
-
- State = AcpiUtCreateGenericState ();
- if (!State)
- {
- return_PTR (NULL);
- }
-
- /* Init fields specific to the control struct */
-
- State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL;
- State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING;
-
- return_PTR (State);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDeleteGenericState
- *
- * PARAMETERS: State - The state object to be deleted
- *
- * RETURN: None
- *
- * DESCRIPTION: Release a state object to the state cache. NULL state objects
- * are ignored.
- *
- ******************************************************************************/
-
-void
-AcpiUtDeleteGenericState (
- ACPI_GENERIC_STATE *State)
-{
- ACPI_FUNCTION_TRACE (UtDeleteGenericState);
-
-
- /* Ignore null state */
-
- if (State)
- {
- (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State);
- }
- return_VOID;
-}
-
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/uttrack.c
--- a/head/sys/contrib/dev/acpica/utilities/uttrack.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,711 +0,0 @@
-/******************************************************************************
- *
- * Module Name: uttrack - Memory allocation tracking routines (debug only)
- *
- *****************************************************************************/
-
-/*
- * 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.
- */
-
-/*
- * These procedures are used for tracking memory leaks in the subsystem, and
- * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
- *
- * Each memory allocation is tracked via a doubly linked list. Each
- * element contains the caller's component, module name, function name, and
- * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call
- * AcpiUtTrackAllocation to add an element to the list; deletion
- * occurs in the body of AcpiUtFree.
- */
-
-#define __UTTRACK_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("uttrack")
-
-/* Local prototypes */
-
-static ACPI_DEBUG_MEM_BLOCK *
-AcpiUtFindAllocation (
- void *Allocation);
-
-static ACPI_STATUS
-AcpiUtTrackAllocation (
- ACPI_DEBUG_MEM_BLOCK *Address,
- ACPI_SIZE Size,
- UINT8 AllocType,
- UINT32 Component,
- const char *Module,
- UINT32 Line);
-
-static ACPI_STATUS
-AcpiUtRemoveAllocation (
- ACPI_DEBUG_MEM_BLOCK *Address,
- UINT32 Component,
- const char *Module,
- UINT32 Line);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtCreateList
- *
- * PARAMETERS: CacheName - Ascii name for the cache
- * ObjectSize - Size of each cached object
- * ReturnCache - Where the new cache object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create a local memory list for tracking purposed
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiUtCreateList (
- char *ListName,
- UINT16 ObjectSize,
- ACPI_MEMORY_LIST **ReturnCache)
-{
- ACPI_MEMORY_LIST *Cache;
-
-
- Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
- if (!Cache)
- {
- return (AE_NO_MEMORY);
- }
-
- ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
-
- Cache->ListName = ListName;
- Cache->ObjectSize = ObjectSize;
-
- *ReturnCache = Cache;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocateAndTrack
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: The subsystem's equivalent of malloc.
- *
- ******************************************************************************/
-
-void *
-AcpiUtAllocateAndTrack (
- ACPI_SIZE Size,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- ACPI_DEBUG_MEM_BLOCK *Allocation;
- ACPI_STATUS Status;
-
-
- Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
- Component, Module, Line);
- if (!Allocation)
- {
- return (NULL);
- }
-
- Status = AcpiUtTrackAllocation (Allocation, Size,
- ACPI_MEM_MALLOC, Component, Module, Line);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsFree (Allocation);
- return (NULL);
- }
-
- AcpiGbl_GlobalList->TotalAllocated++;
- AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
- AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
- if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
- {
- AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
- }
-
- return ((void *) &Allocation->UserSpace);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocateZeroedAndTrack
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of calloc.
- *
- ******************************************************************************/
-
-void *
-AcpiUtAllocateZeroedAndTrack (
- ACPI_SIZE Size,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- ACPI_DEBUG_MEM_BLOCK *Allocation;
- ACPI_STATUS Status;
-
-
- Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
- Component, Module, Line);
- if (!Allocation)
- {
- /* Report allocation error */
-
- ACPI_ERROR ((Module, Line,
- "Could not allocate size %u", (UINT32) Size));
- return (NULL);
- }
-
- Status = AcpiUtTrackAllocation (Allocation, Size,
- ACPI_MEM_CALLOC, Component, Module, Line);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsFree (Allocation);
- return (NULL);
- }
-
- AcpiGbl_GlobalList->TotalAllocated++;
- AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
- AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
- if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
- {
- AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
- }
-
- return ((void *) &Allocation->UserSpace);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtFreeAndTrack
- *
- * PARAMETERS: Allocation - Address of the memory to deallocate
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: None
- *
- * DESCRIPTION: Frees the memory at Allocation
- *
- ******************************************************************************/
-
-void
-AcpiUtFreeAndTrack (
- void *Allocation,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- ACPI_DEBUG_MEM_BLOCK *DebugBlock;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation);
-
-
- if (NULL == Allocation)
- {
- ACPI_ERROR ((Module, Line,
- "Attempt to delete a NULL address"));
-
- return_VOID;
- }
-
- DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
- (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
-
- AcpiGbl_GlobalList->TotalFreed++;
- AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size;
-
- Status = AcpiUtRemoveAllocation (DebugBlock,
- Component, Module, Line);
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory"));
- }
-
- AcpiOsFree (DebugBlock);
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtFindAllocation
- *
- * PARAMETERS: Allocation - Address of allocated memory
- *
- * RETURN: A list element if found; NULL otherwise.
- *
- * DESCRIPTION: Searches for an element in the global allocation tracking list.
- *
- ******************************************************************************/
-
-static ACPI_DEBUG_MEM_BLOCK *
-AcpiUtFindAllocation (
- void *Allocation)
-{
- ACPI_DEBUG_MEM_BLOCK *Element;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- Element = AcpiGbl_GlobalList->ListHead;
-
- /* Search for the address. */
-
- while (Element)
- {
- if (Element == Allocation)
- {
- return (Element);
- }
-
- Element = Element->Next;
- }
-
- return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtTrackAllocation
- *
- * PARAMETERS: Allocation - Address of allocated memory
- * Size - Size of the allocation
- * AllocType - MEM_MALLOC or MEM_CALLOC
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: None.
- *
- * DESCRIPTION: Inserts an element into the global allocation tracking list.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtTrackAllocation (
- ACPI_DEBUG_MEM_BLOCK *Allocation,
- ACPI_SIZE Size,
- UINT8 AllocType,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- ACPI_MEMORY_LIST *MemList;
- ACPI_DEBUG_MEM_BLOCK *Element;
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation);
-
-
- if (AcpiGbl_DisableMemTracking)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- MemList = AcpiGbl_GlobalList;
- Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Search list for this address to make sure it is not already on the list.
- * This will catch several kinds of problems.
- */
- Element = AcpiUtFindAllocation (Allocation);
- if (Element)
- {
- ACPI_ERROR ((AE_INFO,
- "UtTrackAllocation: Allocation already present in list! (%p)",
- Allocation));
-
- ACPI_ERROR ((AE_INFO, "Element %p Address %p",
- Element, Allocation));
-
- goto UnlockAndExit;
- }
-
- /* Fill in the instance data. */
-
- Allocation->Size = (UINT32) Size;
- Allocation->AllocType = AllocType;
- Allocation->Component = Component;
- Allocation->Line = Line;
-
- ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
- Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0;
-
- /* Insert at list head */
-
- if (MemList->ListHead)
- {
- ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
- }
-
- Allocation->Next = MemList->ListHead;
- Allocation->Previous = NULL;
-
- MemList->ListHead = Allocation;
-
-
-UnlockAndExit:
- Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtRemoveAllocation
- *
- * PARAMETERS: Allocation - Address of allocated memory
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN:
- *
- * DESCRIPTION: Deletes an element from the global allocation tracking list.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtRemoveAllocation (
- ACPI_DEBUG_MEM_BLOCK *Allocation,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- ACPI_MEMORY_LIST *MemList;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (UtRemoveAllocation);
-
-
- if (AcpiGbl_DisableMemTracking)
- {
- return_ACPI_STATUS (AE_OK);
- }
-
- MemList = AcpiGbl_GlobalList;
- if (NULL == MemList->ListHead)
- {
- /* No allocations! */
-
- ACPI_ERROR ((Module, Line,
- "Empty allocation list, nothing to free!"));
-
- return_ACPI_STATUS (AE_OK);
- }
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Unlink */
-
- if (Allocation->Previous)
- {
- (Allocation->Previous)->Next = Allocation->Next;
- }
- else
- {
- MemList->ListHead = Allocation->Next;
- }
-
- if (Allocation->Next)
- {
- (Allocation->Next)->Previous = Allocation->Previous;
- }
-
- /* Mark the segment as deleted */
-
- ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
- Allocation->Size));
-
- Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
- return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDumpAllocationInfo
- *
- * PARAMETERS:
- *
- * RETURN: None
- *
- * DESCRIPTION: Print some info about the outstanding allocations.
- *
- ******************************************************************************/
-
-void
-AcpiUtDumpAllocationInfo (
- void)
-{
-/*
- ACPI_MEMORY_LIST *MemList;
-*/
-
- ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);
-
-/*
- ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
- ("%30s: %4d (%3d Kb)\n", "Current allocations",
- MemList->CurrentCount,
- ROUND_UP_TO_1K (MemList->CurrentSize)));
-
- ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
- ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
- MemList->MaxConcurrentCount,
- ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
-
-
- ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
- ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
- RunningObjectCount,
- ROUND_UP_TO_1K (RunningObjectSize)));
-
- ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
- ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
- RunningAllocCount,
- ROUND_UP_TO_1K (RunningAllocSize)));
-
-
- ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
- ("%30s: %4d (%3d Kb)\n", "Current Nodes",
- AcpiGbl_CurrentNodeCount,
- ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
-
- ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
- ("%30s: %4d (%3d Kb)\n", "Max Nodes",
- AcpiGbl_MaxConcurrentNodeCount,
- ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount *
- sizeof (ACPI_NAMESPACE_NODE)))));
-*/
- return_VOID;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtDumpAllocations
- *
- * PARAMETERS: Component - Component(s) to dump info for.
- * Module - Module to dump info for. NULL means all.
- *
- * RETURN: None
- *
- * DESCRIPTION: Print a list of all outstanding allocations.
- *
- ******************************************************************************/
-
-void
-AcpiUtDumpAllocations (
- UINT32 Component,
- const char *Module)
-{
- ACPI_DEBUG_MEM_BLOCK *Element;
- ACPI_DESCRIPTOR *Descriptor;
- UINT32 NumOutstanding = 0;
- UINT8 DescriptorType;
-
-
- ACPI_FUNCTION_TRACE (UtDumpAllocations);
-
-
- if (AcpiGbl_DisableMemTracking)
- {
- return;
- }
-
- /*
- * Walk the allocation list.
- */
- if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
- {
- return;
- }
-
- Element = AcpiGbl_GlobalList->ListHead;
- while (Element)
- {
- if ((Element->Component & Component) &&
- ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
- {
- Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
-
- if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))
- {
- AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u "
- "[Not a Descriptor - too small]\n",
- Descriptor, Element->Size, Element->Module,
- Element->Line);
- }
- else
- {
- /* Ignore allocated objects that are in a cache */
-
- if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED)
- {
- AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ",
- Descriptor, Element->Size, Element->Module,
- Element->Line, AcpiUtGetDescriptorName (Descriptor));
-
- /* Validate the descriptor type using Type field and length */
-
- DescriptorType = 0; /* Not a valid descriptor type */
-
- switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
- {
- case ACPI_DESC_TYPE_OPERAND:
- if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND))
- {
- DescriptorType = ACPI_DESC_TYPE_OPERAND;
- }
- break;
-
- case ACPI_DESC_TYPE_PARSER:
- if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER))
- {
- DescriptorType = ACPI_DESC_TYPE_PARSER;
- }
- break;
-
- case ACPI_DESC_TYPE_NAMED:
- if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED))
- {
- DescriptorType = ACPI_DESC_TYPE_NAMED;
- }
- break;
-
- default:
- break;
- }
-
- /* Display additional info for the major descriptor types */
-
- switch (DescriptorType)
- {
- case ACPI_DESC_TYPE_OPERAND:
- AcpiOsPrintf ("%12.12s RefCount 0x%04X\n",
- AcpiUtGetTypeName (Descriptor->Object.Common.Type),
- Descriptor->Object.Common.ReferenceCount);
- break;
-
- case ACPI_DESC_TYPE_PARSER:
- AcpiOsPrintf ("AmlOpcode 0x%04hX\n",
- Descriptor->Op.Asl.AmlOpcode);
- break;
-
- case ACPI_DESC_TYPE_NAMED:
- AcpiOsPrintf ("%4.4s\n",
- AcpiUtGetNodeName (&Descriptor->Node));
- break;
-
- default:
- AcpiOsPrintf ( "\n");
- break;
- }
- }
- }
-
- NumOutstanding++;
- }
-
- Element = Element->Next;
- }
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
-
- /* Print summary */
-
- if (!NumOutstanding)
- {
- ACPI_INFO ((AE_INFO, "No outstanding allocations"));
- }
- else
- {
- ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations",
- NumOutstanding, NumOutstanding));
- }
-
- return_VOID;
-}
-
-#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
-
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utxface.c
--- a/head/sys/contrib/dev/acpica/utilities/utxface.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,832 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utxface - External interfaces for "global" ACPI 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.
- */
-
-
-#define __UTXFACE_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/acdebug.h>
-#include <contrib/dev/acpica/include/actables.h>
-#include <contrib/dev/acpica/include/acinterp.h>
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utxface")
-
-
-#ifndef ACPI_ASL_COMPILER
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiInitializeSubsystem
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Initializes all global variables. This is the first function
- * called, so any early initialization belongs here.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiInitializeSubsystem (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
-
-
- AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
- ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
-
- /* Initialize the OS-Dependent layer */
-
- Status = AcpiOsInitialize ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
- return_ACPI_STATUS (Status);
- }
-
- /* Initialize all globals used by the subsystem */
-
- Status = AcpiUtInitGlobals ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
- return_ACPI_STATUS (Status);
- }
-
- /* Create the default mutex objects */
-
- Status = AcpiUtMutexInitialize ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Initialize the namespace manager and
- * the root of the namespace tree
- */
- Status = AcpiNsRootInitialize ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
- return_ACPI_STATUS (Status);
- }
-
- /* Initialize the global OSI interfaces list with the static names */
-
- Status = AcpiUtInitializeInterfaces ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
- return_ACPI_STATUS (Status);
- }
-
- /* If configured, initialize the AML debugger */
-
- ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ());
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiEnableSubsystem
- *
- * PARAMETERS: Flags - Init/enable Options
- *
- * RETURN: Status
- *
- * DESCRIPTION: Completes the subsystem initialization including hardware.
- * Puts system into ACPI mode if it isn't already.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiEnableSubsystem (
- UINT32 Flags)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
-
-
- /* Enable ACPI mode */
-
- if (!(Flags & ACPI_NO_ACPI_ENABLE))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
-
- AcpiGbl_OriginalMode = AcpiHwGetMode();
-
- Status = AcpiEnable ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Obtain a permanent mapping for the FACS. This is required for the
- * Global Lock and the Firmware Waking Vector
- */
- Status = AcpiTbInitializeFacs ();
- if (ACPI_FAILURE (Status))
- {
- ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Install the default OpRegion handlers. These are installed unless
- * other handlers have already been installed via the
- * InstallAddressSpaceHandler interface.
- */
- if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "[Init] Installing default address space handlers\n"));
-
- Status = AcpiEvInstallRegionHandlers ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Initialize ACPI Event handling (Fixed and General Purpose)
- *
- * Note1: We must have the hardware and events initialized before we can
- * execute any control methods safely. Any control method can require
- * ACPI hardware support, so the hardware must be fully initialized before
- * any method execution!
- *
- * Note2: Fixed events are initialized and enabled here. GPEs are
- * initialized, but cannot be enabled until after the hardware is
- * completely initialized (SCI and GlobalLock activated) and the various
- * initialization control methods are run (_REG, _STA, _INI) on the
- * entire namespace.
- */
- if (!(Flags & ACPI_NO_EVENT_INIT))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "[Init] Initializing ACPI events\n"));
-
- Status = AcpiEvInitializeEvents ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Install the SCI handler and Global Lock handler. This completes the
- * hardware initialization.
- */
- if (!(Flags & ACPI_NO_HANDLER_INIT))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "[Init] Installing SCI/GL handlers\n"));
-
- Status = AcpiEvInstallXruptHandlers ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiInitializeObjects
- *
- * PARAMETERS: Flags - Init/enable Options
- *
- * RETURN: Status
- *
- * DESCRIPTION: Completes namespace initialization by initializing device
- * objects and executing AML code for Regions, buffers, etc.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiInitializeObjects (
- UINT32 Flags)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
-
-
- /*
- * Run all _REG methods
- *
- * Note: Any objects accessed by the _REG methods will be automatically
- * initialized, even if they contain executable AML (see the call to
- * AcpiNsInitializeObjects below).
- */
- if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "[Init] Executing _REG OpRegion methods\n"));
-
- Status = AcpiEvInitializeOpRegions ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Execute any module-level code that was detected during the table load
- * phase. Although illegal since ACPI 2.0, there are many machines that
- * contain this type of code. Each block of detected executable AML code
- * outside of any control method is wrapped with a temporary control
- * method object and placed on a global list. The methods on this list
- * are executed below.
- */
- AcpiNsExecModuleCodeList ();
-
- /*
- * Initialize the objects that remain uninitialized. This runs the
- * executable AML that may be part of the declaration of these objects:
- * OperationRegions, BufferFields, Buffers, and Packages.
- */
- if (!(Flags & ACPI_NO_OBJECT_INIT))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "[Init] Completing Initialization of ACPI Objects\n"));
-
- Status = AcpiNsInitializeObjects ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Initialize all device objects in the namespace. This runs the device
- * _STA and _INI methods.
- */
- if (!(Flags & ACPI_NO_DEVICE_INIT))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "[Init] Initializing ACPI Devices\n"));
-
- Status = AcpiNsInitializeDevices ();
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
- }
-
- /*
- * Empty the caches (delete the cached objects) on the assumption that
- * the table load filled them up more than they will be at runtime --
- * thus wasting non-paged memory.
- */
- Status = AcpiPurgeCachedObjects ();
-
- AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInitializeObjects)
-
-
-#endif
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTerminate
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTerminate (
- void)
-{
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiTerminate);
-
-
- /* Just exit if subsystem is already shutdown */
-
- if (AcpiGbl_Shutdown)
- {
- ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated"));
- return_ACPI_STATUS (AE_OK);
- }
-
- /* Subsystem appears active, go ahead and shut it down */
-
- AcpiGbl_Shutdown = TRUE;
- AcpiGbl_StartupFlags = 0;
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
-
- /* Terminate the AML Debugger if present */
-
- ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE);
-
- /* Shutdown and free all resources */
-
- AcpiUtSubsystemShutdown ();
-
- /* Free the mutex objects */
-
- AcpiUtMutexTerminate ();
-
-
-#ifdef ACPI_DEBUGGER
-
- /* Shut down the debugger */
-
- AcpiDbTerminate ();
-#endif
-
- /* Now we can shutdown the OS-dependent layer */
-
- Status = AcpiOsTerminate ();
- return_ACPI_STATUS (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiTerminate)
-
-
-#ifndef ACPI_ASL_COMPILER
-/*******************************************************************************
- *
- * FUNCTION: AcpiSubsystemStatus
- *
- * PARAMETERS: None
- *
- * RETURN: Status of the ACPI subsystem
- *
- * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
- * before making any other calls, to ensure the subsystem
- * initialized successfully.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiSubsystemStatus (
- void)
-{
-
- if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK)
- {
- return (AE_OK);
- }
- else
- {
- return (AE_ERROR);
- }
-}
-
-ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetSystemInfo
- *
- * PARAMETERS: OutBuffer - A buffer to receive the resources for the
- * device
- *
- * RETURN: Status - the status of the call
- *
- * DESCRIPTION: This function is called to get information about the current
- * state of the ACPI subsystem. It will return system information
- * in the OutBuffer.
- *
- * If the function fails an appropriate status will be returned
- * and the value of OutBuffer is undefined.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetSystemInfo (
- ACPI_BUFFER *OutBuffer)
-{
- ACPI_SYSTEM_INFO *InfoPtr;
- ACPI_STATUS Status;
-
-
- ACPI_FUNCTION_TRACE (AcpiGetSystemInfo);
-
-
- /* Parameter validation */
-
- Status = AcpiUtValidateBuffer (OutBuffer);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Populate the return buffer
- */
- InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
-
- InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
-
- /* System flags (ACPI capabilities) */
-
- InfoPtr->Flags = ACPI_SYS_MODE_ACPI;
-
- /* Timer resolution - 24 or 32 bits */
-
- if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
- {
- InfoPtr->TimerResolution = 24;
- }
- else
- {
- InfoPtr->TimerResolution = 32;
- }
-
- /* Clear the reserved fields */
-
- InfoPtr->Reserved1 = 0;
- InfoPtr->Reserved2 = 0;
-
- /* Current debug levels */
-
- InfoPtr->DebugLayer = AcpiDbgLayer;
- InfoPtr->DebugLevel = AcpiDbgLevel;
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiGetStatistics
- *
- * PARAMETERS: Stats - Where the statistics are returned
- *
- * RETURN: Status - the status of the call
- *
- * DESCRIPTION: Get the contents of the various system counters
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiGetStatistics (
- ACPI_STATISTICS *Stats)
-{
- ACPI_FUNCTION_TRACE (AcpiGetStatistics);
-
-
- /* Parameter validation */
-
- if (!Stats)
- {
- return_ACPI_STATUS (AE_BAD_PARAMETER);
- }
-
- /* Various interrupt-based event counters */
-
- Stats->SciCount = AcpiSciCount;
- Stats->GpeCount = AcpiGpeCount;
-
- ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount,
- sizeof (AcpiFixedEventCount));
-
-
- /* Other counters */
-
- Stats->MethodCount = AcpiMethodCount;
-
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiGetStatistics)
-
-
-/*****************************************************************************
- *
- * FUNCTION: AcpiInstallInitializationHandler
- *
- * PARAMETERS: Handler - Callback procedure
- * Function - Not (currently) used, see below
- *
- * RETURN: Status
- *
- * DESCRIPTION: Install an initialization handler
- *
- * TBD: When a second function is added, must save the Function also.
- *
- ****************************************************************************/
-
-ACPI_STATUS
-AcpiInstallInitializationHandler (
- ACPI_INIT_HANDLER Handler,
- UINT32 Function)
-{
-
- if (!Handler)
- {
- return (AE_BAD_PARAMETER);
- }
-
- if (AcpiGbl_InitHandler)
- {
- return (AE_ALREADY_EXISTS);
- }
-
- AcpiGbl_InitHandler = Handler;
- return AE_OK;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler)
-
-
-/*****************************************************************************
- *
- * FUNCTION: AcpiPurgeCachedObjects
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Empty all caches (delete the cached objects)
- *
- ****************************************************************************/
-
-ACPI_STATUS
-AcpiPurgeCachedObjects (
- void)
-{
- ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects);
-
- (void) AcpiOsPurgeCache (AcpiGbl_StateCache);
- (void) AcpiOsPurgeCache (AcpiGbl_OperandCache);
- (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache);
- (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache);
- return_ACPI_STATUS (AE_OK);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects)
-
-
-/*****************************************************************************
- *
- * FUNCTION: AcpiInstallInterface
- *
- * PARAMETERS: InterfaceName - The interface to install
- *
- * RETURN: Status
- *
- * DESCRIPTION: Install an _OSI interface to the global list
- *
- ****************************************************************************/
-
-ACPI_STATUS
-AcpiInstallInterface (
- ACPI_STRING InterfaceName)
-{
- ACPI_STATUS Status;
- ACPI_INTERFACE_INFO *InterfaceInfo;
-
-
- /* Parameter validation */
-
- if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
- {
- return (AE_BAD_PARAMETER);
- }
-
- (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
-
- /* Check if the interface name is already in the global list */
-
- InterfaceInfo = AcpiUtGetInterface (InterfaceName);
- if (InterfaceInfo)
- {
- /*
- * The interface already exists in the list. This is OK if the
- * interface has been marked invalid -- just clear the bit.
- */
- if (InterfaceInfo->Flags & ACPI_OSI_INVALID)
- {
- InterfaceInfo->Flags &= ~ACPI_OSI_INVALID;
- Status = AE_OK;
- }
- else
- {
- Status = AE_ALREADY_EXISTS;
- }
- }
- else
- {
- /* New interface name, install into the global list */
-
- Status = AcpiUtInstallInterface (InterfaceName);
- }
-
- AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInstallInterface)
-
-
-/*****************************************************************************
- *
- * FUNCTION: AcpiRemoveInterface
- *
- * PARAMETERS: InterfaceName - The interface to remove
- *
- * RETURN: Status
- *
- * DESCRIPTION: Remove an _OSI interface from the global list
- *
- ****************************************************************************/
-
-ACPI_STATUS
-AcpiRemoveInterface (
- ACPI_STRING InterfaceName)
-{
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!InterfaceName || (ACPI_STRLEN (InterfaceName) == 0))
- {
- return (AE_BAD_PARAMETER);
- }
-
- (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
-
- Status = AcpiUtRemoveInterface (InterfaceName);
-
- AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiRemoveInterface)
-
-
-/*****************************************************************************
- *
- * FUNCTION: AcpiInstallInterfaceHandler
- *
- * PARAMETERS: Handler - The _OSI interface handler to install
- * NULL means "remove existing handler"
- *
- * RETURN: Status
- *
- * DESCRIPTION: Install a handler for the predefined _OSI ACPI method.
- * invoked during execution of the internal implementation of
- * _OSI. A NULL handler simply removes any existing handler.
- *
- ****************************************************************************/
-
-ACPI_STATUS
-AcpiInstallInterfaceHandler (
- ACPI_INTERFACE_HANDLER Handler)
-{
- ACPI_STATUS Status = AE_OK;
-
-
- (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
-
- if (Handler && AcpiGbl_InterfaceHandler)
- {
- Status = AE_ALREADY_EXISTS;
- }
- else
- {
- AcpiGbl_InterfaceHandler = Handler;
- }
-
- AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
- return (Status);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInstallInterfaceHandler)
-
-
-/*****************************************************************************
- *
- * FUNCTION: AcpiCheckAddressRange
- *
- * PARAMETERS: SpaceId - Address space ID
- * Address - Start address
- * Length - Length
- * Warn - TRUE if warning on overlap desired
- *
- * RETURN: Count of the number of conflicts detected.
- *
- * DESCRIPTION: Check if the input address range overlaps any of the
- * ASL operation region address ranges.
- *
- ****************************************************************************/
-
-UINT32
-AcpiCheckAddressRange (
- ACPI_ADR_SPACE_TYPE SpaceId,
- ACPI_PHYSICAL_ADDRESS Address,
- ACPI_SIZE Length,
- BOOLEAN Warn)
-{
- UINT32 Overlaps;
- ACPI_STATUS Status;
-
-
- Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
- if (ACPI_FAILURE (Status))
- {
- return (0);
- }
-
- Overlaps = AcpiUtCheckAddressRange (SpaceId, Address,
- (UINT32) Length, Warn);
-
- (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (Overlaps);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiCheckAddressRange)
-
-#endif /* !ACPI_ASL_COMPILER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utxferror.c
--- a/head/sys/contrib/dev/acpica/utilities/utxferror.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,483 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utxferror - Various error/warning output 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.
- */
-
-#define __UTXFERROR_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utxferror")
-
-/*
- * This module is used for the in-kernel ACPICA as well as the ACPICA
- * tools/applications.
- *
- * For the iASL compiler case, the output is redirected to stderr so that
- * any of the various ACPI errors and warnings do not appear in the output
- * files, for either the compiler or disassembler portions of the tool.
- */
-#ifdef ACPI_ASL_COMPILER
-#include <stdio.h>
-
-extern FILE *AcpiGbl_OutputFile;
-
-#define ACPI_MSG_REDIRECT_BEGIN \
- FILE *OutputFile = AcpiGbl_OutputFile; \
- AcpiOsRedirectOutput (stderr);
-
-#define ACPI_MSG_REDIRECT_END \
- AcpiOsRedirectOutput (OutputFile);
-
-#else
-/*
- * non-iASL case - no redirection, nothing to do
- */
-#define ACPI_MSG_REDIRECT_BEGIN
-#define ACPI_MSG_REDIRECT_END
-#endif
-
-/*
- * Common message prefixes
- */
-#define ACPI_MSG_ERROR "ACPI Error: "
-#define ACPI_MSG_EXCEPTION "ACPI Exception: "
-#define ACPI_MSG_WARNING "ACPI Warning: "
-#define ACPI_MSG_INFO "ACPI: "
-
-/*
- * Common message suffix
- */
-#define ACPI_MSG_SUFFIX \
- AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiError
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Format - Printf format string + additional args
- *
- * RETURN: None
- *
- * DESCRIPTION: Print "ACPI Error" message with module/line/version info
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiError (
- const char *ModuleName,
- UINT32 LineNumber,
- const char *Format,
- ...)
-{
- va_list ArgList;
-
-
- ACPI_MSG_REDIRECT_BEGIN;
- AcpiOsPrintf (ACPI_MSG_ERROR);
-
- va_start (ArgList, Format);
- AcpiOsVprintf (Format, ArgList);
- ACPI_MSG_SUFFIX;
- va_end (ArgList);
-
- ACPI_MSG_REDIRECT_END;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiError)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiException
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Status - Status to be formatted
- * Format - Printf format string + additional args
- *
- * RETURN: None
- *
- * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
- * and decoded ACPI_STATUS.
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiException (
- const char *ModuleName,
- UINT32 LineNumber,
- ACPI_STATUS Status,
- const char *Format,
- ...)
-{
- va_list ArgList;
-
-
- ACPI_MSG_REDIRECT_BEGIN;
- AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
-
- va_start (ArgList, Format);
- AcpiOsVprintf (Format, ArgList);
- ACPI_MSG_SUFFIX;
- va_end (ArgList);
-
- ACPI_MSG_REDIRECT_END;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiException)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiWarning
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Format - Printf format string + additional args
- *
- * RETURN: None
- *
- * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiWarning (
- const char *ModuleName,
- UINT32 LineNumber,
- const char *Format,
- ...)
-{
- va_list ArgList;
-
-
- ACPI_MSG_REDIRECT_BEGIN;
- AcpiOsPrintf (ACPI_MSG_WARNING);
-
- va_start (ArgList, Format);
- AcpiOsVprintf (Format, ArgList);
- ACPI_MSG_SUFFIX;
- va_end (ArgList);
-
- ACPI_MSG_REDIRECT_END;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiWarning)
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiInfo
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Format - Printf format string + additional args
- *
- * RETURN: None
- *
- * DESCRIPTION: Print generic "ACPI:" information message. There is no
- * module/line/version info in order to keep the message simple.
- *
- * TBD: ModuleName and LineNumber args are not needed, should be removed.
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiInfo (
- const char *ModuleName,
- UINT32 LineNumber,
- const char *Format,
- ...)
-{
- va_list ArgList;
-
-#ifdef _KERNEL
- /* Temporarily hide too verbose printfs. */
- if (!bootverbose)
- return;
-#endif
-
- ACPI_MSG_REDIRECT_BEGIN;
- AcpiOsPrintf (ACPI_MSG_INFO);
-
- va_start (ArgList, Format);
- AcpiOsVprintf (Format, ArgList);
- AcpiOsPrintf ("\n");
- va_end (ArgList);
-
- ACPI_MSG_REDIRECT_END;
-}
-
-ACPI_EXPORT_SYMBOL (AcpiInfo)
-
-
-/*
- * The remainder of this module contains internal error functions that may
- * be configured out.
- */
-#if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtPredefinedWarning
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Pathname - Full pathname to the node
- * NodeFlags - From Namespace node for the method/object
- * Format - Printf format string + additional args
- *
- * RETURN: None
- *
- * DESCRIPTION: Warnings for the predefined validation module. Messages are
- * only emitted the first time a problem with a particular
- * method/object is detected. This prevents a flood of error
- * messages for methods that are repeatedly evaluated.
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiUtPredefinedWarning (
- const char *ModuleName,
- UINT32 LineNumber,
- char *Pathname,
- UINT8 NodeFlags,
- const char *Format,
- ...)
-{
- va_list ArgList;
-
-
- /*
- * Warning messages for this method/object will be disabled after the
- * first time a validation fails or an object is successfully repaired.
- */
- if (NodeFlags & ANOBJ_EVALUATED)
- {
- return;
- }
-
- AcpiOsPrintf (ACPI_MSG_WARNING "For %s: ", Pathname);
-
- va_start (ArgList, Format);
- AcpiOsVprintf (Format, ArgList);
- ACPI_MSG_SUFFIX;
- va_end (ArgList);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtPredefinedInfo
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Pathname - Full pathname to the node
- * NodeFlags - From Namespace node for the method/object
- * Format - Printf format string + additional args
- *
- * RETURN: None
- *
- * DESCRIPTION: Info messages for the predefined validation module. Messages
- * are only emitted the first time a problem with a particular
- * method/object is detected. This prevents a flood of
- * messages for methods that are repeatedly evaluated.
- *
- ******************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiUtPredefinedInfo (
- const char *ModuleName,
- UINT32 LineNumber,
- char *Pathname,
- UINT8 NodeFlags,
- const char *Format,
- ...)
-{
- va_list ArgList;
-
-
- /*
- * Warning messages for this method/object will be disabled after the
- * first time a validation fails or an object is successfully repaired.
- */
- if (NodeFlags & ANOBJ_EVALUATED)
- {
- return;
- }
-
- AcpiOsPrintf (ACPI_MSG_INFO "For %s: ", Pathname);
-
- va_start (ArgList, Format);
- AcpiOsVprintf (Format, ArgList);
- ACPI_MSG_SUFFIX;
- va_end (ArgList);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtNamespaceError
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * InternalName - Name or path of the namespace node
- * LookupStatus - Exception code from NS lookup
- *
- * RETURN: None
- *
- * DESCRIPTION: Print error message with the full pathname for the NS node.
- *
- ******************************************************************************/
-
-void
-AcpiUtNamespaceError (
- const char *ModuleName,
- UINT32 LineNumber,
- const char *InternalName,
- ACPI_STATUS LookupStatus)
-{
- ACPI_STATUS Status;
- UINT32 BadName;
- char *Name = NULL;
-
-
- ACPI_MSG_REDIRECT_BEGIN;
- AcpiOsPrintf (ACPI_MSG_ERROR);
-
- if (LookupStatus == AE_BAD_CHARACTER)
- {
- /* There is a non-ascii character in the name */
-
- ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
- AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)", BadName);
- }
- else
- {
- /* Convert path to external format */
-
- Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
- InternalName, NULL, &Name);
-
- /* Print target name */
-
- if (ACPI_SUCCESS (Status))
- {
- AcpiOsPrintf ("[%s]", Name);
- }
- else
- {
- AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
- }
-
- if (Name)
- {
- ACPI_FREE (Name);
- }
- }
-
- AcpiOsPrintf (" Namespace lookup failure, %s",
- AcpiFormatException (LookupStatus));
-
- ACPI_MSG_SUFFIX;
- ACPI_MSG_REDIRECT_END;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtMethodError
- *
- * PARAMETERS: ModuleName - Caller's module name (for error output)
- * LineNumber - Caller's line number (for error output)
- * Message - Error message to use on failure
- * PrefixNode - Prefix relative to the path
- * Path - Path to the node (optional)
- * MethodStatus - Execution status
- *
- * RETURN: None
- *
- * DESCRIPTION: Print error message with the full pathname for the method.
- *
- ******************************************************************************/
-
-void
-AcpiUtMethodError (
- const char *ModuleName,
- UINT32 LineNumber,
- const char *Message,
- ACPI_NAMESPACE_NODE *PrefixNode,
- const char *Path,
- ACPI_STATUS MethodStatus)
-{
- ACPI_STATUS Status;
- ACPI_NAMESPACE_NODE *Node = PrefixNode;
-
-
- ACPI_MSG_REDIRECT_BEGIN;
- AcpiOsPrintf (ACPI_MSG_ERROR);
-
- if (Path)
- {
- Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
- &Node);
- if (ACPI_FAILURE (Status))
- {
- AcpiOsPrintf ("[Could not get node by pathname]");
- }
- }
-
- AcpiNsPrintNodePathname (Node, Message);
- AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
-
- ACPI_MSG_SUFFIX;
- ACPI_MSG_REDIRECT_END;
-}
-
-#endif /* ACPI_NO_ERROR_MESSAGES */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/utilities/utxfmutex.c
--- a/head/sys/contrib/dev/acpica/utilities/utxfmutex.c Fri Mar 02 17:08:15 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*******************************************************************************
- *
- * Module Name: utxfmutex - external AML mutex access 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.
- */
-
-#define __UTXFMUTEX_C__
-
-#include <contrib/dev/acpica/include/acpi.h>
-#include <contrib/dev/acpica/include/accommon.h>
-#include <contrib/dev/acpica/include/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("utxfmutex")
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiUtGetMutexObject (
- ACPI_HANDLE Handle,
- ACPI_STRING Pathname,
- ACPI_OPERAND_OBJECT **RetObj);
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtGetMutexObject
- *
- * PARAMETERS: Handle - Mutex or prefix handle (optional)
- * Pathname - Mutex pathname (optional)
- * RetObj - Where the mutex object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Get an AML mutex object. The mutex node is pointed to by
- * Handle:Pathname. Either Handle or Pathname can be NULL, but
- * not both.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiUtGetMutexObject (
- ACPI_HANDLE Handle,
- ACPI_STRING Pathname,
- ACPI_OPERAND_OBJECT **RetObj)
-{
- ACPI_NAMESPACE_NODE *MutexNode;
- ACPI_OPERAND_OBJECT *MutexObj;
- ACPI_STATUS Status;
-
-
- /* Parameter validation */
-
- if (!RetObj || (!Handle && !Pathname))
- {
- return (AE_BAD_PARAMETER);
- }
-
- /* Get a the namespace node for the mutex */
-
- MutexNode = Handle;
- if (Pathname != NULL)
- {
- Status = AcpiGetHandle (Handle, Pathname,
- ACPI_CAST_PTR (ACPI_HANDLE, &MutexNode));
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
-
- /* Ensure that we actually have a Mutex object */
-
- if (!MutexNode ||
- (MutexNode->Type != ACPI_TYPE_MUTEX))
- {
- return (AE_TYPE);
- }
-
- /* Get the low-level mutex object */
-
- MutexObj = AcpiNsGetAttachedObject (MutexNode);
- if (!MutexObj)
- {
- return (AE_NULL_OBJECT);
- }
-
- *RetObj = MutexObj;
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiAcquireMutex
- *
- * PARAMETERS: Handle - Mutex or prefix handle (optional)
- * Pathname - Mutex pathname (optional)
- * Timeout - Max time to wait for the lock (millisec)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Acquire an AML mutex. This is a device driver interface to
- * AML mutex objects, and allows for transaction locking between
- * drivers and AML code. The mutex node is pointed to by
- * Handle:Pathname. Either Handle or Pathname can be NULL, but
- * not both.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiAcquireMutex (
- ACPI_HANDLE Handle,
- ACPI_STRING Pathname,
- UINT16 Timeout)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *MutexObj;
-
-
- /* Get the low-level mutex associated with Handle:Pathname */
-
- Status = AcpiUtGetMutexObject (Handle, Pathname, &MutexObj);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Acquire the OS mutex */
-
- Status = AcpiOsAcquireMutex (MutexObj->Mutex.OsMutex, Timeout);
- return (Status);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiReleaseMutex
- *
- * PARAMETERS: Handle - Mutex or prefix handle (optional)
- * Pathname - Mutex pathname (optional)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Release an AML mutex. This is a device driver interface to
- * AML mutex objects, and allows for transaction locking between
- * drivers and AML code. The mutex node is pointed to by
- * Handle:Pathname. Either Handle or Pathname can be NULL, but
- * not both.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiReleaseMutex (
- ACPI_HANDLE Handle,
- ACPI_STRING Pathname)
-{
- ACPI_STATUS Status;
- ACPI_OPERAND_OBJECT *MutexObj;
-
-
- /* Get the low-level mutex associated with Handle:Pathname */
-
- Status = AcpiUtGetMutexObject (Handle, Pathname, &MutexObj);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
-
- /* Release the OS mutex */
-
- AcpiOsReleaseMutex (MutexObj->Mutex.OsMutex);
- return (AE_OK);
-}
More information about the Zrouter-src-freebsd
mailing list