From 748be155016b7e29202235815e27acc5ff5e9e87 Mon Sep 17 00:00:00 2001 From: msmith Date: Sat, 28 Oct 2000 05:01:06 +0000 Subject: Initial import of the Intel-maintained ACPI Component Architecture. This is Intel's reference implementation of the core operating-system ACPI support. (This import is on the vendor branch.) --- sys/contrib/dev/acpica/Subsystem/Common/cmalloc.c | 801 +++++++++++ sys/contrib/dev/acpica/Subsystem/Common/cmclib.c | 956 +++++++++++++ sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c | 826 +++++++++++ sys/contrib/dev/acpica/Subsystem/Common/cmdebug.c | 657 +++++++++ sys/contrib/dev/acpica/Subsystem/Common/cmdelete.c | 806 +++++++++++ sys/contrib/dev/acpica/Subsystem/Common/cmeval.c | 494 +++++++ sys/contrib/dev/acpica/Subsystem/Common/cmglobal.c | 705 +++++++++ sys/contrib/dev/acpica/Subsystem/Common/cminit.c | 347 +++++ sys/contrib/dev/acpica/Subsystem/Common/cmobject.c | 817 +++++++++++ sys/contrib/dev/acpica/Subsystem/Common/cmutils.c | 915 ++++++++++++ sys/contrib/dev/acpica/Subsystem/Common/cmxface.c | 529 +++++++ sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c | 997 +++++++++++++ .../dev/acpica/Subsystem/Debugger/dbdisasm.c | 822 +++++++++++ .../dev/acpica/Subsystem/Debugger/dbdisply.c | 904 ++++++++++++ sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c | 482 +++++++ .../dev/acpica/Subsystem/Debugger/dbfileio.c | 472 ++++++ .../dev/acpica/Subsystem/Debugger/dbhistry.c | 301 ++++ .../dev/acpica/Subsystem/Debugger/dbinput.c | 981 +++++++++++++ .../dev/acpica/Subsystem/Debugger/dbstats.c | 548 +++++++ .../dev/acpica/Subsystem/Debugger/dbutils.c | 465 ++++++ .../dev/acpica/Subsystem/Debugger/dbxface.c | 432 ++++++ .../dev/acpica/Subsystem/Dispatcher/dsfield.c | 546 +++++++ .../dev/acpica/Subsystem/Dispatcher/dsmethod.c | 644 +++++++++ .../dev/acpica/Subsystem/Dispatcher/dsmthdat.c | 882 ++++++++++++ .../dev/acpica/Subsystem/Dispatcher/dsobject.c | 805 +++++++++++ .../dev/acpica/Subsystem/Dispatcher/dsopcode.c | 1070 ++++++++++++++ .../dev/acpica/Subsystem/Dispatcher/dsutils.c | 932 ++++++++++++ .../dev/acpica/Subsystem/Dispatcher/dswexec.c | 800 +++++++++++ .../dev/acpica/Subsystem/Dispatcher/dswload.c | 928 ++++++++++++ .../dev/acpica/Subsystem/Dispatcher/dswscope.c | 268 ++++ .../dev/acpica/Subsystem/Dispatcher/dswstate.c | 841 +++++++++++ sys/contrib/dev/acpica/Subsystem/Events/evevent.c | 953 +++++++++++++ sys/contrib/dev/acpica/Subsystem/Events/evmisc.c | 486 +++++++ sys/contrib/dev/acpica/Subsystem/Events/evregion.c | 765 ++++++++++ sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c | 557 ++++++++ sys/contrib/dev/acpica/Subsystem/Events/evsci.c | 448 ++++++ sys/contrib/dev/acpica/Subsystem/Events/evxface.c | 744 ++++++++++ sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c | 610 ++++++++ sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c | 515 +++++++ sys/contrib/dev/acpica/Subsystem/Hardware/hwacpi.c | 501 +++++++ .../dev/acpica/Subsystem/Hardware/hwcpu32.c | 845 +++++++++++ sys/contrib/dev/acpica/Subsystem/Hardware/hwgpe.c | 303 ++++ sys/contrib/dev/acpica/Subsystem/Hardware/hwregs.c | 825 +++++++++++ .../dev/acpica/Subsystem/Hardware/hwxface.c | 728 ++++++++++ .../dev/acpica/Subsystem/Include/accommon.h | 757 ++++++++++ .../dev/acpica/Subsystem/Include/acconfig.h | 269 ++++ sys/contrib/dev/acpica/Subsystem/Include/acdebug.h | 493 +++++++ .../dev/acpica/Subsystem/Include/acdispat.h | 523 +++++++ sys/contrib/dev/acpica/Subsystem/Include/acefi.h | 127 ++ sys/contrib/dev/acpica/Subsystem/Include/acenv.h | 374 +++++ .../dev/acpica/Subsystem/Include/acevents.h | 306 ++++ sys/contrib/dev/acpica/Subsystem/Include/acexcep.h | 312 ++++ .../dev/acpica/Subsystem/Include/acfreebsd.h | 134 ++ sys/contrib/dev/acpica/Subsystem/Include/acgcc.h | 240 ++++ .../dev/acpica/Subsystem/Include/acglobal.h | 410 ++++++ sys/contrib/dev/acpica/Subsystem/Include/achware.h | 260 ++++ .../dev/acpica/Subsystem/Include/acinterp.h | 624 ++++++++ sys/contrib/dev/acpica/Subsystem/Include/aclinux.h | 150 ++ sys/contrib/dev/acpica/Subsystem/Include/aclocal.h | 963 +++++++++++++ .../dev/acpica/Subsystem/Include/acmacros.h | 536 +++++++ sys/contrib/dev/acpica/Subsystem/Include/acmsvc.h | 129 ++ .../dev/acpica/Subsystem/Include/acnamesp.h | 519 +++++++ .../dev/acpica/Subsystem/Include/acobject.h | 515 +++++++ .../dev/acpica/Subsystem/Include/acoutput.h | 217 +++ .../dev/acpica/Subsystem/Include/acparser.h | 437 ++++++ sys/contrib/dev/acpica/Subsystem/Include/acpi.h | 141 ++ .../dev/acpica/Subsystem/Include/acpiosxf.h | 419 ++++++ sys/contrib/dev/acpica/Subsystem/Include/acpixf.h | 410 ++++++ sys/contrib/dev/acpica/Subsystem/Include/acresrc.h | 396 +++++ .../dev/acpica/Subsystem/Include/actables.h | 259 ++++ sys/contrib/dev/acpica/Subsystem/Include/actbl.h | 282 ++++ sys/contrib/dev/acpica/Subsystem/Include/actbl32.h | 206 +++ sys/contrib/dev/acpica/Subsystem/Include/actbl64.h | 206 +++ sys/contrib/dev/acpica/Subsystem/Include/actypes.h | 1111 +++++++++++++++ sys/contrib/dev/acpica/Subsystem/Include/acwin.h | 190 +++ sys/contrib/dev/acpica/Subsystem/Include/amlcode.h | 553 +++++++ .../dev/acpica/Subsystem/Interpreter/amconfig.c | 433 ++++++ .../dev/acpica/Subsystem/Interpreter/amcreate.c | 1216 ++++++++++++++++ .../dev/acpica/Subsystem/Interpreter/amdump.c | 992 +++++++++++++ .../dev/acpica/Subsystem/Interpreter/amdyadic.c | 906 ++++++++++++ .../dev/acpica/Subsystem/Interpreter/amfield.c | 446 ++++++ .../dev/acpica/Subsystem/Interpreter/amfldio.c | 857 +++++++++++ .../dev/acpica/Subsystem/Interpreter/ammisc.c | 682 +++++++++ .../dev/acpica/Subsystem/Interpreter/ammonad.c | 1183 +++++++++++++++ .../dev/acpica/Subsystem/Interpreter/amnames.c | 551 +++++++ .../dev/acpica/Subsystem/Interpreter/amprep.c | 580 ++++++++ .../dev/acpica/Subsystem/Interpreter/amregion.c | 561 ++++++++ .../dev/acpica/Subsystem/Interpreter/amresnte.c | 693 +++++++++ .../dev/acpica/Subsystem/Interpreter/amresolv.c | 629 ++++++++ .../dev/acpica/Subsystem/Interpreter/amresop.c | 629 ++++++++ .../dev/acpica/Subsystem/Interpreter/amstore.c | 531 +++++++ .../dev/acpica/Subsystem/Interpreter/amstoren.c | 713 +++++++++ .../dev/acpica/Subsystem/Interpreter/amstorob.c | 442 ++++++ .../dev/acpica/Subsystem/Interpreter/amsystem.c | 463 ++++++ .../dev/acpica/Subsystem/Interpreter/amutils.c | 652 +++++++++ .../dev/acpica/Subsystem/Interpreter/amxface.c | 190 +++ .../dev/acpica/Subsystem/Namespace/nsaccess.c | 737 ++++++++++ .../dev/acpica/Subsystem/Namespace/nsalloc.c | 728 ++++++++++ .../dev/acpica/Subsystem/Namespace/nsdump.c | 677 +++++++++ .../dev/acpica/Subsystem/Namespace/nseval.c | 670 +++++++++ .../dev/acpica/Subsystem/Namespace/nsinit.c | 514 +++++++ .../dev/acpica/Subsystem/Namespace/nsload.c | 712 +++++++++ .../dev/acpica/Subsystem/Namespace/nsnames.c | 334 +++++ .../dev/acpica/Subsystem/Namespace/nsobject.c | 523 +++++++ .../dev/acpica/Subsystem/Namespace/nssearch.c | 505 +++++++ .../dev/acpica/Subsystem/Namespace/nsutils.c | 1001 +++++++++++++ .../dev/acpica/Subsystem/Namespace/nswalk.c | 384 +++++ .../dev/acpica/Subsystem/Namespace/nsxfname.c | 410 ++++++ .../dev/acpica/Subsystem/Namespace/nsxfobj.c | 853 +++++++++++ sys/contrib/dev/acpica/Subsystem/Parser/psargs.c | 950 ++++++++++++ sys/contrib/dev/acpica/Subsystem/Parser/psfind.c | 459 ++++++ sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c | 704 +++++++++ sys/contrib/dev/acpica/Subsystem/Parser/psparse.c | 1506 ++++++++++++++++++++ sys/contrib/dev/acpica/Subsystem/Parser/psscope.c | 375 +++++ sys/contrib/dev/acpica/Subsystem/Parser/pstree.c | 518 +++++++ sys/contrib/dev/acpica/Subsystem/Parser/psutils.c | 683 +++++++++ sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c | 727 ++++++++++ sys/contrib/dev/acpica/Subsystem/Parser/psxface.c | 270 ++++ .../dev/acpica/Subsystem/Resources/rsaddr.c | 922 ++++++++++++ .../dev/acpica/Subsystem/Resources/rscalc.c | 986 +++++++++++++ .../dev/acpica/Subsystem/Resources/rscreate.c | 548 +++++++ .../dev/acpica/Subsystem/Resources/rsdump.c | 1044 ++++++++++++++ sys/contrib/dev/acpica/Subsystem/Resources/rsio.c | 636 +++++++++ sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c | 683 +++++++++ .../dev/acpica/Subsystem/Resources/rslist.c | 606 ++++++++ .../dev/acpica/Subsystem/Resources/rsmemory.c | 660 +++++++++ .../dev/acpica/Subsystem/Resources/rsmisc.c | 725 ++++++++++ .../dev/acpica/Subsystem/Resources/rsutils.c | 511 +++++++ .../dev/acpica/Subsystem/Resources/rsxface.c | 326 +++++ sys/contrib/dev/acpica/Subsystem/Tables/tbget.c | 733 ++++++++++ sys/contrib/dev/acpica/Subsystem/Tables/tbinstal.c | 692 +++++++++ sys/contrib/dev/acpica/Subsystem/Tables/tbutils.c | 486 +++++++ sys/contrib/dev/acpica/Subsystem/Tables/tbxface.c | 506 +++++++ sys/contrib/dev/acpica/Subsystem/Tables/tbxfroot.c | 319 +++++ sys/contrib/dev/acpica/acconfig.h | 269 ++++ sys/contrib/dev/acpica/acdebug.h | 493 +++++++ sys/contrib/dev/acpica/acdispat.h | 523 +++++++ sys/contrib/dev/acpica/acefi.h | 127 ++ sys/contrib/dev/acpica/acenv.h | 374 +++++ sys/contrib/dev/acpica/acevents.h | 306 ++++ sys/contrib/dev/acpica/acexcep.h | 312 ++++ sys/contrib/dev/acpica/acfreebsd.h | 134 ++ sys/contrib/dev/acpica/acgcc.h | 240 ++++ sys/contrib/dev/acpica/acglobal.h | 410 ++++++ sys/contrib/dev/acpica/achware.h | 260 ++++ sys/contrib/dev/acpica/acinterp.h | 624 ++++++++ sys/contrib/dev/acpica/aclocal.h | 963 +++++++++++++ sys/contrib/dev/acpica/acmacros.h | 536 +++++++ sys/contrib/dev/acpica/acnamesp.h | 519 +++++++ sys/contrib/dev/acpica/acobject.h | 515 +++++++ sys/contrib/dev/acpica/acoutput.h | 217 +++ sys/contrib/dev/acpica/acparser.h | 437 ++++++ sys/contrib/dev/acpica/acpi.h | 141 ++ sys/contrib/dev/acpica/acpiosxf.h | 419 ++++++ sys/contrib/dev/acpica/acpixf.h | 410 ++++++ sys/contrib/dev/acpica/acresrc.h | 396 +++++ sys/contrib/dev/acpica/actables.h | 259 ++++ sys/contrib/dev/acpica/actbl.h | 282 ++++ sys/contrib/dev/acpica/actypes.h | 1111 +++++++++++++++ sys/contrib/dev/acpica/acutils.h | 757 ++++++++++ sys/contrib/dev/acpica/amlcode.h | 553 +++++++ sys/contrib/dev/acpica/dbcmds.c | 997 +++++++++++++ sys/contrib/dev/acpica/dbdisasm.c | 822 +++++++++++ sys/contrib/dev/acpica/dbdisply.c | 904 ++++++++++++ sys/contrib/dev/acpica/dbexec.c | 482 +++++++ sys/contrib/dev/acpica/dbfileio.c | 472 ++++++ sys/contrib/dev/acpica/dbhistry.c | 301 ++++ sys/contrib/dev/acpica/dbinput.c | 981 +++++++++++++ sys/contrib/dev/acpica/dbstats.c | 548 +++++++ sys/contrib/dev/acpica/dbutils.c | 465 ++++++ sys/contrib/dev/acpica/dbxface.c | 432 ++++++ sys/contrib/dev/acpica/dsfield.c | 546 +++++++ sys/contrib/dev/acpica/dsmethod.c | 644 +++++++++ sys/contrib/dev/acpica/dsmthdat.c | 882 ++++++++++++ sys/contrib/dev/acpica/dsobject.c | 805 +++++++++++ sys/contrib/dev/acpica/dsopcode.c | 1070 ++++++++++++++ sys/contrib/dev/acpica/dsutils.c | 932 ++++++++++++ sys/contrib/dev/acpica/dswexec.c | 800 +++++++++++ sys/contrib/dev/acpica/dswload.c | 928 ++++++++++++ sys/contrib/dev/acpica/dswscope.c | 268 ++++ sys/contrib/dev/acpica/dswstate.c | 841 +++++++++++ sys/contrib/dev/acpica/evevent.c | 953 +++++++++++++ sys/contrib/dev/acpica/evmisc.c | 486 +++++++ sys/contrib/dev/acpica/evregion.c | 765 ++++++++++ sys/contrib/dev/acpica/evrgnini.c | 557 ++++++++ sys/contrib/dev/acpica/evsci.c | 448 ++++++ sys/contrib/dev/acpica/evxface.c | 744 ++++++++++ sys/contrib/dev/acpica/evxfevnt.c | 610 ++++++++ sys/contrib/dev/acpica/evxfregn.c | 515 +++++++ sys/contrib/dev/acpica/exconfig.c | 433 ++++++ sys/contrib/dev/acpica/excreate.c | 1216 ++++++++++++++++ sys/contrib/dev/acpica/exdump.c | 992 +++++++++++++ sys/contrib/dev/acpica/exdyadic.c | 906 ++++++++++++ sys/contrib/dev/acpica/exfield.c | 446 ++++++ sys/contrib/dev/acpica/exfldio.c | 857 +++++++++++ sys/contrib/dev/acpica/exmisc.c | 682 +++++++++ sys/contrib/dev/acpica/exmonad.c | 1183 +++++++++++++++ sys/contrib/dev/acpica/exnames.c | 551 +++++++ sys/contrib/dev/acpica/exprep.c | 580 ++++++++ sys/contrib/dev/acpica/exregion.c | 561 ++++++++ sys/contrib/dev/acpica/exresnte.c | 693 +++++++++ sys/contrib/dev/acpica/exresolv.c | 629 ++++++++ sys/contrib/dev/acpica/exresop.c | 629 ++++++++ sys/contrib/dev/acpica/exstore.c | 531 +++++++ sys/contrib/dev/acpica/exstoren.c | 713 +++++++++ sys/contrib/dev/acpica/exstorob.c | 442 ++++++ sys/contrib/dev/acpica/exsystem.c | 463 ++++++ sys/contrib/dev/acpica/exutils.c | 652 +++++++++ sys/contrib/dev/acpica/exxface.c | 190 +++ sys/contrib/dev/acpica/hwacpi.c | 501 +++++++ sys/contrib/dev/acpica/hwgpe.c | 303 ++++ sys/contrib/dev/acpica/hwregs.c | 825 +++++++++++ sys/contrib/dev/acpica/nsaccess.c | 737 ++++++++++ sys/contrib/dev/acpica/nsalloc.c | 728 ++++++++++ sys/contrib/dev/acpica/nsdump.c | 677 +++++++++ sys/contrib/dev/acpica/nseval.c | 670 +++++++++ sys/contrib/dev/acpica/nsinit.c | 514 +++++++ sys/contrib/dev/acpica/nsload.c | 712 +++++++++ sys/contrib/dev/acpica/nsnames.c | 334 +++++ sys/contrib/dev/acpica/nsobject.c | 523 +++++++ sys/contrib/dev/acpica/nssearch.c | 505 +++++++ sys/contrib/dev/acpica/nsutils.c | 1001 +++++++++++++ sys/contrib/dev/acpica/nswalk.c | 384 +++++ sys/contrib/dev/acpica/nsxfname.c | 410 ++++++ sys/contrib/dev/acpica/nsxfobj.c | 853 +++++++++++ sys/contrib/dev/acpica/psargs.c | 950 ++++++++++++ sys/contrib/dev/acpica/psfind.c | 459 ++++++ sys/contrib/dev/acpica/psopcode.c | 704 +++++++++ sys/contrib/dev/acpica/psparse.c | 1506 ++++++++++++++++++++ sys/contrib/dev/acpica/psscope.c | 375 +++++ sys/contrib/dev/acpica/pstree.c | 518 +++++++ sys/contrib/dev/acpica/psutils.c | 683 +++++++++ sys/contrib/dev/acpica/pswalk.c | 727 ++++++++++ sys/contrib/dev/acpica/psxface.c | 270 ++++ sys/contrib/dev/acpica/rsaddr.c | 922 ++++++++++++ sys/contrib/dev/acpica/rscalc.c | 986 +++++++++++++ sys/contrib/dev/acpica/rscreate.c | 548 +++++++ sys/contrib/dev/acpica/rsdump.c | 1044 ++++++++++++++ sys/contrib/dev/acpica/rsio.c | 636 +++++++++ sys/contrib/dev/acpica/rsirq.c | 683 +++++++++ sys/contrib/dev/acpica/rslist.c | 606 ++++++++ sys/contrib/dev/acpica/rsmemory.c | 660 +++++++++ sys/contrib/dev/acpica/rsmisc.c | 725 ++++++++++ sys/contrib/dev/acpica/rsutils.c | 511 +++++++ sys/contrib/dev/acpica/rsxface.c | 326 +++++ sys/contrib/dev/acpica/tbget.c | 733 ++++++++++ sys/contrib/dev/acpica/tbinstal.c | 692 +++++++++ sys/contrib/dev/acpica/tbutils.c | 486 +++++++ sys/contrib/dev/acpica/tbxface.c | 506 +++++++ sys/contrib/dev/acpica/tbxfroot.c | 319 +++++ sys/contrib/dev/acpica/utalloc.c | 801 +++++++++++ sys/contrib/dev/acpica/utclib.c | 956 +++++++++++++ sys/contrib/dev/acpica/utcopy.c | 826 +++++++++++ sys/contrib/dev/acpica/utdebug.c | 657 +++++++++ sys/contrib/dev/acpica/utdelete.c | 806 +++++++++++ sys/contrib/dev/acpica/uteval.c | 494 +++++++ sys/contrib/dev/acpica/utglobal.c | 705 +++++++++ sys/contrib/dev/acpica/utinit.c | 347 +++++ sys/contrib/dev/acpica/utmisc.c | 915 ++++++++++++ sys/contrib/dev/acpica/utobject.c | 817 +++++++++++ sys/contrib/dev/acpica/utxface.c | 529 +++++++ 261 files changed, 158932 insertions(+) create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmalloc.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmclib.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmdebug.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmdelete.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmeval.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmglobal.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cminit.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmobject.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Common/cmxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dsfield.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmethod.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmthdat.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dsutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dswexec.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dswload.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dswscope.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Dispatcher/dswstate.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evevent.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evmisc.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evregion.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evsci.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Hardware/hwacpi.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Hardware/hwcpu32.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Hardware/hwgpe.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Hardware/hwregs.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Hardware/hwxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/accommon.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acconfig.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acdebug.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acdispat.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acefi.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acenv.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acevents.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acexcep.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acfreebsd.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acgcc.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acglobal.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/achware.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acinterp.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/aclinux.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/aclocal.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acmacros.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acmsvc.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acobject.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acoutput.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acparser.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acpi.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acpiosxf.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acpixf.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acresrc.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/actables.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/actbl.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/actbl32.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/actbl64.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/actypes.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/acwin.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Include/amlcode.h create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/psargs.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/psfind.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/psparse.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/psscope.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/pstree.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/psutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Parser/psxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsio.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rslist.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Tables/tbget.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Tables/tbinstal.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Tables/tbutils.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Tables/tbxface.c create mode 100644 sys/contrib/dev/acpica/Subsystem/Tables/tbxfroot.c create mode 100644 sys/contrib/dev/acpica/acconfig.h create mode 100644 sys/contrib/dev/acpica/acdebug.h create mode 100644 sys/contrib/dev/acpica/acdispat.h create mode 100644 sys/contrib/dev/acpica/acefi.h create mode 100644 sys/contrib/dev/acpica/acenv.h create mode 100644 sys/contrib/dev/acpica/acevents.h create mode 100644 sys/contrib/dev/acpica/acexcep.h create mode 100644 sys/contrib/dev/acpica/acfreebsd.h create mode 100644 sys/contrib/dev/acpica/acgcc.h create mode 100644 sys/contrib/dev/acpica/acglobal.h create mode 100644 sys/contrib/dev/acpica/achware.h create mode 100644 sys/contrib/dev/acpica/acinterp.h create mode 100644 sys/contrib/dev/acpica/aclocal.h create mode 100644 sys/contrib/dev/acpica/acmacros.h create mode 100644 sys/contrib/dev/acpica/acnamesp.h create mode 100644 sys/contrib/dev/acpica/acobject.h create mode 100644 sys/contrib/dev/acpica/acoutput.h create mode 100644 sys/contrib/dev/acpica/acparser.h create mode 100644 sys/contrib/dev/acpica/acpi.h create mode 100644 sys/contrib/dev/acpica/acpiosxf.h create mode 100644 sys/contrib/dev/acpica/acpixf.h create mode 100644 sys/contrib/dev/acpica/acresrc.h create mode 100644 sys/contrib/dev/acpica/actables.h create mode 100644 sys/contrib/dev/acpica/actbl.h create mode 100644 sys/contrib/dev/acpica/actypes.h create mode 100644 sys/contrib/dev/acpica/acutils.h create mode 100644 sys/contrib/dev/acpica/amlcode.h create mode 100644 sys/contrib/dev/acpica/dbcmds.c create mode 100644 sys/contrib/dev/acpica/dbdisasm.c create mode 100644 sys/contrib/dev/acpica/dbdisply.c create mode 100644 sys/contrib/dev/acpica/dbexec.c create mode 100644 sys/contrib/dev/acpica/dbfileio.c create mode 100644 sys/contrib/dev/acpica/dbhistry.c create mode 100644 sys/contrib/dev/acpica/dbinput.c create mode 100644 sys/contrib/dev/acpica/dbstats.c create mode 100644 sys/contrib/dev/acpica/dbutils.c create mode 100644 sys/contrib/dev/acpica/dbxface.c create mode 100644 sys/contrib/dev/acpica/dsfield.c create mode 100644 sys/contrib/dev/acpica/dsmethod.c create mode 100644 sys/contrib/dev/acpica/dsmthdat.c create mode 100644 sys/contrib/dev/acpica/dsobject.c create mode 100644 sys/contrib/dev/acpica/dsopcode.c create mode 100644 sys/contrib/dev/acpica/dsutils.c create mode 100644 sys/contrib/dev/acpica/dswexec.c create mode 100644 sys/contrib/dev/acpica/dswload.c create mode 100644 sys/contrib/dev/acpica/dswscope.c create mode 100644 sys/contrib/dev/acpica/dswstate.c create mode 100644 sys/contrib/dev/acpica/evevent.c create mode 100644 sys/contrib/dev/acpica/evmisc.c create mode 100644 sys/contrib/dev/acpica/evregion.c create mode 100644 sys/contrib/dev/acpica/evrgnini.c create mode 100644 sys/contrib/dev/acpica/evsci.c create mode 100644 sys/contrib/dev/acpica/evxface.c create mode 100644 sys/contrib/dev/acpica/evxfevnt.c create mode 100644 sys/contrib/dev/acpica/evxfregn.c create mode 100644 sys/contrib/dev/acpica/exconfig.c create mode 100644 sys/contrib/dev/acpica/excreate.c create mode 100644 sys/contrib/dev/acpica/exdump.c create mode 100644 sys/contrib/dev/acpica/exdyadic.c create mode 100644 sys/contrib/dev/acpica/exfield.c create mode 100644 sys/contrib/dev/acpica/exfldio.c create mode 100644 sys/contrib/dev/acpica/exmisc.c create mode 100644 sys/contrib/dev/acpica/exmonad.c create mode 100644 sys/contrib/dev/acpica/exnames.c create mode 100644 sys/contrib/dev/acpica/exprep.c create mode 100644 sys/contrib/dev/acpica/exregion.c create mode 100644 sys/contrib/dev/acpica/exresnte.c create mode 100644 sys/contrib/dev/acpica/exresolv.c create mode 100644 sys/contrib/dev/acpica/exresop.c create mode 100644 sys/contrib/dev/acpica/exstore.c create mode 100644 sys/contrib/dev/acpica/exstoren.c create mode 100644 sys/contrib/dev/acpica/exstorob.c create mode 100644 sys/contrib/dev/acpica/exsystem.c create mode 100644 sys/contrib/dev/acpica/exutils.c create mode 100644 sys/contrib/dev/acpica/exxface.c create mode 100644 sys/contrib/dev/acpica/hwacpi.c create mode 100644 sys/contrib/dev/acpica/hwgpe.c create mode 100644 sys/contrib/dev/acpica/hwregs.c create mode 100644 sys/contrib/dev/acpica/nsaccess.c create mode 100644 sys/contrib/dev/acpica/nsalloc.c create mode 100644 sys/contrib/dev/acpica/nsdump.c create mode 100644 sys/contrib/dev/acpica/nseval.c create mode 100644 sys/contrib/dev/acpica/nsinit.c create mode 100644 sys/contrib/dev/acpica/nsload.c create mode 100644 sys/contrib/dev/acpica/nsnames.c create mode 100644 sys/contrib/dev/acpica/nsobject.c create mode 100644 sys/contrib/dev/acpica/nssearch.c create mode 100644 sys/contrib/dev/acpica/nsutils.c create mode 100644 sys/contrib/dev/acpica/nswalk.c create mode 100644 sys/contrib/dev/acpica/nsxfname.c create mode 100644 sys/contrib/dev/acpica/nsxfobj.c create mode 100644 sys/contrib/dev/acpica/psargs.c create mode 100644 sys/contrib/dev/acpica/psfind.c create mode 100644 sys/contrib/dev/acpica/psopcode.c create mode 100644 sys/contrib/dev/acpica/psparse.c create mode 100644 sys/contrib/dev/acpica/psscope.c create mode 100644 sys/contrib/dev/acpica/pstree.c create mode 100644 sys/contrib/dev/acpica/psutils.c create mode 100644 sys/contrib/dev/acpica/pswalk.c create mode 100644 sys/contrib/dev/acpica/psxface.c create mode 100644 sys/contrib/dev/acpica/rsaddr.c create mode 100644 sys/contrib/dev/acpica/rscalc.c create mode 100644 sys/contrib/dev/acpica/rscreate.c create mode 100644 sys/contrib/dev/acpica/rsdump.c create mode 100644 sys/contrib/dev/acpica/rsio.c create mode 100644 sys/contrib/dev/acpica/rsirq.c create mode 100644 sys/contrib/dev/acpica/rslist.c create mode 100644 sys/contrib/dev/acpica/rsmemory.c create mode 100644 sys/contrib/dev/acpica/rsmisc.c create mode 100644 sys/contrib/dev/acpica/rsutils.c create mode 100644 sys/contrib/dev/acpica/rsxface.c create mode 100644 sys/contrib/dev/acpica/tbget.c create mode 100644 sys/contrib/dev/acpica/tbinstal.c create mode 100644 sys/contrib/dev/acpica/tbutils.c create mode 100644 sys/contrib/dev/acpica/tbxface.c create mode 100644 sys/contrib/dev/acpica/tbxfroot.c create mode 100644 sys/contrib/dev/acpica/utalloc.c create mode 100644 sys/contrib/dev/acpica/utclib.c create mode 100644 sys/contrib/dev/acpica/utcopy.c create mode 100644 sys/contrib/dev/acpica/utdebug.c create mode 100644 sys/contrib/dev/acpica/utdelete.c create mode 100644 sys/contrib/dev/acpica/uteval.c create mode 100644 sys/contrib/dev/acpica/utglobal.c create mode 100644 sys/contrib/dev/acpica/utinit.c create mode 100644 sys/contrib/dev/acpica/utmisc.c create mode 100644 sys/contrib/dev/acpica/utobject.c create mode 100644 sys/contrib/dev/acpica/utxface.c (limited to 'sys/contrib') diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmalloc.c b/sys/contrib/dev/acpica/Subsystem/Common/cmalloc.c new file mode 100644 index 0000000..bb1e0dd --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmalloc.c @@ -0,0 +1,801 @@ +/****************************************************************************** + * + * Module Name: cmalloc - local memory allocation routines + * $Revision: 76 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMALLOC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acglobal.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmalloc") + + +#ifdef ACPI_DEBUG +/* + * Most of this code is for tracking memory leaks in the subsystem, and it + * gets compiled out when the ACPI_DEBUG flag is not set. + * Every memory allocation is kept track of in a doubly linked list. Each + * element contains the caller's component, module name, function name, and + * line number. _CmAllocate and _CmCallocate call AcpiCmAddElementToAllocList + * to add an element to the list; deletion occurs in the bosy of _CmFree. + */ + + +/***************************************************************************** + * + * FUNCTION: AcpiCmSearchAllocList + * + * PARAMETERS: Address - Address of allocated memory + * + * RETURN: A list element if found; NULL otherwise. + * + * DESCRIPTION: Searches for an element in the global allocation tracking list. + * + ****************************************************************************/ + +ALLOCATION_INFO * +AcpiCmSearchAllocList ( + void *Address) +{ + ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr; + + + /* Search for the address. */ + + while (Element) + { + if (Element->Address == Address) + { + return (Element); + } + + Element = Element->Next; + } + + return (NULL); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmAddElementToAllocList + * + * PARAMETERS: Address - Address of allocated memory + * Size - Size of the allocation + * AllocType - MEM_MALLOC or MEM_CALLOC + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None. + * + * DESCRIPTION: Inserts an element into the global allocation tracking list. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiCmAddElementToAllocList ( + void *Address, + UINT32 Size, + UINT8 AllocType, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + ALLOCATION_INFO *Element; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("CmAddElementToAllocList", Address); + + + AcpiCmAcquireMutex (ACPI_MTX_MEMORY); + + /* Keep track of the running total of all allocations. */ + + AcpiGbl_CurrentAllocCount++; + AcpiGbl_RunningAllocCount++; + + if (AcpiGbl_MaxConcurrentAllocCount < AcpiGbl_CurrentAllocCount) + { + AcpiGbl_MaxConcurrentAllocCount = AcpiGbl_CurrentAllocCount; + } + + AcpiGbl_CurrentAllocSize += Size; + AcpiGbl_RunningAllocSize += Size; + + if (AcpiGbl_MaxConcurrentAllocSize < AcpiGbl_CurrentAllocSize) + { + AcpiGbl_MaxConcurrentAllocSize = AcpiGbl_CurrentAllocSize; + } + + /* If the head pointer is null, create the first element and fill it in. */ + + if (NULL == AcpiGbl_HeadAllocPtr) + { + AcpiGbl_HeadAllocPtr = + (ALLOCATION_INFO *) AcpiOsCallocate (sizeof (ALLOCATION_INFO)); + + if (!AcpiGbl_HeadAllocPtr) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not allocate memory info block\n")); + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + AcpiGbl_TailAllocPtr = AcpiGbl_HeadAllocPtr; + } + + else + { + AcpiGbl_TailAllocPtr->Next = + (ALLOCATION_INFO *) AcpiOsCallocate (sizeof (ALLOCATION_INFO)); + if (!AcpiGbl_TailAllocPtr->Next) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not allocate memory info block\n")); + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* error check */ + + AcpiGbl_TailAllocPtr->Next->Previous = AcpiGbl_TailAllocPtr; + AcpiGbl_TailAllocPtr = AcpiGbl_TailAllocPtr->Next; + } + + /* + * Search list for this address to make sure it is not already on the list. + * This will catch several kinds of problems. + */ + + Element = AcpiCmSearchAllocList (Address); + if (Element) + { + REPORT_ERROR (("CmAddElementToAllocList: Address already present in list!\n")); + + DEBUG_PRINT (ACPI_ERROR, ("Element %p Address %p\n", Element, Address)); + + BREAKPOINT3; + } + + /* Fill in the instance data. */ + + AcpiGbl_TailAllocPtr->Address = Address; + AcpiGbl_TailAllocPtr->Size = Size; + AcpiGbl_TailAllocPtr->AllocType = AllocType; + AcpiGbl_TailAllocPtr->Component = Component; + AcpiGbl_TailAllocPtr->Line = Line; + + STRNCPY (AcpiGbl_TailAllocPtr->Module, Module, MAX_MODULE_NAME); + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDeleteElementFromAllocList + * + * PARAMETERS: Address - 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. + * + ****************************************************************************/ + +void +AcpiCmDeleteElementFromAllocList ( + void *Address, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + ALLOCATION_INFO *Element; + UINT32 *DwordPtr; + UINT32 DwordLen; + UINT32 Size; + UINT32 i; + + + FUNCTION_TRACE ("CmDeleteElementFromAllocList"); + + if (NULL == AcpiGbl_HeadAllocPtr) + { + /* Boy we got problems. */ + + _REPORT_ERROR (Module, Line, Component, + ("CmDeleteElementFromAllocList: Empty allocation list, nothing to free!\n")); + + return_VOID; + } + + + AcpiCmAcquireMutex (ACPI_MTX_MEMORY); + + /* Keep track of the amount of memory allocated. */ + + Size = 0; + AcpiGbl_CurrentAllocCount--; + + if (AcpiGbl_HeadAllocPtr == AcpiGbl_TailAllocPtr) + { + if (Address != AcpiGbl_HeadAllocPtr->Address) + { + _REPORT_ERROR (Module, Line, Component, + ("CmDeleteElementFromAllocList: Deleting non-allocated memory\n")); + + goto Cleanup; + } + + Size = AcpiGbl_HeadAllocPtr->Size; + + AcpiOsFree (AcpiGbl_HeadAllocPtr); + AcpiGbl_HeadAllocPtr = NULL; + AcpiGbl_TailAllocPtr = NULL; + + DEBUG_PRINT (TRACE_ALLOCATIONS, + ("_CmFree: Allocation list deleted. There are no outstanding allocations\n")); + + goto Cleanup; + } + + + /* Search list for this address */ + + Element = AcpiCmSearchAllocList (Address); + if (Element) + { + /* cases: head, tail, other */ + + if (Element == AcpiGbl_HeadAllocPtr) + { + Element->Next->Previous = NULL; + AcpiGbl_HeadAllocPtr = Element->Next; + } + + else + { + if (Element == AcpiGbl_TailAllocPtr) + { + Element->Previous->Next = NULL; + AcpiGbl_TailAllocPtr = Element->Previous; + } + + else + { + Element->Previous->Next = Element->Next; + Element->Next->Previous = Element->Previous; + } + } + + + /* Mark the segment as deleted */ + + if (Element->Size >= 4) + { + DwordLen = DIV_4 (Element->Size); + DwordPtr = (UINT32 *) Element->Address; + + for (i = 0; i < DwordLen; i++) + { + DwordPtr[i] = 0x00DEAD00; + } + + /* Set obj type, desc, and ref count fields to all ones */ + + DwordPtr[0] = ACPI_UINT32_MAX; + if (Element->Size >= 8) + { + DwordPtr[1] = ACPI_UINT32_MAX; + } + } + + Size = Element->Size; + + MEMSET (Element, 0xEA, sizeof (ALLOCATION_INFO)); + + + if (Size == sizeof (ACPI_OPERAND_OBJECT)) + { + DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmDelete: Freeing size 0x%X (ACPI_OPERAND_OBJECT)\n", Size)); + } + else + { + DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmDelete: Freeing size 0x%X\n", Size)); + } + + AcpiOsFree (Element); + } + + else + { + _REPORT_ERROR (Module, Line, Component, + ("_CmFree: Entry not found in list\n")); + DEBUG_PRINT (ACPI_ERROR, + ("_CmFree: Entry %p was not found in allocation list\n", + Address)); + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + return_VOID; + } + + +Cleanup: + + AcpiGbl_CurrentAllocSize -= Size; + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDumpAllocationInfo + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: Print some info about the outstanding allocations. + * + ****************************************************************************/ + +void +AcpiCmDumpAllocationInfo ( + void) +{ + FUNCTION_TRACE ("CmDumpAllocationInfo"); + + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current allocations", + AcpiGbl_CurrentAllocCount, + (AcpiGbl_CurrentAllocSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", + AcpiGbl_MaxConcurrentAllocCount, + (AcpiGbl_MaxConcurrentAllocSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Internal objects", + AcpiGbl_CurrentObjectCount, + (AcpiGbl_CurrentObjectSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max internal objects", + AcpiGbl_MaxConcurrentObjectCount, + (AcpiGbl_MaxConcurrentObjectSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Nodes", + AcpiGbl_CurrentNodeCount, + (AcpiGbl_CurrentNodeSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max Nodes", + AcpiGbl_MaxConcurrentNodeCount, + ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)) + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", + AcpiGbl_RunningObjectCount, + (AcpiGbl_RunningObjectSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", + AcpiGbl_RunningAllocCount, + (AcpiGbl_RunningAllocSize + 1023) / 1024)); + + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDumpCurrentAllocations + * + * 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 +AcpiCmDumpCurrentAllocations ( + UINT32 Component, + NATIVE_CHAR *Module) +{ + ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr; + UINT32 i; + + + FUNCTION_TRACE ("CmDumpCurrentAllocations"); + + + if (Element == NULL) + { + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("No outstanding allocations.\n")); + return_VOID; + } + + + /* + * Walk the allocation list. + */ + + AcpiCmAcquireMutex (ACPI_MTX_MEMORY); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("Outstanding allocations:\n")); + + for (i = 1; ; i++) /* Just a counter */ + { + if ((Element->Component & Component) && + ((Module == NULL) || (0 == STRCMP (Module, Element->Module)))) + { + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%p Len %04lX %9.9s-%ld", + Element->Address, Element->Size, Element->Module, + Element->Line)); + + /* Most of the elements will be internal objects. */ + + switch (((ACPI_OPERAND_OBJECT *) + (Element->Address))->Common.DataType) + { + case ACPI_DESC_TYPE_INTERNAL: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" ObjType %s", + AcpiCmGetTypeName (((ACPI_OPERAND_OBJECT *)(Element->Address))->Common.Type))); + break; + + case ACPI_DESC_TYPE_PARSER: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" ParseObj Opcode %04X", + ((ACPI_PARSE_OBJECT *)(Element->Address))->Opcode)); + break; + + case ACPI_DESC_TYPE_NAMED: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" Node %4.4s", + &((ACPI_NAMESPACE_NODE *)(Element->Address))->Name)); + break; + + case ACPI_DESC_TYPE_STATE: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" StateObj")); + break; + } + + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, ("\n")); + } + + if (Element->Next == NULL) + { + break; + } + + Element = Element->Next; + } + + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("Total number of unfreed allocations = %d\n", i)); + + return_VOID; +} + +#endif /* Debug routines for memory leak detection */ + + +/***************************************************************************** + * + * FUNCTION: _CmAllocate + * + * 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 * +_CmAllocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + void *Address = NULL; + DEBUG_EXEC (\ + ACPI_STATUS Status) + + + FUNCTION_TRACE_U32 ("_CmAllocate", Size); + + + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + _REPORT_ERROR (Module, Line, Component, + ("CmAllocate: Attempt to allocate zero bytes\n")); + Size = 1; + } + + Address = AcpiOsAllocate (Size); + if (!Address) + { + /* Report allocation error */ + + _REPORT_ERROR (Module, Line, Component, + ("CmAllocate: Could not allocate size 0x%x\n", Size)); + + return_VALUE (NULL); + } + +#ifdef ACPI_DEBUG + Status = AcpiCmAddElementToAllocList (Address, Size, MEM_MALLOC, Component, + Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Address); + return_PTR (NULL); + } + + DEBUG_PRINT (TRACE_ALLOCATIONS, + ("CmAllocate: %p Size 0x%x\n", Address, Size)); +#endif + + return_PTR (Address); +} + + +/***************************************************************************** + * + * FUNCTION: _CmCallocate + * + * 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 * +_CmCallocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + void *Address = NULL; + DEBUG_EXEC (\ + ACPI_STATUS Status) + + + FUNCTION_TRACE_U32 ("_CmCallocate", Size); + + + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + _REPORT_ERROR (Module, Line, Component, + ("CmCallocate: Attempt to allocate zero bytes\n")); + return_VALUE (NULL); + } + + + Address = AcpiOsCallocate (Size); + + if (!Address) + { + /* Report allocation error */ + + _REPORT_ERROR (Module, Line, Component, + ("CmCallocate: Could not allocate size 0x%x\n", Size)); + return_VALUE (NULL); + } + +#ifdef ACPI_DEBUG + Status = AcpiCmAddElementToAllocList (Address, Size, MEM_CALLOC, Component, + Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Address); + return_PTR (NULL); + } +#endif + + DEBUG_PRINT (TRACE_ALLOCATIONS, + ("CmCallocate: %p Size 0x%x\n", Address, Size)); + + return_PTR (Address); +} + + +/***************************************************************************** + * + * FUNCTION: _CmFree + * + * PARAMETERS: Address - 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 Address + * + ****************************************************************************/ + +void +_CmFree ( + void *Address, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + FUNCTION_TRACE_PTR ("_CmFree", Address); + + + if (NULL == Address) + { + _REPORT_ERROR (Module, Line, Component, + ("_CmFree: Trying to delete a NULL address\n")); + + return_VOID; + } + +#ifdef ACPI_DEBUG + AcpiCmDeleteElementFromAllocList (Address, Component, Module, Line); +#endif + + AcpiOsFree (Address); + + DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmFree: %p freed\n", Address)); + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmclib.c b/sys/contrib/dev/acpica/Subsystem/Common/cmclib.c new file mode 100644 index 0000000..24e7466 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmclib.c @@ -0,0 +1,956 @@ +/****************************************************************************** + * + * Module Name: cmclib - Local implementation of C library functions + * $Revision: 26 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMCLIB_C__ + +#include "acpi.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" + +/* + * These implementations of standard C Library routines can optionally be + * used if a C library is not available. In general, they are less efficient + * than an inline or assembly implementation + */ + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmclib") + + +#ifdef _MSC_VER /* disable some level-4 warnings for VC++ */ +#pragma warning(disable:4706) /* warning C4706: assignment within conditional expression */ +#endif + +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +/******************************************************************************* + * + * FUNCTION: strlen + * + * PARAMETERS: String - Null terminated string + * + * RETURN: Length + * + * DESCRIPTION: Returns the length of the input string + * + ******************************************************************************/ + + +NATIVE_UINT +AcpiCmStrlen ( + const NATIVE_CHAR *String) +{ + NATIVE_UINT Length = 0; + + + /* Count the string until a null is encountered */ + + while (*String) + { + Length++; + String++; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: strcpy + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrcpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString) +{ + NATIVE_CHAR *String = DstString; + + + /* Move bytes brute force */ + + while (*SrcString) + { + *String = *SrcString; + + String++; + SrcString++; + } + + /* Null terminate */ + + *String = 0; + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: strncpy + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string, with a maximum length + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrncpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count) +{ + NATIVE_CHAR *String = DstString; + + + /* Copy the string */ + + for (String = DstString; + Count && (Count--, (*String++ = *SrcString++)); ) + {;} + + /* Pad with nulls if necessary */ + + while (Count--) + { + *String = 0; + String++; + } + + /* Return original pointer */ + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: strcmp + * + * PARAMETERS: String1 - First string + * String2 - Second string + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings + * + ******************************************************************************/ + +UINT32 +AcpiCmStrcmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2) +{ + + + for ( ; (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + + return ((unsigned char) *String1 - (unsigned char) *String2); +} + + +/******************************************************************************* + * + * FUNCTION: strncmp + * + * PARAMETERS: String1 - First string + * String2 - Second string + * Count - Maximum # of bytes to compare + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings, with a maximum length + * + ******************************************************************************/ + +UINT32 +AcpiCmStrncmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2, + NATIVE_UINT Count) +{ + + + for ( ; Count-- && (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((Count == -1) ? 0 : ((unsigned char) *String1 - + (unsigned char) *String2)); +} + + +/******************************************************************************* + * + * FUNCTION: Strcat + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrcat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString) +{ + NATIVE_CHAR *String; + + + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatinate the string */ + + for (--String; (*String++ = *SrcString++); ) + { ; } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: strncat + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string, + * with a maximum count. + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrncat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count) +{ + NATIVE_CHAR *String; + + + if (Count) + { + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatinate the string */ + + for (--String; (*String++ = *SrcString++) && --Count; ) + { ; } + + /* Null terminate if necessary */ + + if (!Count) + { + *String = 0; + } + } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: memcpy + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +AcpiCmMemcpy ( + void *Dest, + const void *Src, + NATIVE_UINT Count) +{ + NATIVE_CHAR *New = (NATIVE_CHAR *) Dest; + NATIVE_CHAR *Old = (NATIVE_CHAR *) Src; + + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: memset + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +AcpiCmMemset ( + void *Dest, + UINT32 Value, + NATIVE_UINT Count) +{ + NATIVE_CHAR *New = (NATIVE_CHAR *) Dest; + + + while (Count) + { + *New = (char) Value; + New++; + Count--; + } + + return (Dest); +} + + +#define NEGATIVE 1 +#define POSITIVE 0 + + +#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ +#define _ACPI_XS 0x40 /* extra space */ +#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ +#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ +#define _ACPI_DI 0x04 /* '0'-'9' */ +#define _ACPI_LO 0x02 /* 'a'-'z' */ +#define _ACPI_PU 0x10 /* punctuation */ +#define _ACPI_SP 0x08 /* space */ +#define _ACPI_UP 0x01 /* 'A'-'Z' */ +#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +static const UINT8 _acpi_ctype[257] = { + _ACPI_CN, /* 0x0 0. */ + _ACPI_CN, /* 0x1 1. */ + _ACPI_CN, /* 0x2 2. */ + _ACPI_CN, /* 0x3 3. */ + _ACPI_CN, /* 0x4 4. */ + _ACPI_CN, /* 0x5 5. */ + _ACPI_CN, /* 0x6 6. */ + _ACPI_CN, /* 0x7 7. */ + _ACPI_CN, /* 0x8 8. */ + _ACPI_CN|_ACPI_SP, /* 0x9 9. */ + _ACPI_CN|_ACPI_SP, /* 0xA 10. */ + _ACPI_CN|_ACPI_SP, /* 0xB 11. */ + _ACPI_CN|_ACPI_SP, /* 0xC 12. */ + _ACPI_CN|_ACPI_SP, /* 0xD 13. */ + _ACPI_CN, /* 0xE 14. */ + _ACPI_CN, /* 0xF 15. */ + _ACPI_CN, /* 0x10 16. */ + _ACPI_CN, /* 0x11 17. */ + _ACPI_CN, /* 0x12 18. */ + _ACPI_CN, /* 0x13 19. */ + _ACPI_CN, /* 0x14 20. */ + _ACPI_CN, /* 0x15 21. */ + _ACPI_CN, /* 0x16 22. */ + _ACPI_CN, /* 0x17 23. */ + _ACPI_CN, /* 0x18 24. */ + _ACPI_CN, /* 0x19 25. */ + _ACPI_CN, /* 0x1A 26. */ + _ACPI_CN, /* 0x1B 27. */ + _ACPI_CN, /* 0x1C 28. */ + _ACPI_CN, /* 0x1D 29. */ + _ACPI_CN, /* 0x1E 30. */ + _ACPI_CN, /* 0x1F 31. */ + _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ + _ACPI_PU, /* 0x21 33. '!' */ + _ACPI_PU, /* 0x22 34. '"' */ + _ACPI_PU, /* 0x23 35. '#' */ + _ACPI_PU, /* 0x24 36. '$' */ + _ACPI_PU, /* 0x25 37. '%' */ + _ACPI_PU, /* 0x26 38. '&' */ + _ACPI_PU, /* 0x27 39. ''' */ + _ACPI_PU, /* 0x28 40. '(' */ + _ACPI_PU, /* 0x29 41. ')' */ + _ACPI_PU, /* 0x2A 42. '*' */ + _ACPI_PU, /* 0x2B 43. '+' */ + _ACPI_PU, /* 0x2C 44. ',' */ + _ACPI_PU, /* 0x2D 45. '-' */ + _ACPI_PU, /* 0x2E 46. '.' */ + _ACPI_PU, /* 0x2F 47. '/' */ + _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ + _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ + _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ + _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ + _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ + _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ + _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ + _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ + _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ + _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ + _ACPI_PU, /* 0x3A 58. ':' */ + _ACPI_PU, /* 0x3B 59. ';' */ + _ACPI_PU, /* 0x3C 60. '<' */ + _ACPI_PU, /* 0x3D 61. '=' */ + _ACPI_PU, /* 0x3E 62. '>' */ + _ACPI_PU, /* 0x3F 63. '?' */ + _ACPI_PU, /* 0x40 64. '@' */ + _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ + _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ + _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ + _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ + _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ + _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ + _ACPI_UP, /* 0x47 71. 'G' */ + _ACPI_UP, /* 0x48 72. 'H' */ + _ACPI_UP, /* 0x49 73. 'I' */ + _ACPI_UP, /* 0x4A 74. 'J' */ + _ACPI_UP, /* 0x4B 75. 'K' */ + _ACPI_UP, /* 0x4C 76. 'L' */ + _ACPI_UP, /* 0x4D 77. 'M' */ + _ACPI_UP, /* 0x4E 78. 'N' */ + _ACPI_UP, /* 0x4F 79. 'O' */ + _ACPI_UP, /* 0x50 80. 'P' */ + _ACPI_UP, /* 0x51 81. 'Q' */ + _ACPI_UP, /* 0x52 82. 'R' */ + _ACPI_UP, /* 0x53 83. 'S' */ + _ACPI_UP, /* 0x54 84. 'T' */ + _ACPI_UP, /* 0x55 85. 'U' */ + _ACPI_UP, /* 0x56 86. 'V' */ + _ACPI_UP, /* 0x57 87. 'W' */ + _ACPI_UP, /* 0x58 88. 'X' */ + _ACPI_UP, /* 0x59 89. 'Y' */ + _ACPI_UP, /* 0x5A 90. 'Z' */ + _ACPI_PU, /* 0x5B 91. '[' */ + _ACPI_PU, /* 0x5C 92. '\' */ + _ACPI_PU, /* 0x5D 93. ']' */ + _ACPI_PU, /* 0x5E 94. '^' */ + _ACPI_PU, /* 0x5F 95. '_' */ + _ACPI_PU, /* 0x60 96. '`' */ + _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ + _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ + _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ + _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ + _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ + _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ + _ACPI_LO, /* 0x67 103. 'g' */ + _ACPI_LO, /* 0x68 104. 'h' */ + _ACPI_LO, /* 0x69 105. 'i' */ + _ACPI_LO, /* 0x6A 106. 'j' */ + _ACPI_LO, /* 0x6B 107. 'k' */ + _ACPI_LO, /* 0x6C 108. 'l' */ + _ACPI_LO, /* 0x6D 109. 'm' */ + _ACPI_LO, /* 0x6E 110. 'n' */ + _ACPI_LO, /* 0x6F 111. 'o' */ + _ACPI_LO, /* 0x70 112. 'p' */ + _ACPI_LO, /* 0x71 113. 'q' */ + _ACPI_LO, /* 0x72 114. 'r' */ + _ACPI_LO, /* 0x73 115. 's' */ + _ACPI_LO, /* 0x74 116. 't' */ + _ACPI_LO, /* 0x75 117. 'u' */ + _ACPI_LO, /* 0x76 118. 'v' */ + _ACPI_LO, /* 0x77 119. 'w' */ + _ACPI_LO, /* 0x78 120. 'x' */ + _ACPI_LO, /* 0x79 121. 'y' */ + _ACPI_LO, /* 0x7A 122. 'z' */ + _ACPI_PU, /* 0x7B 123. '{' */ + _ACPI_PU, /* 0x7C 124. '|' */ + _ACPI_PU, /* 0x7D 125. '}' */ + _ACPI_PU, /* 0x7E 126. '~' */ + _ACPI_CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + +#define IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) +#define IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) +#define IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) +#define IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) + + +/******************************************************************************* + * + * FUNCTION: AcpiCmToUpper + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +UINT32 +AcpiCmToUpper ( + UINT32 c) +{ + + return (IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmToLower + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +UINT32 +AcpiCmToLower ( + UINT32 c) +{ + + return (IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: strupr + * + * PARAMETERS: SrcString - The source string to convert to + * + * RETURN: SrcString + * + * DESCRIPTION: Convert string to uppercase + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrupr ( + NATIVE_CHAR *SrcString) +{ + NATIVE_CHAR *String; + + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; ) + { + *String = (char) AcpiCmToUpper (*String); + String++; + } + + + return (SrcString); +} + + +/******************************************************************************* + * + * FUNCTION: strstr + * + * PARAMETERS: String1 - + * String2 + * + * RETURN: + * + * DESCRIPTION: Checks if String2 occurs in String1. This is not really a + * full implementation of strstr, only sufficient for command + * matching + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrstr ( + NATIVE_CHAR *String1, + NATIVE_CHAR *String2) +{ + NATIVE_CHAR *String; + + + if (AcpiCmStrlen (String2) > AcpiCmStrlen (String1)) + { + return (NULL); + } + + /* Walk entire string, uppercasing the letters */ + + for (String = String1; *String2; ) + { + if (*String2 != *String) + { + return (NULL); + } + + String2++; + String++; + } + + + return (String1); +} + + +/******************************************************************************* + * + * FUNCTION: strtoul + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte is returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. + * + ******************************************************************************/ + +UINT32 +AcpiCmStrtoul ( + const NATIVE_CHAR *String, + NATIVE_CHAR **Terminator, + UINT32 Base) +{ + UINT32 converted = 0; + UINT32 index; + UINT32 sign; + const NATIVE_CHAR *StringStart; + UINT32 ReturnValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* + * Save the value of the pointer to the buffer's first + * character, save the current errno value, and then + * skip over any white space in the buffer: + */ + StringStart = String; + while (IS_SPACE (*String) || *String == '\t') + { + ++String; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*String == '-') + { + sign = NEGATIVE; + ++String; + } + + else if (*String == '+') + { + ++String; + sign = POSITIVE; + } + + else + { + sign = POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (Base == 0) + { + if (*String == '0') + { + if (AcpiCmToLower (*(++String)) == 'x') + { + Base = 16; + ++String; + } + + else + { + Base = 8; + } + } + + else + { + Base = 10; + } + } + + else if (Base < 2 || Base > 36) + { + /* + * The specified Base parameter is not in the domain of + * this function: + */ + goto done; + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (Base == 8 && *String == '0') + { + String++; + } + + if (Base == 16 && + *String == '0' && + AcpiCmToLower (*(++String)) == 'x') + { + String++; + } + + + /* + * Main loop: convert the string to an unsigned long: + */ + while (*String) + { + if (IS_DIGIT (*String)) + { + index = *String - '0'; + } + + else + { + index = AcpiCmToUpper (*String); + if (IS_UPPER (index)) + { + index = index - 'A' + 10; + } + + else + { + goto done; + } + } + + if (index >= Base) + { + goto done; + } + + /* + * Check to see if value is out of range: + */ + + if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) / + (UINT32) Base)) + { + Status = AE_ERROR; + ReturnValue = 0L; /* reset */ + } + + else + { + ReturnValue *= Base; + ReturnValue += index; + converted = 1; + } + + ++String; + } + +done: + /* + * If appropriate, update the caller's pointer to the next + * unconverted character in the buffer. + */ + if (Terminator) + { + if (converted == 0 && ReturnValue == 0L && String != NULL) + { + *Terminator = (NATIVE_CHAR *) StringStart; + } + + else + { + *Terminator = (NATIVE_CHAR *) String; + } + } + + if (Status == AE_ERROR) + { + ReturnValue = ACPI_UINT32_MAX; + } + + /* + * If a minus sign was present, then "the conversion is negated": + */ + if (sign == NEGATIVE) + { + ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + } + + return (ReturnValue); +} + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c b/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c new file mode 100644 index 0000000..e7f36c5 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: cmcopy - Internal to external object translation utilities + * $Revision: 56 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMCOPY_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmcopy") + + +typedef struct Search_st +{ + ACPI_OPERAND_OBJECT *InternalObj; + UINT32 Index; + ACPI_OBJECT *ExternalObj; + +} PKG_SEARCH_INFO; + + +/* Used to traverse nested packages */ + +PKG_SEARCH_INFO Level[MAX_PACKAGE_DEPTH]; + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildExternalSimpleObject + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *Buffer - Where the object is returned + * *SpaceUsed - Where the data length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to place a simple object in a user + * buffer. + * + * The buffer is assumed to have sufficient space for the object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildExternalSimpleObject ( + ACPI_OPERAND_OBJECT *InternalObj, + ACPI_OBJECT *ExternalObj, + UINT8 *DataSpace, + UINT32 *BufferSpaceUsed) +{ + UINT32 Length = 0; + UINT8 *SourcePtr = NULL; + + + FUNCTION_TRACE ("CmBuildExternalSimpleObject"); + + + /* + * Check for NULL object case (could be an uninitialized + * package element + */ + + if (!InternalObj) + { + *BufferSpaceUsed = 0; + return_ACPI_STATUS (AE_OK); + } + + /* Always clear the external object */ + + MEMSET (ExternalObj, 0, sizeof (ACPI_OBJECT)); + + /* + * In general, the external object will be the same type as + * the internal object + */ + + ExternalObj->Type = InternalObj->Common.Type; + + /* However, only a limited number of external types are supported */ + + switch (ExternalObj->Type) + { + + case ACPI_TYPE_STRING: + + Length = InternalObj->String.Length; + ExternalObj->String.Length = InternalObj->String.Length; + ExternalObj->String.Pointer = (NATIVE_CHAR *) DataSpace; + SourcePtr = (UINT8 *) InternalObj->String.Pointer; + break; + + + case ACPI_TYPE_BUFFER: + + Length = InternalObj->Buffer.Length; + ExternalObj->Buffer.Length = InternalObj->Buffer.Length; + ExternalObj->Buffer.Pointer = DataSpace; + SourcePtr = (UINT8 *) InternalObj->Buffer.Pointer; + break; + + + case ACPI_TYPE_NUMBER: + + ExternalObj->Number.Value= InternalObj->Number.Value; + break; + + + case INTERNAL_TYPE_REFERENCE: + + /* + * This is an object reference. We use the object type of "Any" + * to indicate a reference object containing a handle to an ACPI + * named object. + */ + + ExternalObj->Type = ACPI_TYPE_ANY; + ExternalObj->Reference.Handle = InternalObj->Reference.Node; + break; + + + case ACPI_TYPE_PROCESSOR: + + ExternalObj->Processor.ProcId = + InternalObj->Processor.ProcId; + + ExternalObj->Processor.PblkAddress = + InternalObj->Processor.Address; + + ExternalObj->Processor.PblkLength = + InternalObj->Processor.Length; + break; + + case ACPI_TYPE_POWER: + + ExternalObj->PowerResource.SystemLevel = + InternalObj->PowerResource.SystemLevel; + + ExternalObj->PowerResource.ResourceOrder = + InternalObj->PowerResource.ResourceOrder; + break; + + default: + return_ACPI_STATUS (AE_CTRL_RETURN_VALUE); + break; + } + + + /* Copy data if necessary (strings or buffers) */ + + if (Length) + { + /* + * Copy the return data to the caller's buffer + */ + MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length); + } + + + *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildExternalPackageObject + * + * PARAMETERS: *InternalObj - Pointer to the object we are returning + * *Buffer - Where the object is returned + * *SpaceUsed - Where the object length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to place a package object in a user + * buffer. A package object by definition contains other objects. + * + * The buffer is assumed to have sufficient space for the object. + * The caller must have verified the buffer length needed using the + * AcpiCmGetObjectSize function before calling this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildExternalPackageObject ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT8 *Buffer, + UINT32 *SpaceUsed) +{ + UINT8 *FreeSpace; + ACPI_OBJECT *ExternalObj; + UINT32 CurrentDepth = 0; + ACPI_STATUS Status; + UINT32 Length = 0; + UINT32 ThisIndex; + UINT32 ObjectSpace; + ACPI_OPERAND_OBJECT *ThisInternalObj; + ACPI_OBJECT *ThisExternalObj; + PKG_SEARCH_INFO *LevelPtr; + + + FUNCTION_TRACE ("CmBuildExternalPackageObject"); + + + /* + * First package at head of the buffer + */ + ExternalObj = (ACPI_OBJECT *) Buffer; + + /* + * Free space begins right after the first package + */ + FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + + + /* + * Initialize the working variables + */ + + MEMSET ((void *) Level, 0, sizeof (Level)); + + Level[0].InternalObj = InternalObj; + Level[0].ExternalObj = ExternalObj; + Level[0].Index = 0; + LevelPtr = &Level[0]; + CurrentDepth = 0; + + ExternalObj->Type = InternalObj->Common.Type; + ExternalObj->Package.Count = InternalObj->Package.Count; + ExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; + + + /* + * Build an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + + FreeSpace += ExternalObj->Package.Count * + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + + + while (1) + { + ThisIndex = LevelPtr->Index; + ThisInternalObj = + (ACPI_OPERAND_OBJECT *) + LevelPtr->InternalObj->Package.Elements[ThisIndex]; + ThisExternalObj = + (ACPI_OBJECT *) + &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; + + + /* + * Check for + * 1) Null object -- OK, this can happen if package + * element is never initialized + * 2) Not an internal object - can be Node instead + * 3) Any internal object other than a package. + * + * The more complex package case is handled later + */ + + if ((!ThisInternalObj) || + (!VALID_DESCRIPTOR_TYPE ( + ThisInternalObj, ACPI_DESC_TYPE_INTERNAL)) || + (!IS_THIS_OBJECT_TYPE ( + ThisInternalObj, ACPI_TYPE_PACKAGE))) + { + /* + * This is a simple or null object -- get the size + */ + + Status = + AcpiCmBuildExternalSimpleObject (ThisInternalObj, + ThisExternalObj, + FreeSpace, + &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + LevelPtr->Index++; + while (LevelPtr->Index >= + LevelPtr->InternalObj->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 + */ + if (CurrentDepth == 0) + { + /* + * We have handled all of the objects + * in the top level package just add + * the length of the package objects + * and get out + */ + *SpaceUsed = Length; + return_ACPI_STATUS (AE_OK); + } + + /* + * go back up a level and move the index + * past the just completed package object. + */ + CurrentDepth--; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->Index++; + } + } + + + else + { + /* + * This object is a package + * -- we must go one level deeper + */ + if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) + { + /* + * Too many nested levels of packages + * for us to handle + */ + DEBUG_PRINT (ACPI_ERROR, + ("CmBuildPackageObject: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* + * Build the package object + */ + ThisExternalObj->Type = ACPI_TYPE_PACKAGE; + ThisExternalObj->Package.Count = + ThisInternalObj->Package.Count; + ThisExternalObj->Package.Elements = + (ACPI_OBJECT *) FreeSpace; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD ( + ThisExternalObj->Package.Count * + sizeof (ACPI_OBJECT)); + + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + CurrentDepth++; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->InternalObj = ThisInternalObj; + LevelPtr->ExternalObj = ThisExternalObj; + LevelPtr->Index = 0; + } + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildExternalObject + * + * PARAMETERS: *InternalObj - The internal object to be converted + * *BufferPtr - Where the object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to build an API object to be returned to + * the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildExternalObject ( + ACPI_OPERAND_OBJECT *InternalObj, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmBuildExternalObject"); + + + if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE)) + { + /* + * Package objects contain other objects (which can be objects) + * buildpackage does it all + */ + Status = + AcpiCmBuildExternalPackageObject (InternalObj, + RetBuffer->Pointer, + &RetBuffer->Length); + } + + else + { + /* + * Build a simple object (no nested objects) + */ + Status = + AcpiCmBuildExternalSimpleObject (InternalObj, + (ACPI_OBJECT *) RetBuffer->Pointer, + ((UINT8 *) RetBuffer->Pointer + + 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: AcpiCmBuildInternalSimpleObject + * + * PARAMETERS: *ExternalObj - The external object to be converted + * *InternalObj - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function copies an external object to an internal one. + * NOTE: Pointers can be copied, we don't need to copy data. + * (The pointers have to be valid in our address space no matter + * what we do with them!) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildInternalSimpleObject ( + ACPI_OBJECT *ExternalObj, + ACPI_OPERAND_OBJECT *InternalObj) +{ + + FUNCTION_TRACE ("CmBuildInternalSimpleObject"); + + + InternalObj->Common.Type = (UINT8) ExternalObj->Type; + + switch (ExternalObj->Type) + { + + case ACPI_TYPE_STRING: + + InternalObj->String.Length = ExternalObj->String.Length; + InternalObj->String.Pointer = ExternalObj->String.Pointer; + break; + + + case ACPI_TYPE_BUFFER: + + InternalObj->Buffer.Length = ExternalObj->Buffer.Length; + InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer; + break; + + + case ACPI_TYPE_NUMBER: + /* + * Number is included in the object itself + */ + InternalObj->Number.Value = ExternalObj->Number.Value; + break; + + + default: + return_ACPI_STATUS (AE_CTRL_RETURN_VALUE); + break; + } + + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildInternalPackageObject + * + * PARAMETERS: *InternalObj - Pointer to the object we are returning + * *Buffer - Where the object is returned + * *SpaceUsed - Where the length of the object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to place a package object in a user + * buffer. A package object by definition contains other objects. + * + * The buffer is assumed to have sufficient space for the object. + * The caller must have verified the buffer length needed using the + * AcpiCmGetObjectSize function before calling this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildInternalPackageObject ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT8 *Buffer, + UINT32 *SpaceUsed) +{ + UINT8 *FreeSpace; + ACPI_OBJECT *ExternalObj; + UINT32 CurrentDepth = 0; + UINT32 Length = 0; + UINT32 ThisIndex; + UINT32 ObjectSpace = 0; + ACPI_OPERAND_OBJECT *ThisInternalObj; + ACPI_OBJECT *ThisExternalObj; + PKG_SEARCH_INFO *LevelPtr; + + + FUNCTION_TRACE ("CmBuildInternalPackageObject"); + + + /* + * First package at head of the buffer + */ + ExternalObj = (ACPI_OBJECT *)Buffer; + + /* + * Free space begins right after the first package + */ + FreeSpace = Buffer + sizeof(ACPI_OBJECT); + + + /* + * Initialize the working variables + */ + + MEMSET ((void *) Level, 0, sizeof(Level)); + + Level[0].InternalObj = InternalObj; + Level[0].ExternalObj = ExternalObj; + LevelPtr = &Level[0]; + CurrentDepth = 0; + + ExternalObj->Type = InternalObj->Common.Type; + ExternalObj->Package.Count = InternalObj->Package.Count; + ExternalObj->Package.Elements = (ACPI_OBJECT *)FreeSpace; + + + /* + * Build an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + + FreeSpace += ExternalObj->Package.Count * sizeof(ACPI_OBJECT); + + + while (1) + { + ThisIndex = LevelPtr->Index; + + ThisInternalObj = (ACPI_OPERAND_OBJECT *) + &LevelPtr->InternalObj->Package.Elements[ThisIndex]; + + ThisExternalObj = (ACPI_OBJECT *) + &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; + + if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE)) + { + /* + * If this object is a package then we go one deeper + */ + if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) + { + /* + * Too many nested levels of packages for us to handle + */ + DEBUG_PRINT (ACPI_ERROR, + ("CmBuildPackageObject: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* + * Build the package object + */ + ThisExternalObj->Type = ACPI_TYPE_PACKAGE; + ThisExternalObj->Package.Count = ThisInternalObj->Package.Count; + ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = ThisExternalObj->Package.Count * + sizeof (ACPI_OBJECT); + + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + CurrentDepth++; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->InternalObj = ThisInternalObj; + LevelPtr->ExternalObj = ThisExternalObj; + LevelPtr->Index = 0; + + } /* if object is a package */ + + else + { + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + LevelPtr->Index++; + while (LevelPtr->Index >= + LevelPtr->InternalObj->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 + */ + if (CurrentDepth == 0) + { + /* + * We have handled all of the objects + * in the top level package just add + * the length of the package objects + * and get out + */ + *SpaceUsed = Length; + return_ACPI_STATUS (AE_OK); + } + + /* + * go back up a level and move the index + * past the just completed package object. + */ + CurrentDepth--; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->Index++; + } + } /* else object is NOT a package */ + } /* while (1) */ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildInternalObject + * + * PARAMETERS: *InternalObj - The external object to be converted + * *BufferPtr - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: Converts an external object to an internal object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildInternalObject ( + ACPI_OBJECT *ExternalObj, + ACPI_OPERAND_OBJECT *InternalObj) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmBuildInternalObject"); + + + if (ExternalObj->Type == ACPI_TYPE_PACKAGE) + { + /* + * Package objects contain other objects (which can be objects) + * buildpackage does it all + */ +/* + Status = AcpiCmBuildInternalPackageObject(InternalObj, + RetBuffer->Pointer, + &RetBuffer->Length); +*/ + DEBUG_PRINT (ACPI_ERROR, + ("CmBuildInternalObject: Packages as parameters not implemented!\n")); + + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiCmBuildInternalSimpleObject (ExternalObj, InternalObj); + /* + * build simple does not include the object size in the length + * so we add it in here + */ + } + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmdebug.c b/sys/contrib/dev/acpica/Subsystem/Common/cmdebug.c new file mode 100644 index 0000000..e9a4f5b --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmdebug.c @@ -0,0 +1,657 @@ +/****************************************************************************** + * + * Module Name: cmdebug - Debug print routines + * $Revision: 60 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMDEBUG_C__ + +#include "acpi.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmdebug") + + +/***************************************************************************** + * + * FUNCTION: Get/Set debug level + * + * DESCRIPTION: Get or set value of the debug flag + * + * These are used to allow user's to get/set the debug level + * + ****************************************************************************/ + + +UINT32 +GetDebugLevel (void) +{ + + return (AcpiDbgLevel); +} + +void +SetDebugLevel ( + UINT32 NewDebugLevel) +{ + + AcpiDbgLevel = NewDebugLevel; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTrace + * + * 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) + * FunctionName - Name of Caller's function + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTrace ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName) +{ + + AcpiGbl_NestingLevel++; + + DebugPrint (ModuleName, LineNumber, ComponentId, + TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s\n", + AcpiGbl_NestingLevel, FunctionName); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTracePtr + * + * 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) + * FunctionName - Name of Caller's function + * Pointer - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTracePtr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + void *Pointer) +{ + + AcpiGbl_NestingLevel++; + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s, 0x%p\n", + AcpiGbl_NestingLevel, FunctionName, Pointer); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTraceStr + * + * 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) + * FunctionName - Name of Caller's function + * String - Additional string to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTraceStr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_CHAR *String) +{ + + AcpiGbl_NestingLevel++; + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s, %s\n", + AcpiGbl_NestingLevel, FunctionName, String); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTraceU32 + * + * 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) + * FunctionName - Name of Caller's function + * Integer - Integer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTraceU32 ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT32 Integer) +{ + + AcpiGbl_NestingLevel++; + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s, 0x%lX\n", + AcpiGbl_NestingLevel, FunctionName, Integer); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionExit + * + * 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) + * FunctionName - Name of Caller's function + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s\n", + AcpiGbl_NestingLevel, FunctionName); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionStatusExit + * + * 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) + * FunctionName - Name of Caller's function + * 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 +FunctionStatusExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + ACPI_STATUS Status) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, + TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s, %s\n", + AcpiGbl_NestingLevel, + FunctionName, + AcpiCmFormatException (Status)); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionValueExit + * + * 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) + * FunctionName - Name of Caller's function + * 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 +FunctionValueExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_UINT Value) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s, 0x%X\n", + AcpiGbl_NestingLevel, FunctionName, Value); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionPtrExit + * + * 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) + * FunctionName - Name of Caller's function + * 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 +FunctionPtrExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT8 *Ptr) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s, 0x%p\n", + AcpiGbl_NestingLevel, FunctionName, Ptr); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: DebugPrint + * + * 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) + * PrintLevel - Requested debug print level + * 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 +DebugPrint ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + UINT32 PrintLevel, + NATIVE_CHAR *Format, + ...) +{ + va_list args; + + + /* Both the level and the component must be enabled */ + + if ((PrintLevel & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer)) + { + va_start (args, Format); + + AcpiOsPrintf ("%8s-%04d: ", ModuleName, LineNumber); + AcpiOsVprintf (Format, args); + } +} + + +/***************************************************************************** + * + * FUNCTION: DebugPrintPrefix + * + * 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: None + * + * DESCRIPTION: Print the prefix part of an error message, consisting of the + * module name, and line number + * + ****************************************************************************/ + +void +DebugPrintPrefix ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber) +{ + + + AcpiOsPrintf ("%8s-%04d: ", ModuleName, LineNumber); +} + + +/***************************************************************************** + * + * FUNCTION: DebugPrintRaw + * + * PARAMETERS: Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print error message -- without module/line indentifiers + * + ****************************************************************************/ + +void +DebugPrintRaw ( + NATIVE_CHAR *Format, + ...) +{ + va_list args; + + + va_start (args, Format); + + AcpiOsVprintf (Format, args); + + va_end (args); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ****************************************************************************/ + +void +AcpiCmDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 ComponentId) +{ + UINT32 i = 0; + UINT32 j; + UINT32 Temp32; + UINT8 BufChar; + + + /* Only dump the buffer if tracing is enabled */ + + if (!((TRACE_TABLES & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer))) + { + return; + } + + + /* + * Nasty little dump buffer routine! + */ + while (i < Count) + { + /* Print current offset */ + + AcpiOsPrintf ("%05X ", i); + + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Count) + { + AcpiOsPrintf ("\n"); + return; + } + + /* Make sure that the INT8 doesn't get sign-extended! */ + + switch (Display) + { + /* Default is BYTE display */ + + default: + + AcpiOsPrintf ("%02X ", + *((UINT8 *) &Buffer[i + j])); + j += 1; + break; + + + case DB_WORD_DISPLAY: + + MOVE_UNALIGNED16_TO_32 (&Temp32, + &Buffer[i + j]); + AcpiOsPrintf ("%04X ", Temp32); + j += 2; + break; + + + case DB_DWORD_DISPLAY: + + MOVE_UNALIGNED32_TO_32 (&Temp32, + &Buffer[i + j]); + AcpiOsPrintf ("%08X ", Temp32); + j += 4; + break; + + + case DB_QWORD_DISPLAY: + + MOVE_UNALIGNED32_TO_32 (&Temp32, + &Buffer[i + j]); + AcpiOsPrintf ("%08X", Temp32); + + MOVE_UNALIGNED32_TO_32 (&Temp32, + &Buffer[i + j + 4]); + AcpiOsPrintf ("%08X ", Temp32); + j += 8; + break; + } + } + + + /* + * Print the ASCII equivalent characters + * But watch out for the bad unprintable ones... + */ + + for (j = 0; j < 16; j++) + { + if (i + j >= Count) + { + AcpiOsPrintf ("\n"); + return; + } + + BufChar = Buffer[i + j]; + if ((BufChar > 0x1F && BufChar < 0x2E) || + (BufChar > 0x2F && BufChar < 0x61) || + (BufChar > 0x60 && BufChar < 0x7F)) + { + AcpiOsPrintf ("%c", BufChar); + } + else + { + AcpiOsPrintf ("."); + } + } + + /* Done with that line. */ + + AcpiOsPrintf ("\n"); + i += 16; + } + + return; +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmdelete.c b/sys/contrib/dev/acpica/Subsystem/Common/cmdelete.c new file mode 100644 index 0000000..bce5e2e --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmdelete.c @@ -0,0 +1,806 @@ +/******************************************************************************* + * + * Module Name: cmdelete - object deletion and reference count utilities + * $Revision: 57 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMDELETE_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acparser.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmdelete") + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteInternalObj + * + * PARAMETERS: *Object - Pointer to the list to be deleted + * + * RETURN: None + * + * DESCRIPTION: Low level object deletion, after reference counts have been + * updated (All reference counts, including sub-objects!) + * + ******************************************************************************/ + +void +AcpiCmDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object) +{ + void *ObjPointer = NULL; + ACPI_OPERAND_OBJECT *HandlerDesc; + + + FUNCTION_TRACE_PTR ("CmDeleteInternalObj", 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: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: **** String %p, ptr %p\n", + Object, Object->String.Pointer)); + + /* Free the actual string buffer */ + + ObjPointer = Object->String.Pointer; + break; + + + case ACPI_TYPE_BUFFER: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: **** Buffer %p, ptr %p\n", + Object, Object->Buffer.Pointer)); + + /* Free the actual buffer */ + + ObjPointer = Object->Buffer.Pointer; + break; + + + case ACPI_TYPE_PACKAGE: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: **** Package of count %d\n", + Object->Package.Count)); + + /* + * Elements of the package are not handled here, they are deleted + * separately + */ + + /* Free the (variable length) element pointer array */ + + ObjPointer = Object->Package.Elements; + break; + + + case ACPI_TYPE_MUTEX: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Mutex %p, Semaphore %p\n", + Object, Object->Mutex.Semaphore)); + + AcpiOsDeleteSemaphore (Object->Mutex.Semaphore); + break; + + + case ACPI_TYPE_EVENT: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Event %p, Semaphore %p\n", + Object, Object->Event.Semaphore)); + + AcpiOsDeleteSemaphore (Object->Event.Semaphore); + Object->Event.Semaphore = NULL; + break; + + + case ACPI_TYPE_METHOD: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Method %p\n", Object)); + + /* Delete the method semaphore if it exists */ + + if (Object->Method.Semaphore) + { + AcpiOsDeleteSemaphore (Object->Method.Semaphore); + Object->Method.Semaphore = NULL; + } + + break; + + + case ACPI_TYPE_REGION: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Region %p\n", + Object)); + + + if (Object->Region.Extra) + { + /* + * Free the RegionContext if and only if the handler is one of the + * default handlers -- and therefore, we created the context object + * locally, it was not created by an external caller. + */ + HandlerDesc = Object->Region.AddrHandler; + if ((HandlerDesc) && + (HandlerDesc->AddrHandler.Hflags == ADDR_HANDLER_DEFAULT_INSTALLED)) + { + ObjPointer = Object->Region.Extra->Extra.RegionContext; + } + + /* Now we can free the Extra object */ + + AcpiCmDeleteObjectDesc (Object->Region.Extra); + } + break; + + + case ACPI_TYPE_FIELD_UNIT: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** FieldUnit %p\n", + Object)); + + if (Object->FieldUnit.Extra) + { + AcpiCmDeleteObjectDesc (Object->FieldUnit.Extra); + } + break; + + default: + break; + } + + + /* + * Delete any allocated memory found above + */ + + if (ObjPointer) + { + if (!AcpiTbSystemTablePointer (ObjPointer)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: Deleting Obj Ptr %p \n", ObjPointer)); + + AcpiCmFree (ObjPointer); + } + } + + + /* Only delete the object if it was dynamically allocated */ + + if (Object->Common.Flags & AOPOBJ_STATIC_ALLOCATION) + { + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: Object %p [%s] static allocation, no delete\n", + Object, AcpiCmGetTypeName (Object->Common.Type))); + } + + if (!(Object->Common.Flags & AOPOBJ_STATIC_ALLOCATION)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: Deleting object %p [%s]\n", + Object, AcpiCmGetTypeName (Object->Common.Type))); + + AcpiCmDeleteObjectDesc (Object); + + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteInternalObjectList + * + * PARAMETERS: *ObjList - Pointer to the list to be deleted + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function deletes an internal object list, including both + * simple objects and package objects + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList) +{ + ACPI_OPERAND_OBJECT **InternalObj; + + + FUNCTION_TRACE ("CmDeleteInternalObjectList"); + + + /* Walk the null-terminated internal list */ + + for (InternalObj = ObjList; *InternalObj; InternalObj++) + { + /* + * Check for a package + * Simple objects are simply stored in the array and do not + * need to be deleted separately. + */ + + if (IS_THIS_OBJECT_TYPE ((*InternalObj), ACPI_TYPE_PACKAGE)) + { + /* Delete the package */ + + /* + * TBD: [Investigate] This might not be the right thing to do, + * depending on how the internal package object was allocated!!! + */ + AcpiCmDeleteInternalObj (*InternalObj); + } + + } + + /* Free the combined parameter pointer list and object array */ + + AcpiCmFree (ObjList); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmUpdateRefCount + * + * 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. + * + ******************************************************************************/ + +void +AcpiCmUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action) +{ + UINT16 Count; + UINT16 NewCount; + + + if (!Object) + { + return; + } + + + Count = Object->Common.ReferenceCount; + NewCount = Count; + + /* + * Reference count action (increment, decrement, or force delete) + */ + + switch (Action) + { + + case REF_INCREMENT: + + NewCount++; + Object->Common.ReferenceCount = NewCount; + + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, [Incremented]\n", + Object, NewCount)); + break; + + + case REF_DECREMENT: + + if (Count < 1) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, can't decrement! (Set to 0)\n", + Object, NewCount)); + + NewCount = 0; + } + + else + { + NewCount--; + + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, [Decremented]\n", + Object, NewCount)); + } + + if (Object->Common.Type == ACPI_TYPE_METHOD) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Method Obj %p Refs=%d, [Decremented]\n", + Object, NewCount)); + } + + Object->Common.ReferenceCount = NewCount; + if (NewCount == 0) + { + AcpiCmDeleteInternalObj (Object); + } + + break; + + + case REF_FORCE_DELETE: + + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, Force delete! (Set to 0)\n", + Object, Count)); + + NewCount = 0; + Object->Common.ReferenceCount = NewCount; + AcpiCmDeleteInternalObj (Object); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("CmUpdateRefCount: Unknown action (%d)\n", Action)); + break; + } + + + /* + * Sanity check the reference count, for debug purposes only. + * (A deleted object will have a huge reference count) + */ + + if (Count > MAX_REFERENCE_COUNT) + { + + DEBUG_PRINT (ACPI_ERROR, + ("CmUpdateRefCount: **** AE_ERROR **** Invalid Reference Count (0x%X) in object %p\n\n", + Count, Object)); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmUpdateObjectReference + * + * 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 +AcpiCmUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_STATUS Status; + UINT32 i; + ACPI_OPERAND_OBJECT *Next; + ACPI_OPERAND_OBJECT *New; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE_PTR ("CmUpdateObjectReference", Object); + + + /* Ignore a null object ptr */ + + if (!Object) + { + return_ACPI_STATUS (AE_OK); + } + + + /* + * Make sure that this isn't a namespace handle or an AML pointer + */ + + if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateObjectReference: Object %p is NS handle\n", + Object)); + return_ACPI_STATUS (AE_OK); + } + + if (AcpiTbSystemTablePointer (Object)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateObjectReference: **** Object %p is Pcode Ptr\n", + Object)); + return_ACPI_STATUS (AE_OK); + } + + + State = AcpiCmCreateUpdateState (Object, Action); + + while (State) + { + + Object = State->Update.Object; + Action = State->Update.Value; + AcpiCmDeleteGenericState (State); + + /* + * All sub-objects must have their reference count incremented also. + * Different object types have different subobjects. + */ + switch (Object->Common.Type) + { + + case ACPI_TYPE_DEVICE: + + Status = AcpiCmCreateUpdateStateAndPush (Object->Device.AddrHandler, + Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiCmUpdateRefCount (Object->Device.SysHandler, Action); + AcpiCmUpdateRefCount (Object->Device.DrvHandler, Action); + break; + + + case INTERNAL_TYPE_ADDRESS_HANDLER: + + /* Must walk list of address handlers */ + + Next = Object->AddrHandler.Next; + while (Next) + { + New = Next->AddrHandler.Next; + AcpiCmUpdateRefCount (Next, Action); + + Next = New; + } + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * We must update all the sub-objects of the package + * (Each of whom may have their own sub-objects, etc. + */ + for (i = 0; i < Object->Package.Count; i++) + { + /* + * Push each element onto the stack for later processing. + * Note: There can be null elements within the package, + * these are simply ignored + */ + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->Package.Elements[i], Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + break; + + + case ACPI_TYPE_FIELD_UNIT: + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->FieldUnit.Container, Action, &StateList); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->Field.Container, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->BankField.BankSelect, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->BankField.Container, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case ACPI_TYPE_REGION: + + /* TBD: [Investigate] + AcpiCmUpdateRefCount (Object->Region.AddrHandler, Action); + */ +/* + Status = + AcpiCmCreateUpdateStateAndPush (Object->Region.AddrHandler, + Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } +*/ + break; + + + case INTERNAL_TYPE_REFERENCE: + + break; + } + + + /* + * Now we can update the count in the main object. This can only + * happen after we update the sub-objects in case this causes the + * main object to be deleted. + */ + + AcpiCmUpdateRefCount (Object, Action); + + + /* Move on to the next object to be updated */ + + State = AcpiCmPopGenericState (&StateList); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmAddReference + * + * PARAMETERS: *Object - Object whose reference count is to be + * incremented + * + * RETURN: None + * + * DESCRIPTION: Add one reference to an ACPI object + * + ******************************************************************************/ + +void +AcpiCmAddReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + FUNCTION_TRACE_PTR ("CmAddReference", Object); + + + /* + * Ensure that we have a valid object + */ + + if (!AcpiCmValidInternalObject (Object)) + { + return_VOID; + } + + /* + * We have a valid ACPI internal object, now increment the reference count + */ + + AcpiCmUpdateObjectReference (Object, REF_INCREMENT); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmRemoveReference + * + * PARAMETERS: *Object - Object whose ref count will be decremented + * + * RETURN: None + * + * DESCRIPTION: Decrement the reference count of an ACPI internal object + * + ******************************************************************************/ + +void +AcpiCmRemoveReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + FUNCTION_TRACE_PTR ("CmRemoveReference", Object); + + + /* + * Ensure that we have a valid object + */ + + if (!AcpiCmValidInternalObject (Object)) + { + return_VOID; + } + + DEBUG_PRINT (ACPI_INFO, ("CmRemoveReference: Obj %p Refs=%d\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!) + */ + + AcpiCmUpdateObjectReference (Object, REF_DECREMENT); + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmeval.c b/sys/contrib/dev/acpica/Subsystem/Common/cmeval.c new file mode 100644 index 0000000..81be3df --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmeval.c @@ -0,0 +1,494 @@ +/****************************************************************************** + * + * Module Name: cmeval - Object evaluation + * $Revision: 18 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMEVAL_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmeval") + + +/**************************************************************************** + * + * FUNCTION: AcpiCmEvaluateNumericObject + * + * PARAMETERS: *ObjectName - Object name to be evaluated + * DeviceNode - Node for the device + * *Address - Where the value is returned + * + * RETURN: Status + * + * DESCRIPTION: evaluates a numeric namespace object for a selected device + * and stores results in *Address. + * + * NOTE: Internal function, no parameter validation + * + ***************************************************************************/ + +ACPI_STATUS +AcpiCmEvaluateNumericObject ( + NATIVE_CHAR *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Address) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmEvaluateNumericObject"); + + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, ObjectName, NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + DEBUG_PRINT (ACPI_INFO, + ("%s on %4.4s was not found\n", ObjectName, + &DeviceNode->Name)); + } + else + { + DEBUG_PRINT (ACPI_ERROR, + ("%s on %4.4s failed with status %4.4x\n", ObjectName, + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + return_ACPI_STATUS (Status); + } + + + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("No object was returned from %s\n", ObjectName)); + return_ACPI_STATUS (AE_TYPE); + } + + /* Is the return object of the correct type? */ + + if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from %s was not a number: %d \n", + ObjectName, ObjDesc->Common.Type)); + } + else + { + /* + * Since the structure is a union, setting any field will set all + * of the variables in the union + */ + *Address = ObjDesc->Number.Value; + } + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmExecute_HID + * + * PARAMETERS: DeviceNode - Node for the device + * *Hid - Where the HID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _HID control method that returns the hardware + * ID of the device. + * + * NOTE: Internal function, no parameter validation + * + ***************************************************************************/ + +ACPI_STATUS +AcpiCmExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Hid) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmExecute_HID"); + + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, + METHOD_NAME__HID, NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + DEBUG_PRINT (ACPI_INFO, + ("_HID on %4.4s was not found\n", + &DeviceNode->Name)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("_HID on %4.4s failed with status %4.4x\n", + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + return_ACPI_STATUS (Status); + } + + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _HID\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* + * A _HID can return either a Number (32 bit compressed EISA ID) or + * a string + */ + + if ((ObjDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from _HID was not a number or string: [0x%X] \n", + ObjDesc->Common.Type)); + } + + else + { + if (ObjDesc->Common.Type == ACPI_TYPE_NUMBER) + { + /* Convert the Numeric HID to string */ + + AcpiAmlEisaIdToString ((UINT32) ObjDesc->Number.Value, Hid->Buffer); + } + + else + { + /* Copy the String HID from the returned object */ + + STRNCPY(Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer)); + } + } + + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmExecute_UID + * + * PARAMETERS: DeviceNode - Node for the device + * *Uid - Where the UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _UID control method that returns the hardware + * ID of the device. + * + * NOTE: Internal function, no parameter validation + * + ***************************************************************************/ + +ACPI_STATUS +AcpiCmExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Uid) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, + METHOD_NAME__UID, NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + DEBUG_PRINT (ACPI_INFO, + ("_UID on %4.4s was not found\n", + &DeviceNode->Name)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("_UID on %4.4s failed with status %4.4x\n", + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + return (Status); + } + + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _UID\n")); + return (AE_TYPE); + } + + /* + * A _UID can return either a Number (32 bit compressed EISA ID) or + * a string + */ + + if ((ObjDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from _UID was not a number or string: %d \n", + ObjDesc->Common.Type)); + } + + else + { + if (ObjDesc->Common.Type == ACPI_TYPE_NUMBER) + { + /* Convert the Numeric UID to string */ + + AcpiAmlUnsignedIntegerToString (ObjDesc->Number.Value, Uid->Buffer); + } + + else + { + /* Copy the String UID from the returned object */ + + STRNCPY(Uid->Buffer, ObjDesc->String.Pointer, sizeof(Uid->Buffer)); + } + } + + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + + return (Status); +} + +/**************************************************************************** + * + * FUNCTION: AcpiCmExecute_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 +AcpiCmExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *Flags) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmExecute_STA"); + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, + METHOD_NAME__STA, NULL, &ObjDesc); + if (AE_NOT_FOUND == Status) + { + DEBUG_PRINT (ACPI_INFO, + ("_STA on %4.4s was not found, assuming present.\n", + &DeviceNode->Name)); + + *Flags = 0x0F; + Status = AE_OK; + } + + else if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("_STA on %4.4s failed with status %s\n", + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + else /* success */ + { + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _STA\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* Is the return object of the correct type? */ + + if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from _STA was not a number: %d \n", + ObjDesc->Common.Type)); + } + + else + { + /* Extract the status flags */ + + *Flags = (UINT32) ObjDesc->Number.Value; + } + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + } + + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmglobal.c b/sys/contrib/dev/acpica/Subsystem/Common/cmglobal.c new file mode 100644 index 0000000..a57bd51 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmglobal.c @@ -0,0 +1,705 @@ +/****************************************************************************** + * + * Module Name: cmglobal - Global variables for the ACPI subsystem + * $Revision: 104 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMGLOBAL_C__ +#define DEFINE_ACPI_GLOBALS + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmglobal") + + +/****************************************************************************** + * + * 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 +UINT32 AcpiDbgLevel = DEBUG_DEFAULT; +#else +UINT32 AcpiDbgLevel = NORMAL_DEFAULT; +#endif + +/* Debug switch - layer (component) mask */ + +UINT32 AcpiDbgLayer = COMPONENT_DEFAULT; +UINT32 AcpiGbl_NestingLevel = 0; + + +/* Debugger globals */ + +BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; +BOOLEAN AcpiGbl_MethodExecuting = FALSE; + +/* System flags */ + +UINT32 AcpiGbl_SystemFlags = 0; +UINT32 AcpiGbl_StartupFlags = 0; + +/* System starts unitialized! */ +BOOLEAN AcpiGbl_Shutdown = TRUE; + + +/****************************************************************************** + * + * Namespace globals + * + ******************************************************************************/ + + +/* + * Names built-in to the interpreter + * + * Initial values are currently supported only for types String and Number. + * To avoid type punning, both are specified as strings in this table. + */ + +PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = +{ + {"_GPE", INTERNAL_TYPE_DEF_ANY}, + {"_PR_", INTERNAL_TYPE_DEF_ANY}, + {"_SB_", INTERNAL_TYPE_DEF_ANY}, + {"_SI_", INTERNAL_TYPE_DEF_ANY}, + {"_TZ_", INTERNAL_TYPE_DEF_ANY}, + {"_REV", ACPI_TYPE_NUMBER, "2"}, + {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, + {"_GL_", ACPI_TYPE_MUTEX, "0"}, + + /* Table terminator */ + + {NULL, ACPI_TYPE_ANY} +}; + + +/* + * Properties of the ACPI Object Types, both internal and external. + * + * Elements of AcpiNsProperties are bit significant + * and the table is indexed by values of ACPI_OBJECT_TYPE + */ + +UINT8 AcpiGbl_NsProperties[] = +{ + NSP_NORMAL, /* 00 Any */ + NSP_NORMAL, /* 01 Number */ + NSP_NORMAL, /* 02 String */ + NSP_NORMAL, /* 03 Buffer */ + NSP_LOCAL, /* 04 Package */ + NSP_NORMAL, /* 05 FieldUnit */ + NSP_NEWSCOPE | NSP_LOCAL, /* 06 Device */ + NSP_LOCAL, /* 07 AcpiEvent */ + NSP_NEWSCOPE | NSP_LOCAL, /* 08 Method */ + NSP_LOCAL, /* 09 Mutex */ + NSP_LOCAL, /* 10 Region */ + NSP_NEWSCOPE | NSP_LOCAL, /* 11 Power */ + NSP_NEWSCOPE | NSP_LOCAL, /* 12 Processor */ + NSP_NEWSCOPE | NSP_LOCAL, /* 13 Thermal */ + NSP_NORMAL, /* 14 BufferField */ + NSP_NORMAL, /* 15 DdbHandle */ + NSP_NORMAL, /* 16 Debug Object */ + NSP_NORMAL, /* 17 DefField */ + NSP_NORMAL, /* 18 BankField */ + NSP_NORMAL, /* 19 IndexField */ + NSP_NORMAL, /* 20 Reference */ + NSP_NORMAL, /* 21 Alias */ + NSP_NORMAL, /* 22 Notify */ + NSP_NORMAL, /* 23 Address Handler */ + NSP_NORMAL, /* 24 DefFieldDefn */ + NSP_NORMAL, /* 25 BankFieldDefn */ + NSP_NORMAL, /* 26 IndexFieldDefn */ + NSP_NORMAL, /* 27 If */ + NSP_NORMAL, /* 28 Else */ + NSP_NORMAL, /* 29 While */ + NSP_NEWSCOPE, /* 30 Scope */ + NSP_LOCAL, /* 31 DefAny */ + NSP_NORMAL, /* 32 Method Arg */ + NSP_NORMAL, /* 33 Method Local */ + NSP_NORMAL, /* 34 Extra */ + NSP_NORMAL /* 35 Invalid */ +}; + + +/****************************************************************************** + * + * Table globals + * + ******************************************************************************/ + + +ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES]; + + +ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES] = +{ + /* Name, Signature, Signature size, How many allowed?, Supported? Global typed pointer */ + + /* RSDP 0 */ {"RSDP", RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL}, + /* APIC 1 */ {APIC_SIG, APIC_SIG, sizeof (APIC_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_APIC}, + /* DSDT 2 */ {DSDT_SIG, DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_DSDT}, + /* FACP 3 */ {FACP_SIG, FACP_SIG, sizeof (FACP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_FACP}, + /* FACS 4 */ {FACS_SIG, FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_FACS}, + /* PSDT 5 */ {PSDT_SIG, PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, + /* RSDT 6 */ {RSDT_SIG, RSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL}, + /* SSDT 7 */ {SSDT_SIG, SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, + /* SBST 8 */ {SBST_SIG, SBST_SIG, sizeof (SBST_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_SBST}, + /* SPIC 9 */ {SPIC_SIG, SPIC_SIG, sizeof (SPIC_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, + /* BOOT 10 */{BOOT_SIG, BOOT_SIG, sizeof (BOOT_SIG)-1, ACPI_TABLE_SINGLE, AE_SUPPORT, NULL} +}; + + +#ifdef ACPI_DEBUG + +/****************************************************************************** + * + * Strings and procedures used for debug only + * + ******************************************************************************/ + +NATIVE_CHAR *MsgAcpiErrorBreak = "*** Break on ACPI_ERROR ***\n"; + + +/***************************************************************************** + * + * FUNCTION: AcpiCmGetMutexName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a mutex ID into a name string (Debug only) + * + ****************************************************************************/ + +NATIVE_CHAR * +AcpiCmGetMutexName ( + UINT32 MutexId) +{ + + if (MutexId > MAX_MTX) + { + return ("Invalid Mutex ID"); + } + + return (AcpiGbl_MutexNames[MutexId]); +} + + +/* + * Elements of AcpiGbl_NsTypeNames below must match + * one-to-one with values of ACPI_OBJECT_TYPE + * + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when + * stored in a table it really means that we have thus far seen no evidence to + * indicatewhat type is actually going to be stored for this entry. + */ + +static NATIVE_CHAR AcpiGbl_BadType[] = "UNDEFINED"; +#define TYPE_NAME_LENGTH 9 /* Maximum length of each string */ + +static NATIVE_CHAR *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */ +{ + /* 00 */ "Untyped", + /* 01 */ "Number", + /* 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 */ "BufferFld", + /* 15 */ "DdbHandle", + /* 16 */ "DebugObj", + /* 17 */ "DefField", + /* 18 */ "BnkField", + /* 19 */ "IdxField", + /* 20 */ "Reference", + /* 21 */ "Alias", + /* 22 */ "Notify", + /* 23 */ "AddrHndlr", + /* 24 */ "DefFldDfn", + /* 25 */ "BnkFldDfn", + /* 26 */ "IdxFldDfn", + /* 27 */ "If", + /* 28 */ "Else", + /* 29 */ "While", + /* 30 */ "Scope", + /* 31 */ "DefAny", + /* 32 */ "MethodArg", + /* 33 */ "MethodLcl", + /* 34 */ "Extra", + /* 35 */ "Invalid" +}; + + +/***************************************************************************** + * + * FUNCTION: AcpiCmGetTypeName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Type ID into a name string (Debug only) + * + ****************************************************************************/ + +NATIVE_CHAR * +AcpiCmGetTypeName ( + UINT32 Type) +{ + + if (Type > INTERNAL_TYPE_INVALID) + { + return (AcpiGbl_BadType); + } + + return (AcpiGbl_NsTypeNames[Type]); +} + +#endif + + +/***************************************************************************** + * + * FUNCTION: AcpiCmValidObjectType + * + * PARAMETERS: None. + * + * RETURN: TRUE if valid object type + * + * DESCRIPTION: Validate an object type + * + ****************************************************************************/ + +BOOLEAN +AcpiCmValidObjectType ( + UINT32 Type) +{ + + if (Type > ACPI_TYPE_MAX) + { + if ((Type < INTERNAL_TYPE_BEGIN) || + (Type > INTERNAL_TYPE_MAX)) + { + return (FALSE); + } + } + + return (TRUE); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmFormatException + * + * PARAMETERS: Status - Acpi status to be formatted + * + * RETURN: Formatted status string + * + * DESCRIPTION: Convert an ACPI exception to a string + * + ****************************************************************************/ + +NATIVE_CHAR * +AcpiCmFormatException ( + ACPI_STATUS Status) +{ + NATIVE_CHAR *Exception = "UNKNOWN_STATUS"; + ACPI_STATUS SubStatus; + + + 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 -1]; + } + break; + + case AE_CODE_ACPI_TABLES: + + if (SubStatus <= AE_CODE_TBL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; + } + break; + + case AE_CODE_AML: + + if (SubStatus <= AE_CODE_AML_MAX) + { + Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; + } + break; + + case AE_CODE_CONTROL: + + if (SubStatus <= AE_CODE_CTRL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; + } + break; + + default: + break; + } + + + return (Exception); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmAllocateOwnerId + * + * PARAMETERS: IdType - Type of ID (method or table) + * + * DESCRIPTION: Allocate a table or method owner id + * + ***************************************************************************/ + +ACPI_OWNER_ID +AcpiCmAllocateOwnerId ( + UINT32 IdType) +{ + ACPI_OWNER_ID OwnerId = 0xFFFF; + + + FUNCTION_TRACE ("CmAllocateOwnerId"); + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + switch (IdType) + { + case OWNER_TYPE_TABLE: + + OwnerId = AcpiGbl_NextTableOwnerId; + AcpiGbl_NextTableOwnerId++; + + if (AcpiGbl_NextTableOwnerId == FIRST_METHOD_ID) + { + AcpiGbl_NextTableOwnerId = FIRST_TABLE_ID; + } + break; + + + case OWNER_TYPE_METHOD: + + OwnerId = AcpiGbl_NextMethodOwnerId; + AcpiGbl_NextMethodOwnerId++; + + if (AcpiGbl_NextMethodOwnerId == FIRST_TABLE_ID) + { + AcpiGbl_NextMethodOwnerId = FIRST_METHOD_ID; + } + break; + } + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + return_VALUE (OwnerId); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmInitGlobals + * + * PARAMETERS: none + * + * DESCRIPTION: Init library globals. All globals that require specific + * initialization should be initialized here! + * + ***************************************************************************/ + +void +AcpiCmInitGlobals ( + void) +{ + UINT32 i; + + + FUNCTION_TRACE ("CmInitGlobals"); + + + /* ACPI table structure */ + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + AcpiGbl_AcpiTables[i].Prev = &AcpiGbl_AcpiTables[i]; + AcpiGbl_AcpiTables[i].Next = &AcpiGbl_AcpiTables[i]; + AcpiGbl_AcpiTables[i].Pointer = NULL; + AcpiGbl_AcpiTables[i].Length = 0; + AcpiGbl_AcpiTables[i].Allocation = ACPI_MEM_NOT_ALLOCATED; + AcpiGbl_AcpiTables[i].Count = 0; + } + + + /* Address Space handler array */ + + for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++) + { + AcpiGbl_AddressSpaces[i].Handler = NULL; + AcpiGbl_AddressSpaces[i].Context = NULL; + } + + /* Mutex locked flags */ + + for (i = 0; i < NUM_MTX; i++) + { + AcpiGbl_AcpiMutexInfo[i].Mutex = NULL; + AcpiGbl_AcpiMutexInfo[i].Locked = FALSE; + AcpiGbl_AcpiMutexInfo[i].UseCount = 0; + } + + /* Global notify handlers */ + + AcpiGbl_SysNotify.Handler = NULL; + AcpiGbl_DrvNotify.Handler = NULL; + + /* Global "typed" ACPI table pointers */ + + AcpiGbl_RSDP = NULL; + AcpiGbl_RSDT = NULL; + AcpiGbl_FACS = NULL; + AcpiGbl_FACP = NULL; + AcpiGbl_APIC = NULL; + AcpiGbl_DSDT = NULL; + AcpiGbl_SBST = NULL; + + + /* Global Lock support */ + + AcpiGbl_GlobalLockAcquired = FALSE; + AcpiGbl_GlobalLockThreadCount = 0; + + /* Miscellaneous variables */ + + AcpiGbl_SystemFlags = 0; + AcpiGbl_StartupFlags = 0; + AcpiGbl_GlobalLockSet = FALSE; + AcpiGbl_RsdpOriginalLocation = 0; + AcpiGbl_WhenToParseMethods = METHOD_PARSE_CONFIGURATION; + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_DbTerminateThreads = FALSE; + AcpiGbl_Shutdown = FALSE; + AcpiGbl_NsLookupCount = 0; + AcpiGbl_PsFindCount = 0; + AcpiGbl_AcpiHardwarePresent = TRUE; + AcpiGbl_NextTableOwnerId = FIRST_TABLE_ID; + AcpiGbl_NextMethodOwnerId = FIRST_METHOD_ID; + AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; + + /* Cache of small "state" objects */ + + AcpiGbl_GenericStateCache = NULL; + AcpiGbl_GenericStateCacheDepth = 0; + AcpiGbl_StateCacheRequests = 0; + AcpiGbl_StateCacheHits = 0; + + AcpiGbl_ParseCache = NULL; + AcpiGbl_ParseCacheDepth = 0; + AcpiGbl_ParseCacheRequests = 0; + AcpiGbl_ParseCacheHits = 0; + + AcpiGbl_ExtParseCache = NULL; + AcpiGbl_ExtParseCacheDepth = 0; + AcpiGbl_ExtParseCacheRequests = 0; + AcpiGbl_ExtParseCacheHits = 0; + + AcpiGbl_ObjectCache = NULL; + AcpiGbl_ObjectCacheDepth = 0; + AcpiGbl_ObjectCacheRequests = 0; + AcpiGbl_ObjectCacheHits = 0; + + AcpiGbl_WalkStateCache = NULL; + AcpiGbl_WalkStateCacheDepth = 0; + AcpiGbl_WalkStateCacheRequests = 0; + AcpiGbl_WalkStateCacheHits = 0; + + /* Interpreter */ + + AcpiGbl_BufSeq = 0; + AcpiGbl_NodeErr = FALSE; + + /* Parser */ + + AcpiGbl_ParsedNamespaceRoot = NULL; + + /* Hardware oriented */ + + AcpiGbl_Gpe0EnableRegisterSave = NULL; + AcpiGbl_Gpe1EnableRegisterSave = NULL; + AcpiGbl_OriginalMode = SYS_MODE_UNKNOWN; /* original ACPI/legacy mode */ + AcpiGbl_GpeRegisters = NULL; + AcpiGbl_GpeInfo = NULL; + + /* Namespace */ + + AcpiGbl_RootNode = NULL; + + AcpiGbl_RootNodeStruct.Name = ACPI_ROOT_NAME; + AcpiGbl_RootNodeStruct.DataType = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_ANY; + AcpiGbl_RootNodeStruct.Child = NULL; + AcpiGbl_RootNodeStruct.Peer = NULL; + AcpiGbl_RootNodeStruct.Object = NULL; + AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; + + /* Memory allocation metrics - compiled out in non-debug mode. */ + + INITIALIZE_ALLOCATION_METRICS(); + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cminit.c b/sys/contrib/dev/acpica/Subsystem/Common/cminit.c new file mode 100644 index 0000000..a00a82b --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cminit.c @@ -0,0 +1,347 @@ +/****************************************************************************** + * + * Module Name: cminit - Common ACPI subsystem initialization + * $Revision: 84 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMINIT_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acparser.h" +#include "acdispat.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cminit") + + +/******************************************************************************* + * + * FUNCTION: AcpiCmFacpRegisterError + * + * PARAMETERS: *RegisterName - Pointer to string identifying register + * Value - Actual register contents value + * AcpiTestSpecSection - TDS section containing assertion + * AcpiAssertion - Assertion number being tested + * + * RETURN: AE_BAD_VALUE + * + * DESCRIPTION: Display failure message and link failure to TDS assertion + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmFacpRegisterError ( + NATIVE_CHAR *RegisterName, + UINT32 Value) +{ + + REPORT_ERROR ( + ("Invalid FACP register value, %s = 0x%X (FACP=0x%X)\n", + RegisterName, Value, AcpiGbl_FACP)); + + + return (AE_BAD_VALUE); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmValidateFacp + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Validate various ACPI registers in the FACP + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmValidateFacp ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + /* + * Verify Fixed ACPI Description Table fields, + * but don't abort on any problems, just display error + */ + + if (AcpiGbl_FACP->Pm1EvtLen < 4) + { + Status = AcpiCmFacpRegisterError ("PM1_EVT_LEN", + (UINT32) AcpiGbl_FACP->Pm1EvtLen); + } + + if (!AcpiGbl_FACP->Pm1CntLen) + { + Status = AcpiCmFacpRegisterError ("PM1_CNT_LEN", + (UINT32) AcpiGbl_FACP->Pm1CntLen); + } + + if (!AcpiGbl_FACP->Pm1aEvtBlk) + { + Status = AcpiCmFacpRegisterError ("PM1a_EVT_BLK", + AcpiGbl_FACP->Pm1aEvtBlk); + } + + if (!AcpiGbl_FACP->Pm1aCntBlk) + { + Status = AcpiCmFacpRegisterError ("PM1a_CNT_BLK", + AcpiGbl_FACP->Pm1aCntBlk); + } + + if (!AcpiGbl_FACP->PmTmrBlk) + { + Status = AcpiCmFacpRegisterError ("PM_TMR_BLK", + AcpiGbl_FACP->PmTmrBlk); + } + + if (AcpiGbl_FACP->Pm2CntBlk && !AcpiGbl_FACP->Pm2CntLen) + { + Status = AcpiCmFacpRegisterError ("PM2_CNT_LEN", + (UINT32) AcpiGbl_FACP->Pm2CntLen); + } + + if (AcpiGbl_FACP->PmTmLen < 4) + { + Status = AcpiCmFacpRegisterError ("PM_TM_LEN", + (UINT32) AcpiGbl_FACP->PmTmLen); + } + + /* length of GPE blocks must be a multiple of 2 */ + + + if (AcpiGbl_FACP->Gpe0Blk && (AcpiGbl_FACP->Gpe0BlkLen & 1)) + { + Status = AcpiCmFacpRegisterError ("GPE0_BLK_LEN", + (UINT32) AcpiGbl_FACP->Gpe0BlkLen); + } + + if (AcpiGbl_FACP->Gpe1Blk && (AcpiGbl_FACP->Gpe1BlkLen & 1)) + { + Status = AcpiCmFacpRegisterError ("GPE1_BLK_LEN", + (UINT32) AcpiGbl_FACP->Gpe1BlkLen); + } + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiCmTerminate (void) +{ + + FUNCTION_TRACE ("CmTerminate"); + + + /* Free global tables, etc. */ + + if (AcpiGbl_Gpe0EnableRegisterSave) + { + AcpiCmFree (AcpiGbl_Gpe0EnableRegisterSave); + } + + if (AcpiGbl_Gpe1EnableRegisterSave) + { + AcpiCmFree (AcpiGbl_Gpe1EnableRegisterSave); + } + + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmSubsystemShutdown + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex + * objects here -- because the AML debugger may be still running. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmSubsystemShutdown (void) +{ + + FUNCTION_TRACE ("CmSubsystemShutdown"); + + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + DEBUG_PRINT (ACPI_ERROR, ("ACPI Subsystem is already terminated\n")); + return_ACPI_STATUS (AE_OK); + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + DEBUG_PRINT (ACPI_INFO, ("Shutting down ACPI Subsystem...\n")); + + + /* Close the Namespace */ + + AcpiNsTerminate (); + + /* Close the AcpiEvent Handling */ + + AcpiEvTerminate (); + + /* Close the globals */ + + AcpiCmTerminate (); + + /* Flush the local cache(s) */ + + AcpiCmDeleteGenericStateCache (); + AcpiCmDeleteObjectCache (); + AcpiDsDeleteWalkStateCache (); + + /* Close the Parser */ + + /* TBD: [Restructure] AcpiPsTerminate () */ + + AcpiPsDeleteParseCache (); + + /* Debug only - display leftover memory allocation, if any */ +#ifdef ENABLE_DEBUGGER + AcpiCmDumpCurrentAllocations (ACPI_UINT32_MAX, NULL); +#endif + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c b/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c new file mode 100644 index 0000000..b8597fb --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c @@ -0,0 +1,817 @@ +/****************************************************************************** + * + * Module Name: cmobject - ACPI object create/delete/size/cache routines + * $Revision: 30 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMOBJECT_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "amlcode.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmobject") + + +/****************************************************************************** + * + * FUNCTION: _CmCreateInternalObject + * + * PARAMETERS: Address - Address of the memory to deallocate + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * Type - ACPI Type of the new object + * + * RETURN: Object - The new object. Null on failure + * + * DESCRIPTION: Create and initialize a new internal object. + * + * NOTE: + * We always allocate the worst-case object descriptor because these + * objects are cached, and we want them to be one-size-satisifies-any-request. + * This in itself may not be the most memory efficient, but the efficiency + * of the object cache should more than make up for this! + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +_CmCreateInternalObject ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + OBJECT_TYPE_INTERNAL Type) +{ + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE_STR ("CmCreateInternalObject", AcpiCmGetTypeName (Type)); + + + /* Allocate the raw object descriptor */ + + Object = _CmAllocateObjectDesc (ModuleName, LineNumber, ComponentId); + if (!Object) + { + /* Allocation failure */ + + return_VALUE (NULL); + } + + /* Save the object type in the object descriptor */ + + Object->Common.Type = Type; + + /* Init the reference count */ + + Object->Common.ReferenceCount = 1; + + /* Any per-type initialization should go here */ + + + return_PTR (Object); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmValidInternalObject + * + * PARAMETERS: Operand - Object to be validated + * + * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT + * + *****************************************************************************/ + +BOOLEAN +AcpiCmValidInternalObject ( + void *Object) +{ + + /* Check for a null pointer */ + + if (!Object) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Null Object Ptr\n")); + return (FALSE); + } + + /* Check for a pointer within one of the ACPI tables */ + + if (AcpiTbSystemTablePointer (Object)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Object %p is a Pcode Ptr\n", Object)); + return (FALSE); + } + + /* Check the descriptor type field */ + + if (!VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL)) + { + /* Not an ACPI internal object, do some further checking */ + + if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Obj %p is a named obj, not ACPI obj\n", + Object)); + } + + else if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_PARSER)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Obj %p is a parser obj, not ACPI obj\n", + Object)); + } + + else + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Obj %p is of unknown type\n", + Object)); + } + + return (FALSE); + } + + + /* The object appears to be a valid ACPI_OPERAND_OBJECT */ + + return (TRUE); +} + + +/***************************************************************************** + * + * FUNCTION: _CmAllocateObjectDesc + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: Pointer to newly allocated object descriptor. Null on error + * + * DESCRIPTION: Allocate a new object descriptor. Gracefully handle + * error conditions. + * + ****************************************************************************/ + +void * +_CmAllocateObjectDesc ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("_AllocateObjectDesc"); + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + AcpiGbl_ObjectCacheRequests++; + + /* Check the cache first */ + + if (AcpiGbl_ObjectCache) + { + /* There is an object available, use it */ + + Object = AcpiGbl_ObjectCache; + AcpiGbl_ObjectCache = Object->Cache.Next; + Object->Cache.Next = NULL; + + AcpiGbl_ObjectCacheHits++; + AcpiGbl_ObjectCacheDepth--; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* The cache is empty, create a new object */ + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + /* Attempt to allocate new descriptor */ + + Object = _CmCallocate (sizeof (ACPI_OPERAND_OBJECT), ComponentId, + ModuleName, LineNumber); + if (!Object) + { + /* Allocation failed */ + + _REPORT_ERROR (ModuleName, LineNumber, ComponentId, + ("Could not allocate an object descriptor\n")); + + return_PTR (NULL); + } + + /* Memory allocation metrics - compiled out in non debug mode. */ + + INCREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); + } + + /* Mark the descriptor type */ + + Object->Common.DataType = ACPI_DESC_TYPE_INTERNAL; + + DEBUG_PRINT (TRACE_ALLOCATIONS, ("AllocateObjectDesc: %p Size 0x%x\n", + Object, sizeof (ACPI_OPERAND_OBJECT))); + + return_PTR (Object); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDeleteObjectDesc + * + * PARAMETERS: Object - Acpi internal object to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache + * + ****************************************************************************/ + +void +AcpiCmDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object) +{ + + FUNCTION_TRACE_PTR ("AcpiCmDeleteObjectDesc", Object); + + + /* Make sure that the object isn't already in the cache */ + + if (Object->Common.DataType == (ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT)) + { + DEBUG_PRINT (ACPI_ERROR, + ("CmDeleteObjectDesc: Obj %p is already in the object cache\n", + Object)); + return_VOID; + } + + /* Object must be an ACPI_OPERAND_OBJECT */ + + if (Object->Common.DataType != ACPI_DESC_TYPE_INTERNAL) + { + DEBUG_PRINT (ACPI_ERROR, + ("CmDeleteObjectDesc: Obj %p is not an ACPI object\n", Object)); + return_VOID; + } + + + /* If cache is full, just free this object */ + + if (AcpiGbl_ObjectCacheDepth >= MAX_OBJECT_CACHE_DEPTH) + { + /* + * Memory allocation metrics. Call the macro here since we only + * care about dynamically allocated objects. + */ + DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); + + AcpiCmFree (Object); + return_VOID; + } + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + /* Clear the entire object. This is important! */ + + MEMSET (Object, 0, sizeof (ACPI_OPERAND_OBJECT)); + Object->Common.DataType = ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT; + + /* Put the object at the head of the global cache list */ + + Object->Cache.Next = AcpiGbl_ObjectCache; + AcpiGbl_ObjectCache = Object; + AcpiGbl_ObjectCacheDepth++; + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmDeleteObjectCache + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge the global state object cache. Used during subsystem + * termination. + * + ******************************************************************************/ + +void +AcpiCmDeleteObjectCache ( + void) +{ + ACPI_OPERAND_OBJECT *Next; + + + FUNCTION_TRACE ("CmDeleteObjectCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_ObjectCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ObjectCache->Cache.Next; + AcpiGbl_ObjectCache->Cache.Next = NULL; + + /* + * Memory allocation metrics. Call the macro here since we only + * care about dynamically allocated objects. + */ + DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); + + AcpiCmFree (AcpiGbl_ObjectCache); + AcpiGbl_ObjectCache = Next; + AcpiGbl_ObjectCacheDepth--; + } + + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmInitStaticObject + * + * PARAMETERS: ObjDesc - Pointer to a "static" object - on stack + * or in the data segment. + * + * RETURN: None. + * + * DESCRIPTION: Initialize a static object. Sets flags to disallow dynamic + * deletion of the object. + * + ****************************************************************************/ + +void +AcpiCmInitStaticObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + FUNCTION_TRACE_PTR ("CmInitStaticObject", ObjDesc); + + + if (!ObjDesc) + { + return_VOID; + } + + + /* + * Clear the entire descriptor + */ + MEMSET ((void *) ObjDesc, 0, sizeof (ACPI_OPERAND_OBJECT)); + + + /* + * Initialize the header fields + * 1) This is an ACPI_OPERAND_OBJECT descriptor + * 2) The size is the full object (worst case) + * 3) The flags field indicates static allocation + * 4) Reference count starts at one (not really necessary since the + * object can't be deleted, but keeps everything sane) + */ + + ObjDesc->Common.DataType = ACPI_DESC_TYPE_INTERNAL; + ObjDesc->Common.Flags = AOPOBJ_STATIC_ALLOCATION; + ObjDesc->Common.ReferenceCount = 1; + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmGetSimpleObjectSize + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *RetLength - Where the length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to determine the space required to + * contain a simple object for return to an API user. + * + * The length includes the object structure plus any additional + * needed space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT32 *ObjLength) +{ + UINT32 Length; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObj); + + + /* Handle a null object (Could be a uninitialized package element -- which is legal) */ + + if (!InternalObj) + { + *ObjLength = 0; + return_ACPI_STATUS (AE_OK); + } + + + /* Start with the length of the Acpi object */ + + Length = sizeof (ACPI_OBJECT); + + if (VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_NAMED)) + { + /* Object is a named object (reference), just return the length */ + + *ObjLength = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (Status); + } + + + /* + * The final length depends on the object type + * Strings and Buffers are packed right up against the parent object and + * must be accessed bytewise or there may be alignment problems. + * + * TBD:[Investigate] do strings and buffers require alignment also? + */ + + switch (InternalObj->Common.Type) + { + + case ACPI_TYPE_STRING: + + Length += InternalObj->String.Length; + break; + + + case ACPI_TYPE_BUFFER: + + Length += InternalObj->Buffer.Length; + break; + + + case ACPI_TYPE_NUMBER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + + /* + * No extra data for these types + */ + break; + + + case INTERNAL_TYPE_REFERENCE: + + /* + * The only type that should be here is opcode AML_NAMEPATH_OP -- since + * this means an object reference + */ + if (InternalObj->Reference.OpCode != AML_NAMEPATH_OP) + { + DEBUG_PRINT (ACPI_ERROR, + ("CmGetSimpleObjectSize: Unsupported Reference opcode=0x%X in object %p\n", + InternalObj->Reference.OpCode, InternalObj)); + Status = AE_TYPE; + } + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("CmGetSimpleObjectSize: Unsupported type=0x%X in object %p\n", + InternalObj->Common.Type, InternalObj)); + 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 = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmGetPackageObjectSize + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *RetLength - Where the length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to determine the space required to contain + * a package object for return to an API user. + * + * This is moderately complex since a package contains other objects + * including packages. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT32 *ObjLength) +{ + + ACPI_OPERAND_OBJECT *ThisInternalObj; + ACPI_OPERAND_OBJECT *ParentObj[MAX_PACKAGE_DEPTH] = { 0,0,0,0,0 }; + ACPI_OPERAND_OBJECT *ThisParent; + UINT32 ThisIndex; + UINT32 Index[MAX_PACKAGE_DEPTH] = { 0,0,0,0,0 }; + UINT32 Length = 0; + UINT32 ObjectSpace; + UINT32 CurrentDepth = 0; + UINT32 PackageCount = 1; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObj); + + + ParentObj[0] = InternalObj; + + while (1) + { + ThisParent = ParentObj[CurrentDepth]; + ThisIndex = Index[CurrentDepth]; + ThisInternalObj = ThisParent->Package.Elements[ThisIndex]; + + + /* + * Check for 1) An uninitialized package element. It is completely + * legal to declare a package and leave it uninitialized + * 2) Any type other than a package. Packages are handled + * below. + */ + + if ((!ThisInternalObj) || + (!IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE))) + { + /* + * Simple object - just get the size (Null object/entry handled + * also) + */ + + Status = + AcpiCmGetSimpleObjectSize (ThisInternalObj, &ObjectSpace); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length += ObjectSpace; + + Index[CurrentDepth]++; + while (Index[CurrentDepth] >= + ParentObj[CurrentDepth]->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. + */ + if (CurrentDepth == 0) + { + /* + * We have handled all of the objects + * in the top level package just add the + * length of the package objects and + * get out. Round up to the next machine + * word. + */ + Length += + ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)) * + PackageCount; + + *ObjLength = Length; + + return_ACPI_STATUS (AE_OK); + } + + /* + * Go back up a level and move the index + * past the just completed package object. + */ + CurrentDepth--; + Index[CurrentDepth]++; + } + } + + else + { + /* + * This object is a package + * -- go one level deeper + */ + PackageCount++; + if (CurrentDepth < MAX_PACKAGE_DEPTH-1) + { + CurrentDepth++; + ParentObj[CurrentDepth] = ThisInternalObj; + Index[CurrentDepth] = 0; + } + + else + { + /* + * Too many nested levels of packages for us + * to handle + */ + + DEBUG_PRINT (ACPI_ERROR, + ("CmGetPackageObjectSize: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + } + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmGetObjectSize + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *RetLength - Where the length will be returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to determine the space required to + * contain an object for return to an API user. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetObjectSize( + ACPI_OPERAND_OBJECT *InternalObj, + UINT32 *ObjLength) +{ + ACPI_STATUS Status; + + + if ((VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_INTERNAL)) && + (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE))) + { + Status = + AcpiCmGetPackageObjectSize (InternalObj, ObjLength); + } + + else + { + Status = + AcpiCmGetSimpleObjectSize (InternalObj, ObjLength); + } + + return (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c b/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c new file mode 100644 index 0000000..64e08ba --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c @@ -0,0 +1,915 @@ +/******************************************************************************* + * + * Module Name: cmutils - common utility procedures + * $Revision: 21 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMUTILS_C__ + +#include "acpi.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acdebug.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiCmValidAcpiName + * + * PARAMETERS: Character - The character to be examined + * + * RETURN: 1 if Character may appear in a name, else 0 + * + * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + ******************************************************************************/ + +BOOLEAN +AcpiCmValidAcpiName ( + UINT32 Name) +{ + NATIVE_CHAR *NamePtr = (NATIVE_CHAR *) &Name; + UINT32 i; + + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!((NamePtr[i] == '_') || + (NamePtr[i] >= 'A' && NamePtr[i] <= 'Z') || + (NamePtr[i] >= '0' && NamePtr[i] <= '9'))) + { + return (FALSE); + } + } + + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmValidAcpiCharacter + * + * PARAMETERS: Character - The character to be examined + * + * RETURN: 1 if Character may appear in a name, else 0 + * + * DESCRIPTION: Check for a printable character + * + ******************************************************************************/ + +BOOLEAN +AcpiCmValidAcpiCharacter ( + NATIVE_CHAR Character) +{ + + return ((BOOLEAN) ((Character == '_') || + (Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9'))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmMutexInitialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmMutexInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmMutexInitialize"); + + + /* + * Create each of the predefined mutex objects + */ + for (i = 0; i < NUM_MTX; i++) + { + Status = AcpiCmCreateMutex (i); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmMutexTerminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. + * + ******************************************************************************/ + +void +AcpiCmMutexTerminate ( + void) +{ + UINT32 i; + + + FUNCTION_TRACE ("CmMutexTerminate"); + + + /* + * Delete each predefined mutex object + */ + for (i = 0; i < NUM_MTX; i++) + { + AcpiCmDeleteMutex (i); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateMutex + * + * PARAMETERS: MutexID - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCreateMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_U32 ("CmCreateMutex", MutexId); + + + if (MutexId > MAX_MTX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + if (!AcpiGbl_AcpiMutexInfo[MutexId].Mutex) + { + Status = AcpiOsCreateSemaphore (1, 1, + &AcpiGbl_AcpiMutexInfo[MutexId].Mutex); + AcpiGbl_AcpiMutexInfo[MutexId].Locked = FALSE; + AcpiGbl_AcpiMutexInfo[MutexId].UseCount = 0; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteMutex + * + * PARAMETERS: MutexID - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE_U32 ("CmDeleteMutex", MutexId); + + + if (MutexId > MAX_MTX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + Status = AcpiOsDeleteSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex); + + AcpiGbl_AcpiMutexInfo[MutexId].Mutex = NULL; + AcpiGbl_AcpiMutexInfo[MutexId].Locked = FALSE; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmAcquireMutex + * + * PARAMETERS: MutexID - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + + + DEBUG_PRINT (TRACE_MUTEX, + ("Acquiring Mutex [%s]\n", AcpiCmGetMutexName (MutexId))); + + if (MutexId > MAX_MTX) + { + return (AE_BAD_PARAMETER); + } + + + Status = AcpiOsWaitSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex, + 1, WAIT_FOREVER); + + DEBUG_PRINT (TRACE_MUTEX, ("Acquired Mutex [%s] Status %s\n", + AcpiCmGetMutexName (MutexId), AcpiCmFormatException (Status))); + + if (ACPI_SUCCESS (Status)) + { + AcpiGbl_AcpiMutexInfo[MutexId].Locked = TRUE; + AcpiGbl_AcpiMutexInfo[MutexId].UseCount++; + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmReleaseMutex + * + * PARAMETERS: MutexID - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + + + DEBUG_PRINT (TRACE_MUTEX, + ("Releasing Mutex [%s]\n", AcpiCmGetMutexName (MutexId))); + + if (MutexId > MAX_MTX) + { + return (AE_BAD_PARAMETER); + } + + + AcpiGbl_AcpiMutexInfo[MutexId].Locked = FALSE; /* Mark before unlocking */ + + Status = AcpiOsSignalSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex, 1); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("Error Releasing Mutex [%s], %s\n", + AcpiCmGetMutexName (MutexId), AcpiCmFormatException (Status))); + } + else + { + DEBUG_PRINT (TRACE_MUTEX, ("Released Mutex [%s], %s\n", + AcpiCmGetMutexName (MutexId), AcpiCmFormatException (Status))); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateUpdateStateAndPush + * + * PARAMETERS: *Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: None + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + /* Ignore null objects; these are expected */ + + if (!Object) + { + return (AE_OK); + } + + State = AcpiCmCreateUpdateState (Object, Action); + if (!State) + { + return (AE_NO_MEMORY); + } + + + AcpiCmPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmPushGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * State - State object to push + * + * RETURN: Status + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +AcpiCmPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State) +{ + FUNCTION_TRACE ("CmPushGenericState"); + + /* Push the state object onto the front of the list (stack) */ + + State->Common.Next = *ListHead; + *ListHead = State; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmPopGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * + * RETURN: Status + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmPopGenericState ( + ACPI_GENERIC_STATE **ListHead) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE ("DsPopGenericState"); + + + /* 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: AcpiCmCreateGenericState + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreateGenericState (void) +{ + ACPI_GENERIC_STATE *State; + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + AcpiGbl_StateCacheRequests++; + + /* Check the cache first */ + + if (AcpiGbl_GenericStateCache) + { + /* There is an object available, use it */ + + State = AcpiGbl_GenericStateCache; + AcpiGbl_GenericStateCache = State->Common.Next; + State->Common.Next = NULL; + + AcpiGbl_StateCacheHits++; + AcpiGbl_GenericStateCacheDepth--; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + DEBUG_PRINT (TRACE_EXEC, ("CreateGenState: State %p from cache\n", State)); + } + + else + { + /* The cache is empty, create a new object */ + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + State = AcpiCmCallocate (sizeof (ACPI_GENERIC_STATE)); + } + + /* Initialize */ + + if (State) + { + /* Always zero out the object before init */ + + MEMSET (State, 0, sizeof (ACPI_GENERIC_STATE)); + + State->Common.DataType = ACPI_DESC_TYPE_STATE; + } + + return (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateUpdateState + * + * PARAMETERS: Object - Initial Object to be installed in the + * state + * Action - Update action to be performed + * + * RETURN: Status + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE_PTR ("CmCreateUpdateState", Object); + + + /* Create the generic state object */ + + State = AcpiCmCreateGenericState (); + if (!State) + { + return (NULL); + } + + /* Init fields specific to the update struct */ + + State->Update.Object = Object; + State->Update.Value = Action; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateControlState + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreateControlState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE ("CmCreateControlState"); + + /* Create the generic state object */ + + State = AcpiCmCreateGenericState (); + if (!State) + { + return (NULL); + } + + + /* Init fields specific to the control struct */ + + State->Common.State = CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteGenericState + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Put a state object back into the global state cache. The object + * is not actually freed at this time. + * + ******************************************************************************/ + +void +AcpiCmDeleteGenericState ( + ACPI_GENERIC_STATE *State) +{ + FUNCTION_TRACE ("CmDeleteGenericState"); + + + /* If cache is full, just free this state object */ + + if (AcpiGbl_GenericStateCacheDepth >= MAX_STATE_CACHE_DEPTH) + { + AcpiCmFree (State); + } + + /* Otherwise put this object back into the cache */ + + else + { + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + /* Clear the state */ + + MEMSET (State, 0, sizeof (ACPI_GENERIC_STATE)); + State->Common.DataType = ACPI_DESC_TYPE_STATE; + + /* Put the object at the head of the global cache list */ + + State->Common.Next = AcpiGbl_GenericStateCache; + AcpiGbl_GenericStateCache = State; + AcpiGbl_GenericStateCacheDepth++; + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteGenericStateCache + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge the global state object cache. Used during subsystem + * termination. + * + ******************************************************************************/ + +void +AcpiCmDeleteGenericStateCache ( + void) +{ + ACPI_GENERIC_STATE *Next; + + + FUNCTION_TRACE ("CmDeleteGenericStateCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_GenericStateCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_GenericStateCache->Common.Next; + AcpiCmFree (AcpiGbl_GenericStateCache); + AcpiGbl_GenericStateCache = Next; + AcpiGbl_GenericStateCacheDepth--; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmResolvePackageReferences + * + * PARAMETERS: ObjDesc - The Package object on which to resolve refs + * + * RETURN: Status + * + * DESCRIPTION: Walk through a package and turn internal references into values + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmResolvePackageReferences ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + UINT32 Count; + ACPI_OPERAND_OBJECT *SubObject; + + FUNCTION_TRACE ("AcpiCmResolvePackageReferences"); + + if (ObjDesc->Common.Type != ACPI_TYPE_PACKAGE) + { + /* Must be a package */ + + REPORT_ERROR (("Must resolve Package Refs on a Package\n")); + return_ACPI_STATUS(AE_ERROR); + } + + for (Count = 0; Count < ObjDesc->Package.Count; Count++) + { + SubObject = ObjDesc->Package.Elements[Count]; + + if (SubObject->Common.Type == INTERNAL_TYPE_REFERENCE) + { + if (SubObject->Reference.OpCode == AML_ZERO_OP) + { + SubObject->Common.Type = ACPI_TYPE_NUMBER; + SubObject->Number.Value = 0; + } + else if (SubObject->Reference.OpCode == AML_ONE_OP) + { + SubObject->Common.Type = ACPI_TYPE_NUMBER; + SubObject->Number.Value = 1; + } + else if (SubObject->Reference.OpCode == AML_ONES_OP) + { + SubObject->Common.Type = ACPI_TYPE_NUMBER; + SubObject->Number.Value = ACPI_INTEGER_MAX; + } + } + } + + return_ACPI_STATUS(AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: _ReportError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: None + * + * DESCRIPTION: Print error message from KD table + * + ******************************************************************************/ + +void +_ReportError ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + + + AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber); +} + + +/******************************************************************************* + * + * FUNCTION: _ReportWarning + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: None + * + * DESCRIPTION: Print warning message from KD table + * + ******************************************************************************/ + +void +_ReportWarning ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + + AcpiOsPrintf ("%8s-%04d: *** Warning: ", ModuleName, LineNumber); +} + + +/******************************************************************************* + * + * FUNCTION: _ReportInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: None + * + * DESCRIPTION: Print information message from KD table + * + ******************************************************************************/ + +void +_ReportInfo ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + + AcpiOsPrintf ("%8s-%04d: *** Info: ", ModuleName, LineNumber); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c b/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c new file mode 100644 index 0000000..3e8e8d7 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c @@ -0,0 +1,529 @@ +/****************************************************************************** + * + * Module Name: cmxface - External interfaces for "global" ACPI functions + * $Revision: 51 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMXFACE_C__ + +#include "acpi.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acdebug.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmxface") + + +/******************************************************************************* + * + * 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; + + + FUNCTION_TRACE ("AcpiInitializeSubsystem"); + + DEBUG_PRINT_RAW (ACPI_OK, + ("ACPI Subsystem version [%s]\n", ACPI_CA_VERSION)); + DEBUG_PRINT (ACPI_INFO, ("Initializing ACPI Subsystem...\n")); + + + /* Initialize all globals used by the subsystem */ + + AcpiCmInitGlobals (); + + /* Initialize the OS-Dependent layer */ + + Status = AcpiOsInitialize (); + if (ACPI_FAILURE (Status)) + { + REPORT_ERROR (("OSD failed to initialize, %s\n", + AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); + } + + /* Create the default mutex objects */ + + Status = AcpiCmMutexInitialize (); + if (ACPI_FAILURE (Status)) + { + REPORT_ERROR (("Global mutex creation failure, %s\n", + AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); + } + + /* + * Initialize the namespace manager and + * the root of the namespace tree + */ + + Status = AcpiNsRootInitialize (); + if (ACPI_FAILURE (Status)) + { + REPORT_ERROR (("Namespace initialization failure, %s\n", + AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); + } + + + /* If configured, initialize the AML debugger */ + + DEBUGGER_EXEC (AcpiDbInitialize ()); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableSubsystem + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes the subsystem initialization including hardware. + * Puts system into ACPI mode if it isn't already. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiEnableSubsystem"); + + + /* Sanity check the FACP for valid values */ + + Status = AcpiCmValidateFacp (); + if (ACPI_FAILURE (Status)) + { + 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)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Installing default address space handlers\n")); + + Status = AcpiEvInstallDefaultAddressSpaceHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * We must initialize the hardware before we can enable ACPI. + */ + + if (!(Flags & ACPI_NO_HARDWARE_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI hardware\n")); + + Status = AcpiHwInitialize (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Enable ACPI on this platform + */ + + if (!(Flags & ACPI_NO_ACPI_ENABLE)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Going into ACPI mode\n")); + + AcpiEnable (); + } + + /* + * Note: + * We must have the hardware AND events initialized before we can execute + * ANY control methods SAFELY. Any control method can require ACPI hardware + * support, so the hardware MUST be initialized before execution! + */ + + if (!(Flags & ACPI_NO_EVENT_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI events\n")); + + Status = AcpiEvInitialize (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + /* + * Initialize all device objects in the namespace + * This runs the _STA, _INI, and _HID methods, and detects + * the PCI root bus(es) + */ + + if (!(Flags & ACPI_NO_DEVICE_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI Devices\n")); + + Status = AcpiNsInitializeDevices (Flags & ACPI_NO_PCI_INIT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + /* + * Initialize the objects that remain unitialized. This + * runs the executable AML that is part of the declaration of OpRegions + * and Fields. + */ + + if (!(Flags & ACPI_NO_OBJECT_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI Objects\n")); + + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTerminate + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTerminate (void) +{ + + FUNCTION_TRACE ("AcpiTerminate"); + + /* Terminate the AML Debuger if present */ + + AcpiGbl_DbTerminateThreads = TRUE; + + /* TBD: [Investigate] This is no longer needed?*/ +/* AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); */ + + + /* Shutdown and free all resources */ + + AcpiCmSubsystemShutdown (); + + + /* Free the mutex objects */ + + AcpiCmMutexTerminate (); + + + /* Now we can shutdown the OS-dependent layer */ + + AcpiOsTerminate (); + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetSystemInfo + * + * PARAMETERS: OutBuffer - a pointer to a buffer to receive the + * resources for the device + * BufferLength - the number of bytes available in the buffer + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get information about the current + * state of the ACPI subsystem. It will return system information + * in the OutBuffer. + * + * If the function fails an appropriate status will be returned + * and the value of OutBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *OutBuffer) +{ + ACPI_SYSTEM_INFO *InfoPtr; + UINT32 i; + + + FUNCTION_TRACE ("AcpiGetSystemInfo"); + + + /* + * Must have a valid buffer + */ + if ((!OutBuffer) || + (!OutBuffer->Pointer)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (OutBuffer->Length < sizeof (ACPI_SYSTEM_INFO)) + { + /* + * Caller's buffer is too small + */ + OutBuffer->Length = sizeof (ACPI_SYSTEM_INFO); + + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + + /* + * Set return length and get data + */ + OutBuffer->Length = sizeof (ACPI_SYSTEM_INFO); + InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; + + /* TBD [Future]: need a version number, or use the version string */ + InfoPtr->AcpiCaVersion = 0x1234; + + /* System flags (ACPI capabilities) */ + + InfoPtr->Flags = AcpiGbl_SystemFlags; + + /* Timer resolution - 24 or 32 bits */ + + InfoPtr->TimerResolution = AcpiHwPmtResolution (); + + /* Clear the reserved fields */ + + InfoPtr->Reserved1 = 0; + InfoPtr->Reserved2 = 0; + + /* Current debug levels */ + + InfoPtr->DebugLayer = AcpiDbgLayer; + InfoPtr->DebugLevel = AcpiDbgLevel; + + /* Current status of the ACPI tables, per table type */ + + InfoPtr->NumTableTypes = NUM_ACPI_TABLES; + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + InfoPtr->TableInfo[i].Count = AcpiGbl_AcpiTables[i].Count; + } + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiFormatException + * + * PARAMETERS: OutBuffer - a pointer to a buffer to receive the + * exception name + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function translates an ACPI exception into an ASCII string. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiFormatException ( + ACPI_STATUS Exception, + ACPI_BUFFER *OutBuffer) +{ + UINT32 Length; + NATIVE_CHAR *FormattedException; + + + FUNCTION_TRACE ("AcpiFormatException"); + + + /* + * Must have a valid buffer + */ + if ((!OutBuffer) || + (!OutBuffer->Pointer)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Convert the exception code (Handles bad exception codes) */ + + FormattedException = AcpiCmFormatException (Exception); + + /* + * Get length of string and check if it will fit in caller's buffer + */ + + Length = STRLEN (FormattedException); + if (OutBuffer->Length < Length) + { + OutBuffer->Length = Length; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + + /* Copy the string, all done */ + + STRCPY (OutBuffer->Pointer, FormattedException); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c new file mode 100644 index 0000000..bd357df --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbcmds.c @@ -0,0 +1,997 @@ +/******************************************************************************* + * + * Module Name: dbcmds - debug commands and output routines + * $Revision: 41 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbcmds") + + +/* + * Arguments for the Objects command + * These object types map directly to the ACPI_TYPES + */ + +ARGUMENT_INFO AcpiDbObjectTypes [] = +{ + {"ANY"}, + {"NUMBERS"}, + {"STRINGS"}, + {"BUFFERS"}, + {"PACKAGES"}, + {"FIELDS"}, + {"DEVICES"}, + {"EVENTS"}, + {"METHODS"}, + {"MUTEXES"}, + {"REGIONS"}, + {"POWERRESOURCES"}, + {"PROCESSORS"}, + {"THERMALZONES"}, + {"BUFFERFIELDS"}, + {"DDBHANDLES"}, + {NULL} /* Must be null terminated */ +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForReferences + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Check if this namespace object refers to the target object + * that is passed in as the context value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkForReferences ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + + + /* Check for match against the namespace node itself */ + + if (Node == (void *) ObjDesc) + { + AcpiOsPrintf ("Object is a Node [%4.4s]\n", &Node->Name); + } + + /* Check for match against the object attached to the node */ + + if (Node->Object == ObjDesc) + { + AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, &Node->Name); + } + + /* Check first child for a match */ + /* TBD: [Investigate] probably now obsolete with new datastructure */ + + if (Node->Child == (void *) ObjDesc) + { + AcpiOsPrintf ("Reference at Node->Child %p [%4.4s]\n", Node, &Node->Name); + } + + 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 ( + NATIVE_CHAR *ObjectArg) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + /* Convert string to object pointer */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); + + /* Search all nodes in namespace */ + + AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForReferences, (void *) ObjDesc, NULL); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *TableArg) +{ + UINT32 i; + + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + if (AcpiGbl_AcpiTables[i].Pointer) + { + AcpiOsPrintf ("%s at 0x%p length 0x%X\n", AcpiGbl_AcpiTableData[i].Name, + AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbUnloadAcpiTable + * + * PARAMETERS: TableArg - Name of the table to be unloaded + * InstanceArg - Which instance of the table to unload (if + * there are multiple tables of the same type) + * + * RETURN: Nonde + * + * DESCRIPTION: Unload an ACPI table. + * Instance is not implemented + * + ******************************************************************************/ + +void +AcpiDbUnloadAcpiTable ( + NATIVE_CHAR *TableArg, + NATIVE_CHAR *InstanceArg) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Search all tables for the target type */ + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + if (!STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature, AcpiGbl_AcpiTableData[i].SigLength)) + { + /* Found the table, unload it */ + + Status = AcpiUnloadTable (i); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); + } + else + { + AcpiOsPrintf ("%s, while unloading [%s]\n", AcpiCmFormatException (Status), TableArg); + } + + return; + } + } + + AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodBreakpoint + * + * PARAMETERS: Location - AML offset of breakpoint + * WalkState - Current walk info + * Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Set a breakpoint in a control method at the specified + * AML offset + * + ******************************************************************************/ + +void +AcpiDbSetMethodBreakpoint ( + NATIVE_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 = STRTOUL (Location, NULL, 16); + if (Address <= Op->AmlOffset) + { + AcpiOsPrintf ("Breakpoint 0x%X is beyond current address 0x%X\n", Address, Op->AmlOffset); + } + + /* Save breakpoint in current walk */ + + WalkState->MethodBreakpoint = Address; + AcpiOsPrintf ("Breakpoint set at AML offset 0x%X\n", Address); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodCallBreakpoint + * + * PARAMETERS: Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Set a breakpoint in a control method at the specified + * AML offset + * + ******************************************************************************/ + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op) +{ + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + + AcpiGbl_StepToNextCall = TRUE; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisassembleAml + * + * PARAMETERS: Statements - Number of statements to disassemble + * Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number + * of statements specified. + * + ******************************************************************************/ + +void +AcpiDbDisassembleAml ( + NATIVE_CHAR *Statements, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 NumStatements = 8; + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + if (Statements) + { + NumStatements = STRTOUL (Statements, NULL, 0); + } + + + AcpiDbDisplayOp (NULL, Op, NumStatements); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *StartArg, + NATIVE_CHAR *DepthArg) +{ + ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; + UINT32 MaxDepth = ACPI_UINT32_MAX; + + + /* No argument given, just start at the root and dump entire namespace */ + + if (StartArg) + { + /* Check if numeric argument, must be a Node */ + + if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) + { + SubtreeEntry = (ACPI_HANDLE) STRTOUL (StartArg, NULL, 16); + if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); + return; + } + + if (!VALID_DESCRIPTOR_TYPE ((SubtreeEntry), ACPI_DESC_TYPE_NAMED)) + { + AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry); + return; + } + } + + /* Alpha argument */ + + else + { + /* The parameter is a name string that must be resolved to a Named obj*/ + + SubtreeEntry = AcpiDbLocalNsLookup (StartArg); + if (!SubtreeEntry) + { + SubtreeEntry = AcpiGbl_RootNode; + } + } + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = STRTOUL (DepthArg, NULL, 0); + } + } + + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); + AcpiDbSetOutputDestination (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 ( + NATIVE_CHAR *OwnerArg, + NATIVE_CHAR *DepthArg) +{ + ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; + UINT32 MaxDepth = ACPI_UINT32_MAX; + UINT16 OwnerId; + + + OwnerId = (UINT16) STRTOUL (OwnerArg, NULL, 0); + + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = STRTOUL (DepthArg, NULL, 0); + } + + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace by owner 0x%X:\n", OwnerId); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, OwnerId, SubtreeEntry); + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSendNotify + * + * PARAMETERS: Name - Name of ACPI object to send the notify to + * Value - Value of the notify to send. + * + * RETURN: None + * + * DESCRIPTION: Send an ACPI notification. The value specified is sent to the + * named object as an ACPI notify. + * + ******************************************************************************/ + +void +AcpiDbSendNotify ( + NATIVE_CHAR *Name, + UINT32 Value) +{ + ACPI_NAMESPACE_NODE *Node; + + + /* Translate name to an Named object */ + + Node = AcpiDbLocalNsLookup (Name); + if (!Node) + { + return; + } + + /* Decode Named object type */ + + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + /* Send the notify */ + + AcpiEvNotifyDispatch (Node, Value); + break; + + default: + AcpiOsPrintf ("Named object is not a device or a thermal object\n"); + break; + } + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodData + * + * PARAMETERS: TypeArg - L for local, A for argument + * IndexArg - which one + * ValueArg - Value to set. + * + * RETURN: None + * + * DESCRIPTION: Set a local or argument for the running control method. + * NOTE: only object supported is Number. + * + ******************************************************************************/ + +void +AcpiDbSetMethodData ( + NATIVE_CHAR *TypeArg, + NATIVE_CHAR *IndexArg, + NATIVE_CHAR *ValueArg) +{ + NATIVE_CHAR Type; + UINT32 Index; + UINT32 Value; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + + + /* Validate TypeArg */ + + STRUPR (TypeArg); + Type = TypeArg[0]; + if ((Type != 'L') && + (Type != 'A')) + { + AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); + return; + } + + /* Get the index and value */ + + Index = STRTOUL (IndexArg, NULL, 16); + Value = STRTOUL (ValueArg, NULL, 16); + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + + /* Create and initialize the new object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + AcpiOsPrintf ("Could not create an internal object\n"); + return; + } + + ObjDesc->Number.Value = Value; + + + /* Store the new object into the target */ + + switch (Type) + { + case 'A': + + /* Set a method argument */ + + if (Index > MTH_NUM_ARGS) + { + AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); + return; + } + + AcpiDsMethodDataSetValue (MTH_TYPE_ARG, Index, ObjDesc, WalkState); + ObjDesc = WalkState->Arguments[Index].Object; + + AcpiOsPrintf ("Arg%d: ", Index); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + break; + + case 'L': + + /* Set a method local */ + + if (Index > MTH_NUM_LOCALS) + { + AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); + return; + } + + AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, Index, ObjDesc, WalkState); + ObjDesc = WalkState->LocalVariables[Index].Object; + + AcpiOsPrintf ("Local%d: ", Index); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForSpecificObjects + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display short info about objects in the namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkForSpecificObjects ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + UINT32 BufSize; + NATIVE_CHAR buffer[64]; + + + ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; + + /* Get and display the full pathname to this object */ + + Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, buffer); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + return (AE_OK); + } + + AcpiOsPrintf ("%32s", buffer); + + + /* Display short information about the object */ + + if (ObjDesc) + { + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_METHOD: + AcpiOsPrintf (" #Args %d Concurrency %d", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); + break; + + case ACPI_TYPE_NUMBER: + AcpiOsPrintf (" Value 0x%X", ObjDesc->Number.Value); + break; + + case ACPI_TYPE_STRING: + AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); + break; + + case ACPI_TYPE_REGION: + AcpiOsPrintf (" SpaceId %d Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length); + break; + + case ACPI_TYPE_PACKAGE: + AcpiOsPrintf (" #Elements %d", ObjDesc->Package.Count); + break; + + case ACPI_TYPE_BUFFER: + AcpiOsPrintf (" Length %d", ObjDesc->Buffer.Length); + break; + } + } + + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayObjects + * + * PARAMETERS: ObjTypeArg - Type of object to display + * DisplayCountArg - Max depth to display + * + * RETURN: None + * + * DESCRIPTION: Display objects in the namespace of the requested type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisplayObjects ( + NATIVE_CHAR *ObjTypeArg, + NATIVE_CHAR *DisplayCountArg) +{ + UINT32 DisplayCount; + OBJECT_TYPE_INTERNAL Type; + + + /* Get the object type */ + + STRUPR (ObjTypeArg); + Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); + if (Type == ACPI_TYPE_NOT_FOUND) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return (AE_OK); + } + + /* Get the display depth */ + + if (DisplayCountArg) + { + DisplayCount = STRTOUL (DisplayCountArg, NULL, 0); + } + + else + { + DisplayCount = ACPI_UINT32_MAX; + } + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiCmGetTypeName (Type)); + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + + /* Walk the namespace from the root */ + + AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkAndMatchName + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Find a particular name/names within the namespace. Wildcards + * are supported -- '?' matches any character. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkAndMatchName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + NATIVE_CHAR *RequestedName = (NATIVE_CHAR *) Context; + UINT32 i; + UINT32 BufSize; + NATIVE_CHAR Buffer[96]; + + + ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; + + + /* Check for a name match */ + + for (i = 0; i < 4; i++) + { + /* Wildcard support */ + + if ((RequestedName[i] != '?') && + (RequestedName[i] != ((NATIVE_CHAR *) (&((ACPI_NAMESPACE_NODE *) ObjHandle)->Name))[i])) + { + /* No match, just exit */ + + return (AE_OK); + } + } + + + /* Get the full pathname to this object */ + + BufSize = sizeof (Buffer); + + Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + } + + else + { + AcpiOsPrintf ("%32s (0x%p) - %s\n", Buffer, ObjHandle, + AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); + } + + 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 ( + NATIVE_CHAR *NameArg) +{ + + if (STRLEN (NameArg) > 4) + { + AcpiOsPrintf ("Name must be no longer than 4 characters\n"); + return (AE_OK); + } + + /* Walk the namespace from the root */ + + AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkAndMatchName, NameArg, NULL); + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetScope + * + * PARAMETERS: Name - New scope path + * + * RETURN: Status + * + * DESCRIPTION: Set the "current scope" as maintained by this utility. + * The scope is used as a prefix to ACPI paths. + * + ******************************************************************************/ + +void +AcpiDbSetScope ( + NATIVE_CHAR *Name) +{ + + if (!Name || Name[0] == 0) + { + AcpiOsPrintf ("Current scope: %s\n", ScopeBuf); + return; + } + + AcpiDbPrepNamestring (Name); + + /* TBD: [Future] Validate scope here */ + + if (Name[0] == '\\') + { + STRCPY (ScopeBuf, Name); + STRCAT (ScopeBuf, "\\"); + } + + else + { + STRCAT (ScopeBuf, Name); + STRCAT (ScopeBuf, "\\"); + } + + AcpiOsPrintf ("New scope: %s\n", ScopeBuf); +} + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c new file mode 100644 index 0000000..4a7b32d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisasm.c @@ -0,0 +1,822 @@ +/******************************************************************************* + * + * Module Name: dbdisasm - parser op tree display routines + * $Revision: 33 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbdisasm") + + +#define MAX_SHOW_ENTRY 128 +#define BLOCK_PAREN 1 +#define BLOCK_BRACE 2 +#define DB_NO_OP_INFO " [%2.2d] " +#define DB_FULL_OP_INFO "%5.5X #%4.4X [%2.2d] " + + +NATIVE_CHAR *INDENT_STRING = "...."; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbBlockType + * + * PARAMETERS: Op - Object to be examined + * + * RETURN: Status + * + * DESCRIPTION: Type of block for this op (parens or braces) + * + ******************************************************************************/ + +UINT32 +AcpiDbBlockType ( + ACPI_PARSE_OBJECT *Op) +{ + + switch (Op->Opcode) + { + case AML_METHOD_OP: + return (BLOCK_BRACE); + break; + + default: + break; + } + + return (BLOCK_PAREN); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDisplayObjectPathname + * + * PARAMETERS: 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) + * + ******************************************************************************/ + +#ifdef PARSER_ONLY + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *TargetOp; + + + /* Search parent tree up to the root if necessary */ + + TargetOp = AcpiPsFind (Op, Op->Value.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 (" **** Path not found in parse tree"); + } + + else + { + /* The target was found, print the name and complete path */ + + AcpiOsPrintf (" (Path "); + AcpiDbDisplayPath (TargetOp); + AcpiOsPrintf (")"); + } + + return (AE_OK); +} + +#else + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + NATIVE_CHAR Buffer[MAX_SHOW_ENTRY]; + UINT32 BufferSize = MAX_SHOW_ENTRY; + + + AcpiOsPrintf (" (Path "); + + /* Just get the Node out of the Op object */ + + Node = Op->Node; + if (!Node) + { + /* + * No Named obj, so 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. + */ + return (AE_OK); + } + + /* Convert NamedDesc/handle to a full pathname */ + + Status = AcpiNsHandleToPathname (Node, &BufferSize, Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("****Could not get pathname****)"); + return (Status); + } + + AcpiOsPrintf ("%s)", Buffer); + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayOp + * + * PARAMETERS: Origin - Starting object + * NumOpcodes - Max number of opcodes to be displayed + * + * RETURN: None + * + * DESCRIPTION: Display parser object and its children + * + ******************************************************************************/ + +void +AcpiDbDisplayOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes) +{ + ACPI_PARSE_OBJECT *Op = Origin; + ACPI_PARSE_OBJECT *arg; + ACPI_PARSE_OBJECT *depth; + UINT32 DepthCount = 0; + UINT32 LastDepth = 0; + UINT32 i; + UINT32 j; + + + if (Op) + { + while (Op) + { + /* indentation */ + + DepthCount = 0; + if (!opt_verbose) + { + DepthCount++; + } + + /* Determine the nesting depth of this argument */ + + for (depth = Op->Parent; depth; depth = depth->Parent) + { + arg = AcpiPsGetArg (depth, 0); + while (arg && arg != Origin) + { + arg = arg->Next; + } + + if (arg) + { + break; + } + + DepthCount++; + } + + + /* Open a new block if we are nested further than last time */ + + if (DepthCount > LastDepth) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth)); + for (i = 0; i < LastDepth; i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + if (AcpiDbBlockType (Op) == BLOCK_PAREN) + AcpiOsPrintf ("(\n"); + else + AcpiOsPrintf ("{\n"); + } + + /* Close a block if we are nested less than last time */ + + else if (DepthCount < LastDepth) + { + for (j = 0; j < (LastDepth - DepthCount); j++) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth - j)); + for (i = 0; i < (LastDepth - j - 1); i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + if (AcpiDbBlockType (Op) == BLOCK_PAREN) + AcpiOsPrintf (")\n"); + else + AcpiOsPrintf ("}\n"); + } + } + + /* In verbose mode, print the AML offset, opcode and depth count */ + + VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) Op->AmlOffset, Op->Opcode, DepthCount)); + + + /* Indent the output according to the depth count */ + + for (i = 0; i < DepthCount; i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + + /* Now print the opcode */ + + AcpiDbDisplayOpcode (WalkState, Op); + + /* Resolve a name reference */ + + if ((Op->Opcode == AML_NAMEPATH_OP && Op->Value.Name) && + (Op->Parent) && + (opt_verbose)) + { + AcpiPsDisplayObjectPathname (Op); + } + + AcpiOsPrintf ("\n"); + + /* Get the next node in the tree */ + + Op = AcpiPsGetDepthNext (Origin, Op); + LastDepth = DepthCount; + + NumOpcodes--; + if (!NumOpcodes) + { + Op = NULL; + } + } + + /* Close the last block(s) */ + + DepthCount = LastDepth -1; + for (i = 0; i < LastDepth; i++) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth - i)); + for (j = 0; j < DepthCount; j++) + { + AcpiOsPrintf (INDENT_STRING); + } + AcpiOsPrintf ("}\n"); + DepthCount--; + } + + } + + else + { + AcpiDbDisplayOpcode (WalkState, Op); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayNamestring + * + * PARAMETERS: Name - ACPI Name string to store + * + * RETURN: None + * + * DESCRIPTION: Display namestring. Handles prefix characters + * + ******************************************************************************/ + +void +AcpiDbDisplayNamestring ( + NATIVE_CHAR *Name) +{ + UINT32 SegCount; + BOOLEAN DoDot = FALSE; + + + if (!Name) + { + AcpiOsPrintf (""); + return; + } + + if (AcpiPsIsPrefixChar (GET8 (Name))) + { + /* append prefix character */ + + AcpiOsPrintf ("%1c", GET8 (Name)); + Name++; + } + + switch (GET8 (Name)) + { + case AML_DUAL_NAME_PREFIX: + SegCount = 2; + Name++; + break; + + case AML_MULTI_NAME_PREFIX_OP: + SegCount = (UINT32) GET8 (Name + 1); + Name += 2; + break; + + default: + SegCount = 1; + break; + } + + while (SegCount--) + { + /* append Name segment */ + + if (DoDot) + { + /* append dot */ + + AcpiOsPrintf ("."); + } + + AcpiOsPrintf ("%4.4s", Name); + DoDot = TRUE; + + Name += 4; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayPath + * + * 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 +AcpiDbDisplayPath ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Search; + UINT32 Name; + BOOLEAN DoDot = FALSE; + ACPI_PARSE_OBJECT *NamePath; + + + /* We are only interested in named objects */ + + if (!AcpiPsIsNodeOp (Op->Opcode)) + { + return; + } + + + if (AcpiPsIsCreateFieldOp (Op->Opcode)) + { + /* Field creation - check for a fully qualified namepath */ + + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + NamePath = AcpiPsGetArg (Op, 3); + } + else + { + NamePath = AcpiPsGetArg (Op, 2); + } + + if ((NamePath) && + (NamePath->Value.String) && + (NamePath->Value.String[0] == '\\')) + { + AcpiDbDisplayNamestring (NamePath->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->Parent == Prev) + { + break; + } + + /* Go up one level */ + + Search = Search->Parent; + } + + if (Prev && !AcpiPsIsFieldOp (Search->Opcode)) + { + /* below root scope, append scope name */ + + if (DoDot) + { + /* append dot */ + + AcpiOsPrintf ("."); + } + + if (AcpiPsIsCreateFieldOp (Search->Opcode)) + { + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + NamePath = AcpiPsGetArg (Op, 3); + } + else + { + NamePath = AcpiPsGetArg (Op, 2); + } + + if ((NamePath) && + (NamePath->Value.String)) + { + AcpiOsPrintf ("%4.4s", NamePath->Value.String); + } + } + + else + { + Name = AcpiPsGetName (Search); + AcpiOsPrintf ("%4.4s", &Name); + } + + DoDot = TRUE; + } + + Prev = Search; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayOpcode + * + * PARAMETERS: Op - Op that is to be printed + * + * RETURN: Status + * + * DESCRIPTION: Store printed op in a Buffer and return its length + * (or -1 if out of space) + * + * NOTE: Terse mode prints out ASL-like code. Verbose mode adds more info. + * + ******************************************************************************/ + +void +AcpiDbDisplayOpcode ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *ByteData; + UINT32 ByteCount; + UINT32 i; + ACPI_OPCODE_INFO *Opc = NULL; + UINT32 Name; + + + if (!Op) + { + AcpiOsPrintf (""); + } + + + /* op and arguments */ + + switch (Op->Opcode) + { + + case AML_BYTE_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT8) 0x%2.2X", Op->Value.Integer & ACPI_UINT8_MAX); + } + + else + { + AcpiOsPrintf ("0x%2.2X", Op->Value.Integer & ACPI_UINT8_MAX); + } + + break; + + + case AML_WORD_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT16) 0x%4.4X", Op->Value.Integer & ACPI_UINT16_MAX); + } + + else + { + AcpiOsPrintf ("0x%4.4X", Op->Value.Integer & ACPI_UINT16_MAX); + } + + break; + + + case AML_DWORD_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT32) 0x%8.8X", Op->Value.Integer); + } + + else + { + AcpiOsPrintf ("0x%8.8X", Op->Value.Integer); + } + + break; + + + case AML_STRING_OP: + + if (Op->Value.String) + { + AcpiOsPrintf ("\"%s\"", Op->Value.String); + } + + else + { + AcpiOsPrintf ("<\"NULL STRING PTR\">"); + } + + break; + + + case AML_STATICSTRING_OP: + + if (Op->Value.String) + { + AcpiOsPrintf ("\"%s\"", Op->Value.String); + } + + else + { + AcpiOsPrintf ("\"\""); + } + + break; + + + case AML_NAMEPATH_OP: + + AcpiDbDisplayNamestring (Op->Value.Name); + break; + + + case AML_NAMEDFIELD_OP: + + AcpiOsPrintf ("NamedField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_RESERVEDFIELD_OP: + + AcpiOsPrintf ("ReservedField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_ACCESSFIELD_OP: + + AcpiOsPrintf ("AccessField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_BYTELIST_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("ByteList (Length 0x%8.8X) ", Op->Value.Integer); + } + + else + { + AcpiOsPrintf ("0x%2.2X", Op->Value.Integer); + + ByteCount = Op->Value.Integer; + ByteData = ((ACPI_PARSE2_OBJECT *) Op)->Data; + + for (i = 0; i < ByteCount; i++) + { + AcpiOsPrintf (", 0x%2.2X", ByteData[i]); + } + } + + break; + + + default: + + /* Just get the opcode name and print it */ + + Opc = AcpiPsGetOpcodeInfo (Op->Opcode); + DEBUG_ONLY_MEMBERS ((AcpiOsPrintf ("%s", Opc->Name))); + + +#ifndef PARSER_ONLY + if ((Op->Opcode == AML_RETURN_VALUE_OP) && + (WalkState->NumResults)) + { + AcpiDbDecodeInternalObject (WalkState->Results [WalkState->NumResults-1]); + } +#endif + + break; + } + + + if (!Opc) + { + /* If there is another element in the list, add a comma */ + + if (Op->Next) + { + AcpiOsPrintf (","); + } + } + + + /* + * If this is a named opcode, print the associated name value + */ + + if (Op && AcpiPsIsNamedOp (Op->Opcode)) + { + Name = AcpiPsGetName (Op); + AcpiOsPrintf (" %4.4s", &Name); + + if (opt_verbose) + { + AcpiOsPrintf (" (Path \\"); + AcpiDbDisplayPath (Op); + AcpiOsPrintf (")"); + } + } +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c new file mode 100644 index 0000000..1128e57 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbdisply.c @@ -0,0 +1,904 @@ +/******************************************************************************* + * + * Module Name: dbdisply - debug display commands + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbdisply") + + +/****************************************************************************** + * + * FUNCTION: AcpiDbGetPointer + * + * PARAMETERS: Target - Pointer to string to be converted + * + * RETURN: Converted pointer + * + * DESCRIPTION: Convert an ascii pointer value to a real value + * + *****************************************************************************/ + +void * +AcpiDbGetPointer ( + void *Target) +{ + void *ObjPtr; + + +#ifdef _IA16 +#include + + /* Have to handle 16-bit pointers of the form segment:offset */ + + if (!sscanf (Target, "%p", &ObjPtr)) + { + AcpiOsPrintf ("Invalid pointer: %s\n", Target); + return (NULL); + } + +#else + + /* Simple flat pointer */ + + ObjPtr = (void *) STRTOUL (Target, NULL, 16); + +#endif + + return (ObjPtr); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpParserDescriptor + * + * PARAMETERS: Op - A parser Op descriptor + * + * RETURN: None + * + * DESCRIPTION: Display a formatted parser object + * + ******************************************************************************/ + +void +AcpiDbDumpParserDescriptor ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_OPCODE_INFO *Info; + + + Info = AcpiPsGetOpcodeInfo (Op->Opcode); + + AcpiOsPrintf ("Parser Op Descriptor:\n"); + AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Opcode); + + DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name)); + + AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Value); + AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Parent); + AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Next); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeAndDisplayObject + * + * PARAMETERS: Target - String with object to be displayed. Names + * and hex pointers are supported. + * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q) + * + * RETURN: None + * + * DESCRIPTION: Display a formatted ACPI object + * + ******************************************************************************/ + +void +AcpiDbDecodeAndDisplayObject ( + NATIVE_CHAR *Target, + NATIVE_CHAR *OutputType) +{ + void *ObjPtr; + ACPI_NAMESPACE_NODE *Node; + UINT32 Display = DB_BYTE_DISPLAY; + NATIVE_CHAR Buffer[80]; + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + UINT32 Size; + + + if (!Target) + { + return; + } + + /* Decode the output type */ + + if (OutputType) + { + STRUPR (OutputType); + if (OutputType[0] == 'W') + { + Display = DB_WORD_DISPLAY; + } + else if (OutputType[0] == 'D') + { + Display = DB_DWORD_DISPLAY; + } + else if (OutputType[0] == 'Q') + { + Display = DB_QWORD_DISPLAY; + } + } + + + RetBuf.Length = sizeof (Buffer); + RetBuf.Pointer = Buffer; + + /* Differentiate between a number and a name */ + + if ((Target[0] >= 0x30) && (Target[0] <= 0x39)) + { + ObjPtr = AcpiDbGetPointer (Target); + if (!AcpiOsReadable (ObjPtr, 16)) + { + AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr); + return; + } + + /* Decode the object type */ + + if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_NAMED)) + { + /* This is a Node */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr); + return; + } + + Node = ObjPtr; + goto DumpNte; + } + + else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_INTERNAL)) + { + /* This is an ACPI OBJECT */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) + { + AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr); + return; + } + + AcpiCmDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiAmlDumpObjectDescriptor (ObjPtr, 1); + } + + else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_PARSER)) + { + /* This is an Parser Op object */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) + { + AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr); + return; + } + + + AcpiCmDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX); + AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); + } + + else + { + Size = 16; + if (AcpiOsReadable (ObjPtr, 64)) + { + Size = 64; + } + + /* Just dump some memory */ + + AcpiCmDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); + } + + return; + } + + + /* The parameter is a name string that must be resolved to a Named obj */ + + Node = AcpiDbLocalNsLookup (Target); + if (!Node) + { + return; + } + + +DumpNte: + /* Now dump the Named obj */ + + Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not convert name to pathname\n"); + return; + } + + AcpiOsPrintf ("Object Pathname: %s\n", RetBuf.Pointer); + if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Invalid Named object at address %p\n", Node); + return; + } + + AcpiCmDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX); + AcpiAmlDumpNode (Node, 1); + + if (Node->Object) + { + AcpiOsPrintf ("\nAttached Object (0x%p):\n", Node->Object); + if (!AcpiOsReadable (Node->Object, sizeof (ACPI_OPERAND_OBJECT))) + { + AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", Node->Object); + return; + } + + AcpiCmDumpBuffer (Node->Object, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiAmlDumpObjectDescriptor (Node->Object, 1); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object. Numbers and Strings. + * + ******************************************************************************/ + +void +AcpiDbDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + if (!ObjDesc) + { + return; + } + + AcpiOsPrintf (" %9.9s ", AcpiCmGetTypeName (ObjDesc->Common.Type)); + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + AcpiOsPrintf ("0x%.8X", ObjDesc->Number.Value); + break; + + case ACPI_TYPE_STRING: + AcpiOsPrintf ("\"%.16s\"...", ObjDesc->String.Pointer); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object + * + ******************************************************************************/ + +void +AcpiDbDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + UINT8 Type; + + + AcpiOsPrintf ("%p ", ObjDesc); + + if (!ObjDesc) + { + AcpiOsPrintf ("\n"); + return; + } + + + /* Decode the object type */ + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_PARSER)) + { + AcpiOsPrintf (" "); + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + AcpiOsPrintf (" Name %4.4s Type %s", &((ACPI_NAMESPACE_NODE *)ObjDesc)->Name, + AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjDesc)->Type)); + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) + { + AcpiOsPrintf (" "); + Type = ObjDesc->Common.Type; + if (Type > INTERNAL_TYPE_MAX) + { + AcpiOsPrintf (" Type %x [Invalid Type]", Type); + return; + } + + /* Decode the ACPI object type */ + + switch (ObjDesc->Common.Type) + { + case INTERNAL_TYPE_REFERENCE: + switch (ObjDesc->Reference.OpCode) + { + case AML_ZERO_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", 0); + break; + + case AML_ONES_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", ACPI_UINT32_MAX); + break; + + case AML_ONE_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", 1); + break; + + case AML_LOCAL_OP: + AcpiOsPrintf ("[Local%d]", ObjDesc->Reference.Offset); + if (WalkState) + { + ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object; + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case AML_ARG_OP: + AcpiOsPrintf ("[Arg%d] ", ObjDesc->Reference.Offset); + if (WalkState) + { + ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object; + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case AML_DEBUG_OP: + AcpiOsPrintf ("[Debug] "); + break; + + case AML_INDEX_OP: + AcpiOsPrintf ("[Index] "); + AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); + break; + + default: + break; + + } + break; + + default: + AcpiOsPrintf (" "); + AcpiDbDecodeInternalObject (ObjDesc); + break; + } + } + + else + { + AcpiOsPrintf (" "); + } + + AcpiOsPrintf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayMethodInfo + * + * PARAMETERS: StartOp - Root of the control method parse tree + * + * RETURN: None + * + * DESCRIPTION: Display information about the current method + * + ******************************************************************************/ + +void +AcpiDbDisplayMethodInfo ( + ACPI_PARSE_OBJECT *StartOp) +{ + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *RootOp; + ACPI_PARSE_OBJECT *Op; + ACPI_OPCODE_INFO *OpInfo; + UINT32 NumOps = 0; + UINT32 NumOperands = 0; + UINT32 NumOperators = 0; + UINT32 NumRemainingOps = 0; + UINT32 NumRemainingOperands = 0; + UINT32 NumRemainingOperators = 0; + UINT32 NumArgs; + UINT32 Concurrency; + BOOLEAN CountRemaining = FALSE; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + NumArgs = ObjDesc->Method.ParamCount; + Concurrency = ObjDesc->Method.Concurrency; + + AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", &Node->Name); + AcpiOsPrintf ("%d arguments, max concurrency = %d\n", NumArgs, Concurrency); + + + RootOp = StartOp; + while (RootOp->Parent) + { + RootOp = RootOp->Parent; + } + + Op = RootOp; + + while (Op) + { + if (Op == StartOp) + { + CountRemaining = TRUE; + } + + NumOps++; + if (CountRemaining) + { + NumRemainingOps++; + } + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Bad opcode or ASCII character */ + + continue; + } + + + /* Decode the opcode */ + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + if (CountRemaining) + { + NumRemainingOperands++; + } + + NumOperands++; + break; + + default: + if (CountRemaining) + { + NumRemainingOperators++; + } + + NumOperators++; + break; + } + + + Op = AcpiPsGetDepthNext (StartOp, Op); + } + + AcpiOsPrintf ("Method contains: %d AML Opcodes - %d Operators, %d Operands\n", + NumOps, NumOperators, NumOperands); + + AcpiOsPrintf ("Remaining to execute: %d AML Opcodes - %d Operators, %d Operands\n", + NumRemainingOps, NumRemainingOperators, NumRemainingOperands); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayLocals + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all locals for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDisplayLocals (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + + AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", &Node->Name); + + for (i = 0; i < MTH_NUM_LOCALS; i++) + { + ObjDesc = WalkState->LocalVariables[i].Object; + AcpiOsPrintf ("Local%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayArguments + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all arguments for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDisplayArguments (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 NumArgs; + UINT32 Concurrency; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->MethodNode; + + NumArgs = ObjDesc->Method.ParamCount; + Concurrency = ObjDesc->Method.Concurrency; + + AcpiOsPrintf ("Method [%4.4s] has %d arguments, max concurrency = %d\n", &Node->Name, NumArgs, Concurrency); + + for (i = 0; i < NumArgs; i++) + { + ObjDesc = WalkState->Arguments[i].Object; + AcpiOsPrintf ("Arg%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResults + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display current contents of a method result stack + * + ******************************************************************************/ + +void +AcpiDbDisplayResults (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 NumResults; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->MethodNode; + NumResults = WalkState->NumResults - WalkState->CurrentResult; + + AcpiOsPrintf ("Method [%4.4s] has %d stacked result objects\n", &Node->Name, NumResults); + + for (i = WalkState->CurrentResult; i < WalkState->NumResults; i++) + { + ObjDesc = WalkState->Results[i]; + AcpiOsPrintf ("Result%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayCallingTree + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display current calling tree of nested control methods + * + ******************************************************************************/ + +void +AcpiDbDisplayCallingTree (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + AcpiOsPrintf ("Current Control Method Call Tree\n"); + + for (i = 0; WalkState; i++) + { + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + AcpiOsPrintf (" [%4.4s]\n", &Node->Name); + + WalkState = WalkState->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResultObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Display the result of an AML opcode + * + ******************************************************************************/ + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + + /* TBD: [Future] We don't always want to display the result. + * For now, only display if single stepping + * however, this output is very useful in other contexts also + */ + + if (!AcpiGbl_CmSingleStep) + { + return; + } + + AcpiOsPrintf ("ResultObj: "); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + AcpiOsPrintf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayArgumentObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Display the result of an AML opcode + * + ******************************************************************************/ + +void +AcpiDbDisplayArgumentObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + + + if (!AcpiGbl_CmSingleStep) + { + return; + } + + AcpiOsPrintf ("ArgObj: "); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); +} + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c new file mode 100644 index 0000000..af1d884 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbexec.c @@ -0,0 +1,482 @@ +/******************************************************************************* + * + * Module Name: dbexec - debugger control method execution + * $Revision: 16 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbexec") + + +typedef struct dbmethodinfo +{ + ACPI_HANDLE ThreadGate; + NATIVE_CHAR *Name; + NATIVE_CHAR **Args; + UINT32 Flags; + UINT32 NumLoops; + NATIVE_CHAR Pathname[128]; + +} DB_METHOD_INFO; + + +DB_METHOD_INFO Info; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteMethod + * + * PARAMETERS: Info - Valid info segment + * ReturnObj - Where to put return object + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbExecuteMethod ( + DB_METHOD_INFO *Info, + ACPI_BUFFER *ReturnObj) +{ + ACPI_STATUS Status; + ACPI_OBJECT_LIST ParamObjects; + ACPI_OBJECT Params[MTH_NUM_ARGS]; + UINT32 i; + + + if (OutputToFile && !AcpiDbgLevel) + { + AcpiOsPrintf ("Warning: debug output is not enabled!\n"); + } + + /* Are there arguments to the method? */ + + if (Info->Args && Info->Args[0]) + { + for (i = 0; Info->Args[i] && i < MTH_NUM_ARGS; i++) + { + Params[i].Type = ACPI_TYPE_NUMBER; + Params[i].Number.Value = STRTOUL (Info->Args[i], NULL, 16); + } + + ParamObjects.Pointer = Params; + ParamObjects.Count = i; + } + + else + { + /* Setup default parameters */ + + Params[0].Type = ACPI_TYPE_NUMBER; + Params[0].Number.Value = 0x01020304; + + Params[1].Type = ACPI_TYPE_STRING; + Params[1].String.Length = 12; + Params[1].String.Pointer = "AML Debugger"; + + ParamObjects.Pointer = Params; + ParamObjects.Count = 2; + } + + /* Prepare for a return object of arbitrary size */ + + ReturnObj->Pointer = Buffer; + ReturnObj->Length = BUFFER_SIZE; + + + /* Do the actual method execution */ + + Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj); + + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_MethodExecuting = FALSE; + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteSetup + * + * PARAMETERS: Info - Valid method info + * + * RETURN: Status + * + * DESCRIPTION: Setup info segment prior to method execution + * + ******************************************************************************/ + +void +AcpiDbExecuteSetup ( + DB_METHOD_INFO *Info) +{ + + /* Catenate the current scope to the supplied name */ + + Info->Pathname[0] = 0; + if ((Info->Name[0] != '\\') && + (Info->Name[0] != '/')) + { + STRCAT (Info->Pathname, ScopeBuf); + } + + STRCAT (Info->Pathname, Info->Name); + AcpiDbPrepNamestring (Info->Pathname); + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("Executing %s\n", Info->Pathname); + + if (Info->Flags & EX_SINGLE_STEP) + { + AcpiGbl_CmSingleStep = TRUE; + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + } + + else + { + /* No single step, allow redirection to a file */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecute + * + * PARAMETERS: Name - Name of method to execute + * Args - Parameters to the method + * Flags - single step/no single step + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method. Name is relative to the current + * scope. + * + ******************************************************************************/ + +void +AcpiDbExecute ( + NATIVE_CHAR *Name, + NATIVE_CHAR **Args, + UINT32 Flags) +{ + ACPI_STATUS Status; + UINT32 PreviousAllocations; + UINT32 PreviousSize; + UINT32 Allocations; + UINT32 Size; + ACPI_BUFFER ReturnObj; + + + /* Memory allocation tracking */ + + PreviousAllocations = AcpiGbl_CurrentAllocCount; + PreviousSize = AcpiGbl_CurrentAllocSize; + + + Info.Name = Name; + Info.Args = Args; + Info.Flags = Flags; + + AcpiDbExecuteSetup (&Info); + Status = AcpiDbExecuteMethod (&Info, &ReturnObj); + + + /* Memory allocation tracking */ + + Allocations = AcpiGbl_CurrentAllocCount - PreviousAllocations; + Size = AcpiGbl_CurrentAllocSize - PreviousSize; + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + + if (Allocations > 0) + { + AcpiOsPrintf ("Outstanding: %ld allocations of total size %ld after execution\n", + Allocations, Size); + } + + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Execution of %s failed with status %s\n", Info.Pathname, AcpiCmFormatException (Status)); + } + + else + { + /* Display a return object, if any */ + + if (ReturnObj.Length) + { + AcpiOsPrintf ("Execution of %s returned object %p\n", Info.Pathname, ReturnObj.Pointer); + AcpiDbDumpObject (ReturnObj.Pointer, 1); + } + } + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbMethodThread + * + * PARAMETERS: Context - Execution info segment + * + * RETURN: None + * + * DESCRIPTION: Debugger execute thread. Waits for a command line, then + * simply dispatches it. + * + ******************************************************************************/ + +void +AcpiDbMethodThread ( + void *Context) +{ + ACPI_STATUS Status; + DB_METHOD_INFO *Info = Context; + UINT32 i; + ACPI_BUFFER ReturnObj; + + + for (i = 0; i < Info->NumLoops; i++) + { + Status = AcpiDbExecuteMethod (Info, &ReturnObj); + if (ACPI_SUCCESS (Status)) + { + if (ReturnObj.Length) + { + AcpiOsPrintf ("Execution of %s returned object %p\n", Info->Pathname, ReturnObj.Pointer); + AcpiDbDumpObject (ReturnObj.Pointer, 1); + } + } + } + + + /* Signal our completion */ + + AcpiOsSignalSemaphore (Info->ThreadGate, 1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCreateExecutionThreads + * + * PARAMETERS: NumThreadsArg - Number of threads to create + * NumLoopsArg - Loop count for the thread(s) + * MethodNameArg - Control method to execute + * + * RETURN: None + * + * DESCRIPTION: Create threads to execute method(s) + * + ******************************************************************************/ + +void +AcpiDbCreateExecutionThreads ( + NATIVE_CHAR *NumThreadsArg, + NATIVE_CHAR *NumLoopsArg, + NATIVE_CHAR *MethodNameArg) +{ + ACPI_STATUS Status; + UINT32 NumThreads; + UINT32 NumLoops; + UINT32 i; + ACPI_HANDLE ThreadGate; + + + /* Get the arguments */ + + NumThreads = STRTOUL (NumThreadsArg, NULL, 0); + NumLoops = STRTOUL (NumLoopsArg, NULL, 0); + + if (!NumThreads || !NumLoops) + { + AcpiOsPrintf ("Bad argument: Threads %d, Loops %d\n", NumThreads, NumLoops); + return; + } + + + /* Create the synchronization semaphore */ + + Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiCmFormatException (Status)); + return; + } + + /* Setup the context to be passed to each thread */ + + Info.Name = MethodNameArg; + Info.Args = NULL; + Info.Flags = 0; + Info.NumLoops = NumLoops; + Info.ThreadGate = ThreadGate; + + AcpiDbExecuteSetup (&Info); + + + /* Create the threads */ + + AcpiOsPrintf ("Creating %d threads to execute %d times each\n", NumThreads, NumLoops); + + for (i = 0; i < (NumThreads); i++) + { + AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &Info); + } + + + /* Wait for all threads to complete */ + + i = NumThreads; + while (i) /* Brain damage for OSD implementations that only support wait of 1 unit */ + { + Status = AcpiOsWaitSemaphore (ThreadGate, 1, WAIT_FOREVER); + i--; + } + + /* Cleanup and exit */ + + AcpiOsDeleteSemaphore (ThreadGate); + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("All threads (%d) have completed\n", NumThreads); + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); +} + + +#endif /* ENABLE_DEBUGGER */ + + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c new file mode 100644 index 0000000..c7fe4fe --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbfileio.c @@ -0,0 +1,472 @@ +/******************************************************************************* + * + * Module Name: dbfileio - Debugger file I/O commands. These can't usually + * be used when running the debugger in Ring 0 (Kernel mode) + * $Revision: 30 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acdebug.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbfileio") + + +ACPI_PARSE_OBJECT *root; + +#ifdef ACPI_APPLICATION +#include +FILE *DebugFile = NULL; +#endif + + +/* + * NOTE: this is here for lack of a better place. It is used in all + * flavors of the debugger, need LCD file + */ + +/******************************************************************************* + * + * 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 + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDbMatchArgument ( + NATIVE_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 (STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name) + { + return ((OBJECT_TYPE_INTERNAL) i); + } + } + + /* Argument not recognized */ + + return (ACPI_TYPE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCloseDebugFile + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: If open, close the current debug output file + * + ******************************************************************************/ + +void +AcpiDbCloseDebugFile ( + void) +{ + +#ifdef ACPI_APPLICATION + + if (DebugFile) + { + fclose (DebugFile); + DebugFile = NULL; + OutputToFile = FALSE; + AcpiOsPrintf ("Debug output file %s closed\n", DebugFilename); + } +#endif + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbOpenDebugFile + * + * PARAMETERS: Name - Filename to open + * + * RETURN: Status + * + * DESCRIPTION: Open a file where debug output will be directed. + * + ******************************************************************************/ + +void +AcpiDbOpenDebugFile ( + NATIVE_CHAR *Name) +{ + +#ifdef ACPI_APPLICATION + + AcpiDbCloseDebugFile (); + DebugFile = fopen (Name, "w+"); + if (DebugFile) + { + AcpiOsPrintf ("Debug output file %s opened\n", Name); + STRCPY (DebugFilename, Name); + OutputToFile = TRUE; + } + +#endif +} + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiDbLoadTable + * + * PARAMETERS: fp - File that contains table + * TablePtr - Return value, buffer with table + * TableLenght - Return value, length of table + * + * RETURN: Status + * + * DESCRIPTION: Load the DSDT from the file pointer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbLoadTable( + FILE *fp, + ACPI_TABLE_HEADER **TablePtr, + UINT32 *TableLength) +{ + ACPI_TABLE_HEADER TableHeader; + UINT8 *AmlPtr; + UINT32 AmlLength; + UINT32 Actual; + + + /* Read the table header */ + + if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (TableHeader)) + { + AcpiOsPrintf ("Couldn't read the table header\n"); + return (AE_BAD_SIGNATURE); + } + + /* Get and validate the table length */ + + *TableLength = TableHeader.Length; + if (!*TableLength) + { + AcpiOsPrintf ("Found a table length of zero!\n"); + return (AE_ERROR); + } + + /* Allocate a buffer for the table */ + + *TablePtr = (ACPI_TABLE_HEADER *) malloc ((size_t) *TableLength); + if (!*TablePtr) + { + AcpiOsPrintf ("Could not allocate memory for the table (size=0x%X)\n", TableHeader.Length); + return (AE_NO_MEMORY); + } + + + AmlPtr = (UINT8 *) *TablePtr + sizeof (TableHeader); + AmlLength = *TableLength - sizeof (TableHeader); + + /* Copy the header to the buffer */ + + MEMCPY (*TablePtr, &TableHeader, sizeof (TableHeader)); + + /* Get the rest of the table */ + + Actual = fread (AmlPtr, 1, (size_t) AmlLength, fp); + if (Actual == AmlLength) + { + return (AE_OK); + } + + if (Actual > 0) + { + AcpiOsPrintf ("Warning - reading table, asked for %d got %d\n", AmlLength, Actual); + return (AE_OK); + } + + + AcpiOsPrintf ("Error - could not read the table file\n"); + free (*TablePtr); + *TablePtr = NULL; + *TableLength = 0; + + return (AE_ERROR); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AeLocalLoadTable + * + * PARAMETERS: TablePtr - pointer to a buffer containing the entire + * table to be loaded + * + * RETURN: Status + * + * DESCRIPTION: This function is called to load a table from the caller's + * buffer. The buffer must contain an entire ACPI Table including + * a valid header. The header fields will be verified, and if it + * is determined that the table is invalid, the call will fail. + * + * If the call fails an appropriate status will be returned. + * + ******************************************************************************/ + +ACPI_STATUS +AeLocalLoadTable ( + ACPI_TABLE_HEADER *TablePtr) +{ + ACPI_STATUS Status; + ACPI_TABLE_DESC TableInfo; + + + FUNCTION_TRACE ("AeLocalLoadTable"); + + if (!TablePtr) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Install the new table into the local data structures */ + + TableInfo.Pointer = TablePtr; + + Status = AcpiTbInstallTable (NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + /* Free table allocated by AcpiTbGetTable */ + + AcpiTbDeleteSingleTable (&TableInfo); + return_ACPI_STATUS (Status); + } + + +#ifndef PARSER_ONLY + Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + /* Uninstall table and free the buffer */ + + AcpiTbUninstallTable (TableInfo.InstalledDesc); + return_ACPI_STATUS (Status); + } +#endif + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbLoadAcpiTable + * + * PARAMETERS: Filname - File where table is located + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from a file + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + NATIVE_CHAR *Filename) +{ +#ifdef ACPI_APPLICATION + FILE *fp; + ACPI_STATUS Status; + ACPI_TABLE_HEADER *TablePtr; + UINT32 TableLength; + + + /* Open the file */ + + fp = fopen (Filename, "rb"); + if (!fp) + { + AcpiOsPrintf ("Could not open file %s\n", Filename); + return (AE_ERROR); + } + + + /* Get the entire file */ + + AcpiOsPrintf ("Loading Acpi table from file %s\n", Filename); + Status = AcpiDbLoadTable (fp, &TablePtr, &TableLength); + fclose(fp); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Couldn't get table from the file\n"); + return (Status); + } + + + /* Attempt to recognize and install the table */ + Status = AeLocalLoadTable (TablePtr); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_EXIST) + { + AcpiOsPrintf ("Table %4.4s is already installed\n", + &TablePtr->Signature); + } + else + { + AcpiOsPrintf ("Could not install table, %s\n", + AcpiCmFormatException (Status)); + } + free (TablePtr); + return (Status); + } + + AcpiOsPrintf ("%4.4s at %p successfully installed and loaded\n", + &TablePtr->Signature, TablePtr); + + AcpiGbl_AcpiHardwarePresent = FALSE; + +#endif /* ACPI_APPLICATION */ + return (AE_OK); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c new file mode 100644 index 0000000..bcc18a8 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbhistry.c @@ -0,0 +1,301 @@ +/****************************************************************************** + * + * Module Name: dbhistry - debugger HISTORY command + * $Revision: 15 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbhistry") + + +#define HI_NO_HISTORY 0 +#define HI_RECORD_HISTORY 1 +#define HISTORY_SIZE 20 + + +typedef struct HistoryInfo +{ + NATIVE_CHAR Command[80]; + UINT32 CmdNum; + +} HISTORY_INFO; + + +HISTORY_INFO HistoryBuffer[HISTORY_SIZE]; +UINT16 LoHistory = 0; +UINT16 NumHistory = 0; +UINT16 NextHistoryIndex = 0; +UINT32 NextCmdNum = 1; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbAddToHistory + * + * PARAMETERS: CommandLine - Command to add + * + * RETURN: None + * + * DESCRIPTION: Add a command line to the history buffer. + * + ******************************************************************************/ + +void +AcpiDbAddToHistory ( + NATIVE_CHAR *CommandLine) +{ + + + /* Put command into the next available slot */ + + STRCPY (HistoryBuffer[NextHistoryIndex].Command, CommandLine); + HistoryBuffer[NextHistoryIndex].CmdNum = NextCmdNum; + + /* Adjust indexes */ + + if ((NumHistory == HISTORY_SIZE) && + (NextHistoryIndex == LoHistory)) + { + LoHistory++; + if (LoHistory >= HISTORY_SIZE) + { + LoHistory = 0; + } + } + + NextHistoryIndex++; + if (NextHistoryIndex >= HISTORY_SIZE) + { + NextHistoryIndex = 0; + } + + + NextCmdNum++; + if (NumHistory < HISTORY_SIZE) + { + NumHistory++; + } + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayHistory + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display the contents of the history buffer + * + ******************************************************************************/ + +void +AcpiDbDisplayHistory (void) +{ + NATIVE_UINT i; + UINT16 HistoryIndex; + + + HistoryIndex = LoHistory; + + /* Dump entire history buffer */ + + for (i = 0; i < NumHistory; i++) + { + AcpiOsPrintf ("%ld %s\n", HistoryBuffer[HistoryIndex].CmdNum, HistoryBuffer[HistoryIndex].Command); + + HistoryIndex++; + if (HistoryIndex >= HISTORY_SIZE) + { + HistoryIndex = 0; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetFromHistory + * + * PARAMETERS: CommandNumArg - String containing the number of the + * command to be retrieved + * + * RETURN: None + * + * DESCRIPTION: Get a command from the history buffer + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiDbGetFromHistory ( + NATIVE_CHAR *CommandNumArg) +{ + NATIVE_UINT i; + UINT16 HistoryIndex; + UINT32 CmdNum; + + + if (CommandNumArg == NULL) + { + CmdNum = NextCmdNum - 1; + } + + else + { + CmdNum = STRTOUL (CommandNumArg, NULL, 0); + } + + + /* Search history buffer */ + + HistoryIndex = LoHistory; + for (i = 0; i < NumHistory; i++) + { + if (HistoryBuffer[HistoryIndex].CmdNum == CmdNum) + { + /* Found the commnad, return it */ + + return (HistoryBuffer[HistoryIndex].Command); + } + + + HistoryIndex++; + if (HistoryIndex >= HISTORY_SIZE) + { + HistoryIndex = 0; + } + } + + AcpiOsPrintf ("Invalid history number: %d\n", HistoryIndex); + return (NULL); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c new file mode 100644 index 0000000..d81e1ad --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbinput.c @@ -0,0 +1,981 @@ +/******************************************************************************* + * + * Module Name: dbinput - user front-end to the AML debugger + * $Revision: 51 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "actables.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbinput") + + +/* + * Globals that are specific to the debugger + */ + +NATIVE_CHAR LineBuf[80]; +NATIVE_CHAR ParsedBuf[80]; +NATIVE_CHAR ScopeBuf[40]; +NATIVE_CHAR DebugFilename[40]; +NATIVE_CHAR *Args[DB_MAX_ARGS]; +NATIVE_CHAR *Buffer; +NATIVE_CHAR *Filename = NULL; +BOOLEAN OutputToFile = FALSE; + + +UINT32 AcpiGbl_DbDebugLevel = 0x0FFFFFFF; +UINT32 AcpiGbl_DbConsoleDebugLevel = NORMAL_DEFAULT | TRACE_TABLES; +UINT8 AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT; + + +BOOLEAN opt_tables = FALSE; +BOOLEAN opt_disasm = FALSE; +BOOLEAN opt_stats = FALSE; +BOOLEAN opt_parse_jit = FALSE; +BOOLEAN opt_verbose = TRUE; + + +/* + * Top-level debugger commands. + * + * This list of commands must match the string table below it + */ + +enum AcpiAmlDebuggerCommands +{ + CMD_NOT_FOUND = 0, + CMD_NULL, + CMD_ALLOCATIONS, + CMD_ARGS, + CMD_ARGUMENTS, + CMD_BREAKPOINT, + CMD_CALL, + CMD_CLOSE, + CMD_DEBUG, + CMD_DUMP, + CMD_ENABLEACPI, + CMD_EVENT, + CMD_EXECUTE, + CMD_EXIT, + CMD_FIND, + CMD_GO, + CMD_HELP, + CMD_HELP2, + CMD_HISTORY, + CMD_HISTORY_EXE, + CMD_HISTORY_LAST, + CMD_INFORMATION, + CMD_INTO, + CMD_LEVEL, + CMD_LIST, + CMD_LOAD, + CMD_LOCALS, + CMD_METHODS, + CMD_NAMESPACE, + CMD_NOTIFY, + CMD_OBJECT, + CMD_OPEN, + CMD_OWNER, + CMD_PREFIX, + CMD_QUIT, + CMD_REFERENCES, + CMD_RESULTS, + CMD_SET, + CMD_STATS, + CMD_STOP, + CMD_TABLES, + CMD_TERMINATE, + CMD_THREADS, + CMD_TREE, + CMD_UNLOAD +}; + +#define CMD_FIRST_VALID 2 + + +COMMAND_INFO Commands[] = +{ + {"", 0}, + {"", 0}, + {"ALLOCATIONS", 0}, + {"ARGS", 0}, + {"ARGUMENTS", 0}, + {"BREAKPOINT", 1}, + {"CALL", 0}, + {"CLOSE", 0}, + {"DEBUG", 1}, + {"DUMP", 1}, + {"ENABLEACPI", 0}, + {"EVENT", 1}, + {"EXECUTE", 1}, + {"EXIT", 0}, + {"FIND", 1}, + {"GO", 0}, + {"HELP", 0}, + {"?", 0}, + {"HISTORY", 0}, + {"!", 1}, + {"!!", 0}, + {"INFORMATION", 0}, + {"INTO", 0}, + {"LEVEL", 0}, + {"LIST", 0}, + {"LOAD", 1}, + {"LOCALS", 0}, + {"METHODS", 0}, + {"NAMESPACE", 0}, + {"NOTIFY", 2}, + {"OBJECT", 1}, + {"OPEN", 1}, + {"OWNER", 1}, + {"PREFIX", 0}, + {"QUIT", 0}, + {"REFERENCES", 1}, + {"RESULTS", 0}, + {"SET", 3}, + {"STATS", 0}, + {"STOP", 0}, + {"TABLES", 0}, + {"TERMINATE", 0}, + {"THREADS", 3}, + {"TREE", 0}, + {"UNLOAD", 0}, + {NULL, 0} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayHelp + * + * PARAMETERS: HelpType - Subcommand (optional) + * + * RETURN: None + * + * DESCRIPTION: Print a usage message. + * + ******************************************************************************/ + +void +AcpiDbDisplayHelp ( + NATIVE_CHAR *HelpType) +{ + + + /* No parameter, just give the overview */ + + if (!HelpType) + { + AcpiOsPrintf ("ACPI CA Debugger Commands\n\n"); + AcpiOsPrintf ("The following classes of commands are available. Help is available for\n"); + AcpiOsPrintf ("each class by entering \"Help \"\n\n"); + AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n"); + AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n"); + AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n"); + AcpiOsPrintf (" [FILE] File I/O Commands\n"); + return; + + } + + + /* + * Parameter is the command class + * + * The idea here is to keep each class of commands smaller than a screenful + */ + + switch (HelpType[0]) + { + case 'G': + AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n"); + AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); + AcpiOsPrintf ("Dump
|\n"); + AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n"); + AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n"); + AcpiOsPrintf ("Help This help screen\n"); + AcpiOsPrintf ("History Display command history buffer\n"); + AcpiOsPrintf ("Level [] [console] Get/Set debug level for file or console\n"); + AcpiOsPrintf ("Quit or Exit Exit this command\n"); + AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); + AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n"); + AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); + AcpiOsPrintf ("Unload Unload an ACPI table\n"); + AcpiOsPrintf ("! Execute command from history buffer\n"); + AcpiOsPrintf ("!! Execute last command again\n"); + return; + + case 'N': + AcpiOsPrintf ("\nNamespace Access Commands\n\n"); + AcpiOsPrintf ("Debug [Arguments] Single Step a control method\n"); + AcpiOsPrintf ("Event Generate AcpiEvent (Fixed/GPE)\n"); + AcpiOsPrintf ("Execute [Arguments] Execute control method\n"); + AcpiOsPrintf ("Find (? is wildcard) Find ACPI name(s) with wildcards\n"); + AcpiOsPrintf ("Method Display list of loaded control methods\n"); + AcpiOsPrintf ("Namespace [|] [Depth] Display loaded namespace tree/subtree\n"); + AcpiOsPrintf ("Notify Send a notification\n"); + AcpiOsPrintf ("Objects Display all objects of the given type\n"); + AcpiOsPrintf ("Owner [Depth] Display loaded namespace by object owner\n"); + AcpiOsPrintf ("Prefix [] Set or Get current execution prefix\n"); + AcpiOsPrintf ("References Find all references to object at addr\n"); + AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); + AcpiOsPrintf ("Thread Spawn threads to execute method(s)\n"); + return; + + case 'M': + AcpiOsPrintf ("\nControl Method Execution Commands\n\n"); + AcpiOsPrintf ("Arguments (or Args) Display method arguments\n"); + AcpiOsPrintf ("Breakpoint Set an AML execution breakpoint\n"); + AcpiOsPrintf ("Call Run to next control method invocation\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 AcpiAml Opcodes] Display method ASL statements\n"); + AcpiOsPrintf ("Locals Display method local variables\n"); + AcpiOsPrintf ("Results Display method result stack\n"); + AcpiOsPrintf ("Set <#> Set method data (Arguments/Locals)\n"); + AcpiOsPrintf ("Stop Terminate control method\n"); + AcpiOsPrintf ("Tree Display control method calling tree\n"); + AcpiOsPrintf (" Single step next AML opcode (over calls)\n"); + return; + + case 'F': + AcpiOsPrintf ("\nFile I/O Commands\n\n"); + AcpiOsPrintf ("Close Close debug output file\n"); + AcpiOsPrintf ("Open Open a file for debug output\n"); + AcpiOsPrintf ("Load Load ACPI table from a file\n"); + return; + + default: + AcpiOsPrintf ("Unrecognized Command Class: %x\n", HelpType); + return; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetNextToken + * + * PARAMETERS: String - Command buffer + * Next - Return value, end of next token + * + * RETURN: Pointer to the start of the next token. + * + * DESCRIPTION: Command line parsing. Get the next token on the command line + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiDbGetNextToken ( + NATIVE_CHAR *String, + NATIVE_CHAR **Next) +{ + NATIVE_CHAR *Start; + + /* At end of buffer? */ + + if (!String || !(*String)) + { + return (NULL); + } + + + /* Get rid of any spaces at the beginning */ + + if (*String == ' ') + { + while (*String && (*String == ' ')) + { + String++; + } + + if (!(*String)) + { + return (NULL); + } + } + + Start = String; + + /* Find end of token */ + + while (*String && (*String != ' ')) + { + String++; + } + + + if (!(*String)) + { + *Next = NULL; + } + + else + { + *String = 0; + *Next = String + 1; + } + + return (Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetLine + * + * PARAMETERS: InputBuffer - Command line buffer + * + * RETURN: None + * + * DESCRIPTION: Get the next command line from the user. Gets entire line + * up to the next newline + * + ******************************************************************************/ + +UINT32 +AcpiDbGetLine ( + NATIVE_CHAR *InputBuffer) +{ + UINT32 i; + UINT32 Count; + NATIVE_CHAR *Next; + NATIVE_CHAR *This; + + + STRCPY (ParsedBuf, InputBuffer); + STRUPR (ParsedBuf); + + This = ParsedBuf; + for (i = 0; i < DB_MAX_ARGS; i++) + { + Args[i] = AcpiDbGetNextToken (This, &Next); + if (!Args[i]) + { + break; + } + + This = Next; + } + + + /* Uppercase the actual command */ + + if (Args[0]) + { + STRUPR (Args[0]); + } + + Count = i; + if (Count) + { + Count--; /* Number of args only */ + } + + return (Count); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbMatchCommand + * + * PARAMETERS: UserCommand - User command line + * + * RETURN: Index into command array, -1 if not found + * + * DESCRIPTION: Search command array for a command match + * + ******************************************************************************/ + +UINT32 +AcpiDbMatchCommand ( + NATIVE_CHAR *UserCommand) +{ + UINT32 i; + + + if (!UserCommand || UserCommand[0] == 0) + { + return (CMD_NULL); + } + + for (i = CMD_FIRST_VALID; Commands[i].Name; i++) + { + if (STRSTR (Commands[i].Name, UserCommand) == Commands[i].Name) + { + return (i); + } + } + + /* Command not recognized */ + + return (CMD_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCommandDispatch + * + * PARAMETERS: InputBuffer - Command line buffer + * WalkState - Current walk + * Op - Current (executing) parse op + * + * RETURN: Status + * + * DESCRIPTION: Command dispatcher. Called from two places: + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbCommandDispatch ( + NATIVE_CHAR *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 Temp; + UINT32 CommandIndex; + UINT32 ParamCount; + NATIVE_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 (Args[0]); + Temp = 0; + + /* Verify that we have the minimum number of params */ + + if (ParamCount < Commands[CommandIndex].MinArgs) + { + AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", + ParamCount, Commands[CommandIndex].Name, Commands[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: + AcpiCmDumpCurrentAllocations ((UINT32) -1, NULL); + break; + + case CMD_ARGS: + case CMD_ARGUMENTS: + AcpiDbDisplayArguments (); + break; + + case CMD_BREAKPOINT: + AcpiDbSetMethodBreakpoint (Args[1], WalkState, Op); + break; + + case CMD_CALL: + AcpiDbSetMethodCallBreakpoint (Op); + Status = AE_OK; + break; + + case CMD_CLOSE: + AcpiDbCloseDebugFile (); + break; + + case CMD_DEBUG: + AcpiDbExecute (Args[1], &Args[2], EX_SINGLE_STEP); + break; + + case CMD_DUMP: + AcpiDbDecodeAndDisplayObject (Args[1], Args[2]); + break; + + case CMD_ENABLEACPI: + Status = AcpiEnable(); + if (ACPI_FAILURE(Status)) + { + AcpiOsPrintf("AcpiEnable failed (0x%x)\n", Status); + return (Status); + } + break; + + case CMD_EVENT: + AcpiOsPrintf ("Event command not implemented\n"); + break; + + case CMD_EXECUTE: + AcpiDbExecute (Args[1], &Args[2], EX_NO_SINGLE_STEP); + break; + + case CMD_FIND: + AcpiDbFindNameInNamespace (Args[1]); + break; + + case CMD_GO: + AcpiGbl_CmSingleStep = FALSE; + return (AE_OK); + + case CMD_HELP: + case CMD_HELP2: + AcpiDbDisplayHelp (Args[1]); + break; + + case CMD_HISTORY: + AcpiDbDisplayHistory (); + break; + + case CMD_HISTORY_EXE: + CommandLine = AcpiDbGetFromHistory (Args[1]); + if (!CommandLine) + { + return (AE_CTRL_TRUE); + } + + Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); + if (ACPI_SUCCESS (Status)) + Status = AE_CTRL_TRUE; + return (Status); + break; + + case CMD_HISTORY_LAST: + CommandLine = AcpiDbGetFromHistory (NULL); + if (!CommandLine) + { + return (AE_CTRL_TRUE); + } + + Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); + if (ACPI_SUCCESS (Status)) + Status = AE_CTRL_TRUE; + return (Status); + + case CMD_INFORMATION: + AcpiDbDisplayMethodInfo (Op); + break; + + case CMD_INTO: + if (Op) + { + AcpiGbl_CmSingleStep = TRUE; + +/* TBD: Must get current walk state */ + /* AcpiGbl_MethodBreakpoint = 0; */ + 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 = STRTOUL (Args[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 = STRTOUL (Args[1], NULL, 16); + AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); + } + break; + + case CMD_LIST: + AcpiDbDisassembleAml (Args[1], Op); + break; + + case CMD_LOAD: + Status = AcpiDbLoadAcpiTable (Args[1]); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case CMD_LOCALS: + AcpiDbDisplayLocals (); + break; + + case CMD_METHODS: + AcpiDbDisplayObjects ("METHOD", Args[1]); + break; + + case CMD_NAMESPACE: + AcpiDbDumpNamespace (Args[1], Args[2]); + break; + + case CMD_NOTIFY: + Temp = STRTOUL (Args[2], NULL, 0); + AcpiDbSendNotify (Args[1], Temp); + break; + + case CMD_OBJECT: + AcpiDbDisplayObjects (Args[1], Args[2]); + break; + + case CMD_OPEN: + AcpiDbOpenDebugFile (Args[1]); + break; + + case CMD_OWNER: + AcpiDbDumpNamespaceByOwner (Args[1], Args[2]); + break; + + case CMD_PREFIX: + AcpiDbSetScope (Args[1]); + break; + + case CMD_REFERENCES: + AcpiDbFindReferences (Args[1]); + break; + + case CMD_RESULTS: + AcpiDbDisplayResults (); + break; + + case CMD_SET: + AcpiDbSetMethodData (Args[1], Args[2], Args[3]); + break; + + case CMD_STATS: + AcpiDbDisplayStatistics (Args[1]); + break; + + case CMD_STOP: + return (AE_AML_ERROR); + break; + + case CMD_TABLES: + AcpiDbDisplayTableInfo (Args[1]); + break; + + case CMD_TERMINATE: + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiCmSubsystemShutdown (); + + /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */ + + /* AcpiInitialize (NULL); */ + break; + + case CMD_THREADS: + AcpiDbCreateExecutionThreads (Args[1], Args[2], Args[3]); + break; + + case CMD_TREE: + AcpiDbDisplayCallingTree (); + break; + + case CMD_UNLOAD: + AcpiDbUnloadAcpiTable (Args[1], Args[2]); + break; + + case CMD_EXIT: + case CMD_QUIT: + if (Op) + { + return (AE_AML_ERROR); + } + + if (!OutputToFile) + { + AcpiDbgLevel = DEBUG_DEFAULT; + } + + /* Shutdown */ + + /* AcpiCmSubsystemShutdown (); */ + AcpiDbCloseDebugFile (); + + AcpiGbl_DbTerminateThreads = TRUE; + + return (AE_CTRL_TERMINATE); + + case CMD_NOT_FOUND: + AcpiOsPrintf ("Unknown Command\n"); + return (AE_CTRL_TRUE); + } + + + /* Add all commands that come here to the history buffer */ + + AcpiDbAddToHistory (InputBuffer); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteThread + * + * PARAMETERS: Context - Not used + * + * RETURN: None + * + * DESCRIPTION: Debugger execute thread. Waits for a command line, then + * simply dispatches it. + * + ******************************************************************************/ + +void +AcpiDbExecuteThread ( + void *Context) +{ + ACPI_STATUS Status = AE_OK; + + + while (Status != AE_CTRL_TERMINATE) + { + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; + + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + Status = AcpiDbCommandDispatch (LineBuf, NULL, NULL); + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSingleThread + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Debugger execute thread. Waits for a command line, then + * simply dispatches it. + * + ******************************************************************************/ + +void +AcpiDbSingleThread ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; + + Status = AcpiDbCommandDispatch (LineBuf, 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 ( + NATIVE_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 (DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + AcpiOsGetLine (LineBuf); + + + /* 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. + */ + + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + } + + 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 + */ + AcpiTerminate (); + + return (Status); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c new file mode 100644 index 0000000..afb8b44 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbstats.c @@ -0,0 +1,548 @@ +/******************************************************************************* + * + * Module Name: dbstats - Generation and display of ACPI table statistics + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include +#include +#include +#include + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbstats") + +/* + * Statistics subcommands + */ +ARGUMENT_INFO AcpiDbStatTypes [] = +{ + {"ALLOCATIONS"}, + {"OBJECTS"}, + {"MEMORY"}, + {"MISC"}, + {"TABLES"}, + {"SIZES"}, + {NULL} /* Must be null terminated */ +}; + +#define CMD_ALLOCATIONS 0 +#define CMD_OBJECTS 1 +#define CMD_MEMORY 2 +#define CMD_MISC 3 +#define CMD_TABLES 4 +#define CMD_SIZES 5 + + +/* + * Statistic globals + */ +UINT16 AcpiGbl_ObjTypeCount[INTERNAL_TYPE_NODE_MAX+1]; +UINT16 AcpiGbl_NodeTypeCount[INTERNAL_TYPE_NODE_MAX+1]; +UINT16 AcpiGbl_ObjTypeCountMisc; +UINT16 AcpiGbl_NodeTypeCountMisc; +UINT32 NumNodes; +UINT32 NumObjects; + + +UINT32 SizeOfParseTree; +UINT32 SizeOfMethodTrees; +UINT32 SizeOfNodeEntries; +UINT32 SizeOfAcpiObjects; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbEnumerateObject + * + * PARAMETERS: ObjDesc - Object to be counted + * + * RETURN: None + * + * DESCRIPTION: Add this object to the global counts, by object type. + * Recursively handles subobjects and packages. + * + * [TBD] Restructure - remove recursion. + * + ******************************************************************************/ + +void +AcpiDbEnumerateObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + UINT32 Type; + UINT32 i; + + + if (!ObjDesc) + { + return; + } + + + /* Enumerate this object first */ + + NumObjects++; + + Type = ObjDesc->Common.Type; + if (Type > INTERNAL_TYPE_NODE_MAX) + { + AcpiGbl_ObjTypeCountMisc++; + } + else + { + AcpiGbl_ObjTypeCount [Type]++; + } + + /* Count the sub-objects */ + + switch (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.SysHandler); + AcpiDbEnumerateObject (ObjDesc->Device.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->Device.AddrHandler); + break; + + case ACPI_TYPE_REGION: + AcpiDbEnumerateObject (ObjDesc->Region.AddrHandler); + break; + + case ACPI_TYPE_POWER: + AcpiDbEnumerateObject (ObjDesc->PowerResource.SysHandler); + AcpiDbEnumerateObject (ObjDesc->PowerResource.DrvHandler); + break; + + case ACPI_TYPE_PROCESSOR: + AcpiDbEnumerateObject (ObjDesc->Processor.SysHandler); + AcpiDbEnumerateObject (ObjDesc->Processor.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->Processor.AddrHandler); + break; + + case ACPI_TYPE_THERMAL: + AcpiDbEnumerateObject (ObjDesc->ThermalZone.SysHandler); + AcpiDbEnumerateObject (ObjDesc->ThermalZone.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->ThermalZone.AddrHandler); + break; + } +} + + +#ifndef PARSER_ONLY + +/******************************************************************************* + * + * FUNCTION: AcpiDbClassifyOneObject + * + * PARAMETERS: Callback for WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and + * the parent namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbClassifyOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Type; + + + NumNodes++; + + Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ObjDesc = ((ACPI_NAMESPACE_NODE *) ObjHandle)->Object; + + AcpiDbEnumerateObject (ObjDesc); + + Type = Node->Type; + if (Type > INTERNAL_TYPE_INVALID) + { + AcpiGbl_NodeTypeCountMisc++; + } + + else + { + AcpiGbl_NodeTypeCount [Type]++; + } + + return AE_OK; + + + /* TBD: These need to be counted during the initial parsing phase */ + /* + if (AcpiPsIsNamedOp (Op->Opcode)) + { + NumNodes++; + } + + if (IsMethod) + { + NumMethodElements++; + } + + NumGrammarElements++; + Op = AcpiPsGetDepthNext (Root, Op); + + SizeOfParseTree = (NumGrammarElements - NumMethodElements) * (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); + SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); + + */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCountNamespaceObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Count and classify the entire namespace, including all + * namespace nodes and attached objects. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbCountNamespaceObjects ( + void) +{ + UINT32 i; + + + NumNodes = 0; + NumObjects = 0; + + AcpiGbl_ObjTypeCountMisc = 0; + for (i = 0; i < INTERNAL_TYPE_INVALID; i++) + { + AcpiGbl_ObjTypeCount [i] = 0; + AcpiGbl_NodeTypeCount [i] = 0; + } + + AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + FALSE, AcpiDbClassifyOneObject, NULL, NULL); + + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayStatistics + * + * PARAMETERS: TypeArg - Subcommand + * + * RETURN: Status + * + * DESCRIPTION: Display various statistics + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisplayStatistics ( + NATIVE_CHAR *TypeArg) +{ + UINT32 i; + UINT32 Type; + + + if (!AcpiGbl_DSDT) + { + AcpiOsPrintf ("*** Warning: There is no DSDT loaded\n"); + } + + if (!TypeArg) + { + AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); + return (AE_OK); + } + + STRUPR (TypeArg); + Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); + if (Type == (UINT32) -1) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return (AE_OK); + } + +#ifndef PARSER_ONLY + + AcpiDbCountNamespaceObjects (); +#endif + + + switch (Type) + { +#ifndef PARSER_ONLY + case CMD_ALLOCATIONS: + AcpiCmDumpAllocationInfo (); + break; +#endif + + case CMD_TABLES: + + AcpiOsPrintf ("ACPI Table Information:\n\n"); + if (AcpiGbl_DSDT) + { + AcpiOsPrintf ("DSDT Length:................% 7ld (0x%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); + } + break; + + case CMD_OBJECTS: + + AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n"); + + AcpiOsPrintf ("%16.16s % 10.10s % 10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS"); + + for (i = 0; i < INTERNAL_TYPE_NODE_MAX; i++) + { + AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiCmGetTypeName (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:", + NumNodes, NumObjects); + + +/* + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("ASL/AML Grammar Usage:\n\n"); + AcpiOsPrintf ("Elements Inside Methods:....% 7ld\n", NumMethodElements); + AcpiOsPrintf ("Elements Outside Methods:...% 7ld\n", NumGrammarElements - NumMethodElements); + AcpiOsPrintf ("Total Grammar Elements:.....% 7ld\n", NumGrammarElements); +*/ + break; + + case CMD_MEMORY: + + AcpiOsPrintf ("\nDynamic Memory Estimates:\n\n"); + AcpiOsPrintf ("Parse Tree without Methods:.% 7ld\n", SizeOfParseTree); + AcpiOsPrintf ("Control Method Parse Trees:.% 7ld (If parsed simultaneously)\n", SizeOfMethodTrees); + AcpiOsPrintf ("Namespace Nodes:............% 7ld (%d nodes)\n", sizeof (ACPI_NAMESPACE_NODE) * NumNodes, NumNodes); + AcpiOsPrintf ("Named Internal Objects......% 7ld\n", SizeOfAcpiObjects); + AcpiOsPrintf ("State Cache size............% 7ld\n", AcpiGbl_GenericStateCacheDepth * sizeof (ACPI_GENERIC_STATE)); + AcpiOsPrintf ("Parse Cache size............% 7ld\n", AcpiGbl_ParseCacheDepth * sizeof (ACPI_PARSE_OBJECT)); + AcpiOsPrintf ("Object Cache size...........% 7ld\n", AcpiGbl_ObjectCacheDepth * sizeof (ACPI_OPERAND_OBJECT)); + AcpiOsPrintf ("WalkState Cache size........% 7ld\n", AcpiGbl_WalkStateCacheDepth * sizeof (ACPI_WALK_STATE)); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("Cache Statistics:\n\n"); + AcpiOsPrintf ("State Cache requests........% 7ld\n", AcpiGbl_StateCacheRequests); + AcpiOsPrintf ("State Cache hits............% 7ld\n", AcpiGbl_StateCacheHits); + AcpiOsPrintf ("State Cache depth...........% 7ld (%d remaining entries)\n", AcpiGbl_GenericStateCacheDepth, + MAX_STATE_CACHE_DEPTH - AcpiGbl_GenericStateCacheDepth); + AcpiOsPrintf ("Parse Cache requests........% 7ld\n", AcpiGbl_ParseCacheRequests); + AcpiOsPrintf ("Parse Cache hits............% 7ld\n", AcpiGbl_ParseCacheHits); + AcpiOsPrintf ("Parse Cache depth...........% 7ld (%d remaining entries)\n", AcpiGbl_ParseCacheDepth, + MAX_PARSE_CACHE_DEPTH - AcpiGbl_ParseCacheDepth); + AcpiOsPrintf ("Ext Parse Cache requests....% 7ld\n", AcpiGbl_ExtParseCacheRequests); + AcpiOsPrintf ("Ext Parse Cache hits........% 7ld\n", AcpiGbl_ExtParseCacheHits); + AcpiOsPrintf ("Ext Parse Cache depth.......% 7ld (%d remaining entries)\n", AcpiGbl_ExtParseCacheDepth, + MAX_EXTPARSE_CACHE_DEPTH - AcpiGbl_ExtParseCacheDepth); + AcpiOsPrintf ("Object Cache requests.......% 7ld\n", AcpiGbl_ObjectCacheRequests); + AcpiOsPrintf ("Object Cache hits...........% 7ld\n", AcpiGbl_ObjectCacheHits); + AcpiOsPrintf ("Object Cache depth..........% 7ld (%d remaining entries)\n", AcpiGbl_ObjectCacheDepth, + MAX_OBJECT_CACHE_DEPTH - AcpiGbl_ObjectCacheDepth); + AcpiOsPrintf ("WalkState Cache requests....% 7ld\n", AcpiGbl_WalkStateCacheRequests); + AcpiOsPrintf ("WalkState Cache hits........% 7ld\n", AcpiGbl_WalkStateCacheHits); + AcpiOsPrintf ("WalkState Cache depth.......% 7ld (%d remaining entries)\n", AcpiGbl_WalkStateCacheDepth, + MAX_WALK_CACHE_DEPTH - AcpiGbl_WalkStateCacheDepth); + break; + + case CMD_MISC: + + AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n"); + AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", AcpiGbl_PsFindCount); + AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", AcpiGbl_NsLookupCount); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("Mutex usage:\n\n"); + for (i = 0; i < NUM_MTX; i++) + { + AcpiOsPrintf ("%-20s: % 7ld\n", AcpiCmGetMutexName (i), AcpiGbl_AcpiMutexInfo[i].UseCount); + } + break; + + + case CMD_SIZES: + + AcpiOsPrintf ("\nInternal object sizes:\n\n"); + + AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON)); + AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_NUMBER)); + 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 ("FieldUnit %3d\n", sizeof (ACPI_OBJECT_FIELD_UNIT)); + 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 ("Field %3d\n", sizeof (ACPI_OBJECT_FIELD)); + AcpiOsPrintf ("BankField %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD)); + AcpiOsPrintf ("IndexField %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD)); + AcpiOsPrintf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE)); + AcpiOsPrintf ("NotifyHandler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER)); + AcpiOsPrintf ("AddrHandler %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER)); + AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA)); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJECT)); + AcpiOsPrintf ("Parse2Object %3d\n", sizeof (ACPI_PARSE2_OBJECT)); + AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT)); + AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE)); + + break; + + } + + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c new file mode 100644 index 0000000..a520221 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbutils.c @@ -0,0 +1,465 @@ +/******************************************************************************* + * + * Module Name: dbutils - AML debugger utilities + * $Revision: 32 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "acdispat.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetOutputDestination + * + * PARAMETERS: OutputFlags - Current flags word + * + * RETURN: None + * + * DESCRIPTION: Set the current destination for debugger output. Alos sets + * the debug output level accordingly. + * + ******************************************************************************/ + +void +AcpiDbSetOutputDestination ( + UINT32 OutputFlags) +{ + + AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; + + if (OutputFlags & DB_REDIRECTABLE_OUTPUT) + { + if (OutputToFile) + { + AcpiDbgLevel = AcpiGbl_DbDebugLevel; + } + } + else + { + AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpBuffer + * + * PARAMETERS: Address - Pointer to the buffer + * + * RETURN: None + * + * DESCRIPTION: Print a portion of a buffer + * + ******************************************************************************/ + +void +AcpiDbDumpBuffer ( + UINT32 Address) +{ + + AcpiOsPrintf ("\nLocation 0x%X:\n", Address); + + AcpiDbgLevel |= TRACE_TABLES; + AcpiCmDumpBuffer ((UINT8 *) Address, 64, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpObject + * + * PARAMETERS: ObjDesc - External ACPI object to dump + * Level - Nesting level. + * + * RETURN: None + * + * DESCRIPTION: Dump the contents of an ACPI external object + * + ******************************************************************************/ + +void +AcpiDbDumpObject ( + ACPI_OBJECT *ObjDesc, + UINT32 Level) +{ + UINT32 i; + + + if (!ObjDesc) + { + AcpiOsPrintf ("[Null Object]\n"); + return; + } + + for (i = 0; i < Level; i++) + { + AcpiOsPrintf (" "); + } + + switch (ObjDesc->Type) + { + case ACPI_TYPE_ANY: + + AcpiOsPrintf ("[Object Reference] Value: %p\n", ObjDesc->Reference.Handle); + break; + + + case ACPI_TYPE_NUMBER: + AcpiOsPrintf ("[Number] Value: %ld (0x%lX)\n", ObjDesc->Number.Value, ObjDesc->Number.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] Value: "); + AcpiCmDumpBuffer ((UINT8 *) ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("[Package] Contains %d Elements: \n", ObjDesc->Package.Count); + + for (i = 0; i < ObjDesc->Package.Count; i++) + { + AcpiDbDumpObject (&ObjDesc->Package.Elements[i], Level+1); + } + break; + + + case INTERNAL_TYPE_REFERENCE: + AcpiOsPrintf ("[Object Reference] Value: %p\n", ObjDesc->Reference.Handle); + break; + + case ACPI_TYPE_PROCESSOR: + AcpiOsPrintf ("[Processor]\n"); + break; + + case ACPI_TYPE_POWER: + AcpiOsPrintf ("[Power Resource]\n"); + break; + + default: + + AcpiOsPrintf ("[Unknown Type] 0x%X \n", ObjDesc->Type); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbPrepNamestring + * + * PARAMETERS: Name - String to prepare + * + * RETURN: None + * + * DESCRIPTION: Translate all forward slashes and dots to backslashes. + * + ******************************************************************************/ + +void +AcpiDbPrepNamestring ( + NATIVE_CHAR *Name) +{ + + + if (!Name) + { + return; + } + + STRUPR (Name); + + /* Convert a leading forward slash to a backslash */ + + if (*Name == '/') + { + *Name = '\\'; + } + + /* Ignore a leading backslash, this is the root prefix */ + + if (*Name == '\\') + { + Name++; + } + + /* Convert all slash path separators to dots */ + + while (*Name) + { + if ((*Name == '/') || + (*Name == '\\')) + { + *Name = '.'; + } + + Name++; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSecondPassParse + * + * PARAMETERS: Root - Root of the parse tree + * + * RETURN: Status + * + * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until + * second pass to parse the control methods + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbSecondPassParse ( + ACPI_PARSE_OBJECT *Root) +{ + ACPI_PARSE_OBJECT *Op = Root; + ACPI_PARSE2_OBJECT *Method; + ACPI_PARSE_OBJECT *SearchOp; + ACPI_PARSE_OBJECT *StartOp; + ACPI_STATUS Status = AE_OK; + UINT32 BaseAmlOffset; + + + AcpiOsPrintf ("Pass two parse ....\n"); + + while (Op) + { + if (Op->Opcode == AML_METHOD_OP) + { + Method = (ACPI_PARSE2_OBJECT *) Op; + Status = AcpiPsParseAml (Op, Method->Data, Method->Length, 0, + NULL, NULL, NULL, AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + + + BaseAmlOffset = (Method->Value.Arg)->AmlOffset + 1; + StartOp = (Method->Value.Arg)->Next; + SearchOp = StartOp; + + while (SearchOp) + { + SearchOp->AmlOffset += BaseAmlOffset; + SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp); + } + + } + + if (Op->Opcode == 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)) + { + return (Status); + } + + Op = AcpiPsGetDepthNext (Root, Op); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbLocalNsLookup + * + * PARAMETERS: Name - Name to lookup + * + * RETURN: Pointer to a namespace node + * + * DESCRIPTION: Lookup a name in the ACPI namespace + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + NATIVE_CHAR *Name) +{ + NATIVE_CHAR *InternalPath; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + + + AcpiDbPrepNamestring (Name); + + /* Build an internal namestring */ + + Status = AcpiNsInternalizeName (Name, &InternalPath); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Invalid namestring: %s\n", Name); + return (NULL); + } + + /* Lookup the name */ + + /* TBD: [Investigate] what scope do we use? */ + /* Use the root scope for the start of the search */ + + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not locate name: %s %s\n", Name, AcpiCmFormatException (Status)); + } + + + AcpiCmFree (InternalPath); + + return (Node); +} + + +#endif /* ENABLE_DEBUGGER */ + + diff --git a/sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c b/sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c new file mode 100644 index 0000000..19cfafb --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Debugger/dbxface.c @@ -0,0 +1,432 @@ +/******************************************************************************* + * + * Module Name: dbxface - AML Debugger external interfaces + * $Revision: 31 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSingleStep + * + * PARAMETERS: WalkState - Current walk + * Op - Current executing op + * OpType - Type 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, + UINT8 OpType) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_STATUS Status = AE_OK; + UINT32 OriginalDebugLevel; + ACPI_PARSE_OBJECT *DisplayOp; + + + /* Is there a breakpoint set? */ + + if (WalkState->MethodBreakpoint) + { + /* Check if the breakpoint has been reached or passed */ + + if (WalkState->MethodBreakpoint <= Op->AmlOffset) + { + /* Hit the breakpoint, resume single step, reset breakpoint */ + + AcpiOsPrintf ("***Break*** at AML offset 0x%X\n", Op->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->Opcode == AML_NAMEDFIELD_OP) + { + return (AE_OK); + } + + switch (OpType) + { + case OPTYPE_UNDEFINED: + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + return (AE_OK); + break; + + case OPTYPE_NAMED_OBJECT: + switch (Op->Opcode) + { + case AML_NAMEPATH_OP: + return (AE_OK); + break; + } + } + + + /* + * Under certain debug conditions, display this opcode and its operands + */ + + if ((OutputToFile) || + (AcpiGbl_CmSingleStep) || + (AcpiDbgLevel & TRACE_PARSE)) + { + if ((OutputToFile) || + (AcpiDbgLevel & TRACE_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 &= ~(TRACE_PARSE | TRACE_FUNCTIONS); + Next = Op->Next; + Op->Next = NULL; + + + DisplayOp = Op; + if (Op->Parent) + { + if ((Op->Parent->Opcode == AML_IF_OP) || + (Op->Parent->Opcode == AML_WHILE_OP)) + { + DisplayOp = Op->Parent; + } + } + + /* Now we can display it */ + + AcpiDbDisplayOp (WalkState, DisplayOp, ACPI_UINT32_MAX); + + if ((Op->Opcode == AML_IF_OP) || + (Op->Opcode == AML_WHILE_OP)) + { + if (WalkState->ControlState->Common.Value) + { + AcpiOsPrintf ("Predicate was TRUE, executed block\n"); + } + else + { + AcpiOsPrintf ("Predicate is FALSE, skipping block\n"); + } + } + + else if (Op->Opcode == AML_ELSE_OP) + { + /* TBD */ + } + + + /* Restore everything */ + + Op->Next = Next; + 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->Opcode != AML_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->Opcode == AML_METHODCALL_OP) + { + AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */ + + /* Set the breakpoint on the call, it will stop execution as soon as we return */ + + /* TBD: [Future] don't kill the user breakpoint! */ + + WalkState->MethodBreakpoint = /* Op->AmlOffset + */ 1; /* Must be non-zero! */ + } + + + /* TBD: [Investigate] what are the namespace locking issues here */ + + /* AcpiCmReleaseMutex (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 */ + + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + } + + else + { + /* Single threaded, we must get a command line ourselves */ + + /* Force output to console until a command is entered */ + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + AcpiOsGetLine (LineBuf); + } + + Status = AcpiDbCommandDispatch (LineBuf, WalkState, Op); + } + + /* AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); */ + + + /* User commands complete, continue execution of the interrupted method */ + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Init and start debugger + * + ******************************************************************************/ + +int +AcpiDbInitialize (void) +{ + + + /* Init globals */ + + Buffer = AcpiOsAllocate (BUFFER_SIZE); + + /* Initial scope is the root */ + + ScopeBuf [0] = '\\'; + ScopeBuf [1] = 0; + + + /* + * 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 */ + + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + + /* Create the debug execution thread to execute commands */ + + AcpiOsQueueForExecution (0, AcpiDbExecuteThread, NULL); + } + + if (!opt_verbose) + { + INDENT_STRING = " "; + opt_disasm = TRUE; + opt_stats = FALSE; + } + + + return (0); +} + + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsfield.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsfield.c new file mode 100644 index 0000000..60e31df --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsfield.c @@ -0,0 +1,546 @@ +/****************************************************************************** + * + * Module Name: dsfield - Dispatcher field routines + * $Revision: 29 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSFIELD_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsfield") + + +/* + * Field flags: Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.) + * 04 : LockRule (1 == Lock) + * 05 - 06 : UpdateRule + */ + +#define FIELD_ACCESS_TYPE_MASK 0x0F +#define FIELD_LOCK_RULE_MASK 0x10 +#define FIELD_UPDATE_RULE_MASK 0x60 + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * + * 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 = AE_AML_ERROR; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *Node; + UINT8 FieldFlags; + UINT8 AccessAttribute = 0; + UINT32 FieldBitPosition = 0; + + + FUNCTION_TRACE_PTR ("DsCreateField", Op); + + + /* First arg is the name of the parent OpRegion */ + + Arg = Op->Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name, + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, WalkState, + &RegionNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the field flags */ + + Arg = Arg->Next; + FieldFlags = (UINT8) Arg->Value.Integer; + + /* Each remaining arg is a Named Field */ + + Arg = Arg->Next; + while (Arg) + { + switch (Arg->Opcode) + { + case AML_RESERVEDFIELD_OP: + + FieldBitPosition += Arg->Value.Size; + break; + + + case AML_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute for all + * entries (until end or another AccessAs keyword) + */ + + AccessAttribute = (UINT8) Arg->Value.Integer; + FieldFlags = (UINT8) + ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || + ((UINT8) (Arg->Value.Integer >> 8))); + break; + + + case AML_NAMEDFIELD_OP: + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, + INTERNAL_TYPE_DEF_FIELD, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize an object for the new Node that is on + * the object stack + */ + + Status = AcpiAmlPrepDefFieldValue (Node, RegionNode, FieldFlags, + AccessAttribute, FieldBitPosition, Arg->Value.Size); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Keep track of bit position for *next* field */ + + FieldBitPosition += Arg->Value.Size; + break; + } + + Arg = Arg->Next; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBankField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * + * 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 = AE_AML_ERROR; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *RegisterNode; + ACPI_NAMESPACE_NODE *Node; + UINT32 BankValue; + UINT8 FieldFlags; + UINT8 AccessAttribute = 0; + UINT32 FieldBitPosition = 0; + + + FUNCTION_TRACE_PTR ("DsCreateBankField", Op); + + + /* First arg is the name of the parent OpRegion */ + + Arg = Op->Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name, + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, WalkState, + &RegionNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the Bank Register */ + + Arg = Arg->Next; + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, + INTERNAL_TYPE_BANK_FIELD_DEFN, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &RegisterNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Third arg is the BankValue */ + + Arg = Arg->Next; + BankValue = Arg->Value.Integer; + + + /* Next arg is the field flags */ + + Arg = Arg->Next; + FieldFlags = (UINT8) Arg->Value.Integer; + + /* Each remaining arg is a Named Field */ + + Arg = Arg->Next; + while (Arg) + { + switch (Arg->Opcode) + { + case AML_RESERVEDFIELD_OP: + + FieldBitPosition += Arg->Value.Size; + break; + + + case AML_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute for + * all entries (until end or another AccessAs keyword) + */ + + AccessAttribute = (UINT8) Arg->Value.Integer; + FieldFlags = (UINT8) + ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || + ((UINT8) (Arg->Value.Integer >> 8))); + break; + + + case AML_NAMEDFIELD_OP: + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, + INTERNAL_TYPE_DEF_FIELD, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize an object for the new Node that is on + * the object stack + */ + + Status = AcpiAmlPrepBankFieldValue (Node, RegionNode, RegisterNode, + BankValue, FieldFlags, AccessAttribute, + FieldBitPosition, Arg->Value.Size); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Keep track of bit position for the *next* field */ + + FieldBitPosition += Arg->Value.Size; + break; + + } + + Arg = Arg->Next; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateIndexField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * + * RETURN: Status + * + * DESCRIPTION: Create a new index field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *IndexRegisterNode; + ACPI_NAMESPACE_NODE *DataRegisterNode; + UINT8 FieldFlags; + UINT8 AccessAttribute = 0; + UINT32 FieldBitPosition = 0; + + + FUNCTION_TRACE_PTR ("DsCreateIndexField", Op); + + + Arg = Op->Value.Arg; + + /* First arg is the name of the Index register */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, + ACPI_TYPE_ANY, IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &IndexRegisterNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Second arg is the data register */ + + Arg = Arg->Next; + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, + INTERNAL_TYPE_INDEX_FIELD_DEFN, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &DataRegisterNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Next arg is the field flags */ + + Arg = Arg->Next; + FieldFlags = (UINT8) Arg->Value.Integer; + + + /* Each remaining arg is a Named Field */ + + Arg = Arg->Next; + while (Arg) + { + switch (Arg->Opcode) + { + case AML_RESERVEDFIELD_OP: + + FieldBitPosition += Arg->Value.Size; + break; + + + case AML_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute for all + * entries (until end or another AccessAs keyword) + */ + + AccessAttribute = (UINT8) Arg->Value.Integer; + FieldFlags = (UINT8) + ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || + ((UINT8) (Arg->Value.Integer >> 8))); + break; + + + case AML_NAMEDFIELD_OP: + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, + INTERNAL_TYPE_INDEX_FIELD, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize an object for the new Node that is on + * the object stack + */ + + Status = AcpiAmlPrepIndexFieldValue (Node, IndexRegisterNode, DataRegisterNode, + FieldFlags, AccessAttribute, + FieldBitPosition, Arg->Value.Size); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Keep track of bit position for the *next* field */ + + FieldBitPosition += Arg->Value.Size; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("DsEnterIndexField: Invalid opcode in field list: %X\n", + Arg->Opcode)); + Status = AE_AML_ERROR; + break; + } + + Arg = Arg->Next; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmethod.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmethod.c new file mode 100644 index 0000000..98a4ed5 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmethod.c @@ -0,0 +1,644 @@ +/****************************************************************************** + * + * Module Name: dsmethod - Parser/Interpreter interface - control method parsing + * $Revision: 52 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMETHOD_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acdebug.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsmethod") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsParseMethod + * + * PARAMETERS: ObjHandle - Node of the method + * Level - Current nesting level + * Context - Points to a method counter + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Call the parser and parse the AML that is + * associated with the method. + * + * MUTEX: Assumes parser is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsParseMethod ( + ACPI_HANDLE ObjHandle) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *Op; + ACPI_NAMESPACE_NODE *Node; + ACPI_OWNER_ID OwnerId; + + + FUNCTION_TRACE_PTR ("DsParseMethod", ObjHandle); + + + /* Parameter Validation */ + + if (!ObjHandle) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + DEBUG_PRINT (ACPI_INFO, + ("DsParseMethod: **** Parsing [%4.4s] **** NamedObj=%p\n", + &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name, ObjHandle)); + + + /* Extract the method object from the method Node */ + + Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ObjDesc = Node->Object; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Create a mutex for the method if there is a concurrency limit */ + + if ((ObjDesc->Method.Concurrency != INFINITE_CONCURRENCY) && + (!ObjDesc->Method.Semaphore)) + { + Status = AcpiOsCreateSemaphore (1,ObjDesc->Method.Concurrency, + &ObjDesc->Method.Semaphore); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Allocate a new parser op to be the root of the parsed + * method tree + */ + + Op = AcpiPsAllocOp (AML_METHOD_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init new op with the method name and pointer back to the Node */ + + AcpiPsSetName (Op, Node->Name); + Op->Node = Node; + + + /* + * Parse the method, first pass + * + * The first pass load is + * where newly declared named objects are + * added into the namespace. Actual evaluation of + * the named objects (what would be called a "second + * pass") happens during the actual execution of the + * method so that operands to the named objects can + * take on dynamic run-time values. + */ + + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + Node, NULL, NULL, + AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get a new OwnerId for objects created by this method */ + + OwnerId = AcpiCmAllocateOwnerId (OWNER_TYPE_METHOD); + ObjDesc->Method.OwningId = OwnerId; + + DEBUG_PRINT (ACPI_INFO, + ("DsParseMethod: **** [%4.4s] Parsed **** NamedObj=%p Op=%p\n", + &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name, ObjHandle, Op)); + + /* Install the parsed tree in the method object */ + /* TBD: [Restructure] Obsolete field? */ + + AcpiPsDeleteParseTree (Op); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBeginMethodExecution + * + * PARAMETERS: MethodNode - Node of the method + * ObjDesc - The method object + * + * RETURN: Status + * + * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, + * increments the thread count, and waits at the method semaphore + * for clearance to execute. + * + * MUTEX: Locks/unlocks parser. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("DsBeginMethodExecution", MethodNode); + + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + + /* + * If there is a concurrency limit on this method, we need to + * obtain a unit from the method semaphore. This releases the + * interpreter if we block + */ + + if (ObjDesc->Method.Semaphore) + { + Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Method.Semaphore, + WAIT_FOREVER); + } + + + /* + * Increment the method parse tree thread count since there + * is one additional thread executing in it. If configured + * for deletion-on-exit, the parse tree will be deleted when + * the last thread completes execution of the method + */ + + ObjDesc->Method.ThreadCount++; + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCallControlMethod + * + * PARAMETERS: WalkState - Current state of the walk + * Op - Current Op to be walked + * + * RETURN: Status + * + * DESCRIPTION: Transfer execution to a called control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_WALK_LIST *WalkList, + ACPI_WALK_STATE *ThisWalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_WALK_STATE *NextWalkState; + ACPI_PARSE_STATE *ParserState; + UINT32 i; + + + FUNCTION_TRACE_PTR ("DsCallControlMethod", ThisWalkState); + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCall, execute method %p, currentstate=%p\n", + ThisWalkState->PrevOp, ThisWalkState)); + + /* + * Get the namespace entry for the control method we are about to call + */ + + MethodNode = ThisWalkState->MethodCallNode; + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Create and initialize a new parser state */ + + ParserState = AcpiPsCreateState (ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength); + if (!ParserState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiPsInitScope (ParserState, NULL); + ParserState->StartNode = MethodNode; + + + /* Create a new state for the preempting walk */ + + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, + NULL, ObjDesc, WalkList); + if (!NextWalkState) + { + /* TBD: delete parser state */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NextWalkState->WalkType = WALK_METHOD; + NextWalkState->MethodNode = MethodNode; + NextWalkState->ParserState = ParserState; + NextWalkState->ParseFlags = ThisWalkState->ParseFlags; + NextWalkState->DescendingCallback = ThisWalkState->DescendingCallback; + NextWalkState->AscendingCallback = ThisWalkState->AscendingCallback; + + /* The NextOp of the NextWalk will be the beginning of the method */ + /* TBD: [Restructure] -- obsolete? */ + + NextWalkState->NextOp = NULL; + + /* Open a new scope */ + + Status = AcpiDsScopeStackPush (MethodNode, + ACPI_TYPE_METHOD, NextWalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* + * Initialize the arguments for the method. 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. + */ + + Status = AcpiDsMethodDataInitArgs (&ThisWalkState->Operands[0], + ThisWalkState->NumOperands, + NextWalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + MethodNode, NULL, NULL, + AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + AcpiPsDeleteParseTree (Op); + + + /* + * Delete the operands on the previous walkstate operand stack + * (they were copied to new objects) + */ + + for (i = 0; i < ObjDesc->Method.ParamCount; i++) + { + AcpiCmRemoveReference (ThisWalkState->Operands [i]); + ThisWalkState->Operands [i] = NULL; + } + + /* Clear the operand stack */ + + ThisWalkState->NumOperands = 0; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCall, starting nested execution, newstate=%p\n", NextWalkState)); + + return_ACPI_STATUS (AE_OK); + + + /* On error, we must delete the new walk state */ + +Cleanup: + AcpiDsTerminateControlMethod (NextWalkState); + AcpiDsDeleteWalkState (NextWalkState); + return_ACPI_STATUS (Status); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsRestartControlMethod + * + * PARAMETERS: WalkState - State of the method when it was preempted + * Op - Pointer to new current op + * + * RETURN: Status + * + * DESCRIPTION: Restart a method that was preempted + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("DsRestartControlMethod", WalkState); + + + if (ReturnDesc) + { + if (WalkState->ReturnUsed) + { + /* + * Get the return value (if any) from the previous method. + * NULL if no return value + */ + + Status = AcpiDsResultStackPush (ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ReturnDesc); + return_ACPI_STATUS (Status); + } + } + + else + { + /* + * Delete the return value if it will not be used by the + * calling method + */ + AcpiCmRemoveReference (ReturnDesc); + } + + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsRestart: Method=%p Return=%p State=%p\n", + WalkState->MethodCallOp, ReturnDesc, WalkState)); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsTerminateControlMethod + * + * PARAMETERS: WalkState - State of the method + * + * RETURN: Status + * + * DESCRIPTION: Terminate a control method. Delete everything that the method + * created, delete all locals and arguments, and delete the parse + * tree if requested. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsTerminateControlMethod ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *MethodNode; + + + FUNCTION_TRACE_PTR ("DsTerminateControlMethod", WalkState); + + + /* The method object should be stored in the walk state */ + + ObjDesc = WalkState->MethodDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* Delete all arguments and locals */ + + AcpiDsMethodDataDeleteAll (WalkState); + + /* + * Lock the parser while we terminate this method. + * If this is the last thread executing the method, + * we have additional cleanup to perform + */ + + AcpiCmAcquireMutex (ACPI_MTX_PARSER); + + + /* Signal completion of the execution of this method if necessary */ + + if (WalkState->MethodDesc->Method.Semaphore) + { + Status = AcpiOsSignalSemaphore ( + WalkState->MethodDesc->Method.Semaphore, 1); + } + + /* Decrement the thread count on the method parse tree */ + + WalkState->MethodDesc->Method.ThreadCount--; + if (!WalkState->MethodDesc->Method.ThreadCount) + { + /* + * There are no more threads executing this method. Perform + * additional cleanup. + * + * The method Node is stored in the walk state + */ + MethodNode = WalkState->MethodNode; + /* + * Delete any namespace entries created immediately underneath + * the method + */ + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + if (MethodNode->Child) + { + AcpiNsDeleteNamespaceSubtree (MethodNode); + } + + /* + * Delete any namespace entries created anywhere else within + * the namespace + */ + AcpiNsDeleteNamespaceByOwner (WalkState->MethodDesc->Method.OwningId); + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + AcpiCmReleaseMutex (ACPI_MTX_PARSER); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmthdat.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmthdat.c new file mode 100644 index 0000000..e6b5cec --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsmthdat.c @@ -0,0 +1,882 @@ +/******************************************************************************* + * + * Module Name: dsmthdat - control method arguments and local variables + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMTHDAT_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsmthdat") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInit + * + * PARAMETERS: *ObjDesc + * + * RETURN: Status + * + * DESCRIPTION: Initialize the data structures that hold the method's arguments + * and locals. The data struct is an array of NTEs for each. + * This allows RefOf and DeRefOf to work properly for these + * special data types. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + FUNCTION_TRACE ("DsMethodDataInit"); + + /* + * WalkState fields are initialized to zero by the + * AcpiCmCallocate(). + * + * An Node is assigned to each argument and local so + * that RefOf() can return a pointer to the Node. + */ + + /* Init the method arguments */ + + for (i = 0; i < MTH_NUM_ARGS; i++) + { + MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, + NAMEOF_ARG_NTE); + + WalkState->Arguments[i].Name |= (i << 24); + WalkState->Arguments[i].DataType = ACPI_DESC_TYPE_NAMED; + WalkState->Arguments[i].Type = INTERNAL_TYPE_METHOD_ARGUMENT; + } + + /* Init the method locals */ + + for (i = 0; i < MTH_NUM_LOCALS; i++) + { + MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name, + NAMEOF_LOCAL_NTE); + + WalkState->LocalVariables[i].Name |= (i << 24); + WalkState->LocalVariables[i].DataType = ACPI_DESC_TYPE_NAMED; + WalkState->LocalVariables[i].Type = INTERNAL_TYPE_METHOD_LOCAL_VAR; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteAll + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Delete method locals and arguments. Arguments are only + * deleted if this method was called from another method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataDeleteAll"); + + + /* Delete the locals */ + + DEBUG_PRINT (ACPI_INFO, + ("MethodDeleteAll: Deleting local variables in %p\n", WalkState)); + + for (Index = 0; Index < MTH_NUM_LOCALS; Index++) + { + Object = WalkState->LocalVariables[Index].Object; + if (Object) + { + DEBUG_PRINT (TRACE_EXEC, + ("MethodDeleteAll: Deleting Local%d=%p\n", Index, Object)); + + /* Remove first */ + + WalkState->LocalVariables[Index].Object = NULL; + + /* Was given a ref when stored */ + + AcpiCmRemoveReference (Object); + } + } + + + /* Delete the arguments */ + + DEBUG_PRINT (ACPI_INFO, + ("MethodDeleteAll: Deleting arguments in %p\n", WalkState)); + + for (Index = 0; Index < MTH_NUM_ARGS; Index++) + { + Object = WalkState->Arguments[Index].Object; + if (Object) + { + DEBUG_PRINT (TRACE_EXEC, + ("MethodDeleteAll: Deleting Arg%d=%p\n", Index, Object)); + + /* Remove first */ + + WalkState->Arguments[Index].Object = NULL; + + /* Was given a ref when stored */ + + AcpiCmRemoveReference (Object); + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInitArgs + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize arguments for a method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + UINT32 Mindex; + UINT32 Pindex; + + + FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); + + + if (!Params) + { + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataInitArgs: No param list passed to method\n")); + return_ACPI_STATUS (AE_OK); + } + + /* Copy passed parameters into the new method stack frame */ + + for (Pindex = Mindex = 0; + (Mindex < MTH_NUM_ARGS) && (Pindex < MaxParamCount); + Mindex++) + { + if (Params[Pindex]) + { + /* + * A valid parameter. + * Set the current method argument to the + * Params[Pindex++] argument object descriptor + */ + Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG, Mindex, + Params[Pindex], WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + Pindex++; + } + + else + { + break; + } + } + + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataInitArgs: %d args passed to method\n", Pindex)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetEntry + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to get + * Entry - Pointer to where a pointer to the stack + * entry is returned. + * + * RETURN: Status + * + * DESCRIPTION: Get the address of the stack entry given by Type:Index + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT ***Entry) +{ + + FUNCTION_TRACE_U32 ("DsMethodDataGetEntry", Index); + + + /* + * Get the requested object. + * The stack "Type" is either a LocalVariable or an Argument + */ + + switch (Type) + { + + case MTH_TYPE_LOCAL: + + if (Index > MTH_MAX_LOCAL) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: LocalVar index %d is invalid (max %d)\n", + Index, MTH_MAX_LOCAL)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + *Entry = + (ACPI_OPERAND_OBJECT **) &WalkState->LocalVariables[Index].Object; + break; + + + case MTH_TYPE_ARG: + + if (Index > MTH_MAX_ARG) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Argument index %d is invalid (max %d)\n", + Index, MTH_MAX_ARG)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + *Entry = + (ACPI_OPERAND_OBJECT **) &WalkState->Arguments[Index].Object; + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Stack type %d is invalid\n", + Type)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataSetEntry + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to get + * Object - Object to be inserted into the stack entry + * + * RETURN: Status + * + * DESCRIPTION: Insert an object onto the method stack at entry Type:Index. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataSetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + + + FUNCTION_TRACE ("DsMethodDataSetEntry"); + + /* Get a pointer to the stack entry to set */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Increment ref count so object can't be deleted while installed */ + + AcpiCmAddReference (Object); + + /* Install the object into the stack entry */ + + *Entry = Object; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetType + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument whose type + * to get + * + * RETURN: Data type of selected Arg or Local + * Used only in ExecMonadic2()/TypeOp. + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDsMethodDataGetType ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataGetType"); + + + /* Get a pointer to the requested stack entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_VALUE ((ACPI_TYPE_NOT_FOUND)); + } + + /* Get the object from the method stack */ + + Object = *Entry; + + /* Get the object type */ + + if (!Object) + { + /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */ + return_VALUE (ACPI_TYPE_ANY); + } + + return_VALUE (Object->Common.Type); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetNte + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument whose type + * to get + * + * RETURN: Get the Node associated with a local or arg. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiDsMethodDataGetNte ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_NAMESPACE_NODE *Node = NULL; + + + FUNCTION_TRACE ("DsMethodDataGetNte"); + + + switch (Type) + { + + case MTH_TYPE_LOCAL: + + if (Index > MTH_MAX_LOCAL) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: LocalVar index %d is invalid (max %d)\n", + Index, MTH_MAX_LOCAL)); + return_PTR (Node); + } + + Node = &WalkState->LocalVariables[Index]; + break; + + + case MTH_TYPE_ARG: + + if (Index > MTH_MAX_ARG) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Argument index %d is invalid (max %d)\n", + Index, MTH_MAX_ARG)); + return_PTR (Node); + } + + Node = &WalkState->Arguments[Index]; + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Stack type %d is invalid\n", + Type)); + break; + } + + + return_PTR (Node); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetValue + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to get + * *DestDesc - Descriptor into which selected Arg + * or Local value should be copied + * + * RETURN: Status + * + * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame + * at the current top of the method stack. + * Used only in AcpiAmlResolveToValue(). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataGetValue"); + + + /* Validate the object descriptor */ + + if (!DestDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetValue: NULL object descriptor pointer\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the requested method stack entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the object from the method stack */ + + Object = *Entry; + + + /* Examine the returned object, it must be valid. */ + + if (!Object) + { + /* + * Index points to uninitialized object stack value. + * This means that either 1) The expected argument was + * not passed to the method, or 2) A local variable + * was referenced by the method (via the ASL) + * before it was initialized. Either case is an error. + */ + + switch (Type) + { + case MTH_TYPE_ARG: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetValue: Uninitialized Arg[%d] at entry %X\n", + Index, Entry)); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); + break; + + case MTH_TYPE_LOCAL: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetValue: Uninitialized Local[%d] at entry %X\n", + Index, Entry)); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); + break; + } + } + + + /* + * Index points to initialized and valid object stack value. + * Return an additional reference to the object + */ + + *DestDesc = Object; + AcpiCmAddReference (Object); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteValue + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to delete + * + * RETURN: Status + * + * DESCRIPTION: Delete the entry at Type:Index on the method stack. Inserts + * a null into the stack slot after the object is deleted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataDeleteValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataDeleteValue"); + + + /* Get a pointer to the requested entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the current entry in this slot k */ + + Object = *Entry; + + /* + * Undefine the Arg or Local by setting its descriptor + * pointer to NULL. Locals/Args can contain both + * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs + */ + *Entry = NULL; + + + if ((Object) && + (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL))) + { + /* + * There is a valid object in this slot + * Decrement the reference count by one to balance the + * increment when the object was stored in the slot. + */ + + AcpiCmRemoveReference (Object); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataSetValue + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to set + * *SrcDesc - Value to be stored + * *DestDesc - Descriptor into which *SrcDesc + * can be copied, or NULL if one must + * be allocated for the purpose. If + * provided, this descriptor will be + * used for the new value. + * + * RETURN: Status + * + * DESCRIPTION: Store a value in an Arg or Local. The SrcDesc is installed + * as the new value for the Arg or Local and the reference count + * is incremented. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + + + FUNCTION_TRACE ("DsMethodDataSetValue"); + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataSetValue: Type=%d Idx=%d Obj=%p\n", + Type, Index, SrcDesc)); + + + /* Parameter validation */ + + if (!SrcDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the requested method stack entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (*Entry == SrcDesc) + { + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataSetValue: Obj=%p already installed!\n", + SrcDesc)); + goto Cleanup; + } + + + /* + * 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 (*Entry) + { + /* + * 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 == MTH_TYPE_ARG) && + (VALID_DESCRIPTOR_TYPE (*Entry, ACPI_DESC_TYPE_NAMED))) + { + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataSetValue: Arg (%p) is an ObjRef(Node), storing in %p\n", + SrcDesc, *Entry)); + + /* Detach an existing object from the Node */ + + AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) *Entry); + + /* + * Store this object into the Node + * (do the indirect store) + */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) *Entry, SrcDesc, + SrcDesc->Common.Type); + return_ACPI_STATUS (Status); + } + + + /* + * Otherwise, just delete the existing object + * before storing the new one + */ + + AcpiDsMethodDataDeleteValue (Type, Index, WalkState); + } + + + /* + * Install the ObjStack descriptor (*SrcDesc) into + * the descriptor for the Arg or Local. + * Install the new object in the stack entry + * (increments the object reference count by one) + */ + + Status = AcpiDsMethodDataSetEntry (Type, Index, SrcDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + + + /* Error exit */ + +Cleanup: + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c new file mode 100644 index 0000000..71cb151 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c @@ -0,0 +1,805 @@ +/****************************************************************************** + * + * Module Name: dsobject - Dispatcher object management routines + * $Revision: 48 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOBJECT_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsobject") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitOneObject + * + * PARAMETERS: ObjHandle - Node + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Op Regions + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + OBJECT_TYPE_INTERNAL Type; + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + + + Info->ObjectCount++; + + /* + * We are only interested in objects owned by the table that + * was just loaded + */ + + if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId != + Info->TableDesc->TableId) + { + return (AE_OK); + } + + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + + switch (Type) + { + + case ACPI_TYPE_REGION: + + AcpiDsInitializeRegion (ObjHandle); + + Info->OpRegionCount++; + break; + + + case ACPI_TYPE_METHOD: + + Info->MethodCount++; + + DEBUG_PRINT_RAW (ACPI_OK, (".")); + + + /* + * Always parse methods to detect errors, we may delete + * the parse tree below + */ + + Status = AcpiDsParseMethod (ObjHandle); + + /* TBD: [Errors] what do we do with an error? */ + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsInitOneObject: Method %p [%4.4s] parse failed! %s\n", + ObjHandle, &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name, + AcpiCmFormatException (Status))); + break; + } + + /* + * Keep the parse tree only if we are parsing all methods + * at init time (versus just-in-time) + */ + + if (AcpiGbl_WhenToParseMethods != METHOD_PARSE_AT_INIT) + { + AcpiNsDeleteNamespaceSubtree (ObjHandle); + } + + 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: None + * + * RETURN: Status + * + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeObjects ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + + + FUNCTION_TRACE ("DsInitializeObjects"); + + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsInitializeObjects: **** Starting initialization of namespace objects ****\n")); + DEBUG_PRINT_RAW (ACPI_OK, ("Parsing Methods:")); + + + Info.MethodCount = 0; + Info.OpRegionCount = 0; + Info.ObjectCount = 0; + Info.TableDesc = TableDesc; + + + /* Walk entire namespace from the supplied root */ + + Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, + ACPI_UINT32_MAX, AcpiDsInitOneObject, + &Info, NULL); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsInitializeObjects: WalkNamespace failed! %x\n", Status)); + } + + DEBUG_PRINT_RAW (ACPI_OK, + ("\n%d Control Methods found and parsed (%d nodes total)\n", + Info.MethodCount, Info.ObjectCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("DsInitializeObjects: %d Control Methods found\n", Info.MethodCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("DsInitializeObjects: %d Op Regions found\n", Info.OpRegionCount)); + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsInitObjectFromOp + * + * PARAMETERS: Op - Parser op used to init the internal object + * Opcode - AML opcode associated with the object + * ObjDesc - 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 **ObjDesc) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE2_OBJECT *ByteList; + ACPI_OPERAND_OBJECT *ArgDesc; + ACPI_OPCODE_INFO *OpInfo; + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Unknown opcode */ + + return (AE_TYPE); + } + + + /* Get and prepare the first argument */ + + switch ((*ObjDesc)->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* First arg is a number */ + + AcpiDsCreateOperand (WalkState, Op->Value.Arg); + ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; + AcpiDsObjStackPop (1, WalkState); + + /* Resolve the object (could be an arg or local) */ + + Status = AcpiAmlResolveToValue (&ArgDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ArgDesc); + return (Status); + } + + /* We are expecting a number */ + + if (ArgDesc->Common.Type != ACPI_TYPE_NUMBER) + { + DEBUG_PRINT (ACPI_ERROR, + ("InitObject: Expecting number, got obj: %p type %X\n", + ArgDesc, ArgDesc->Common.Type)); + AcpiCmRemoveReference (ArgDesc); + return (AE_TYPE); + } + + /* Get the value, delete the internal object */ + + (*ObjDesc)->Buffer.Length = (UINT32) ArgDesc->Number.Value; + AcpiCmRemoveReference (ArgDesc); + + /* Allocate the buffer */ + + if ((*ObjDesc)->Buffer.Length == 0) + { + (*ObjDesc)->Buffer.Pointer = NULL; + REPORT_WARNING (("Buffer created with zero length in AML\n")); + break; + } + + else + { + (*ObjDesc)->Buffer.Pointer = + AcpiCmCallocate ((*ObjDesc)->Buffer.Length); + + if (!(*ObjDesc)->Buffer.Pointer) + { + return (AE_NO_MEMORY); + } + } + + /* + * Second arg is the buffer data (optional) + * ByteList can be either individual bytes or a + * string initializer! + */ + + /* skip first arg */ + Arg = Op->Value.Arg; + ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next; + if (ByteList) + { + if (ByteList->Opcode != AML_BYTELIST_OP) + { + DEBUG_PRINT (ACPI_ERROR, + ("InitObject: Expecting bytelist, got: %x\n", + ByteList)); + return (AE_TYPE); + } + + MEMCPY ((*ObjDesc)->Buffer.Pointer, ByteList->Data, + (*ObjDesc)->Buffer.Length); + } + + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * When called, an internal package object has already + * been built and is pointed to by *ObjDesc. + * AcpiDsBuildInternalObject build another internal + * package object, so remove reference to the original + * so that it is deleted. Error checking is done + * within the remove reference function. + */ + AcpiCmRemoveReference(*ObjDesc); + + Status = AcpiDsBuildInternalObject (WalkState, Op, ObjDesc); + break; + + case ACPI_TYPE_NUMBER: + (*ObjDesc)->Number.Value = Op->Value.Integer; + break; + + + case ACPI_TYPE_STRING: + (*ObjDesc)->String.Pointer = Op->Value.String; + (*ObjDesc)->String.Length = STRLEN (Op->Value.String); + break; + + + case ACPI_TYPE_METHOD: + break; + + + case INTERNAL_TYPE_REFERENCE: + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + case OPTYPE_LOCAL_VARIABLE: + + /* Split the opcode into a base opcode + offset */ + + (*ObjDesc)->Reference.OpCode = AML_LOCAL_OP; + (*ObjDesc)->Reference.Offset = Opcode - AML_LOCAL_OP; + break; + + case OPTYPE_METHOD_ARGUMENT: + + /* Split the opcode into a base opcode + offset */ + + (*ObjDesc)->Reference.OpCode = AML_ARG_OP; + (*ObjDesc)->Reference.Offset = Opcode - AML_ARG_OP; + break; + + default: /* Constants, Literals, etc.. */ + + if (Op->Opcode == AML_NAMEPATH_OP) + { + /* Node was saved in Op */ + + (*ObjDesc)->Reference.Node = Op->Node; + } + + (*ObjDesc)->Reference.OpCode = Opcode; + break; + } + + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("InitObject: Unimplemented data type: %x\n", + (*ObjDesc)->Common.Type)); + + break; + } + + return (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsBuildInternalSimpleObj + * + * PARAMETERS: Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op object to the equivalent namespace object + * Simple objects are any objects other than a package object! + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalSimpleObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + OBJECT_TYPE_INTERNAL Type; + ACPI_STATUS Status; + UINT32 Length; + char *Name; + + + FUNCTION_TRACE ("DsBuildInternalSimpleObj"); + + + if (Op->Opcode == AML_NAMEPATH_OP) + { + /* + * This is an object reference. If The name was + * previously looked up in the NS, it is stored in this op. + * Otherwise, go ahead and look it up now + */ + + if (!Op->Node) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + Op->Value.String, ACPI_TYPE_ANY, + IMODE_EXECUTE, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, + NULL, + (ACPI_NAMESPACE_NODE **)&(Op->Node)); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + Name = NULL; + AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Value.String, &Length, &Name); + + if (Name) + { + REPORT_WARNING (("Reference %s AML 0x%X not found\n", + Name, Op->AmlOffset)); + AcpiCmFree (Name); + } + else + { + REPORT_WARNING (("Reference %s AML 0x%X not found\n", + Op->Value.String, Op->AmlOffset)); + } + *ObjDescPtr = NULL; + return_ACPI_STATUS (AE_OK); + } + + return_ACPI_STATUS (Status); + } + } + + /* + * The reference will be a Reference + * TBD: [Restructure] unless we really need a separate + * type of INTERNAL_TYPE_REFERENCE change + * AcpiDsMapOpcodeToDataType to handle this case + */ + Type = INTERNAL_TYPE_REFERENCE; + } + else + { + Type = AcpiDsMapOpcodeToDataType (Op->Opcode, NULL); + } + + + /* Create and init the internal ACPI object */ + + ObjDesc = AcpiCmCreateInternalObject (Type); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiDsInitObjectFromOp (WalkState, Op, + Op->Opcode, &ObjDesc); + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); + } + + *ObjDescPtr = ObjDesc; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsBuildInternalPackageObj + * + * PARAMETERS: Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("DsBuildInternalPackageObj"); + + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* The first argument must be the package length */ + + Arg = Op->Value.Arg; + ObjDesc->Package.Count = Arg->Value.Integer; + + /* + * Allocate the array of pointers (ptrs to the + * individual objects) Add an extra pointer slot so + * that the list is always null terminated. + */ + + ObjDesc->Package.Elements = + AcpiCmCallocate ((ObjDesc->Package.Count + 1) * + sizeof (void *)); + + if (!ObjDesc->Package.Elements) + { + /* Package vector allocation failure */ + + REPORT_ERROR (("DsBuildInternalPackageObj: Package vector allocation failure\n")); + + AcpiCmDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.NextElement = ObjDesc->Package.Elements; + + /* + * Now init the elements of the package + */ + + Arg = Arg->Next; + while (Arg) + { + if (Arg->Opcode == AML_PACKAGE_OP) + { + Status = AcpiDsBuildInternalPackageObj (WalkState, Arg, + ObjDesc->Package.NextElement); + } + + else + { + Status = AcpiDsBuildInternalSimpleObj (WalkState, Arg, + ObjDesc->Package.NextElement); + } + + ObjDesc->Package.NextElement++; + Arg = Arg->Next; + } + + *ObjDescPtr = ObjDesc; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsBuildInternalObject + * + * PARAMETERS: 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 + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_STATUS Status; + + + if (Op->Opcode == AML_PACKAGE_OP) + { + Status = AcpiDsBuildInternalPackageObj (WalkState, Op, + ObjDescPtr); + } + + else + { + Status = AcpiDsBuildInternalSimpleObj (WalkState, Op, + ObjDescPtr); + } + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsCreateNode + * + * PARAMETERS: Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("DsCreateNode", Op); + + + if (!Op->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->Value.Arg, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Re-type the object according to it's argument */ + + Node->Type = ObjDesc->Common.Type; + + /* Init obj */ + + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) Node->Type); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + return_ACPI_STATUS (Status); + + +Cleanup: + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c new file mode 100644 index 0000000..b3d63c1 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsopcode.c @@ -0,0 +1,1070 @@ +/****************************************************************************** + * + * Module Name: dsopcode - Dispatcher Op Region support and handling of + * "control" opcodes + * $Revision: 21 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOPCODE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsopcode") + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetFieldUnitArguments + * + * PARAMETERS: ObjDesc - A valid FieldUnit object + * + * RETURN: Status. + * + * DESCRIPTION: Get FieldUnit Buffer and Index. This implements the late + * evaluation of these field attributes. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetFieldUnitArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *FieldOp; + ACPI_STATUS Status; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE_PTR ("DsGetFieldUnitArguments", ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + + /* Get the AML pointer (method object) and FieldUnit node */ + + ExtraDesc = ObjDesc->FieldUnit.Extra; + Node = ObjDesc->FieldUnit.Node; + + DEBUG_PRINT (TRACE_EXEC, + ("DsGetFieldUnitArguments: [%4.4s] FieldUnit JIT Init\n", + &Node->Name)); + + + /* + * Allocate a new parser op to be the root of the parsed + * OpRegion tree + */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Save the Node for use in AcpiPsParseAml */ + + Op->Node = AcpiNsGetParentObject (Node); + + /* Get a handle to the parent ACPI table */ + + Status = AcpiTbHandleToObject (Node->OwnerId, &TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Pass1: Parse the entire FieldUnit declaration */ + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, 0, + NULL, NULL, NULL, AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + if (ACPI_FAILURE (Status)) + { + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); + } + + + /* Get and init the actual FielUnitOp created above */ + + FieldOp = Op->Value.Arg; + Op->Node = Node; + + + FieldOp = Op->Value.Arg; + FieldOp->Node = Node; + AcpiPsDeleteParseTree (Op); + + /* AcpiEvaluate the address and length arguments for the OpRegion */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + Op->Node = AcpiNsGetParentObject (Node); + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + NULL /*MethodDesc*/, NULL, NULL, + AcpiDsExecBeginOp, AcpiDsExecEndOp); + /* All done with the parse tree, delete it */ + + AcpiPsDeleteParseTree (Op); + + + /* + * The pseudo-method object is no longer needed since the region is + * now initialized + */ + AcpiCmRemoveReference (ObjDesc->FieldUnit.Extra); + ObjDesc->FieldUnit.Extra = NULL; + + 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_OPERAND_OBJECT *ExtraDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *RegionOp; + ACPI_STATUS Status; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); + + + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + + /* Get the AML pointer (method object) and region node */ + + ExtraDesc = ObjDesc->Region.Extra; + Node = ObjDesc->Region.Node; + + DEBUG_PRINT (TRACE_EXEC, + ("DsGetRegionArguments: [%4.4s] OpRegion JIT Init\n", + &Node->Name)); + + /* + * Allocate a new parser op to be the root of the parsed + * OpRegion tree + */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Save the Node for use in AcpiPsParseAml */ + + Op->Node = AcpiNsGetParentObject (Node); + + /* Get a handle to the parent ACPI table */ + + Status = AcpiTbHandleToObject (Node->OwnerId, &TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Parse the entire OpRegion declaration, creating a parse tree */ + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, 0, + NULL, NULL, NULL, AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + + if (ACPI_FAILURE (Status)) + { + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); + } + + + /* Get and init the actual RegionOp created above */ + + RegionOp = Op->Value.Arg; + Op->Node = Node; + + + RegionOp = Op->Value.Arg; + RegionOp->Node = Node; + AcpiPsDeleteParseTree (Op); + + /* AcpiEvaluate the address and length arguments for the OpRegion */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + Op->Node = AcpiNsGetParentObject (Node); + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + NULL /*MethodDesc*/, NULL, NULL, + AcpiDsExecBeginOp, AcpiDsExecEndOp); + + /* All done with the parse tree, delete it */ + + AcpiPsDeleteParseTree (Op); + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsInitializeRegion + * + * PARAMETERS: Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: + * + ****************************************************************************/ + +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: AcpiDsEvalFieldUnitOperands + * + * PARAMETERS: Op - A valid FieldUnit Op object + * + * RETURN: Status + * + * DESCRIPTION: Get FieldUnit Buffer and Index + * Called from AcpiDsExecEndOp during FieldUnit parse tree walk + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsEvalFieldUnitOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *FieldDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + UINT32 Offset; + UINT32 BitOffset; + UINT16 BitCount; + + + ACPI_OPERAND_OBJECT *ResDesc = NULL; + ACPI_OPERAND_OBJECT *CntDesc = NULL; + ACPI_OPERAND_OBJECT *OffDesc = NULL; + ACPI_OPERAND_OBJECT *SrcDesc = NULL; + UINT32 NumOperands = 3; + + + FUNCTION_TRACE_PTR ("DsEvalFieldUnitOperands", Op); + + + /* + * This is where we evaluate the address and length fields of the OpFieldUnit declaration + */ + + Node = Op->Node; + + /* NextOp points to the op that holds the Buffer */ + NextOp = Op->Value.Arg; + + /* AcpiEvaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + FieldDesc = AcpiNsGetAttachedObject (Node); + if (!FieldDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Op->Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Op->Opcode), + NumOperands, "after AcpiAmlResolveOperands"); + + + /* Get the operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + if (AML_CREATE_FIELD_OP == Op->Opcode) + { + NumOperands = 4; + Status |= AcpiDsObjStackPopObject (&CntDesc, WalkState); + } + + Status |= AcpiDsObjStackPopObject (&OffDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&SrcDesc, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecCreateField/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Op->Opcode), Status)); + + goto Cleanup; + } + + + Offset = (UINT32) OffDesc->Number.Value; + + + /* + * If ResDesc is a Name, it will be a direct name pointer after + * AcpiAmlResolveOperands() + */ + + if (!VALID_DESCRIPTOR_TYPE (ResDesc, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField (%s): destination must be a Node\n", + AcpiPsGetOpcodeName (Op->Opcode))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + + switch (Op->Opcode) + { + + /* DefCreateBitField */ + + case AML_BIT_FIELD_OP: + + /* Offset is in bits, Field is a bit */ + + BitOffset = Offset; + BitCount = 1; + break; + + + /* DefCreateByteField */ + + case AML_BYTE_FIELD_OP: + + /* Offset is in bytes, field is a byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + break; + + + /* DefCreateWordField */ + + case AML_WORD_FIELD_OP: + + /* Offset is in bytes, field is a word */ + + BitOffset = 8 * Offset; + BitCount = 16; + break; + + + /* DefCreateDWordField */ + + case AML_DWORD_FIELD_OP: + + /* Offset is in bytes, field is a dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + break; + + + /* DefCreateField */ + + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + BitOffset = Offset; + BitCount = (UINT16) CntDesc->Number.Value; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Internal error - unknown field creation opcode %02x\n", + Op->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Setup field according to the object type + */ + + switch (SrcDesc->Common.Type) + { + + /* SourceBuff := TermArg=>Buffer */ + + case ACPI_TYPE_BUFFER: + + if (BitOffset + (UINT32) BitCount > + (8 * (UINT32) SrcDesc->Buffer.Length)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Field exceeds Buffer %d > %d\n", + BitOffset + (UINT32) BitCount, + 8 * (UINT32) SrcDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + + /* Construct the remainder of the field object */ + + FieldDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC; + FieldDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK; + FieldDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE; + FieldDesc->FieldUnit.Length = BitCount; + FieldDesc->FieldUnit.BitOffset = (UINT8) (BitOffset % 8); + FieldDesc->FieldUnit.Offset = DIV_8 (BitOffset); + FieldDesc->FieldUnit.Container = SrcDesc; + + /* Reference count for SrcDesc inherits FieldDesc count */ + + SrcDesc->Common.ReferenceCount = (UINT16) (SrcDesc->Common.ReferenceCount + + FieldDesc->Common.ReferenceCount); + + break; + + + /* Improper object type */ + + default: + + if ((SrcDesc->Common.Type > (UINT8) INTERNAL_TYPE_REFERENCE) || + !AcpiCmValidObjectType (SrcDesc->Common.Type)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in invalid object type - 0x%X\n", + SrcDesc->Common.Type)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in improper object type - %s\n", + AcpiCmGetTypeName (SrcDesc->Common.Type))); + } + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + if (AML_CREATE_FIELD_OP == Op->Opcode) + { + /* Delete object descriptor unique to CreateField */ + + AcpiCmRemoveReference (CntDesc); + CntDesc = NULL; + } + + +Cleanup: + + /* Always delete the operands */ + + AcpiCmRemoveReference (OffDesc); + AcpiCmRemoveReference (SrcDesc); + + if (AML_CREATE_FIELD_OP == Op->Opcode) + { + AcpiCmRemoveReference (CntDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); /* Result descriptor */ + } + + else + { + /* Now the address and length are valid for this opFieldUnit */ + + FieldDesc->FieldUnit.Flags |= AOPOBJ_DATA_VALID; + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsEvalRegionOperands + * + * PARAMETERS: 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; + + + FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); + + + /* + * This is where we evaluate the address and length fields of the OpRegion declaration + */ + + Node = Op->Node; + + /* NextOp points to the op that holds the SpaceID */ + NextOp = Op->Value.Arg; + + /* NextOp points to address op */ + NextOp = NextOp->Next; + + /* AcpiEvaluate/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); + } + + /* Get the length and save it */ + + /* Top of stack */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; + + ObjDesc->Region.Length = (UINT32) OperandDesc->Number.Value; + AcpiCmRemoveReference (OperandDesc); + + /* Get the address and save it */ + + /* Top of stack - 1 */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; + + ObjDesc->Region.Address = OperandDesc->Number.Value; + AcpiCmRemoveReference (OperandDesc); + + + DEBUG_PRINT (TRACE_EXEC, + ("DsEvalRegionOperands: RgnObj %p Addr %X Len %X\n", + ObjDesc, 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: 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; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("BeginControlOp: Op=%p Opcode=%2.2X State=%p\n", Op, + Op->Opcode, WalkState)); + + switch (Op->Opcode) + { + case AML_IF_OP: + case AML_WHILE_OP: + + /* + * IF/WHILE: Create a new control state to manage these + * constructs. We need to manage these as a stack, in order + * to handle nesting. + */ + + ControlState = AcpiCmCreateControlState (); + if (!ControlState) + { + Status = AE_NO_MEMORY; + break; + } + + AcpiCmPushGenericState (&WalkState->ControlState, ControlState); + + /* + * Save a pointer to the predicate for multiple executions + * of a loop + */ + WalkState->ControlState->Control.AmlPredicateStart = + WalkState->ParserState->Aml - 1; + /* TBD: can this be removed? */ + /*AcpiPsPkgLengthEncodingSize (GET8 (WalkState->ParserState->Aml));*/ + 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; + + + switch (Op->Opcode) + { + case AML_IF_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [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 = + AcpiCmPopGenericState (&WalkState->ControlState); + + AcpiCmDeleteGenericState (ControlState); + + break; + + + case AML_ELSE_OP: + + break; + + + case AML_WHILE_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [WHILE_OP] Op=%p\n", Op)); + + if (WalkState->ControlState->Common.Value) + { + /* Predicate was true, go back and evaluate it again! */ + + Status = AE_CTRL_PENDING; + } + + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [WHILE_OP] termination! Op=%p\n", Op)); + + /* Pop this control state and free it */ + + ControlState = + AcpiCmPopGenericState (&WalkState->ControlState); + + WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; + AcpiCmDeleteGenericState (ControlState); + + break; + + + case AML_RETURN_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [RETURN_OP] Op=%p Arg=%p\n",Op, Op->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->Value.Arg) + { + /* Return statement has an immediate operand */ + + Status = AcpiDsCreateOperands (WalkState, Op->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 = AcpiAmlResolveToValue (&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->NumResults > 0) + { + /* + * The return value has come from a previous calculation. + * + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + */ + + Status = AcpiAmlResolveToValue (&WalkState->Results [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + WalkState->ReturnDesc = WalkState->Results [0]; + } + + else + { + /* No return operand */ + + if (WalkState->NumOperands) + { + AcpiCmRemoveReference (WalkState->Operands [0]); + } + + WalkState->Operands [0] = NULL; + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; + } + + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: Completed RETURN_OP State=%p, RetVal=%p\n", + WalkState, WalkState->ReturnDesc)); + + /* End the control method execution right now */ + Status = AE_CTRL_TERMINATE; + break; + + + case AML_NOOP_OP: + + /* Just do nothing! */ + break; + + + case AML_BREAK_POINT_OP: + + /* Call up to the OS dependent layer to handle this */ + + AcpiOsBreakpoint (NULL); + + /* If it returns, we are done! */ + + break; + + + case AML_BREAK_OP: + + DEBUG_PRINT (ACPI_INFO, + ("EndControlOp: Break to end of current package, Op=%p\n", Op)); + + /* + * As per the ACPI specification: + * "The break operation causes the current package + * execution to complete" + * "Break -- Stop executing the current code package + * at this point" + * + * Returning AE_FALSE here will cause termination of + * the current package, and execution will continue one + * level up, starting with the completion of the parent Op. + */ + + Status = AE_CTRL_FALSE; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("EndControlOp: Unknown control opcode=%X Op=%p\n", + Op->Opcode, Op)); + + Status = AE_AML_BAD_OPCODE; + break; + } + + + return (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsutils.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsutils.c new file mode 100644 index 0000000..28e01c5 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsutils.c @@ -0,0 +1,932 @@ +/******************************************************************************* + * + * Module Name: dsutils - Dispatcher utilities + * $Revision: 45 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSUTILS_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT PARSER + MODULE_NAME ("dsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsIsResultUsed + * + * PARAMETERS: Op + * ResultObj + * WalkState + * + * RETURN: Status + * + * DESCRIPTION: Check if a result object will be used by the parent + * + ******************************************************************************/ + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPCODE_INFO *ParentInfo; + + + FUNCTION_TRACE_PTR ("DsIsResultUsed", Op); + + + /* Must have both an Op and a Result Object */ + + if (!Op) + { + DEBUG_PRINT (ACPI_ERROR, ("DsIsResultUsed: Null Op\n")); + return_VALUE (TRUE); + } + + + /* + * If there is no parent, the result can't possibly be used! + * (An executing method typically has no parent, since each + * method is parsed separately) However, a method that is + * invoked from another method has a parent. + */ + if (!Op->Parent) + { + return_VALUE (FALSE); + } + + + /* + * Get info on the parent. The root Op is AML_SCOPE + */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode); + if (ACPI_GET_OP_TYPE (ParentInfo) != ACPI_OP_TYPE_OPCODE) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsIsResultUsed: Unknown parent opcode. Op=%X\n", + Op)); + + return_VALUE (FALSE); + } + + + /* + * Decide what to do with the result based on the parent. If + * the parent opcode will not use the result, delete the object. + * Otherwise leave it as is, it will be deleted when it is used + * as an operand later. + */ + + switch (ACPI_GET_OP_CLASS (ParentInfo)) + { + /* + * In these cases, the parent will never use the return object + */ + case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ + + switch (Op->Parent->Opcode) + { + case AML_RETURN_OP: + + /* Never delete the return value associated with a return opcode */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsIsResultUsed: Result used, [RETURN] opcode=%X Op=%X\n", + Op->Opcode, Op)); + return_VALUE (TRUE); + break; + + 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 == CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("DsIsResultUsed: Result used as a predicate, [IF/WHILE] opcode=%X Op=%X\n", + Op->Opcode, Op)); + return_VALUE (TRUE); + } + + break; + } + + + /* Fall through to not used case below */ + + + + case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsIsResultUsed: Result not used, Parent opcode=%X Op=%X\n", + Op->Opcode, Op)); + + return_VALUE (FALSE); + break; + + /* + * In all other cases. the parent will actually use the return + * object, so keep it. + */ + default: + break; + } + + return_VALUE (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteResultIfNotUsed + * + * PARAMETERS: Op + * ResultObj + * WalkState + * + * RETURN: Status + * + * DESCRIPTION: Used after interpretation of an opcode. If there is an internal + * result descriptor, check if the parent opcode will actually use + * this result. If not, delete the result now so that it will + * not become orphaned. + * + ******************************************************************************/ + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj); + + + if (!Op) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsDeleteResultIfNotUsed: Null Op=%X\n", + Op)); + return_VOID; + } + + if (!ResultObj) + { + return_VOID; + } + + + if (!AcpiDsIsResultUsed (Op, WalkState)) + { + /* + * Must pop the result stack (ObjDesc should be equal + * to ResultObj) + */ + + Status = AcpiDsResultStackPop (&ObjDesc, WalkState); + if (ACPI_SUCCESS (Status)) + { + AcpiCmRemoveReference (ResultObj); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperand + * + * PARAMETERS: WalkState + * Arg + * + * RETURN: Status + * + * DESCRIPTION: Translate a parse tree object that is an argument to an AML + * opcode to the equivalent interpreter object. This may include + * looking up a name or entering a new name into the internal + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_STATUS Status = AE_OK; + NATIVE_CHAR *NameString; + UINT32 NameLength; + OBJECT_TYPE_INTERNAL DataType; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ParentOp; + UINT16 Opcode; + UINT32 Flags; + OPERATING_MODE InterpreterMode; + + + FUNCTION_TRACE_PTR ("DsCreateOperand", Arg); + + + /* A valid name must be looked up in the namespace */ + + if ((Arg->Opcode == AML_NAMEPATH_OP) && + (Arg->Value.String)) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperand: Getting a name: Arg=%p\n", Arg)); + + /* Get the entire name string from the AML stream */ + + Status = AcpiAmlGetNameString (ACPI_TYPE_ANY, + Arg->Value.Buffer, + &NameString, + &NameLength); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * All prefixes have been handled, and the name is + * in NameString + */ + + /* + * Differentiate between a namespace "create" operation + * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. + * IMODE_EXECUTE) in order to support the creation of + * namespace objects during the execution of control methods. + */ + + ParentOp = Arg->Parent; + if ((AcpiPsIsNodeOp (ParentOp->Opcode)) && + (ParentOp->Opcode != AML_METHODCALL_OP) && + (ParentOp->Opcode != AML_NAMEPATH_OP)) + { + /* Enter name into namespace if not found */ + + InterpreterMode = IMODE_LOAD_PASS2; + } + + else + { + /* Return a failure if name not found */ + + InterpreterMode = IMODE_EXECUTE; + } + + Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, + ACPI_TYPE_ANY, InterpreterMode, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, + WalkState, + (ACPI_NAMESPACE_NODE **) &ObjDesc); + + /* Free the namestring created above */ + + AcpiCmFree (NameString); + + /* + * The only case where we pass through (ignore) a NOT_FOUND + * error is for the CondRefOf opcode. + */ + + if (Status == AE_NOT_FOUND) + { + if (ParentOp->Opcode == 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_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; + } + } + + /* 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); + } + DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + + + else + { + /* Check for null name case */ + + if (Arg->Opcode == AML_NAMEPATH_OP) + { + /* + * If the name is null, this means that this is an + * optional result parameter that was not specified + * in the original ASL. Create an Reference for a + * placeholder + */ + Opcode = AML_ZERO_OP; /* Has no arguments! */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperand: Null namepath: Arg=%p\n", Arg)); + + /* + * TBD: [Investigate] anything else needed for the + * zero op lvalue? + */ + } + + else + { + Opcode = Arg->Opcode; + } + + + /* Get the data type of the argument */ + + DataType = AcpiDsMapOpcodeToDataType (Opcode, &Flags); + if (DataType == INTERNAL_TYPE_INVALID) + { + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + if (Flags & OP_HAS_RETURN_VALUE) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperand: Argument previously created, already stacked \n")); + + DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (WalkState->Operands [WalkState->NumOperands - 1], WalkState)); + + /* + * Use value that was already previously returned + * by the evaluation of this argument + */ + + Status = AcpiDsResultStackPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* + * Only error is underflow, and this indicates + * a missing or null operand! + */ + DEBUG_PRINT (ACPI_ERROR, + ("DsCreateOperand: Could not pop result\n")); + return_ACPI_STATUS (Status); + } + + } + + else + { + /* Create an ACPI_INTERNAL_OBJECT for the argument */ + + ObjDesc = AcpiCmCreateInternalObject (DataType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new object */ + + Status = AcpiDsInitObjectFromOp (WalkState, Arg, + Opcode, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmDeleteObjectDesc (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); + } + + DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperands + * + * PARAMETERS: FirstArg - First argument of a parser argument tree + * + * RETURN: Status + * + * DESCRIPTION: Convert an operator's arguments from a parse tree format to + * namespace objects and place those argument object on the object + * stack in preparation for evaluation by the interpreter. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg; + UINT32 ArgsPushed = 0; + + + FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg); + + Arg = FirstArg; + + + /* For all arguments in the list... */ + + while (Arg) + { + + Status = AcpiDsCreateOperand (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperands: Arg #%d (%p) done, Arg1=%p\n", + ArgsPushed, Arg, FirstArg)); + + /* Move on to next argument, if any */ + + Arg = Arg->Next; + ArgsPushed++; + } + + 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 (ArgsPushed, WalkState); + + DEBUG_PRINT (ACPI_ERROR, + ("DsCreateOperands: Error while creating Arg %d - %s\n", + (ArgsPushed+1), AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * 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; + + + FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState); + + + /* + * Attempt to resolve each of the valid operands + * Method arguments are passed by value, not by reference + */ + + /* + * TBD: [Investigate] Note from previous parser: + * RefOf problem with AcpiAmlResolveToValue() conversion. + */ + + for (i = 0; i < WalkState->NumOperands; i++) + { + Status = AcpiAmlResolveToValue (&WalkState->Operands[i], WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMapOpcodeToDataType + * + * PARAMETERS: Opcode - AML opcode to map + * OutFlags - Additional info about the opcode + * + * RETURN: The ACPI type associated with the opcode + * + * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type, + * if any. If the opcode returns a value as part of the + * intepreter execution, a flag is returned in OutFlags. + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDsMapOpcodeToDataType ( + UINT16 Opcode, + UINT32 *OutFlags) +{ + OBJECT_TYPE_INTERNAL DataType = INTERNAL_TYPE_INVALID; + ACPI_OPCODE_INFO *OpInfo; + UINT32 Flags = 0; + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Unknown opcode */ + + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unknown AML opcode: %x\n", + Opcode)); + + return (DataType); + } + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + + case OPTYPE_LITERAL: + + switch (Opcode) + { + case AML_BYTE_OP: + case AML_WORD_OP: + case AML_DWORD_OP: + + DataType = ACPI_TYPE_NUMBER; + break; + + + case AML_STRING_OP: + + DataType = ACPI_TYPE_STRING; + break; + + case AML_NAMEPATH_OP: + DataType = INTERNAL_TYPE_REFERENCE; + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unknown (type LITERAL) AML opcode: %x\n", + Opcode)); + break; + } + break; + + + case OPTYPE_DATA_TERM: + + switch (Opcode) + { + case AML_BUFFER_OP: + + DataType = ACPI_TYPE_BUFFER; + break; + + case AML_PACKAGE_OP: + + DataType = ACPI_TYPE_PACKAGE; + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unknown (type DATA_TERM) AML opcode: %x\n", + Opcode)); + break; + } + break; + + + case OPTYPE_CONSTANT: + case OPTYPE_METHOD_ARGUMENT: + case OPTYPE_LOCAL_VARIABLE: + + DataType = INTERNAL_TYPE_REFERENCE; + break; + + + case OPTYPE_MONADIC2: + case OPTYPE_MONADIC2R: + case OPTYPE_DYADIC2: + case OPTYPE_DYADIC2R: + case OPTYPE_DYADIC2S: + case OPTYPE_INDEX: + case OPTYPE_MATCH: + case OPTYPE_RETURN: + + Flags = OP_HAS_RETURN_VALUE; + DataType = ACPI_TYPE_ANY; + break; + + case OPTYPE_METHOD_CALL: + + Flags = OP_HAS_RETURN_VALUE; + DataType = ACPI_TYPE_METHOD; + break; + + + case OPTYPE_NAMED_OBJECT: + + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); + break; + + + case OPTYPE_DYADIC1: + case OPTYPE_CONTROL: + + /* No mapping needed at this time */ + + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unimplemented data type opcode: %x\n", + Opcode)); + break; + } + + /* Return flags to caller if requested */ + + if (OutFlags) + { + *OutFlags = Flags; + } + + return (DataType); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMapNamedOpcodeToDataType + * + * PARAMETERS: Opcode - The Named AML opcode to map + * + * RETURN: The ACPI type associated with the named opcode + * + * DESCRIPTION: Convert a raw Named AML opcode to the associated data type. + * Named opcodes are a subsystem of the AML opcodes. + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDsMapNamedOpcodeToDataType ( + UINT16 Opcode) +{ + OBJECT_TYPE_INTERNAL DataType; + + + /* Decode Opcode */ + + switch (Opcode) + { + case AML_SCOPE_OP: + DataType = INTERNAL_TYPE_SCOPE; + break; + + case AML_DEVICE_OP: + DataType = ACPI_TYPE_DEVICE; + break; + + case AML_THERMAL_ZONE_OP: + DataType = ACPI_TYPE_THERMAL; + break; + + case AML_METHOD_OP: + DataType = ACPI_TYPE_METHOD; + break; + + case AML_POWER_RES_OP: + DataType = ACPI_TYPE_POWER; + break; + + case AML_PROCESSOR_OP: + DataType = ACPI_TYPE_PROCESSOR; + break; + + case AML_DEF_FIELD_OP: /* DefFieldOp */ + DataType = INTERNAL_TYPE_DEF_FIELD_DEFN; + break; + + case AML_INDEX_FIELD_OP: /* IndexFieldOp */ + DataType = INTERNAL_TYPE_INDEX_FIELD_DEFN; + break; + + case AML_BANK_FIELD_OP: /* BankFieldOp */ + DataType = INTERNAL_TYPE_BANK_FIELD_DEFN; + break; + + case AML_NAMEDFIELD_OP: /* NO CASE IN ORIGINAL */ + DataType = ACPI_TYPE_ANY; + break; + + case AML_NAME_OP: /* NameOp - special code in original */ + case AML_NAMEPATH_OP: + DataType = ACPI_TYPE_ANY; + break; + + case AML_ALIAS_OP: + DataType = INTERNAL_TYPE_ALIAS; + break; + + case AML_MUTEX_OP: + DataType = ACPI_TYPE_MUTEX; + break; + + case AML_EVENT_OP: + DataType = ACPI_TYPE_EVENT; + break; + + case AML_REGION_OP: + DataType = ACPI_TYPE_REGION; + break; + + + default: + DataType = ACPI_TYPE_ANY; + break; + + } + + return (DataType); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswexec.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswexec.c new file mode 100644 index 0000000..7e3d58b --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswexec.c @@ -0,0 +1,800 @@ +/****************************************************************************** + * + * Module Name: dswexec - Dispatcher method execution callbacks; + * dispatch to interpreter. + * $Revision: 45 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWEXEC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswexec") + + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetPredicateValue + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 HasResultObj) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState); + + + WalkState->ControlState->Common.State = 0; + + if (HasResultObj) + { + Status = AcpiDsResultStackPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + else + { + Status = AcpiDsCreateOperand (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = WalkState->Operands [0]; + } + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecEndOp: No predicate ObjDesc=%X State=%X\n", + ObjDesc, WalkState)); + + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + + /* + * Result of predicate evaluation currently must + * be a number + */ + + if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecEndOp: Bad predicate (not a number) ObjDesc=%X State=%X Type=%X\n", + ObjDesc, WalkState, ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Save the result of the predicate evaluation on + * the control stack + */ + + if (ObjDesc->Number.Value) + { + WalkState->ControlState->Common.Value = TRUE; + } + + else + { + /* + * Predicate is FALSE, we will just toss the + * rest of the package + */ + + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_FALSE; + } + + + +Cleanup: + + DEBUG_PRINT (TRACE_EXEC, + ("ExecEndOp: Completed a predicate eval=%X Op=%X\n", + WalkState->ControlState->Common.Value, Op)); + + /* Break to debugger to display result */ + + DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState)); + + /* + * Delete the predicate result object (we know that + * we don't need it anymore) + */ + + AcpiCmRemoveReference (ObjDesc); + + WalkState->ControlState->Common.State = CONTROL_NORMAL; + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecBeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been reached in the + * walk; Arguments have not been evaluated yet. + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the execution of control + * methods. This is where most operators and operands are + * dispatched to the interpreter. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_OPCODE_INFO *OpInfo; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("DsExecBeginOp", Op); + + + if (!Op) + { + Status = AcpiDsLoad2BeginOp (Opcode, NULL, WalkState, OutOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Op = *OutOp; + } + + 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 == + CONTROL_CONDITIONAL_EXECUTING)) + { + DEBUG_PRINT (TRACE_EXEC, ("BeginOp: Exec predicate Op=%X State=%X\n", + Op, WalkState)); + + WalkState->ControlState->Common.State = CONTROL_PREDICATE_EXECUTING; + + /* Save start of predicate */ + + WalkState->ControlState->Control.PredicateOp = Op; + } + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + + /* We want to send namepaths to the load code */ + + if (Op->Opcode == AML_NAMEPATH_OP) + { + OpInfo->Flags = OPTYPE_NAMED_OBJECT; + } + + + /* + * Handle the opcode based upon the opcode type + */ + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + case OPTYPE_CONTROL: + + Status = AcpiDsExecBeginControlOp (WalkState, Op); + break; + + + case OPTYPE_NAMED_OBJECT: + + if (WalkState->WalkType == WALK_METHOD) + { + /* + * Found a named object declaration during method + * execution; we must enter this object into the + * namespace. The created object is temporary and + * will be deleted upon completion of the execution + * of this method. + */ + + Status = AcpiDsLoad2BeginOp (Op->Opcode, Op, WalkState, NULL); + } + break; + + + default: + break; + } + + /* Nothing to do here during method execution */ + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecEndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been completed in the + * walk; Arguments have now been evaluated. + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the execution of control + * methods. The only thing we really need to do here is to + * notice the beginning of IF, ELSE, and WHILE blocks. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + UINT16 Opcode; + UINT8 Optype; + ACPI_PARSE_OBJECT *NextOp; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *FirstArg; + ACPI_OPERAND_OBJECT *ResultObj = NULL; + ACPI_OPCODE_INFO *OpInfo; + UINT32 OperandIndex; + + + FUNCTION_TRACE_PTR ("DsExecEndOp", Op); + + + Opcode = (UINT16) Op->Opcode; + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + DEBUG_PRINT (ACPI_ERROR, ("ExecEndOp: Unknown opcode. Op=%X\n", + Op)); + + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + Optype = (UINT8) ACPI_GET_OP_CLASS (OpInfo); + FirstArg = Op->Value.Arg; + + /* Init the walk state */ + + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; + + + /* Call debugger for single step support (DEBUG build only) */ + + DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, Optype)); + DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);}); + + + /* Decode the opcode */ + + switch (Optype) + { + case OPTYPE_UNDEFINED: + + DEBUG_PRINT (ACPI_ERROR, ("ExecEndOp: Undefined opcode type Op=%X\n", + Op)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + break; + + + case OPTYPE_BOGUS: + DEBUG_PRINT (TRACE_DISPATCH, + ("ExecEndOp: Internal opcode=%X type Op=%X\n", + Opcode, Op)); + break; + + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + break; + + + /* most operators with arguments */ + + case OPTYPE_MONADIC1: + case OPTYPE_DYADIC1: + case OPTYPE_MONADIC2: + case OPTYPE_MONADIC2R: + case OPTYPE_DYADIC2: + case OPTYPE_DYADIC2R: + case OPTYPE_DYADIC2S: + case OPTYPE_RECONFIGURATION: + case OPTYPE_INDEX: + case OPTYPE_MATCH: + case OPTYPE_FATAL: + + + Status = AcpiDsCreateOperands (WalkState, FirstArg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + OperandIndex = WalkState->NumOperands - 1; + + switch (Optype) + { + + case OPTYPE_MONADIC1: + + /* 1 Operand, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiAmlExecMonadic1 (Opcode, WalkState); + break; + + + case OPTYPE_MONADIC2: + + /* 1 Operand, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecMonadic2 (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_MONADIC2R: + + /* 1 Operand, 1 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecMonadic2R (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_DYADIC1: + + /* 2 Operands, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiAmlExecDyadic1 (Opcode, WalkState); + + break; + + + case OPTYPE_DYADIC2: + + /* 2 Operands, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecDyadic2 (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_DYADIC2R: + + /* 2 Operands, 1 or 2 ExternalResults, 1 InternalResult */ + + + /* NEW INTERFACE: + * Pass in WalkState, keep result obj but let interpreter + * push the result + */ + + Status = AcpiAmlExecDyadic2R (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_DYADIC2S: /* Synchronization Operator */ + + /* 2 Operands, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecDyadic2S (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_RECONFIGURATION: + + /* 1 or 2 operands, 0 Internal Result */ + + Status = AcpiAmlExecReconfiguration (Opcode, WalkState); + break; + + + case OPTYPE_FATAL: + + /* 3 Operands, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiAmlExecFatal (WalkState); + break; + + + case OPTYPE_INDEX: /* Type 2 opcode with 3 operands */ + + /* 3 Operands, 1 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecIndex (WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_MATCH: /* Type 2 opcode with 6 operands */ + + /* 6 Operands, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecMatch (WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + } + + break; + + + case OPTYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ + + /* 1 Operand, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiDsExecEndControlOp (WalkState, Op); + + break; + + + case OPTYPE_METHOD_CALL: + + DEBUG_PRINT (TRACE_DISPATCH, + ("ExecEndOp: Method invocation, Op=%X\n", Op)); + + /* + * (AML_METHODCALL) Op->Value->Arg->Node contains + * the method Node pointer + */ + /* NextOp points to the op that holds the method name */ + + NextOp = FirstArg; + Node = NextOp->Node; + + /* NextOp points to first argument op */ + + NextOp = NextOp->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)) + { + 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); + break; + + + case OPTYPE_CREATE_FIELD: + + DEBUG_PRINT (TRACE_EXEC, + ("ExecEndOp: Executing CreateField Buffer/Index Op=%X\n", + Op)); + + Status = AcpiDsLoad2EndOp (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + + Status = AcpiDsEvalFieldUnitOperands (WalkState, Op); + break; + + + case OPTYPE_NAMED_OBJECT: + + Status = AcpiDsLoad2EndOp (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + + switch (Op->Opcode) + { + case AML_REGION_OP: + + DEBUG_PRINT (TRACE_EXEC, + ("ExecEndOp: Executing OpRegion Address/Length Op=%X\n", + Op)); + + Status = AcpiDsEvalRegionOperands (WalkState, Op); + + break; + + + case AML_METHOD_OP: + + break; + + + case AML_ALIAS_OP: + + /* Alias creation was already handled by call + to psxload above */ + break; + + + default: + /* Nothing needs to be done */ + + Status = AE_OK; + break; + } + + break; + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("ExecEndOp: Unimplemented opcode, type=%X Opcode=%X Op=%X\n", + Optype, Op->Opcode, Op)); + + Status = AE_NOT_IMPLEMENTED; + break; + } + + + /* + * Check if we just completed the evaluation of a + * conditional predicate + */ + + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + + Status = AcpiDsGetPredicateValue (WalkState, Op, (UINT32) ResultObj); + ResultObj = NULL; + } + + +Cleanup: + + if (ResultObj) + { + /* Break to debugger to display result */ + + DEBUGGER_EXEC (AcpiDbDisplayResultObject (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, ResultObj, WalkState); + } + + /* Always clear the object stack */ + + /* TBD: [Investigate] Clear stack of return value, + but don't delete it */ + WalkState->NumOperands = 0; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswload.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswload.c new file mode 100644 index 0000000..c595c5d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswload.c @@ -0,0 +1,928 @@ +/****************************************************************************** + * + * Module Name: dswload - Dispatcher namespace load callbacks + * $Revision: 23 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWLOAD_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswload") + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad1BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been reached in the + * walk; Arguments have not been evaluated yet. + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + OBJECT_TYPE_INTERNAL DataType; + NATIVE_CHAR *Path; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: Op=%p State=%p\n", Op, WalkState)); + + + /* We are only interested in opcodes that have an associated name */ + + if (!AcpiPsIsNamedOp (Opcode)) + { + *OutOp = Op; + return (AE_OK); + } + + + /* Check if this object has already been installed in the namespace */ + + if (Op && Op->Node) + { + *OutOp = Op; + return (AE_OK); + } + + Path = AcpiPsGetNextNamestring (WalkState->ParserState); + + /* Map the raw opcode into an internal object type */ + + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + + + if (Opcode == AML_SCOPE_OP) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + } + + /* + * 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, + DataType, IMODE_LOAD_PASS1, + NS_NO_UPSEARCH, WalkState, &(Node)); + + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return (AE_NO_MEMORY); + } + } + + /* Initialize */ + + ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name; + + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Node = Node; + + + AcpiPsAppendArg (AcpiPsGetParentScope (WalkState->ParserState), Op); + + *OutOp = Op; + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad1EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been completed in the + * walk; Arguments have now been evaluated. + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + OBJECT_TYPE_INTERNAL DataType; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1EndOp: Op=%p State=%p\n", Op, WalkState)); + + /* We are only interested in opcodes that have an associated name */ + + if (!AcpiPsIsNamedOp (Op->Opcode)) + { + return (AE_OK); + } + + + /* Get the type to determine if we should pop the scope */ + + DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); + + if (Op->Opcode == AML_NAME_OP) + { + /* For Name opcode, check the argument */ + + if (Op->Value.Arg) + { + DataType = AcpiDsMapOpcodeToDataType ( + (Op->Value.Arg)->Opcode, NULL); + ((ACPI_NAMESPACE_NODE *)Op->Node)->Type = + (UINT8) DataType; + } + } + + + /* Pop the scope stack */ + + if (AcpiNsOpensScope (DataType)) + { + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1EndOp/%s: Popping scope for Op %p\n", + AcpiCmGetTypeName (DataType), Op)); + AcpiDsScopeStackPop (WalkState); + } + + return (AE_OK); + +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad2BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been reached in the + * walk; Arguments have not been evaluated yet. + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + OBJECT_TYPE_INTERNAL DataType; + NATIVE_CHAR *BufferPtr; + void *Original = NULL; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2BeginOp: Op=%p State=%p\n", Op, WalkState)); + + + /* We only care about Namespace opcodes here */ + + if (!AcpiPsIsNamespaceOp (Opcode) && + Opcode != AML_NAMEPATH_OP) + { + return (AE_OK); + } + + + /* Temp! same code as in psparse */ + + if (!AcpiPsIsNamedOp (Opcode)) + { + return (AE_OK); + } + + if (Op) + { + /* + * Get the name we are going to enter or lookup in the namespace + */ + if (Opcode == AML_NAMEPATH_OP) + { + /* For Namepath op, get the path string */ + + BufferPtr = Op->Value.String; + if (!BufferPtr) + { + /* No name, just exit */ + + return (AE_OK); + } + } + + else + { + /* Get name from the op */ + + BufferPtr = (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Op)->Name; + } + } + + else + { + BufferPtr = AcpiPsGetNextNamestring (WalkState->ParserState); + } + + + /* Map the raw opcode into an internal object type */ + + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + + + if (Opcode == AML_DEF_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP) + { + Node = NULL; + Status = AE_OK; + } + + else if (Opcode == AML_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, + DataType, IMODE_EXECUTE, + NS_SEARCH_PARENT, WalkState, + &(Node)); + } + + else + { + if (Op && Op->Node) + { + Original = Op->Node; + Node = Op->Node; + + if (AcpiNsOpensScope (DataType)) + { + Status = AcpiDsScopeStackPush (Node, + DataType, + WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + } + return (AE_OK); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that involve + * arguments to the opcode must be created as we go back up the parse tree later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, + DataType, IMODE_EXECUTE, + NS_NO_UPSEARCH, WalkState, + &(Node)); + } + + if (ACPI_SUCCESS (Status)) + { + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Initialize */ + + ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name; + *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->Node = Node; + + if (Original) + { + DEBUG_PRINT (ACPI_INFO, + ("Lookup: old %p new %p\n", Original, Node)); + + if (Original != Node) + { + DEBUG_PRINT (ACPI_INFO, + ("Lookup match error: old %p new %p\n", Original, Node)); + } + } + } + + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad2EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been completed in the + * walk; Arguments have now been evaluated. + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + OBJECT_TYPE_INTERNAL DataType; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *NewNode; + + + DEBUG_PRINT (TRACE_DISPATCH, ("Load2EndOp: Op=%p State=%p\n", Op, WalkState)); + + if (!AcpiPsIsNamespaceObjectOp (Op->Opcode)) + { + return (AE_OK); + } + + if (Op->Opcode == AML_SCOPE_OP) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2EndOp: ending scope Op=%p State=%p\n", Op, WalkState)); + + if (((ACPI_PARSE2_OBJECT *)Op)->Name == -1) + { + DEBUG_PRINT (ACPI_ERROR, + ("Load2EndOp: Un-named scope! Op=%p State=%p\n", Op, + WalkState)); + return (AE_OK); + } + } + + + DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); + + /* + * Get the Node/name from the earlier lookup + * (It was saved in the *op structure) + */ + Node = Op->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 (DataType)) + { + + DEBUG_PRINT (TRACE_DISPATCH, + ("AmlEndNamespaceScope/%s: Popping scope for Op %p\n", + AcpiCmGetTypeName (DataType), Op)); + AcpiDsScopeStackPop (WalkState); + } + + + /* + * Named operations are as follows: + * + * AML_SCOPE + * AML_DEVICE + * AML_THERMALZONE + * AML_METHOD + * AML_POWERRES + * AML_PROCESSOR + * AML_FIELD + * AML_INDEXFIELD + * AML_BANKFIELD + * AML_NAMEDFIELD + * AML_NAME + * AML_ALIAS + * AML_MUTEX + * AML_EVENT + * AML_OPREGION + * AML_CREATEFIELD + * AML_CREATEBITFIELD + * AML_CREATEBYTEFIELD + * AML_CREATEWORDFIELD + * AML_CREATEDWORDFIELD + * AML_METHODCALL + */ + + + /* Decode the opcode */ + + Arg = Op->Value.Arg; + + switch (Op->Opcode) + { + + case AML_CREATE_FIELD_OP: + case AML_BIT_FIELD_OP: + case AML_BYTE_FIELD_OP: + case AML_WORD_FIELD_OP: + case AML_DWORD_FIELD_OP: + + /* + * Create the field object, but the field buffer and index must + * be evaluated later during the execution phase + */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-CreateXxxField: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + /* Get the NameString argument */ + + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + Arg = AcpiPsGetArg (Op, 3); + } + else + { + /* Create Bit/Byte/Word/Dword field */ + + Arg = AcpiPsGetArg (Op, 2); + } + + /* + * Enter the NameString into the namespace + */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, + Arg->Value.String, + INTERNAL_TYPE_DEF_ANY, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); + + if (ACPI_SUCCESS (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->Node = NewNode; + + /* + * 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 (!NewNode->Object) + { + /* + * The Field definition is not fully parsed at this time. + * (We must save the address of the AML for the buffer and index operands) + */ + Status = AcpiAmlExecCreateField (((ACPI_PARSE2_OBJECT *) Op)->Data, + ((ACPI_PARSE2_OBJECT *) Op)->Length, + NewNode, WalkState); + } + } + + + break; + + + case AML_METHODCALL_OP: + + DEBUG_PRINT (TRACE_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->Value.String, + ACPI_TYPE_ANY, IMODE_LOAD_PASS2, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); + + if (ACPI_SUCCESS (Status)) + { + +/* has name already been resolved by here ??*/ + + /* TBD: [Restructure] Make sure that what we found is indeed a method! */ + /* We didn't search for a method on purpose, to see if the name would resolve! */ + + /* We 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->Node = NewNode; + } + + + break; + + + case AML_PROCESSOR_OP: + + /* Nothing to do other than enter object into namespace */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Processor: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Status = AcpiAmlExecCreateProcessor (Op, (ACPI_HANDLE) Node); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed Processor Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Node)); + break; + + + case AML_POWER_RES_OP: + + /* Nothing to do other than enter object into namespace */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-PowerResource: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Status = AcpiAmlExecCreatePowerResource (Op, (ACPI_HANDLE) Node); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed PowerResource Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Node)); + break; + + + case AML_THERMAL_ZONE_OP: + + /* Nothing to do other than enter object into namespace */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-ThermalZone: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + break; + + + case AML_DEF_FIELD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Field: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Arg = Op->Value.Arg; + + Status = AcpiDsCreateField (Op, + Arg->Node, + WalkState); + break; + + + case AML_INDEX_FIELD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-IndexField: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Arg = Op->Value.Arg; + + Status = AcpiDsCreateIndexField (Op, + (ACPI_HANDLE) Arg->Node, + WalkState); + break; + + + case AML_BANK_FIELD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-BankField: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Arg = Op->Value.Arg; + Status = AcpiDsCreateBankField (Op, + Arg->Node, + WalkState); + break; + + + /* + * MethodOp PkgLength NamesString MethodFlags TermList + */ + case AML_METHOD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Method: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + if (!Node->Object) + { + Status = AcpiAmlExecCreateMethod (((ACPI_PARSE2_OBJECT *) Op)->Data, + ((ACPI_PARSE2_OBJECT *) Op)->Length, + Arg->Value.Integer, (ACPI_HANDLE) Node); + } + + break; + + + case AML_MUTEX_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Mutex: Op=%p State=%p\n", Op, WalkState)); + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecCreateMutex (WalkState); + break; + + + case AML_EVENT_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Event: Op=%p State=%p\n", Op, WalkState)); + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecCreateEvent (WalkState); + break; + + + case AML_REGION_OP: + + if (Node->Object) + { + break; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Opregion: Op=%p State=%p NamedObj=%p\n", Op, WalkState, Node)); + + + /* + * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId. + * (We must save the address of the AML of the address and length operands) + */ + + Status = AcpiAmlExecCreateRegion (((ACPI_PARSE2_OBJECT *) Op)->Data, + ((ACPI_PARSE2_OBJECT *) Op)->Length, + Arg->Value.Integer, WalkState); + + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed OpRegion Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Node)); + break; + + + /* Namespace Modifier Opcodes */ + + case AML_ALIAS_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Alias: Op=%p State=%p\n", Op, WalkState)); + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecCreateAlias (WalkState); + break; + + + case AML_NAME_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Name: Op=%p State=%p\n", Op, WalkState)); + + /* + * 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 (!Node->Object) + { + Status = AcpiDsCreateNode (WalkState, Node, Op); + } + + break; + + + case AML_NAMEPATH_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-NamePath object: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + break; + + + default: + break; + } + + +Cleanup: + + /* Remove the Node pushed at the very beginning */ + + AcpiDsObjStackPop (1, WalkState); + return (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswscope.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswscope.c new file mode 100644 index 0000000..9d7f1da --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswscope.c @@ -0,0 +1,268 @@ +/****************************************************************************** + * + * Module Name: dswscope - Scope stack manipulation + * $Revision: 39 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWSCOPE_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acdispat.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("dswscope") + + +#define STACK_POP(head) head + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackClear + * + * PARAMETERS: None + * + * DESCRIPTION: Pop (and free) everything on the scope stack except the + * root scope object (which remains at the stack top.) + * + ***************************************************************************/ + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + + while (WalkState->ScopeInfo) + { + /* Pop a scope off the stack */ + + ScopeInfo = WalkState->ScopeInfo; + WalkState->ScopeInfo = ScopeInfo->Scope.Next; + + DEBUG_PRINT (TRACE_EXEC, + ("Popped object type 0x%X\n", ScopeInfo->Common.Value)); + AcpiCmDeleteGenericState (ScopeInfo); + } +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPush + * + * PARAMETERS: *Node, - Name to be made current + * Type, - Type of frame being pushed + * + * DESCRIPTION: Push the current scope on the scope stack, and make the + * passed Node current. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + + FUNCTION_TRACE ("DsScopeStackPush"); + + + if (!Node) + { + /* invalid scope */ + + REPORT_ERROR (("DsScopeStackPush: null scope passed\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Make sure object type is valid */ + + if (!AcpiAmlValidateObjectType (Type)) + { + REPORT_WARNING (("DsScopeStackPush: type code out of range\n")); + } + + + /* Allocate a new scope object */ + + ScopeInfo = AcpiCmCreateGenericState (); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init new scope object */ + + ScopeInfo->Scope.Node = Node; + ScopeInfo->Common.Value = (UINT16) Type; + + /* Push new scope object onto stack */ + + AcpiCmPushGenericState (&WalkState->ScopeInfo, ScopeInfo); + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPop + * + * PARAMETERS: Type - The type of frame to be found + * + * DESCRIPTION: Pop the scope stack until a frame of the requested type + * is found. + * + * RETURN: Count of frames popped. If no frame of the requested type + * was found, the count is returned as a negative number and + * the scope stack is emptied (which sets the current scope + * to the root). If the scope stack was empty at entry, the + * function is a no-op and returns 0. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + + FUNCTION_TRACE ("DsScopeStackPop"); + + /* + * Pop scope info object off the stack. + */ + + ScopeInfo = AcpiCmPopGenericState (&WalkState->ScopeInfo); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_STACK_UNDERFLOW); + } + + DEBUG_PRINT (TRACE_EXEC, + ("Popped object type 0x%X\n", ScopeInfo->Common.Value)); + + AcpiCmDeleteGenericState (ScopeInfo); + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswstate.c b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswstate.c new file mode 100644 index 0000000..28ffce9 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Dispatcher/dswstate.c @@ -0,0 +1,841 @@ +/****************************************************************************** + * + * Module Name: dswstate - Dispatcher parse tree walk management routines + * $Revision: 31 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __DSWSTATE_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswstate") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackClear + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Reset this walk's result stack pointers to zero, thus setting + * the stack to zero. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultStackClear ( + ACPI_WALK_STATE *WalkState) +{ + + WalkState->NumResults = 0; + WalkState->CurrentResult = 0; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPush + * + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto this walk's result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState) +{ + + + if (WalkState->NumResults >= OBJ_NUM_OPERANDS) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsResultStackPush: overflow! Obj=%p State=%p Num=%X\n", + Object, WalkState, WalkState->NumResults)); + return (AE_STACK_OVERFLOW); + } + + WalkState->Results [WalkState->NumResults] = Object; + WalkState->NumResults++; + + DEBUG_PRINT (TRACE_EXEC, + ("DsResultStackPush: Obj=%p State=%p Num=%X Cur=%X\n", + Object, WalkState, WalkState->NumResults, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPop + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In + * other words, this is a FIFO. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + + + /* Check for stack underflow */ + + if (WalkState->NumResults == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsResultStackPop: Underflow! State=%p Cur=%X Num=%X\n", + WalkState, WalkState->CurrentResult, WalkState->NumResults)); + return (AE_AML_NO_OPERAND); + } + + + /* Pop the stack */ + + WalkState->NumResults--; + + /* Check for a valid result object */ + + if (!WalkState->Results [WalkState->NumResults]) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsResultStackPop: Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumResults)); + return (AE_AML_NO_OPERAND); + } + + *Object = WalkState->Results [WalkState->NumResults]; + WalkState->Results [WalkState->NumResults] = NULL; + + DEBUG_PRINT (TRACE_EXEC, + ("DsResultStackPop: Obj=%p State=%p Num=%X Cur=%X\n", + *Object, WalkState, WalkState->NumResults, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackDeleteAll + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Clear the object stack by deleting all objects that are on it. + * Should be used with great care, if at all! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); + + + /* The stack size is configurable, but fixed */ + + for (i = 0; i < OBJ_NUM_OPERANDS; i++) + { + if (WalkState->Operands[i]) + { + AcpiCmRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPush + * + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto this walk's object/operand stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState) +{ + + + /* Check for stack overflow */ + + if (WalkState->NumOperands >= OBJ_NUM_OPERANDS) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPush: overflow! Obj=%p State=%p #Ops=%X\n", + Object, WalkState, WalkState->NumOperands)); + return (AE_STACK_OVERFLOW); + } + + /* Put the object onto the stack */ + + WalkState->Operands [WalkState->NumOperands] = Object; + WalkState->NumOperands++; + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPush: Obj=%p State=%p #Ops=%X\n", + Object, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopObject + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT + * deleted by this routine. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + + + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Missing operand/stack empty! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + return (AE_AML_NO_OPERAND); + } + + + /* Pop the stack */ + + WalkState->NumOperands--; + + /* Check for a valid operand */ + + if (!WalkState->Operands [WalkState->NumOperands]) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + return (AE_AML_NO_OPERAND); + } + + /* Get operand and set stack entry to null */ + + *Object = WalkState->Operands [WalkState->NumOperands]; + WalkState->Operands [WalkState->NumOperands] = NULL; + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPopObject: State=%p #Ops=%X\n", + 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; + + + for (i = 0; i < PopCount; i++) + { + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + return (AE_STACK_UNDERFLOW); + } + + /* Just set the stack entry to null */ + + WalkState->NumOperands--; + WalkState->Operands [WalkState->NumOperands] = NULL; + } + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopAndDelete + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack and delete each object that is + * popped off. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; + + + for (i = 0; i < PopCount; i++) + { + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + return (AE_STACK_UNDERFLOW); + } + + /* Pop the stack and delete an object if present in this stack entry */ + + WalkState->NumOperands--; + ObjDesc = WalkState->Operands [WalkState->NumOperands]; + if (ObjDesc) + { + AcpiCmRemoveReference (WalkState->Operands [WalkState->NumOperands]); + WalkState->Operands [WalkState->NumOperands] = NULL; + } + } + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackGetValue + * + * PARAMETERS: Index - Stack index whose value is desired. Based + * on the top of the stack (index=0 == top) + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Retrieve an object from this walk's object stack. Index must + * be within the range of the current stack pointer. + * + ******************************************************************************/ + +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + + FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); + + + /* Can't do it if the stack is empty */ + + if (WalkState->NumOperands == 0) + { + return_VALUE (NULL); + } + + /* or if the index is past the top of the stack */ + + if (Index > (WalkState->NumOperands - (UINT32) 1)) + { + return_VALUE (NULL); + } + + + return_PTR (WalkState->Operands[(NATIVE_UINT)(WalkState->NumOperands - 1) - + Index]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetCurrentWalkState + * + * PARAMETERS: WalkList - Get current active state for this walk list + * + * 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_WALK_LIST *WalkList) + +{ + + DEBUG_PRINT (TRACE_PARSE, ("DsGetCurrentWalkState, =%p\n", WalkList->WalkState)); + + if (!WalkList) + { + return (NULL); + } + + return (WalkList->WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPushWalkState + * + * PARAMETERS: WalkState - State to push + * WalkList - The list that owns the walk stack + * + * RETURN: None + * + * DESCRIPTION: Place the WalkState at the head of the state list. + * + ******************************************************************************/ + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_WALK_LIST *WalkList) +{ + + + FUNCTION_TRACE ("DsPushWalkState"); + + + WalkState->Next = WalkList->WalkState; + WalkList->WalkState = WalkState; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPopWalkState + * + * PARAMETERS: WalkList - The list that owns the walk stack + * + * RETURN: A WalkState object popped from the stack + * + * DESCRIPTION: Remove and return the walkstate object that is at the head of + * the walk stack for the given walk list. NULL indicates that + * the list is empty. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_WALK_LIST *WalkList) +{ + ACPI_WALK_STATE *WalkState; + + + FUNCTION_TRACE ("DsPopWalkState"); + + + WalkState = WalkList->WalkState; + + if (WalkState) + { + /* Next walk state becomes the current walk state */ + + WalkList->WalkState = WalkState->Next; + + /* + * Don't clear the NEXT field, this serves as an indicator + * that there is a parent WALK STATE + * WalkState->Next = NULL; + */ + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateWalkState + * + * PARAMETERS: Origin - Starting point for this walk + * WalkList - Owning walk list + * + * RETURN: Pointer to the new walk state. + * + * DESCRIPTION: Allocate and initialize a new walk state. The current walk state + * is set to this new state. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_WALK_LIST *WalkList) +{ + ACPI_WALK_STATE *WalkState; + + + FUNCTION_TRACE ("DsCreateWalkState"); + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_WalkStateCacheRequests++; + + /* Check the cache first */ + + if (AcpiGbl_WalkStateCache) + { + /* There is an object available, use it */ + + WalkState = AcpiGbl_WalkStateCache; + AcpiGbl_WalkStateCache = WalkState->Next; + + AcpiGbl_WalkStateCacheHits++; + AcpiGbl_WalkStateCacheDepth--; + + DEBUG_PRINT (TRACE_EXEC, ("DsCreateWalkState: State %p from cache\n", WalkState)); + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* The cache is empty, create a new object */ + + /* Avoid deadlock with AcpiCmCallocate */ + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + WalkState = AcpiCmCallocate (sizeof (ACPI_WALK_STATE)); + if (!WalkState) + { + return_VALUE (NULL); + } + } + + WalkState->DataType = ACPI_DESC_TYPE_WALK; + WalkState->OwnerId = OwnerId; + WalkState->Origin = Origin; + WalkState->MethodDesc = MthDesc; + + /* Init the method args/local */ + + AcpiDsMethodDataInit (WalkState); + + /* Put the new state at the head of the walk list */ + + AcpiDsPushWalkState (WalkState, WalkList); + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * 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; + + + FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); + + + if (!WalkState) + { + return; + } + + if (WalkState->DataType != ACPI_DESC_TYPE_WALK) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsDeleteWalkState: **** %p not a valid walk state\n", WalkState)); + return; + } + + /* Always must free any linked control states */ + + while (WalkState->ControlState) + { + State = WalkState->ControlState; + WalkState->ControlState = State->Common.Next; + + AcpiCmDeleteGenericState (State); + } + + + /* Always must free any linked parse states */ + + while (WalkState->ScopeInfo) + { + State = WalkState->ScopeInfo; + WalkState->ScopeInfo = State->Common.Next; + + AcpiCmDeleteGenericState (State); + } + + /* If walk cache is full, just free this wallkstate object */ + + if (AcpiGbl_WalkStateCacheDepth >= MAX_WALK_CACHE_DEPTH) + { + AcpiCmFree (WalkState); + } + + /* Otherwise put this object back into the cache */ + + else + { + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + /* Clear the state */ + + MEMSET (WalkState, 0, sizeof (ACPI_WALK_STATE)); + WalkState->DataType = ACPI_DESC_TYPE_WALK; + + /* Put the object at the head of the global cache list */ + + WalkState->Next = AcpiGbl_WalkStateCache; + AcpiGbl_WalkStateCache = WalkState; + AcpiGbl_WalkStateCacheDepth++; + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDsDeleteWalkStateCache + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge the global state object cache. Used during subsystem + * termination. + * + ******************************************************************************/ + +void +AcpiDsDeleteWalkStateCache ( + void) +{ + ACPI_WALK_STATE *Next; + + + FUNCTION_TRACE ("DsDeleteWalkStateCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_WalkStateCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_WalkStateCache->Next; + AcpiCmFree (AcpiGbl_WalkStateCache); + AcpiGbl_WalkStateCache = Next; + AcpiGbl_WalkStateCacheDepth--; + } + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evevent.c b/sys/contrib/dev/acpica/Subsystem/Events/evevent.c new file mode 100644 index 0000000..066946c --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evevent.c @@ -0,0 +1,953 @@ +/****************************************************************************** + * + * Module Name: evevent - Fixed and General Purpose AcpiEvent + * handling and dispatch + * $Revision: 17 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "achware.h" +#include "acevents.h" +#include "acnamesp.h" +#include "accommon.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evevent") + + +/************************************************************************** + * + * FUNCTION: AcpiEvInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Ensures that the system control interrupt (SCI) is properly + * configured, disables SCI event sources, installs the SCI + * handler + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvInitialize ( + void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInitialize"); + + + /* Make sure we've got ACPI tables */ + + if (!AcpiGbl_DSDT) + { + DEBUG_PRINT (ACPI_WARN, ("EvInitialize: No ACPI tables present!\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + + /* Make sure the BIOS supports ACPI mode */ + + if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities()) + { + DEBUG_PRINT (ACPI_WARN, + ("EvInitialize: Only legacy mode supported!\n")); + return_ACPI_STATUS (AE_ERROR); + } + + + AcpiGbl_OriginalMode = AcpiHwGetMode(); + + /* + * Initialize the Fixed and General Purpose AcpiEvents prior. This is + * done prior to enabling SCIs to prevent interrupts from occuring + * before handers are installed. + */ + + Status = AcpiEvFixedEventInitialize (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, + ("EvInitialize: Unable to initialize fixed events.\n")); + return_ACPI_STATUS (Status); + } + + Status = AcpiEvGpeInitialize (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, + ("EvInitialize: Unable to initialize general purpose events.\n")); + return_ACPI_STATUS (Status); + } + + /* Install the SCI handler */ + + Status = AcpiEvInstallSciHandler (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, + ("EvInitialize: Unable to install System Control Interrupt Handler\n")); + return_ACPI_STATUS (Status); + } + + + /* Install handlers for control method GPE handlers (_Lxx, _Exx) */ + + AcpiEvInitGpeControlMethods (); + + /* Install the handler for the Global Lock */ + + Status = AcpiEvInitGlobalLockHandler (); + + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvFixedEventInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the Fixed AcpiEvent data structures + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvFixedEventInitialize(void) +{ + int i = 0; + + /* Initialize the structure that keeps track of fixed event handlers */ + + for (i = 0; i < NUM_FIXED_EVENTS; i++) + { + AcpiGbl_FixedEventHandlers[i].Handler = NULL; + AcpiGbl_FixedEventHandlers[i].Context = NULL; + } + + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_PMTIMER + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_GLOBAL + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_POWER_BUTTON + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_SLEEP_BUTTON + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_RTC + + TMR_EN, 0); + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvFixedEventDetect + * + * PARAMETERS: None + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Checks the PM status register for fixed events + * + ******************************************************************************/ + +UINT32 +AcpiEvFixedEventDetect(void) +{ + UINT32 IntStatus = INTERRUPT_NOT_HANDLED; + UINT32 StatusRegister = 0; + UINT32 EnableRegister = 0; + + /* + * Read the fixed feature status and enable registers, as all the cases + * depend on their values. + */ + + StatusRegister = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk); + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + StatusRegister |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk); + } + + EnableRegister = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + EnableRegister |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + } + + DEBUG_PRINT (TRACE_INTERRUPTS, + ("Fixed AcpiEvent Block: Enable = %08x\tStatus = %08x\n", + EnableRegister, StatusRegister)); + + /* power management timer roll over */ + + if ((StatusRegister & ACPI_STATUS_PMTIMER) && + (EnableRegister & ACPI_ENABLE_PMTIMER)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_PMTIMER); + } + + /* global event (BIOS want's the global lock) */ + + if ((StatusRegister & ACPI_STATUS_GLOBAL) && + (EnableRegister & ACPI_ENABLE_GLOBAL)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_GLOBAL); + } + + /* power button event */ + + if ((StatusRegister & ACPI_STATUS_POWER_BUTTON) && + (EnableRegister & ACPI_ENABLE_POWER_BUTTON)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_POWER_BUTTON); + } + + /* sleep button event */ + + if ((StatusRegister & ACPI_STATUS_SLEEP_BUTTON) && + (EnableRegister & ACPI_ENABLE_SLEEP_BUTTON)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_SLEEP_BUTTON); + } + + return (IntStatus); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvFixedEventDispatch + * + * PARAMETERS: Event - Event type + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Clears the status bit for the requested event, calls the + * handler that previously registered for the event. + * + ******************************************************************************/ + +UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event) +{ + /* Clear the status bit */ + + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, TMR_STS + + Event, 1); + + /* + * 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) + { + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, + TMR_EN + Event, 0); + + REPORT_ERROR ( + ("EvGpeDispatch: No installed handler for fixed event [0x%08X]\n", + Event)); + + return (INTERRUPT_NOT_HANDLED); + } + + /* Invoke the handler */ + + return ((AcpiGbl_FixedEventHandlers[Event].Handler)( + AcpiGbl_FixedEventHandlers[Event].Context)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the GPE data structures + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvGpeInitialize (void) +{ + UINT32 i; + UINT32 j; + UINT32 RegisterIndex; + UINT32 GpeNumber; + UINT16 Gpe0RegisterCount; + UINT16 Gpe1RegisterCount; + + + FUNCTION_TRACE ("EvGpeInitialize"); + + /*******************************************************************/ + /* Setting up various GPE counts */ + /* */ + /* You may ask,why are the GPE register block lengths divided by 2?*/ + /* From the ACPI 2.0 Spec, section, 4.7.1.6 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." */ + /*******************************************************************/ + Gpe0RegisterCount = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); + Gpe1RegisterCount = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); + AcpiGbl_GpeRegisterCount = Gpe0RegisterCount + Gpe1RegisterCount; + + if (!AcpiGbl_GpeRegisterCount) + { + REPORT_WARNING (("Zero GPEs are defined in the FACP\n")); + return_ACPI_STATUS (AE_OK); + } + + /* + * Allocate the Gpe information block + */ + + AcpiGbl_GpeRegisters = AcpiCmCallocate (AcpiGbl_GpeRegisterCount * + sizeof (ACPI_GPE_REGISTERS)); + if (!AcpiGbl_GpeRegisters) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not allocate the GpeRegisters block\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Allocate the Gpe dispatch handler block + * There are eight distinct GP events per register. + * Initialization to zeros is sufficient + */ + + AcpiGbl_GpeInfo = AcpiCmCallocate (MUL_8 (AcpiGbl_GpeRegisterCount) * + sizeof (ACPI_GPE_LEVEL_INFO)); + if (!AcpiGbl_GpeInfo) + { + AcpiCmFree (AcpiGbl_GpeRegisters); + DEBUG_PRINT (ACPI_ERROR, ("Could not allocate the GpeInfo block\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Set the Gpe validation table to GPE_INVALID */ + + MEMSET (AcpiGbl_GpeValid, (int) ACPI_GPE_INVALID, NUM_GPE); + + /* + * Initialize the Gpe information and validation blocks. A goal of these + * blocks is to hide the fact that there are two separate GPE register sets + * In a given block, the status registers occupy the first half, and + * the enable registers occupy the second half. + */ + + /* GPE Block 0 */ + + RegisterIndex = 0; + + for (i = 0; i < Gpe0RegisterCount; i++) + { + AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr = + (UINT16) (AcpiGbl_FACP->Gpe0Blk + i); + + AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr = + (UINT16) (AcpiGbl_FACP->Gpe0Blk + i + Gpe0RegisterCount); + + AcpiGbl_GpeRegisters[RegisterIndex].GpeBase = (UINT8) MUL_8 (i); + + for (j = 0; j < 8; j++) + { + GpeNumber = AcpiGbl_GpeRegisters[RegisterIndex].GpeBase + j; + AcpiGbl_GpeValid[GpeNumber] = (UINT8) RegisterIndex; + } + + /* + * Clear the status/enable registers. Note that status registers + * are cleared by writing a '1', while enable registers are cleared + * by writing a '0'. + */ + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, 0x00); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, 0xFF); + + RegisterIndex++; + } + + /* GPE Block 1 */ + + for (i = 0; i < Gpe1RegisterCount; i++) + { + AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr = + (UINT16) (AcpiGbl_FACP->Gpe1Blk + i); + + AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr = + (UINT16) (AcpiGbl_FACP->Gpe1Blk + i + Gpe1RegisterCount); + + AcpiGbl_GpeRegisters[RegisterIndex].GpeBase = + (UINT8) (AcpiGbl_FACP->Gpe1Base + MUL_8 (i)); + + for (j = 0; j < 8; j++) + { + GpeNumber = AcpiGbl_GpeRegisters[RegisterIndex].GpeBase + j; + AcpiGbl_GpeValid[GpeNumber] = (UINT8) RegisterIndex; + } + + /* + * Clear the status/enable registers. Note that status registers + * are cleared by writing a '1', while enable registers are cleared + * by writing a '0'. + */ + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, 0x00); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, 0xFF); + + RegisterIndex++; + } + + DEBUG_PRINT (ACPI_INFO, + ("GPE registers: %d@%X (Blk0) %d@%X (Blk1)\n", + Gpe0RegisterCount, AcpiGbl_FACP->Gpe0Blk, Gpe1RegisterCount, + AcpiGbl_FACP->Gpe1Blk)); + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvSaveMethodInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * control method under the _GPE portion of the namespace. + * Extract the name and GPE type from the object, saving this + * information for quick lookup during GPE dispatch + * + * The name of each GPE control method is of the form: + * "_Lnn" or "_Enn" + * Where: + * L - means that the GPE is level triggered + * E - means that the GPE is edge triggered + * nn - is the GPE number + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue) +{ + UINT32 GpeNumber; + NATIVE_CHAR Name[ACPI_NAME_SIZE + 1]; + UINT8 Type; + + + /* Extract the name from the object and convert to a string */ + + MOVE_UNALIGNED32_TO_32 (Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name); + Name[ACPI_NAME_SIZE] = 0; + + /* + * Edge/Level determination is based on the 2nd INT8 of the method name + */ + if (Name[1] == 'L') + { + Type = ACPI_EVENT_LEVEL_TRIGGERED; + } + else if (Name[1] == 'E') + { + Type = ACPI_EVENT_EDGE_TRIGGERED; + } + else + { + /* Unknown method type, just ignore it! */ + + DEBUG_PRINT (ACPI_ERROR, + ("EvSaveMethodInfo: Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n", + Name)); + return (AE_OK); + } + + /* Convert the last two characters of the name to the Gpe Number */ + + GpeNumber = STRTOUL (&Name[2], NULL, 16); + if (GpeNumber == ACPI_UINT32_MAX) + { + /* Conversion failed; invalid method, just ignore it */ + + DEBUG_PRINT (ACPI_ERROR, + ("EvSaveMethodInfo: Could not extract GPE number from name: %s (name not of form _Lnn or _Enn)\n", + Name)); + return (AE_OK); + } + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + /* Not valid, all we can do here is ignore it */ + + return (AE_OK); + } + + /* + * Now we can add this information to the GpeInfo block + * for use during dispatch of this GPE. + */ + + AcpiGbl_GpeInfo [GpeNumber].Type = Type; + AcpiGbl_GpeInfo [GpeNumber].MethodHandle = ObjHandle; + + + /* + * Enable the GPE (SCIs should be disabled at this point) + */ + + AcpiHwEnableGpe (GpeNumber); + + DEBUG_PRINT (ACPI_INFO, + ("EvSaveMethodInfo: Registered GPE method %s as GPE number %d\n", + Name, GpeNumber)); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvInitGpeControlMethods + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Obtain the control methods associated with the GPEs. + * + * NOTE: Must be called AFTER namespace initialization! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitGpeControlMethods (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInitGpeControlMethods"); + + + /* Get a permanent handle to the _GPE object */ + + Status = AcpiGetHandle (NULL, "\\_GPE", &AcpiGbl_GpeObjHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Traverse the namespace under \_GPE to find all methods there */ + + Status = AcpiWalkNamespace (ACPI_TYPE_METHOD, AcpiGbl_GpeObjHandle, + ACPI_UINT32_MAX, AcpiEvSaveMethodInfo, + NULL, NULL); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeCleanup + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Cleanup in preparation for unload. + * + ******************************************************************************/ + +void +AcpiEvGpeCleanup (void) +{ + FUNCTION_TRACE ("EvGpeCleanup"); + + + AcpiCmFree (AcpiGbl_GpeRegisters); + AcpiCmFree (AcpiGbl_GpeInfo); + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeDetect + * + * PARAMETERS: None + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Detect if any GP events have occurred + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDetect (void) +{ + UINT32 IntStatus = INTERRUPT_NOT_HANDLED; + UINT32 i; + UINT32 j; + UINT8 EnabledStatusByte; + UINT8 BitMask; + + + /* + * Read all of the 8-bit GPE status and enable registers + * in both of the register blocks, saving all of it. + * Find all currently active GP events. + */ + + for (i = 0; i < AcpiGbl_GpeRegisterCount; i++) + { + AcpiGbl_GpeRegisters[i].Status = + AcpiOsIn8 (AcpiGbl_GpeRegisters[i].StatusAddr); + + AcpiGbl_GpeRegisters[i].Enable = + AcpiOsIn8 (AcpiGbl_GpeRegisters[i].EnableAddr); + + DEBUG_PRINT (TRACE_INTERRUPTS, + ("GPE block at %x - Enable: %08x\tStatus: %08x\n", + AcpiGbl_GpeRegisters[i].EnableAddr, AcpiGbl_GpeRegisters[i].Status, AcpiGbl_GpeRegisters[i].Enable)); + + /* First check if there is anything active at all in this register */ + + EnabledStatusByte = (UINT8) (AcpiGbl_GpeRegisters[i].Status & + AcpiGbl_GpeRegisters[i].Enable); + + if (!EnabledStatusByte) + { + /* No active GPEs in this register, move on */ + + continue; + } + + /* Now look at the individual GPEs in this byte register */ + + for (j = 0, BitMask = 1; j < 8; j++, BitMask <<= 1) + { + /* Examine one GPE bit */ + + if (EnabledStatusByte & BitMask) + { + /* + * Found an active GPE. Dispatch the event to a handler + * or method. + */ + IntStatus |= + AcpiEvGpeDispatch (AcpiGbl_GpeRegisters[i].GpeBase + j); + } + } + } + + return (IntStatus); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvAsynchExecuteGpeMethod + * + * PARAMETERS: GpeNumber - The 0-based Gpe number + * + * RETURN: None + * + * DESCRIPTION: Perform the actual execution of a GPE control method. This + * function is called from an invocation of AcpiOsQueueForExecution + * (and therefore does NOT execute at interrupt level) so that + * the control method itself is not executed in the context of + * the SCI interrupt handler. + * + ******************************************************************************/ + +void +AcpiEvAsynchExecuteGpeMethod ( + void *Context) +{ + UINT32 GpeNumber = (UINT32) Context; + ACPI_GPE_LEVEL_INFO GpeInfo; + + + FUNCTION_TRACE ("EvAsynchExecuteGpeMethod"); + + + /* Take a snapshot of the GPE info for this level */ + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + + /* + * Function Handler (e.g. EC): + * --------------------------- + * Execute the installed function handler to handle this event. + */ + if (GpeInfo.Handler) + { + GpeInfo.Handler (GpeInfo.Context); + } + + /* + * Method Handler (_Lxx, _Exx): + * ---------------------------- + * AcpiEvaluate the _Lxx/_Exx control method that corresponds to this GPE. + */ + else if (GpeInfo.MethodHandle) + { + AcpiNsEvaluateByHandle (GpeInfo.MethodHandle, NULL, NULL); + } + + /* + * Level-Triggered? + * ---------------- + * If level-triggered, clear the GPE status bit after execution. Note + * that edge-triggered events are cleared prior to calling (via DPC) + * this function. + */ + if (GpeInfo.Type | ACPI_EVENT_LEVEL_TRIGGERED) + { + AcpiHwClearGpe (GpeNumber); + } + + /* + * Enable the GPE. + */ + AcpiHwEnableGpe (GpeNumber); + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeDispatch + * + * PARAMETERS: GpeNumber - The 0-based Gpe number + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Handle and dispatch a General Purpose AcpiEvent. + * Clears the status bit for the requested event. + * + * TBD: [Investigate] is this still valid or necessary: + * The Gpe handler differs from the fixed events in that it clears the enable + * bit rather than the status bit to clear the interrupt. This allows + * software outside of interrupt context to determine what caused the SCI and + * dispatch the correct AML. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDispatch ( + UINT32 GpeNumber) +{ + FUNCTION_TRACE ("EvGpeDispatch"); + + + DEBUG_PRINT (ACPI_INFO, ("GPE [%d] event occurred.\n", GpeNumber)); + + /*DEBUG_INCREMENT_EVENT_COUNT (EVENT_GENERAL);*/ + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + DEBUG_PRINT (ACPI_ERROR, ("Invalid GPE [%d].\n", GpeNumber)); + return_VALUE (INTERRUPT_NOT_HANDLED); + } + + /* + * Disable the GPE. + */ + AcpiHwDisableGpe (GpeNumber); + + /* + * Edge-Triggered? + * --------------- + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced + * (see AcpiEvAsynchExecuteGpeMethod). + */ + if (AcpiGbl_GpeInfo [GpeNumber].Type | ACPI_EVENT_EDGE_TRIGGERED) + { + AcpiHwClearGpe (GpeNumber); + } + + /* + * Queue-up the Handler: + * --------------------- + * Queue the handler, which is either an installable function handler + * (e.g. EC) or a control method (e.g. _Lxx/_Exx) for later execution. + */ + if (AcpiGbl_GpeInfo [GpeNumber].Handler || + AcpiGbl_GpeInfo [GpeNumber].MethodHandle) + { + if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE, + AcpiEvAsynchExecuteGpeMethod, + (void*)(NATIVE_UINT)GpeNumber))) + { + /* + * Shoudn't occur, but if it does report an error. Note that + * the GPE will remain disabled until the ACPI Core Subsystem + * is restarted, or the handler is removed/reinstalled. + */ + REPORT_ERROR ( + ("EvGpeDispatch: Unable to queue the handler for GPE [0x%08X]\n", + GpeNumber)); + } + } + + /* + * Non Handled GPEs: + * ----------------- + * GPEs without handlers are disabled and kept that way until a handler + * is registered for them. + */ + else + { + REPORT_ERROR ( + ("EvGpeDispatch: No installed handler for GPE [0x%08X]\n", + GpeNumber)); + } + + return_VALUE (INTERRUPT_HANDLED); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evmisc.c b/sys/contrib/dev/acpica/Subsystem/Events/evmisc.c new file mode 100644 index 0000000..cdb4af7 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evmisc.c @@ -0,0 +1,486 @@ +/****************************************************************************** + * + * Module Name: evmisc - ACPI device notification handler dispatch + * and ACPI Global Lock support + * $Revision: 15 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "achware.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evmisc") + + +/************************************************************************** + * + * FUNCTION: AcpiEvNotifyDispatch + * + * PARAMETERS: + * + * RETURN: None. + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + *************************************************************************/ + +void +AcpiEvNotifyDispatch ( + ACPI_HANDLE Device, + UINT32 NotifyValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + NOTIFY_HANDLER Handler; + + + /* + * For value 1 (Ejection Request), some device method may need to be run. + * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run. + * For value 0x80 (Status Change) on the power button or sleep button, + * initiate soft-off or sleep operation? + */ + + + DEBUG_PRINT (ACPI_INFO, + ("Dispatching Notify(%d) on device %p\n", NotifyValue, Device)); + + switch (NotifyValue) + { + case 0: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Re-enumerate Devices\n")); + break; + + case 1: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Ejection Request\n")); + break; + + case 2: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Device Wake\n")); + break; + + case 0x80: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Status Change\n")); + break; + + default: + DEBUG_PRINT (ACPI_INFO, ("Unknown Notify Value: %lx \n", NotifyValue)); + break; + } + + + /* + * Invoke a global notify handler if installed. + * This is done _before_ we invoke the per-device handler attached to the device. + */ + + if (NotifyValue <= MAX_SYS_NOTIFY) + { + /* Global system notification handler */ + + if (AcpiGbl_SysNotify.Handler) + { + AcpiGbl_SysNotify.Handler (Device, NotifyValue, + AcpiGbl_SysNotify.Context); + } + } + + else + { + /* Global driver notification handler */ + + if (AcpiGbl_DrvNotify.Handler) + { + AcpiGbl_DrvNotify.Handler (Device, NotifyValue, + AcpiGbl_DrvNotify.Context); + } + } + + + /* + * Get the notify object which must be attached to the device Node + */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Device); + if (!ObjDesc) + { + /* There can be no notify handler for this device */ + + DEBUG_PRINT (ACPI_INFO, + ("No notify handler for device %p \n", Device)); + return; + } + + + /* We have the notify object, Get the right handler */ + + if (NotifyValue <= MAX_SYS_NOTIFY) + { + HandlerObj = ObjDesc->Device.SysHandler; + } + else + { + HandlerObj = ObjDesc->Device.DrvHandler; + } + + /* Validate the handler */ + + if (!HandlerObj) + { + /* There is no notify handler for this device */ + + DEBUG_PRINT (ACPI_INFO, + ("No notify handler for device %p \n", Device)); + return; + } + + /* There is a handler, invoke it */ + + Handler = HandlerObj->NotifyHandler.Handler; + Handler (Device, NotifyValue, HandlerObj->NotifyHandler.Context); + +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvGlobalLockThread + * + * RETURN: None + * + * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the + * Global Lock. Simply signal all threads that are waiting + * for the lock. + * + **************************************************************************/ + +void +AcpiEvGlobalLockThread ( + void *Context) +{ + + /* Signal threads that are waiting for the lock */ + + if (AcpiGbl_GlobalLockThreadCount) + { + /* Send sufficient units to the semaphore */ + + AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, + AcpiGbl_GlobalLockThreadCount); + } +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvGlobalLockHandler + * + * RETURN: Status + * + * DESCRIPTION: Invoked directly from the SCI handler when a global lock + * release interrupt occurs. Grab the global lock and queue + * the global lock thread for execution + * + **************************************************************************/ + +UINT32 +AcpiEvGlobalLockHandler ( + void *Context) +{ + BOOLEAN Acquired = FALSE; + void *GlobalLock; + + + /* + * Attempt to get the lock + * If we don't get it now, it will be marked pending and we will + * take another interrupt when it becomes free. + */ + + GlobalLock = &AcpiGbl_FACS->GlobalLock; + ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); + if (Acquired) + { + /* Got the lock, now wake all threads waiting for it */ + + AcpiGbl_GlobalLockAcquired = TRUE; + + /* Run the Global Lock thread which will signal all waiting threads */ + + AcpiOsQueueForExecution (OSD_PRIORITY_HIGH, AcpiEvGlobalLockThread, + Context); + } + + return (INTERRUPT_HANDLED); +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvInitGlobalLockHandler + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for the global lock release event + * + **************************************************************************/ + +ACPI_STATUS +AcpiEvInitGlobalLockHandler (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInitGlobalLockHandler"); + + + Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler, NULL); + + return_ACPI_STATUS (Status); +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvAcquireGlobalLock + * + * RETURN: Status + * + * DESCRIPTION: Attempt to gain ownership of the Global Lock. + * + **************************************************************************/ + +ACPI_STATUS +AcpiEvAcquireGlobalLock(void) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN Acquired = FALSE; + void *GlobalLock; + + + FUNCTION_TRACE ("EvAcquireGlobalLock"); + + + /* One more thread wants the global lock */ + + AcpiGbl_GlobalLockThreadCount++; + + + /* If we (OS side) have the hardware lock already, we are done */ + + if (AcpiGbl_GlobalLockAcquired) + { + return_ACPI_STATUS (AE_OK); + } + + /* Only if the FACS is valid */ + + if (!AcpiGbl_FACS) + { + return_ACPI_STATUS (AE_OK); + } + + + /* We must acquire the actual hardware lock */ + + GlobalLock = &AcpiGbl_FACS->GlobalLock; + ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); + if (Acquired) + { + /* We got the lock */ + + DEBUG_PRINT (ACPI_INFO, ("Acquired the HW Global Lock\n")); + + AcpiGbl_GlobalLockAcquired = TRUE; + + return_ACPI_STATUS (AE_OK); + } + + + /* + * Did not get the lock. The pending bit was set above, and we must now + * wait until we get the global lock released interrupt. + */ + + DEBUG_PRINT (ACPI_INFO, ("Waiting for the HW Global Lock\n")); + + /* + * Acquire the global lock semaphore first. + * Since this wait will block, we must release the interpreter + */ + + Status = AcpiAmlSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, + ACPI_UINT32_MAX); + + return_ACPI_STATUS (Status); +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvReleaseGlobalLock + * + * DESCRIPTION: Releases ownership of the Global Lock. + * + **************************************************************************/ + +void +AcpiEvReleaseGlobalLock (void) +{ + BOOLEAN Pending = FALSE; + void *GlobalLock; + + + FUNCTION_TRACE ("EvReleaseGlobalLock"); + + if (!AcpiGbl_GlobalLockThreadCount) + { + REPORT_WARNING(("Releasing a non-acquired Global Lock\n")); + return_VOID; + } + + /* One fewer thread has the global lock */ + + AcpiGbl_GlobalLockThreadCount--; + + /* Have all threads released the lock? */ + + if (!AcpiGbl_GlobalLockThreadCount) + { + /* + * No more threads holding lock, we can do the actual hardware + * release + */ + + GlobalLock = &AcpiGbl_FACS->GlobalLock; + ACPI_RELEASE_GLOBAL_LOCK (GlobalLock, Pending); + AcpiGbl_GlobalLockAcquired = FALSE; + + /* + * If the pending bit was set, we must write GBL_RLS to the control + * register + */ + if (Pending) + { + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, + PM1_CONTROL | GBL_RLS, 1); + } + } + + return_VOID; +} diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evregion.c b/sys/contrib/dev/acpica/Subsystem/Events/evregion.c new file mode 100644 index 0000000..1248482 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evregion.c @@ -0,0 +1,765 @@ +/****************************************************************************** + * + * Module Name: evregion - ACPI AddressSpace / OpRegion handler dispatch + * $Revision: 85 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVREGION_C__ + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evregion") + + +/************************************************************************** + * + * FUNCTION: AcpiEvInstallDefaultAddressSpaceHandlers + * + * PARAMETERS: + * + * RETURN: Status + * + * DESCRIPTION: Installs the core subsystem address space handlers. + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvInstallDefaultAddressSpaceHandlers ( + void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInstallDefaultAddressSpaceHandlers"); + + /* + * All address spaces (PCI Config, EC, SMBus) are scope dependent + * and registration must occur for a specific device. In the case + * system memory and IO address spaces there is currently no device + * associated with the address space. For these we use the root. + * We install the default PCI config space handler at the root so + * that this space is immediately available even though the we have + * not enumerated all the PCI Root Buses yet. This is to conform + * to the ACPI specification which states that the PCI config + * space must be always available -- even though we are nowhere + * near ready to find the PCI root buses at this point. + * + * NOTE: We ignore AE_EXIST because this means that a handler has + * already been installed (via AcpiInstallAddressSpaceHandler) + */ + + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + ADDRESS_SPACE_SYSTEM_MEMORY, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if ((ACPI_FAILURE (Status)) && + (Status != AE_EXIST)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + ADDRESS_SPACE_SYSTEM_IO, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if ((ACPI_FAILURE (Status)) && + (Status != AE_EXIST)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + ADDRESS_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if ((ACPI_FAILURE (Status)) && + (Status != AE_EXIST)) + { + return_ACPI_STATUS (Status); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/* TBD: [Restructure] Move elsewhere */ + +/************************************************************************** + * + * FUNCTION: AcpiEvExecuteRegMethod + * + * PARAMETERS: RegionObj - Object structure + * Function - On (1) or Off (0) + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG method for a region + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function) +{ + ACPI_OPERAND_OBJECT *Params[3]; + ACPI_OPERAND_OBJECT SpaceID_Obj; + ACPI_OPERAND_OBJECT Function_Obj; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvExecuteRegMethod"); + + + if (RegionObj->Region.Extra->Extra.Method_REG == NULL) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * _REG method has two arguments + * Arg0: Integer: Operation region space ID + * Same value as RegionObj->Region.SpaceId + * Arg1: Integer: connection status + * 1 for connecting the handler, + * 0 for disconnecting the handler + * Passed as a parameter + */ + + AcpiCmInitStaticObject (&SpaceID_Obj); + AcpiCmInitStaticObject (&Function_Obj); + + /* + * Method requires two parameters. + */ + Params [0] = &SpaceID_Obj; + Params [1] = &Function_Obj; + Params [2] = NULL; + + /* + * Set up the parameter objects + */ + SpaceID_Obj.Common.Type = ACPI_TYPE_NUMBER; + SpaceID_Obj.Number.Value = RegionObj->Region.SpaceId; + + Function_Obj.Common.Type = ACPI_TYPE_NUMBER; + Function_Obj.Number.Value = Function; + + /* + * Execute the method, no return value + */ + Status = AcpiNsEvaluateByHandle (RegionObj->Region.Extra->Extra.Method_REG, Params, NULL); + return_ACPI_STATUS (Status); +} + + +/************************************************************************** + * + * FUNCTION: AcpiEvAddressSpaceDispatch + * + * PARAMETERS: RegionObj - internal region object + * SpaceId - ID of the address space (0-255) + * Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * + * RETURN: Status + * + * DESCRIPTION: Dispatch an address space or operation region access to + * a previously installed handler. + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value) +{ + ACPI_STATUS Status; + ADDRESS_SPACE_HANDLER Handler; + ADDRESS_SPACE_SETUP RegionSetup; + ACPI_OPERAND_OBJECT *HandlerDesc; + void *RegionContext = NULL; + + + FUNCTION_TRACE ("EvAddressSpaceDispatch"); + + + /* + * Check for an installed handler + */ + HandlerDesc = RegionObj->Region.AddrHandler; + + if (!HandlerDesc) + { + DEBUG_PRINT (TRACE_OPREGION, + ("Dispatch address access region 0x%p, no handler\n", RegionObj)); + return_ACPI_STATUS(AE_NOT_EXIST); + } + + /* + * It may be the case that the region has never been initialized + * Some types of regions require special init code + */ + if (!(RegionObj->Region.Flags & AOPOBJ_INITIALIZED)) + { + /* + * This region has not been initialized yet, do it + */ + RegionSetup = HandlerDesc->AddrHandler.Setup; + if (!RegionSetup) + { + /* + * Bad news, no init routine and not init'd + */ + DEBUG_PRINT (ACPI_ERROR, + ("EvAddressSpaceDispatch: No init routine for region %p\n", + RegionObj)); + return_ACPI_STATUS (AE_UNKNOWN_STATUS); + } + + /* + * We must exit the interpreter because the region setup will potentially + * execute control methods + */ + AcpiAmlExitInterpreter (); + + Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, + HandlerDesc->AddrHandler.Context, + &RegionContext); + + /* Re-enter the interpreter */ + + AcpiAmlEnterInterpreter (); + + /* + * Init routine may fail + */ + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("EvAddressSpaceDispatch: %s from region init, SpaceID %d\n", + AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); + return_ACPI_STATUS(Status); + } + + RegionObj->Region.Flags |= AOPOBJ_INITIALIZED; + + /* + * Save the returned context for use in all accesses to + * this particular region. + */ + RegionObj->Region.Extra->Extra.RegionContext = RegionContext; + } + + /* + * We have everything we need, begin the process + */ + Handler = HandlerDesc->AddrHandler.Handler; + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Addrhandler 0x%p (0x%p), Address 0x%p\n", + &RegionObj->Region.AddrHandler->AddrHandler, Handler, Address)); + + if (!(HandlerDesc->AddrHandler.Flags & 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. + */ + AcpiAmlExitInterpreter(); + } + + /* + * Invoke the handler. + */ + Status = Handler (Function, Address, BitWidth, Value, + HandlerDesc->AddrHandler.Context, + RegionObj->Region.Extra->Extra.RegionContext); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("EvAddressSpaceDispatch: %s from handler, SpaceID %d\n", + AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); + } + + if (!(HandlerDesc->AddrHandler.Flags & ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* We just returned from a non-default handler, we must re-enter the + interpreter */ + + AcpiAmlEnterInterpreter (); + } + + return_ACPI_STATUS (Status); +} + +/****************************************************************************** + * + * FUNCTION: AcpiEvDisassociateRegionFromHandler + * + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * + * RETURN: None + * + * DESCRIPTION: Break the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +void +AcpiEvDisassociateRegionFromHandler( + ACPI_OPERAND_OBJECT *RegionObj) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + ADDRESS_SPACE_SETUP RegionSetup; + void *RegionContext; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvDisassociateRegionFromHandler"); + + RegionContext = RegionObj->Region.Extra->Extra.RegionContext; + + /* + * Get the address handler from the region object + */ + + HandlerObj = RegionObj->Region.AddrHandler; + if (!HandlerObj) + { + /* + * This region has no handler, all done + */ + return_VOID; + } + + + /* + * Find this region in the handler's list + */ + + ObjDesc = HandlerObj->AddrHandler.RegionList; + LastObjPtr = &HandlerObj->AddrHandler.RegionList; + + while (ObjDesc) + { + /* + * See if this is the one + */ + if (ObjDesc == RegionObj) + { + DEBUG_PRINT (TRACE_OPREGION, + ("Removing Region 0x%p from address handler 0x%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 */ + + /* + * Now stop region accesses by executing the _REG method + */ + AcpiEvExecuteRegMethod (RegionObj, 0); + + /* + * Call the setup handler with the deactivate notification + */ + RegionSetup = HandlerObj->AddrHandler.Setup; + Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, + HandlerObj->AddrHandler.Context, + &RegionContext); + + /* + * Init routine may fail, Just ignore errors + */ + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("EvDisassociateRegionFromHandler: %s from region init, SpaceID %d\n", + AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); + } + + RegionObj->Region.Flags &= ~(AOPOBJ_INITIALIZED); + + /* + * Remove handler reference in the region + * + * NOTE: this doesn't mean that the region goes away + * The region is just inaccessible as indicated to + * the _REG method + * + * If the region is on the handler's list + * this better be the region's handler + */ + ACPI_ASSERT (RegionObj->Region.AddrHandler == HandlerObj); + + RegionObj->Region.AddrHandler = NULL; + + return_VOID; + + } /* found the right handler */ + + /* + * Move through the linked list of handlers + */ + LastObjPtr = &ObjDesc->Region.Next; + ObjDesc = ObjDesc->Region.Next; + } + + /* + * If we get here, the region was not in the handler's region list + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Cannot remove region 0x%p from address handler 0x%p\n", + RegionObj, HandlerObj)); + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvAssociateRegionAndHandler + * + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * + * RETURN: None + * + * DESCRIPTION: Create the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAssociateRegionAndHandler ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvAssociateRegionAndHandler"); + + + DEBUG_PRINT (TRACE_OPREGION, ("Adding Region 0x%p to address handler 0x%p\n", + RegionObj, HandlerObj)); + + ACPI_ASSERT (RegionObj->Region.SpaceId == HandlerObj->AddrHandler.SpaceId); + ACPI_ASSERT (RegionObj->Region.AddrHandler == 0); + + /* + * Link this region to the front of the handler's list + */ + + RegionObj->Region.Next = HandlerObj->AddrHandler.RegionList; + HandlerObj->AddrHandler.RegionList = RegionObj; + + /* + * set the region's handler + */ + +/* + HandlerObj->Common.ReferenceCount = + (UINT16) (HandlerObj->Common.ReferenceCount + + RegionObj->Common.ReferenceCount - 1); +*/ + RegionObj->Region.AddrHandler = HandlerObj; + + /* + * Last thing, tell all users that this region is usable + */ + if (AcpiNsIsLocked) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + Status = AcpiEvExecuteRegMethod (RegionObj, 1); + + if (AcpiNsIsLocked) + { + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + } + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiEvAddrHandlerHelper + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into AcpiNsWalkNamespace + * + * DESCRIPTION: This routine checks to see if the object is a Region if it + * is then the address handler is installed in it. + * + * If the Object is a Device, and the device has a handler of + * the same type then the search is terminated in that branch. + * + * This is because the existing handler is closer in proximity + * to any more regions than the one we are trying to install. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiEvAddrHandlerHelper ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *TmpObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + HandlerObj = (ACPI_OPERAND_OBJECT *) Context; + + /* Parameter validation */ + + if (!HandlerObj) + { + return (AE_OK); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsConvertHandleToEntry (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions.and objects + * that can have address handlers + */ + + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + if (!ObjDesc) + { + /* + * The object DNE, we don't care about it + */ + return (AE_OK); + } + + /* + * Devices are handled different than regions + */ + if (IS_THIS_OBJECT_TYPE (ObjDesc, ACPI_TYPE_DEVICE)) + { + /* + * See if this guy has any handlers + */ + TmpObj = ObjDesc->Device.AddrHandler; + while (TmpObj) + { + /* + * Now let's see if it's for the same address space. + */ + if (TmpObj->AddrHandler.SpaceId == HandlerObj->AddrHandler.SpaceId) + { + /* + * It's for the same address space + */ + + DEBUG_PRINT (TRACE_OPREGION, + ("Found handler for %s in device 0x%p (0x%p) handler 0x%p\n", + AcpiGbl_RegionTypes[HandlerObj->AddrHandler.SpaceId], ObjDesc, TmpObj, HandlerObj)); + + /* + * Since the object we found it on was a device, then it + * means that someone has already installed a handler for + * the branch of the namespace from this device on. Just + * bail out telling the walk routine to not traverse this + * branch. This preserves the scoping rule for handlers. + */ + return (AE_CTRL_DEPTH); + } + + /* + * Move through the linked list of handlers + */ + TmpObj = TmpObj->AddrHandler.Next; + } + + /* + * As long as the device didn't have a handler for this + * space we don't care about it. We just ignore it and + * proceed. + */ + return (AE_OK); + } + + /* + * Only here if it was a region + */ + ACPI_ASSERT (ObjDesc->Common.Type == ACPI_TYPE_REGION); + + if (ObjDesc->Region.SpaceId != HandlerObj->AddrHandler.SpaceId) + { + /* + * This region is for a different address space + * ignore it + */ + return (AE_OK); + } + + /* + * Now we have a region and it is for the handler's address + * space type. + * + * First disconnect region for any previous handler (if any) + */ + AcpiEvDisassociateRegionFromHandler (ObjDesc); + + /* + * Then connect the region to the new handler + */ + Status = AcpiEvAssociateRegionAndHandler (HandlerObj, ObjDesc, FALSE); + + return (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c b/sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c new file mode 100644 index 0000000..b4aaa7a --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c @@ -0,0 +1,557 @@ +/****************************************************************************** + * + * Module Name: evrgnini- ACPI AddressSpace / OpRegion init + * $Revision: 27 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVRGNINI_C__ + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evrgnini") + + +/***************************************************************************** + * + * FUNCTION: AcpiEvSystemMemoryRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling, a nop for now + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + FUNCTION_TRACE ("EvSystemMemoryRegionSetup"); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + if (*RegionContext) + { + AcpiCmFree (*RegionContext); + *RegionContext = NULL; + } + return_ACPI_STATUS (AE_OK); + } + + + /* Activate. Create a new context */ + + *RegionContext = AcpiCmCallocate (sizeof (MEM_HANDLER_CONTEXT)); + if (!(*RegionContext)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiEvIoSpaceRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + FUNCTION_TRACE ("EvIoSpaceRegionSetup"); + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiEvPciConfigRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling + * + * MUTEX: Assumes namespace is not locked + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Temp; + PCI_HANDLER_CONTEXT *PciContext = *RegionContext; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; + DEVICE_ID ObjectHID; + + FUNCTION_TRACE ("EvPciConfigRegionSetup"); + + HandlerObj = RegionObj->Region.AddrHandler; + + if (!HandlerObj) + { + /* + * No installed handler. This shouldn't happen because the dispatch + * routine checks before we get here, but we check again just in case. + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Attempting to init a region 0x%X, with no handler\n", RegionObj)); + return_ACPI_STATUS(AE_NOT_EXIST); + } + + if (Function == ACPI_REGION_DEACTIVATE) + { + if (PciContext) + { + AcpiCmFree (PciContext); + *RegionContext = NULL; + } + + return_ACPI_STATUS (Status); + } + + + /* Create a new context */ + + PciContext = AcpiCmCallocate (sizeof(PCI_HANDLER_CONTEXT)); + if (!PciContext) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * For PCI Config space access, we have to pass the segment, bus, + * device and function numbers. This routine must acquire those. + */ + + /* + * First get device and function numbers from the _ADR object + * in the parent's scope. + */ + ACPI_ASSERT(RegionObj->Region.Node); + + Node = AcpiNsGetParentObject (RegionObj->Region.Node); + + + /* AcpiEvaluate the _ADR object */ + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__ADR, Node, &Temp); + /* + * The default is zero, since the allocation above zeroed the data, just + * do nothing on failures. + */ + if (ACPI_SUCCESS (Status)) + { + /* + * Got it.. + */ + PciContext->DevFunc = (UINT32) Temp; + } + + /* + * Get the _SEG and _BBN values from the device upon which the handler + * is installed. + * + * We need to get the _SEG and _BBN objects relative to the PCI BUS device. + * This is the device the handler has been registered to handle. + */ + + /* + * If the AddrHandler.Node is still pointing to the root, we need + * to scan upward for a PCI Root bridge and re-associate the OpRegion + * handlers with that device. + */ + if (HandlerObj->AddrHandler.Node == AcpiGbl_RootNode) + { + /* + * Node is currently the parent object + */ + while (Node != AcpiGbl_RootNode) + { + Status = AcpiCmExecute_HID(Node, &ObjectHID); + + if (ACPI_SUCCESS (Status)) + { + if (!(STRNCMP(ObjectHID.Buffer, PCI_ROOT_HID_STRING, + sizeof (PCI_ROOT_HID_STRING)))) + { + AcpiInstallAddressSpaceHandler(Node, + ADDRESS_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + + break; + } + } + + Node = AcpiNsGetParentObject(Node); + } + } + else + { + Node = HandlerObj->AddrHandler.Node; + } + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__SEG, Node, &Temp); + if (ACPI_SUCCESS (Status)) + { + /* + * Got it.. + */ + PciContext->Seg = (UINT32) Temp; + } + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__BBN, Node, &Temp); + if (ACPI_SUCCESS (Status)) + { + /* + * Got it.. + */ + PciContext->Bus = (UINT32) Temp; + } + + *RegionContext = PciContext; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiEvDefaultRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + 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 + * + * 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 intialization. For + * example, PCI regions must have an _ADR object that contains + * a PCI address in the scope of the defintion. This address is + * required to perform an access to PCI config space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 SpaceId; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; + + + FUNCTION_TRACE_U32 ("EvInitializeRegion", AcpiNsLocked); + + + if (!RegionObj) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ACPI_ASSERT(RegionObj->Region.Node); + + Node = AcpiNsGetParentObject (RegionObj->Region.Node); + SpaceId = RegionObj->Region.SpaceId; + + RegionObj->Region.AddrHandler = NULL; + RegionObj->Region.Extra->Extra.Method_REG = NULL; + RegionObj->Region.Flags &= ~(AOPOBJ_INITIALIZED); + + /* + * Find any "_REG" associated with this region definition + */ + Status = AcpiNsSearchNode (*RegNamePtr, Node, + ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per region + * definition. This will be executed when the handler is attached + * or removed + */ + RegionObj->Region.Extra->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 ((ACPI_HANDLE) Node); + if (ObjDesc) + { + /* + * can only be a handler if the object exists + */ + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + + HandlerObj = ObjDesc->Device.AddrHandler; + break; + + case ACPI_TYPE_PROCESSOR: + + HandlerObj = ObjDesc->Processor.AddrHandler; + break; + + case ACPI_TYPE_THERMAL: + + HandlerObj = ObjDesc->ThermalZone.AddrHandler; + break; + } + + while (HandlerObj) + { + /* + * This guy has at least one address handler + * see if it has the type we want + */ + if (HandlerObj->AddrHandler.SpaceId == SpaceId) + { + DEBUG_PRINT (TRACE_OPREGION, + ("Found handler (0x%X) for region 0x%X in obj 0x%X\n", + HandlerObj, RegionObj, ObjDesc)); + + /* + * Found it! Now update the region and the handler + */ + AcpiEvAssociateRegionAndHandler (HandlerObj, RegionObj, AcpiNsLocked); + return_ACPI_STATUS (AE_OK); + } + + HandlerObj = HandlerObj->AddrHandler.Next; + + } /* while handlerobj */ + } + + /* + * This one does not have the handler we need + * Pop up one level + */ + Node = AcpiNsGetParentObject (Node); + + } /* while Node != ROOT */ + + /* + * If we get here, there is no handler for this region + */ + DEBUG_PRINT (TRACE_OPREGION, + ("No handler currently for SpaceId[%d] (Initializing region 0x%X)\n", + SpaceId, RegionObj)); + + return_ACPI_STATUS (AE_NOT_EXIST); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evsci.c b/sys/contrib/dev/acpica/Subsystem/Events/evsci.c new file mode 100644 index 0000000..fb43444 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evsci.c @@ -0,0 +1,448 @@ +/******************************************************************************* + * + * Module Name: evsci - System Control Interrupt configuration and + * legacy to ACPI mode state transition functions + * $Revision: 60 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evsci") + + +/* + * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC, + * and GENERAL respectively. These counts are modified by the ACPI interrupt + * handler. + * + * TBD: [Investigate] Note that GENERAL should probably be split out into + * one element for each bit in the GPE registers + */ + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSciHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Interrupt handler that will figure out what function or + * control method to call to deal with a SCI. Installed + * using BU interrupt support. + * + ******************************************************************************/ + +UINT32 +AcpiEvSciHandler (void *Context) +{ + UINT32 InterruptHandled = INTERRUPT_NOT_HANDLED; + + + FUNCTION_TRACE("EvSciHandler"); + + + /* + * Make sure that ACPI is enabled by checking SCI_EN. Note that we are + * required to treat the SCI interrupt as sharable, level, active low. + */ + if (!AcpiHwRegisterAccess (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) + { + /* ACPI is not enabled; this interrupt cannot be for us */ + + return_VALUE (INTERRUPT_NOT_HANDLED); + } + + /* + * Fixed AcpiEvents: + * ------------- + * Check for and dispatch any Fixed AcpiEvents that have occurred + */ + InterruptHandled |= AcpiEvFixedEventDetect (); + + /* + * GPEs: + * ----- + * Check for and dispatch any GPEs that have occurred + */ + InterruptHandled |= AcpiEvGpeDetect (); + + return_VALUE (InterruptHandled); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvInstallSciHandler + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Installs SCI handler. + * + ******************************************************************************/ + +UINT32 +AcpiEvInstallSciHandler (void) +{ + UINT32 Except = AE_OK; + + + FUNCTION_TRACE ("EvInstallSciHandler"); + + + Except = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FACP->SciInt, + AcpiEvSciHandler, + NULL); + + return_ACPI_STATUS (Except); +} + + +/****************************************************************************** + + * + * FUNCTION: AcpiEvRemoveSciHandler + * + * PARAMETERS: none + * + * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not + * installed to begin with + * + * DESCRIPTION: Restores original status of all fixed event enable bits and + * removes SCI handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvRemoveSciHandler (void) +{ + FUNCTION_TRACE ("EvRemoveSciHandler"); + +#if 0 + /* TBD:[Investigate] Figure this out!! Disable all events first ??? */ + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (TMR_FIXED_EVENT)) + { + AcpiEventDisableEvent (TMR_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (GBL_FIXED_EVENT)) + { + AcpiEventDisableEvent (GBL_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (PWR_BTN_FIXED_EVENT)) + { + AcpiEventDisableEvent (PWR_BTN_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (SLP_BTN_FIXED_EVENT)) + { + AcpiEventDisableEvent (SLP_BTN_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (RTC_FIXED_EVENT)) + { + AcpiEventDisableEvent (RTC_FIXED_EVENT); + } + + OriginalFixedEnableBitStatus = 0; + +#endif + + AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FACP->SciInt, + AcpiEvSciHandler); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSciCount + * + * PARAMETERS: Event Event that generated an SCI. + * + * RETURN: Number of SCI's for requested event since last time + * SciOccured() was called for this event. + * + * DESCRIPTION: Checks to see if SCI has been generated from requested source + * since the last time this function was called. + * + ******************************************************************************/ + +#ifdef ACPI_DEBUG + +UINT32 +AcpiEvSciCount ( + UINT32 Event) +{ + UINT32 Count; + + FUNCTION_TRACE ("EvSciCount"); + + /* + * Elements correspond to counts for TMR, NOT_USED, GBL, + * PWR_BTN, SLP_BTN, RTC, and GENERAL respectively. + */ + + if (Event >= NUM_FIXED_EVENTS) + { + Count = (UINT32) -1; + } + else + { + Count = AcpiGbl_EventCount[Event]; + } + + return_VALUE (Count); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRestoreAcpiState + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Restore the original ACPI state of the machine + * + ******************************************************************************/ + +void +AcpiEvRestoreAcpiState (void) +{ + UINT32 Index; + + + FUNCTION_TRACE ("EvRestoreAcpiState"); + + + /* Restore the state of the chipset enable bits. */ + + if (AcpiGbl_RestoreAcpiChipset == TRUE) + { + /* Restore the fixed events */ + + if (AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk + 2) != + AcpiGbl_Pm1EnableRegisterSave) + { + AcpiOsOut16 ((AcpiGbl_FACP->Pm1aEvtBlk + 2), + AcpiGbl_Pm1EnableRegisterSave); + } + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + if (AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk + 2) != + AcpiGbl_Pm1EnableRegisterSave) + { + AcpiOsOut16 ((AcpiGbl_FACP->Pm1bEvtBlk + 2), + AcpiGbl_Pm1EnableRegisterSave); + } + } + + + /* Ensure that all status bits are clear */ + + AcpiHwClearAcpiStatus (); + + + /* Now restore the GPEs */ + + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); Index++) + { + if (AcpiOsIn8 (AcpiGbl_FACP->Gpe0Blk + + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)) != + AcpiGbl_Gpe0EnableRegisterSave[Index]) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe0Blk + + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)), + AcpiGbl_Gpe0EnableRegisterSave[Index]); + } + } + + if (AcpiGbl_FACP->Gpe1Blk && AcpiGbl_FACP->Gpe1BlkLen) + { + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); Index++) + { + if (AcpiOsIn8 (AcpiGbl_FACP->Gpe1Blk + + DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)) != + AcpiGbl_Gpe1EnableRegisterSave[Index]) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe1Blk + + DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)), + AcpiGbl_Gpe1EnableRegisterSave[Index]); + } + } + } + + if (AcpiHwGetMode() != AcpiGbl_OriginalMode) + { + AcpiHwSetMode (AcpiGbl_OriginalMode); + } + } + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiEvTerminate (void) +{ + + FUNCTION_TRACE ("EvTerminate"); + + + /* + * Free global tables, etc. + */ + + if (AcpiGbl_GpeRegisters) + { + AcpiCmFree (AcpiGbl_GpeRegisters); + } + + if (AcpiGbl_GpeInfo) + { + AcpiCmFree (AcpiGbl_GpeInfo); + } + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evxface.c b/sys/contrib/dev/acpica/Subsystem/Events/evxface.c new file mode 100644 index 0000000..03886ef --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evxface.c @@ -0,0 +1,744 @@ +/****************************************************************************** + * + * Module Name: evxface - External interfaces for ACPI events + * $Revision: 91 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial prton of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFACE_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acinterp.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evxface") + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallFixedEventHandler + * + * PARAMETERS: Event - Event type to enable. + * Handler - Pointer to the handler function for the + * event + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function and then enables the + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 Event, + FIXED_EVENT_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); + + + /* Sanity check the parameters. */ + + if (Event >= NUM_FIXED_EVENTS) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Don't allow two handlers. */ + + if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) + { + Status = AE_EXIST; + goto Cleanup; + } + + + /* Install the handler before enabling the event - just in case... */ + + AcpiGbl_FixedEventHandlers[Event].Handler = Handler; + AcpiGbl_FixedEventHandlers[Event].Context = Context; + + if (1 != AcpiHwRegisterAccess (ACPI_WRITE, + ACPI_MTX_LOCK, Event + TMR_EN, 1)) + { + DEBUG_PRINT (ACPI_WARN, + ("Could not write to fixed event enable register.\n")); + + /* Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + + Status = AE_ERROR; + goto Cleanup; + } + + DEBUG_PRINT (ACPI_INFO, + ("Enabled fixed event %d. Handler: %x\n", Event, Handler)); + + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiRemoveFixedEventHandler + * + * PARAMETERS: Event - Event type to disable. + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Disables the event and unregisters the event handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 Event, + FIXED_EVENT_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveFixedEventHandler"); + + + /* Sanity check the parameters. */ + + if (Event >= NUM_FIXED_EVENTS) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Disable the event before removing the handler - just in case... */ + + if (0 != AcpiHwRegisterAccess (ACPI_WRITE, + ACPI_MTX_LOCK, Event + TMR_EN, 0)) + { + DEBUG_PRINT (ACPI_WARN, + ("Could not write to fixed event enable register.\n")); + Status = AE_ERROR; + goto Cleanup; + } + + /* Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + + DEBUG_PRINT (ACPI_INFO, ("Disabled fixed event %d.\n", Event)); + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * Handler - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiInstallNotifyHandler"); + + + /* Parameter validation */ + + if ((!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Convert and validate the device handle */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + DeviceNode = AcpiNsConvertHandleToEntry (Device); + if (!DeviceNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* + * Support for global notify handlers. These handlers are invoked for + * every notifiy of the type specifiec + */ + + if (Device == ACPI_ROOT_OBJECT) + { + /* + * Make sure the handler is not already installed. + */ + + if (((HandlerType == ACPI_SYSTEM_NOTIFY) && + AcpiGbl_SysNotify.Handler) || + ((HandlerType == ACPI_DEVICE_NOTIFY) && + AcpiGbl_DrvNotify.Handler)) + { + Status = AE_EXIST; + goto UnlockAndExit; + } + + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SysNotify.Node = DeviceNode; + AcpiGbl_SysNotify.Handler = Handler; + AcpiGbl_SysNotify.Context = Context; + } + + else + { + AcpiGbl_DrvNotify.Node = DeviceNode; + AcpiGbl_DrvNotify.Handler = Handler; + AcpiGbl_DrvNotify.Context = Context; + } + + + /* Global notify handler installed */ + + goto UnlockAndExit; + } + + + /* + * These are the ONLY objects that can receive ACPI notifications + */ + + if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && + (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && + (DeviceNode->Type != ACPI_TYPE_POWER) && + (DeviceNode->Type != ACPI_TYPE_THERMAL)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); + if (ObjDesc) + { + /* + * The object exists. + * Make sure the handler is not already installed. + */ + + if (((HandlerType == ACPI_SYSTEM_NOTIFY) && + ObjDesc->Device.SysHandler) || + ((HandlerType == ACPI_DEVICE_NOTIFY) && + ObjDesc->Device.DrvHandler)) + { + Status = AE_EXIST; + goto UnlockAndExit; + } + } + + else + { + /* Create a new object */ + + ObjDesc = AcpiCmCreateInternalObject (DeviceNode->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Attach new object to the Node */ + + Status = AcpiNsAttachObject (Device, ObjDesc, (UINT8) DeviceNode->Type); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + + /* + * If we get here, we know that there is no handler installed + * so let's party + */ + NotifyObj = AcpiCmCreateInternalObject (INTERNAL_TYPE_NOTIFY); + if (!NotifyObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + NotifyObj->NotifyHandler.Node = DeviceNode; + NotifyObj->NotifyHandler.Handler = Handler; + NotifyObj->NotifyHandler.Context = Context; + + + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + ObjDesc->Device.SysHandler = NotifyObj; + } + + else + { + ObjDesc->Device.DrvHandler = NotifyObj; + } + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiRemoveNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * Handler - Address of the handler + * RETURN: Status + * + * DESCRIPTION: Remove a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); + + + /* Parameter validation */ + + if ((!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the device handle */ + + DeviceNode = AcpiNsConvertHandleToEntry (Device); + if (!DeviceNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * These are the ONLY objects that can receive ACPI notifications + */ + + if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && + (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && + (DeviceNode->Type != ACPI_TYPE_POWER) && + (DeviceNode->Type != ACPI_TYPE_THERMAL)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* + * The object exists. + * + * Make sure the handler is installed. + */ + + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + NotifyObj = ObjDesc->Device.SysHandler; + } + else + { + NotifyObj = ObjDesc->Device.DrvHandler; + } + + if ((!NotifyObj) || + (NotifyObj->NotifyHandler.Handler != Handler)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * Now we can remove the handler + */ + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + ObjDesc->Device.SysHandler = NULL; + } + else + { + ObjDesc->Device.DrvHandler = NULL; + } + + AcpiCmRemoveReference (NotifyObj); + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +/****************************************************************************** + * + * FUNCTION: AcpiInstallGpeHandler + * + * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is + * bank 0 first, then bank 1. + * Type - Whether this GPE should be treated as an + * edge- or level-triggered interrupt. + * Handler - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for a General Purpose Event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGpeHandler ( + UINT32 GpeNumber, + UINT32 Type, + GPE_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + + FUNCTION_TRACE ("AcpiInstallGpeHandler"); + + /* Parameter validation */ + + if (!Handler || (GpeNumber > NUM_GPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Make sure that there isn't a handler there already */ + + if (AcpiGbl_GpeInfo[GpeNumber].Handler) + { + Status = AE_EXIST; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_GpeInfo[GpeNumber].Handler = Handler; + AcpiGbl_GpeInfo[GpeNumber].Context = Context; + AcpiGbl_GpeInfo[GpeNumber].Type = (UINT8) Type; + + /* Clear the GPE (of stale events), the enable it */ + + AcpiHwClearGpe (GpeNumber); + AcpiHwEnableGpe (GpeNumber); + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiRemoveGpeHandler + * + * PARAMETERS: GpeNumber - The event to remove a handler + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveGpeHandler ( + UINT32 GpeNumber, + GPE_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveGpeHandler"); + + + /* Parameter validation */ + + if (!Handler || (GpeNumber > NUM_GPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the GPE before removing the handler */ + + AcpiHwDisableGpe (GpeNumber); + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Make sure that the installed handler is the same */ + + if (AcpiGbl_GpeInfo[GpeNumber].Handler != Handler) + { + AcpiHwEnableGpe (GpeNumber); + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* Remove the handler */ + + AcpiGbl_GpeInfo[GpeNumber].Handler = NULL; + AcpiGbl_GpeInfo[GpeNumber].Context = NULL; + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiAcquireGlobalLock + * + * PARAMETERS: Timeout - How long the caller is willing to wait + * OutHandle - A handle to the lock if acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire the ACPI Global Lock + * + ******************************************************************************/ +ACPI_STATUS +AcpiAcquireGlobalLock ( + void) +{ + ACPI_STATUS Status; + + + AcpiAmlEnterInterpreter (); + + /* + * TBD: [Restructure] add timeout param to internal interface, and + * perhaps INTERPRETER_LOCKED + */ + + Status = AcpiEvAcquireGlobalLock (); + AcpiAmlExitInterpreter (); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiReleaseGlobalLock + * + * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock + * + * RETURN: Status + * + * DESCRIPTION: Release the ACPI Global Lock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReleaseGlobalLock ( + void) +{ + AcpiEvReleaseGlobalLock (); + return (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c b/sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c new file mode 100644 index 0000000..d6c849e --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c @@ -0,0 +1,610 @@ +/****************************************************************************** + * + * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial prton of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFEVNT_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acinterp.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evxfevnt") + + +/************************************************************************** + * + * FUNCTION: AcpiEnable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into ACPI mode. + * + *************************************************************************/ + +ACPI_STATUS +AcpiEnable (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiEnable"); + + + /* Make sure we've got ACPI tables */ + + if (!AcpiGbl_DSDT) + { + DEBUG_PRINT (ACPI_WARN, ("No ACPI tables present!\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Make sure the BIOS supports ACPI mode */ + + if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities()) + { + DEBUG_PRINT (ACPI_WARN, + ("AcpiEnable: Only legacy mode supported!\n")); + return_ACPI_STATUS (AE_ERROR); + } + + /* Transition to ACPI mode */ + + Status = AcpiHwSetMode (SYS_MODE_ACPI); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, ("Could not transition to ACPI mode.\n")); + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (ACPI_OK, ("Transition to ACPI mode successful\n")); + + return_ACPI_STATUS (Status); +} + + +/************************************************************************** + * + * FUNCTION: AcpiDisable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Returns the system to original ACPI/legacy mode, and + * uninstalls the SCI interrupt handler. + * + *************************************************************************/ + +ACPI_STATUS +AcpiDisable (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiDisable"); + + + /* Restore original mode */ + + Status = AcpiHwSetMode (AcpiGbl_OriginalMode); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("Unable to transition to original mode")); + return_ACPI_STATUS (Status); + } + + /* Unload the SCI interrupt handler */ + + AcpiEvRemoveSciHandler (); + AcpiEvRestoreAcpiState (); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEnableEvent + * + * PARAMETERS: Event - The fixed event or GPE to be enabled + * Type - The type of event + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (fixed and general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Type) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiEnableEvent"); + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_EN; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_EN; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_EN; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_EN; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_EN; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* + * Enable the requested fixed event (by writing a one to the + * enable register bit) + */ + + AcpiHwRegisterAccess (ACPI_WRITE, TRUE, RegisterId, 1); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Enable the requested GPE number */ + + AcpiHwEnableGpe (Event); + break; + + + default: + + Status = AE_BAD_PARAMETER; + } + + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDisableEvent + * + * PARAMETERS: Event - The fixed event or GPE to be enabled + * Type - The type of event + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (fixed and general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Type) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiDisableEvent"); + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_EN; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_EN; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_EN; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_EN; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_EN; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* + * Disable the requested fixed event (by writing a zero to the + * enable register bit) + */ + + AcpiHwRegisterAccess (ACPI_WRITE, TRUE, RegisterId, 0); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the requested GPE number */ + + AcpiHwDisableGpe (Event); + break; + + + default: + Status = AE_BAD_PARAMETER; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiClearEvent + * + * PARAMETERS: Event - The fixed event or GPE to be cleared + * Type - The type of event + * + * RETURN: Status + * + * DESCRIPTION: Clear an ACPI event (fixed and general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event, + UINT32 Type) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiClearEvent"); + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_STS; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_STS; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_STS; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_STS; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_STS; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* + * Clear the requested fixed event (By writing a one to the + * status register bit) + */ + + AcpiHwRegisterAccess (ACPI_WRITE, TRUE, RegisterId, 1); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + AcpiHwClearGpe (Event); + break; + + + default: + + Status = AE_BAD_PARAMETER; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetEventStatus + * + * PARAMETERS: Event - The fixed event or GPE + * Type - The type of event + * Status - Where the current status of the event will + * be returned + * + * RETURN: Status + * + * DESCRIPTION: Obtains and returns the current status of the event + * + ******************************************************************************/ + + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + UINT32 Type, + ACPI_EVENT_STATUS *EventStatus) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiGetEventStatus"); + + + if (!EventStatus) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_STS; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_STS; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_STS; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_STS; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_STS; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* Get the status of the requested fixed event */ + + *EventStatus = AcpiHwRegisterAccess (ACPI_READ, TRUE, RegisterId); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Obtain status on the requested GPE number */ + + AcpiHwGetGpeStatus (Event, EventStatus); + break; + + + default: + Status = AE_BAD_PARAMETER; + } + + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c b/sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c new file mode 100644 index 0000000..fad4040 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c @@ -0,0 +1,515 @@ +/****************************************************************************** + * + * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and + * Address Spaces. + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial prton of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EVXFREGN_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acinterp.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evxfregn") + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_SPACE_HANDLER Handler, + ADDRESS_SPACE_SETUP Setup, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status = AE_OK; + OBJECT_TYPE_INTERNAL Type; + UINT16 Flags = 0; + + + FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler"); + + /* Parameter validation */ + + if ((!Device) || + ((!Handler) && (Handler != ACPI_DEFAULT_HANDLER)) || + (SpaceId > ACPI_MAX_ADDRESS_SPACE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the device handle */ + + Node = AcpiNsConvertHandleToEntry (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * This registration is valid for only the types below + * and the root. This is where the default handlers + * get placed. + */ + + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if (Handler == ACPI_DEFAULT_HANDLER) + { + Flags = ADDR_HANDLER_DEFAULT_INSTALLED; + + switch (SpaceId) + { + case ADDRESS_SPACE_SYSTEM_MEMORY: + Handler = AcpiAmlSystemMemorySpaceHandler; + Setup = AcpiEvSystemMemoryRegionSetup; + break; + + case ADDRESS_SPACE_SYSTEM_IO: + Handler = AcpiAmlSystemIoSpaceHandler; + Setup = AcpiEvIoSpaceRegionSetup; + break; + + case ADDRESS_SPACE_PCI_CONFIG: + Handler = AcpiAmlPciConfigSpaceHandler; + Setup = AcpiEvPciConfigRegionSetup; + break; + + default: + Status = AE_NOT_EXIST; + goto UnlockAndExit; + break; + } + } + + /* + * If the caller hasn't specified a setup routine, use the default + */ + if (!Setup) + { + Setup = AcpiEvDefaultRegionSetup; + } + + /* + * Check for an existing internal object + */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + if (ObjDesc) + { + /* + * The object exists. + * Make sure the handler is not already installed. + */ + + /* check the address handler the user requested */ + + HandlerObj = ObjDesc->Device.AddrHandler; + while (HandlerObj) + { + /* + * We have an Address handler, see if user requested this + * address space. + */ + if(HandlerObj->AddrHandler.SpaceId == SpaceId) + { + Status = AE_EXIST; + goto UnlockAndExit; + } + + /* + * Move through the linked list of handlers + */ + HandlerObj = HandlerObj->AddrHandler.Next; + } + } + + else + { + DEBUG_PRINT (TRACE_OPREGION, + ("Creating object on Device 0x%X 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 = AcpiCmCreateInternalObject (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, (UINT8) Type); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + goto UnlockAndExit; + } + } + + DEBUG_PRINT (TRACE_OPREGION, + ("Installing address handler for %s on Device 0x%p (0x%p)\n", + AcpiGbl_RegionTypes[SpaceId], Node, ObjDesc)); + + /* + * Now we can install the handler + * + * At this point we know that there is no existing handler. + * So, we just allocate the object for the handler and link it + * into the list. + */ + HandlerObj = AcpiCmCreateInternalObject (INTERNAL_TYPE_ADDRESS_HANDLER); + if (!HandlerObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + HandlerObj->AddrHandler.SpaceId = (UINT8) SpaceId; + HandlerObj->AddrHandler.Hflags = Flags; + HandlerObj->AddrHandler.Next = ObjDesc->Device.AddrHandler; + HandlerObj->AddrHandler.RegionList = NULL; + HandlerObj->AddrHandler.Node = Node; + HandlerObj->AddrHandler.Handler = Handler; + HandlerObj->AddrHandler.Context = Context; + HandlerObj->AddrHandler.Setup = Setup; + + /* + * Now walk the namespace finding all of the regions this + * handler will manage. + * + * We start at the device and search the branch toward + * the leaf nodes until either the leaf is encountered or + * a device is detected that has an address handler of the + * same type. + * + * In either case we back up and search down the remainder + * of the branch + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, + ACPI_UINT32_MAX, NS_WALK_UNLOCK, + AcpiEvAddrHandlerHelper, + HandlerObj, NULL); + + /* + * Place this handler 1st on the list + */ + + HandlerObj->Common.ReferenceCount = + (UINT16) (HandlerObj->Common.ReferenceCount + + ObjDesc->Common.ReferenceCount - 1); + ObjDesc->Device.AddrHandler = HandlerObj; + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiRemoveAddressSpaceHandler + * + * PARAMETERS: SpaceId - The address space ID + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for accesses on an Operation Region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_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 = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveAddressSpaceHandler"); + + + /* Parameter validation */ + + if ((!Device) || + ((!Handler) && (Handler != ACPI_DEFAULT_HANDLER)) || + (SpaceId > ACPI_MAX_ADDRESS_SPACE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the device handle */ + + Node = AcpiNsConvertHandleToEntry (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* Make sure the internal object exists */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + if (!ObjDesc) + { + /* + * The object DNE. + */ + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* + * find the address handler the user requested + */ + + HandlerObj = ObjDesc->Device.AddrHandler; + LastObjPtr = &ObjDesc->Device.AddrHandler; + while (HandlerObj) + { + /* + * We have a handler, see if user requested this one + */ + + if(HandlerObj->AddrHandler.SpaceId == SpaceId) + { + /* + * Got it, first dereference this in the Regions + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Removing address handler 0x%p (0x%p) for %s on Device 0x%p (0x%p)\n", + HandlerObj, Handler, AcpiGbl_RegionTypes[SpaceId], + Node, ObjDesc)); + + RegionObj = HandlerObj->AddrHandler.RegionList; + + /* Walk the handler's region list */ + + while (RegionObj) + { + /* + * First disassociate the handler from the region. + * + * NOTE: this doesn't mean that the region goes away + * The region is just inaccessible as indicated to + * the _REG method + */ + AcpiEvDisassociateRegionFromHandler(RegionObj); + + /* + * Walk the list, since we took the first region and it + * was removed from the list by the dissassociate call + * we just get the first item on the list again + */ + RegionObj = HandlerObj->AddrHandler.RegionList; + + } + + /* + * Remove this Handler object from the list + */ + *LastObjPtr = HandlerObj->AddrHandler.Next; + + /* + * Now we can delete the handler object + */ + AcpiCmRemoveReference (HandlerObj); + AcpiCmRemoveReference (HandlerObj); + + goto UnlockAndExit; + } + + /* + * Move through the linked list of handlers + */ + LastObjPtr = &HandlerObj->AddrHandler.Next; + HandlerObj = HandlerObj->AddrHandler.Next; + } + + + /* + * The handler does not exist + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Unable to remove address handler 0x%p for %s, DeviceNode 0x%p, obj 0x%p\n", + Handler, AcpiGbl_RegionTypes[SpaceId], Node, ObjDesc)); + + Status = AE_NOT_EXIST; + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Hardware/hwacpi.c b/sys/contrib/dev/acpica/Subsystem/Hardware/hwacpi.c new file mode 100644 index 0000000..e709688 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Hardware/hwacpi.c @@ -0,0 +1,501 @@ +/****************************************************************************** + * + * Module Name: hwacpi - ACPI hardware functions - mode and timer + * $Revision: 24 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWACPI_C__ + +#include "acpi.h" +#include "achware.h" + + +#define _COMPONENT HARDWARE + MODULE_NAME ("hwacpi") + + +/****************************************************************************** + * + * FUNCTION: AcpiHwInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize and validate various ACPI registers + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwInitialize ( + void) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Index; + + + FUNCTION_TRACE ("HwInitialize"); + + + /* We must have the ACPI tables by the time we get here */ + + if (!AcpiGbl_FACP) + { + AcpiGbl_RestoreAcpiChipset = FALSE; + + DEBUG_PRINT (ACPI_ERROR, ("HwInitialize: No FACP!\n")); + + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Must support *some* mode! */ +/* + if (!(SystemFlags & SYS_MODES_MASK)) + { + RestoreAcpiChipset = FALSE; + + DEBUG_PRINT (ACPI_ERROR, + ("CmHardwareInitialize: Supported modes uninitialized!\n")); + return_ACPI_STATUS (AE_ERROR); + } + +*/ + + + switch (AcpiGbl_SystemFlags & SYS_MODES_MASK) + { + /* Identify current ACPI/legacy mode */ + + case (SYS_MODE_ACPI): + + AcpiGbl_OriginalMode = SYS_MODE_ACPI; + DEBUG_PRINT (ACPI_INFO, ("System supports ACPI mode only.\n")); + break; + + + case (SYS_MODE_LEGACY): + + AcpiGbl_OriginalMode = SYS_MODE_LEGACY; + DEBUG_PRINT (ACPI_INFO, + ("Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n")); + break; + + + case (SYS_MODE_ACPI | SYS_MODE_LEGACY): + + if (AcpiHwGetMode () == SYS_MODE_ACPI) + { + AcpiGbl_OriginalMode = SYS_MODE_ACPI; + } + else + { + AcpiGbl_OriginalMode = SYS_MODE_LEGACY; + } + + DEBUG_PRINT (ACPI_INFO, + ("System supports both ACPI and LEGACY modes.\n")); + + DEBUG_PRINT (ACPI_INFO, + ("System is currently in %s mode.\n", + (AcpiGbl_OriginalMode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY")); + break; + } + + + if (AcpiGbl_SystemFlags & SYS_MODE_ACPI) + { + /* Target system supports ACPI mode */ + + /* + * The purpose of this block of code is to save the initial state + * of the ACPI event enable registers. An exit function will be + * registered which will restore this state when the application + * exits. The exit function will also clear all of the ACPI event + * status bits prior to restoring the original mode. + * + * The location of the PM1aEvtBlk enable registers is defined as the + * base of PM1aEvtBlk + PM1aEvtBlkLength / 2. Since the spec further + * fully defines the PM1aEvtBlk to be a total of 4 bytes, the offset + * for the enable registers is always 2 from the base. It is hard + * coded here. If this changes in the spec, this code will need to + * be modified. The PM1bEvtBlk behaves as expected. + */ + + AcpiGbl_Pm1EnableRegisterSave = + AcpiOsIn16 ((AcpiGbl_FACP->Pm1aEvtBlk + 2)); + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiGbl_Pm1EnableRegisterSave |= + AcpiOsIn16 ((AcpiGbl_FACP->Pm1bEvtBlk + 2)); + } + + + /* + * The GPEs behave similarly, except that the length of the register + * block is not fixed, so the buffer must be allocated with malloc + */ + + if (AcpiGbl_FACP->Gpe0Blk && AcpiGbl_FACP->Gpe0BlkLen) + { + /* GPE0 specified in FACP */ + + AcpiGbl_Gpe0EnableRegisterSave = + AcpiCmAllocate (DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)); + if (!AcpiGbl_Gpe0EnableRegisterSave) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save state of GPE0 enable bits */ + + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); Index++) + { + AcpiGbl_Gpe0EnableRegisterSave[Index] = + AcpiOsIn8 (AcpiGbl_FACP->Gpe0Blk + + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)); + } + } + + else + { + AcpiGbl_Gpe0EnableRegisterSave = NULL; + } + + if (AcpiGbl_FACP->Gpe1Blk && AcpiGbl_FACP->Gpe1BlkLen) + { + /* GPE1 defined */ + + AcpiGbl_Gpe1EnableRegisterSave = + AcpiCmAllocate (DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)); + if (!AcpiGbl_Gpe1EnableRegisterSave) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* save state of GPE1 enable bits */ + + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); Index++) + { + AcpiGbl_Gpe1EnableRegisterSave[Index] = + AcpiOsIn8 (AcpiGbl_FACP->Gpe1Blk + + DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)); + } + } + + else + { + AcpiGbl_Gpe1EnableRegisterSave = NULL; + } + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwSetMode + * + * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * RETURN: Status + * + * DESCRIPTION: Transitions the system into the requested mode or does nothing + * if the system is already in that mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode) +{ + + ACPI_STATUS Status = AE_ERROR; + + FUNCTION_TRACE ("HwSetMode"); + + + if (Mode == SYS_MODE_ACPI) + { + /* BIOS should have disabled ALL fixed and GP events */ + + AcpiOsOut8 (AcpiGbl_FACP->SmiCmd, AcpiGbl_FACP->AcpiEnable); + DEBUG_PRINT (ACPI_INFO, ("Attempting to enable ACPI mode\n")); + } + + else if (Mode == SYS_MODE_LEGACY) + { + /* + * BIOS should clear all fixed status bits and restore fixed event + * enable bits to default + */ + + AcpiOsOut8 (AcpiGbl_FACP->SmiCmd, AcpiGbl_FACP->AcpiDisable); + DEBUG_PRINT (ACPI_INFO, + ("Attempting to enable Legacy (non-ACPI) mode\n")); + } + + if (AcpiHwGetMode () == Mode) + { + DEBUG_PRINT (ACPI_INFO, ("Mode %d successfully enabled\n", Mode)); + Status = AE_OK; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetMode + * + * PARAMETERS: none + * + * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * DESCRIPTION: Return current operating state of system. Determined by + * querying the SCI_EN bit. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetMode (void) +{ + + FUNCTION_TRACE ("HwGetMode"); + + + if (AcpiHwRegisterAccess (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) + { + return_VALUE (SYS_MODE_ACPI); + } + else + { + return_VALUE (SYS_MODE_LEGACY); + } +} + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetModeCapabilities + * + * PARAMETERS: none + * + * RETURN: logical OR of SYS_MODE_ACPI and SYS_MODE_LEGACY determined at initial + * system state. + * + * DESCRIPTION: Returns capablities of system + * + ******************************************************************************/ + +UINT32 +AcpiHwGetModeCapabilities (void) +{ + + FUNCTION_TRACE ("HwGetModeCapabilities"); + + + if (!(AcpiGbl_SystemFlags & SYS_MODES_MASK)) + { + if (AcpiHwGetMode () == SYS_MODE_LEGACY) + { + /* + * Assume that if this call is being made, AcpiInit has been called + * and ACPI support has been established by the presence of the + * tables. Therefore since we're in SYS_MODE_LEGACY, the system + * must support both modes + */ + + AcpiGbl_SystemFlags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); + } + + else + { + /* TBD: [Investigate] !!! this may be unsafe... */ + /* + * system is is ACPI mode, so try to switch back to LEGACY to see if + * it is supported + */ + AcpiHwSetMode (SYS_MODE_LEGACY); + + if (AcpiHwGetMode () == SYS_MODE_LEGACY) + { + /* Now in SYS_MODE_LEGACY, so both are supported */ + + AcpiGbl_SystemFlags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); + AcpiHwSetMode (SYS_MODE_ACPI); + } + + else + { + /* Still in SYS_MODE_ACPI so this must be an ACPI only system */ + + AcpiGbl_SystemFlags |= SYS_MODE_ACPI; + } + } + } + + return_VALUE (AcpiGbl_SystemFlags & SYS_MODES_MASK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwPmtTicks + * + * PARAMETERS: none + * + * RETURN: Current value of the ACPI PMT (timer) + * + * DESCRIPTION: Obtains current value of ACPI PMT + * + ******************************************************************************/ + +UINT32 +AcpiHwPmtTicks (void) +{ + UINT32 Ticks; + + FUNCTION_TRACE ("AcpiPmtTicks"); + + Ticks = AcpiOsIn32 (AcpiGbl_FACP->PmTmrBlk); + + return_VALUE (Ticks); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwPmtResolution + * + * PARAMETERS: none + * + * RETURN: Number of bits of resolution in the PMT (either 24 or 32) + * + * DESCRIPTION: Obtains resolution of the ACPI PMT (either 24bit or 32bit) + * + ******************************************************************************/ + +UINT32 +AcpiHwPmtResolution (void) +{ + FUNCTION_TRACE ("AcpiPmtResolution"); + + if (0 == AcpiGbl_FACP->TmrValExt) + { + return_VALUE (24); + } + + return_VALUE (32); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Hardware/hwcpu32.c b/sys/contrib/dev/acpica/Subsystem/Hardware/hwcpu32.c new file mode 100644 index 0000000..513a470 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Hardware/hwcpu32.c @@ -0,0 +1,845 @@ +/****************************************************************************** + * + * Name: hwcpu32.c - CPU support for IA32 (Throttling, CxStates) + * $Revision: 33 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "acnamesp.h" +#include "achware.h" + +#define _COMPONENT HARDWARE + MODULE_NAME ("Hwcpu32") + + +#define BIT_4 0x10 /* TBD: [investigate] is this correct? */ + + +/**************************************************************************** + * + * FUNCTION: AcpiHwEnterC1 + * + * PARAMETERS: PblkAddress - Address of the processor control block + * PmTimerTicks - Number of PM timer ticks elapsed while asleep + * + * RETURN: Function status. + * + * DESCRIPTION: Set C1 state on IA32 processor (halt) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwEnterC1( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks) +{ + UINT32 Timer = 0; + + + if (!PmTimerTicks) + { + /* + * Enter C1: + * --------- + */ + enable(); + halt(); + *PmTimerTicks = ACPI_UINT32_MAX; + } + else + { + Timer = AcpiHwPmtTicks (); + + /* + * Enter C1: + * --------- + */ + enable (); + halt (); + + /* + * Compute Time in C1: + * ------------------- + */ + Timer = AcpiHwPmtTicks () - Timer; + + *PmTimerTicks = Timer; + } + + return (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiHwEnterC2 + * + * PARAMETERS: PblkAddress - Address of the processor control block + * PmTimerTicks - Number of PM timer ticks elapsed while asleep + * + * RETURN: + * + * DESCRIPTION: Set C2 state on IA32 processor + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwEnterC2( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks) +{ + UINT32 Timer = 0; + + + if (!PblkAddress || !PmTimerTicks) + { + return (AE_BAD_PARAMETER); + } + + /* + * Disable interrupts before all C2/C3 transitions. + */ + disable (); + + Timer = AcpiHwPmtTicks (); + + /* + * Enter C2: + * --------- + * Read from the P_LVL2 (P_BLK+4) register to invoke a C2 transition. + */ + AcpiOsIn8 ((ACPI_IO_ADDRESS) (PblkAddress + 4)); + + /* + * Perform Dummy Op: + * ----------------- + * We have to do something useless after reading LVL2 because chipsets + * cannot guarantee that STPCLK# gets asserted in time to freeze execution. + */ + AcpiOsIn8 ((ACPI_IO_ADDRESS) AcpiGbl_FACP->Pm2CntBlk); + + /* + * Compute Time in C2: + * ------------------- + */ + Timer = AcpiHwPmtTicks () - Timer; + + *PmTimerTicks = Timer; + + /* + * Re-enable interrupts after coming out of C2/C3. + */ + enable (); + + return (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiHwEnterC3 + * + * PARAMETERS: PblkAddress - Address of the processor control block + * PmTimerTicks - Number of PM timer ticks elapsed while asleep + * + * RETURN: Status of function + * + * DESCRIPTION: Set C3 state on IA32 processor (UP only, cache coherency via + * disabling bus mastering) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwEnterC3( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks) +{ + UINT32 Timer = 0; + UINT8 Pm2CntBlk = 0; + UINT32 BusMasterStatus = 0; + + + if (!PblkAddress || !PmTimerTicks) + { + return (AE_BAD_PARAMETER); + } + + /* + * Check the BM_STS bit, if it is set, do not enter C3 + * but clear the bit (with a write) and exit, telling + * the calling module that we spent zero time in C3. + * If bus mastering continues, this action should + * eventually cause a demotion to C2 + */ + if (1 == (BusMasterStatus = + AcpiHwRegisterAccess (ACPI_READ, ACPI_MTX_LOCK, BM_STS))) + { + /* + * Clear the BM_STS bit by setting it. + */ + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, BM_STS, 1); + *PmTimerTicks = 0; + return (AE_OK); + } + + /* + * Disable interrupts before all C2/C3 transitions. + */ + disable(); + + /* + * Disable Bus Mastering: + * ---------------------- + * Set the PM2_CNT.ARB_DIS bit (bit #0), preserving all other bits. + */ + Pm2CntBlk = AcpiOsIn8 ((ACPI_IO_ADDRESS) AcpiGbl_FACP->Pm2CntBlk); + Pm2CntBlk |= 0x01; + AcpiOsOut8 ((ACPI_IO_ADDRESS) AcpiGbl_FACP->Pm2CntBlk, Pm2CntBlk); + + /* + * Get the timer base before entering C state + */ + Timer = AcpiHwPmtTicks (); + + /* + * Enter C3: + * --------- + * Read from the P_LVL3 (P_BLK+5) register to invoke a C3 transition. + */ + AcpiOsIn8 ((ACPI_IO_ADDRESS)(PblkAddress + 5)); + + /* + * Perform Dummy Op: + * ----------------- + * We have to do something useless after reading LVL3 because chipsets + * cannot guarantee that STPCLK# gets asserted in time to freeze execution. + */ + AcpiOsIn8 ((ACPI_IO_ADDRESS) AcpiGbl_FACP->Pm2CntBlk); + + /* + * Immediately compute the time in the C state + */ + Timer = AcpiHwPmtTicks() - Timer; + + /* + * Re-Enable Bus Mastering: + * ------------------------ + * Clear the PM2_CNT.ARB_DIS bit (bit #0), preserving all other bits. + */ + Pm2CntBlk = AcpiOsIn8 ((ACPI_IO_ADDRESS) AcpiGbl_FACP->Pm2CntBlk); + Pm2CntBlk &= 0xFE; + AcpiOsOut8 ((ACPI_IO_ADDRESS) AcpiGbl_FACP->Pm2CntBlk, Pm2CntBlk); + + /* TBD: [Unhandled]: Support 24-bit timers (this algorithm assumes 32-bit) */ + + *PmTimerTicks = Timer; + + /* + * Re-enable interrupts after coming out of C2/C3. + */ + enable(); + + return (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiHwEnterCx + * + * PARAMETERS: ProcessorHandle - handle of the processor + * + * RETURN: Status of function + * + * DESCRIPTION: Invoke the currently active processor Cx handler to put this + * processor to sleep. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwEnterCx ( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks) +{ + + if (!AcpiHwCxHandlers[AcpiHwActiveCxState]) + { + return (AE_SUPPORT); + } + + return (AcpiHwCxHandlers[AcpiHwActiveCxState] (PblkAddress, PmTimerTicks)); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiHwSetCx + * + * PARAMETERS: State - value (1-3) of the Cx state to 'make active' + * + * RETURN: Function status. + * + * DESCRIPTION: Sets the state to use during calls to AcpiHwEnterCx(). + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwSetCx ( + UINT32 CxState) +{ + /* + * Supported State? + * ---------------- + */ + if ((CxState < 1) || (CxState > 3)) + { + return (AE_BAD_PARAMETER); + } + + if (!AcpiHwCxHandlers[CxState]) + { + return (AE_SUPPORT); + } + + /* + * New Cx State? + * ------------- + * We only care when moving from one state to another... + */ + if (AcpiHwActiveCxState == CxState) + { + return (AE_OK); + } + + /* + * Prepare to Use New State: + * ------------------------- + * If the new CxState is C3, the BM_RLD bit must be set to allow + * the generation of a bus master requets to cause the processor + * in the C3 state to transition to the C0 state. + */ + switch (CxState) + { + case 3: + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, BM_RLD, 1); + break; + } + + /* + * Clean up from Old State: + * ------------------------ + * If the old CxState was C3, the BM_RLD bit is reset. When the + * bit is reset, the generation of a bus master request does not + * effect any processor in the C3 state. + */ + switch (AcpiHwActiveCxState) + { + case 3: + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, BM_RLD, 0); + break; + } + + /* + * Enable: + * ------- + */ + AcpiHwActiveCxState = CxState; + + return (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiHwGetCxInfo + * + * PARAMETERS: CxStates - Information (latencies) on all Cx states + * + * RETURN: Status of function + * + * DESCRIPTION: This function is called both to initialize Cx handling + * and retrieve the current Cx information (latency values). + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwGetCxInfo ( + UINT32 CxStates[]) +{ + BOOLEAN SMP_system = FALSE; + + + FUNCTION_TRACE("HwGetCxInfo"); + + + if (!CxStates) + { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + /* + * TBD: [Unhandled] need to init SMP_system using info from the MAPIC + * table. + */ + + /* + * Set Defaults: + * ------------- + * C0 and C1 support is implied (but what about that PROC_C1 register + * in the FADT?!?!). Set C2/C3 to max. latency (not supported until + * proven otherwise). + */ + CxStates[0] = 0; + CxStates[1] = 0; + CxStates[2] = MAX_CX_STATE_LATENCY; + CxStates[3] = MAX_CX_STATE_LATENCY; + + /* + * C2 Supported? + * ------------- + * We're only supporting C2 when the latency is <= 100 microseconds, + * and on SMP systems when P_LVL2_UP (which indicates C2 only on UP) + * is not set. + */ + if (AcpiGbl_FACP->Plvl2Lat <= 100) + { + if (!SMP_system) + { + AcpiHwCxHandlers[2] = AcpiHwEnterC2; + CxStates[2] = AcpiGbl_FACP->Plvl2Lat; + } + + else if (!AcpiGbl_FACP->Plvl2Up) + { + AcpiHwCxHandlers[2] = AcpiHwEnterC2; + CxStates[2] = AcpiGbl_FACP->Plvl2Lat; + } + } + + /* + * C3 Supported? + * ------------- + * We're only supporting C3 on UP systems when the latency is + * <= 1000 microseconds and that include the ability to disable + * Bus Mastering while in C3 (ARB_DIS) but allows Bus Mastering + * requests to wake the system from C3 (BM_RLD). Note his method + * of maintaining cache coherency (disabling of bus mastering) + * cannot be used on SMP systems, and flushing caches (e.g. WBINVD) + * is simply too costly (at this time). + */ + if (AcpiGbl_FACP->Plvl3Lat <= 1000) + { + if (!SMP_system && (AcpiGbl_FACP->Pm2CntBlk && + AcpiGbl_FACP->Pm2CntLen)) + { + AcpiHwCxHandlers[3] = AcpiHwEnterC3; + CxStates[3] = AcpiGbl_FACP->Plvl3Lat; + } + } + + return_ACPI_STATUS(AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiHwGetCxHandler + * + * PARAMETERS: State - the Cx state + * Handler - pointer to location for the returned handler + * + * RETURN: Status of function + * + * DESCRIPTION: This function is called to get an installed Cx state handler. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwGetCxHandler ( + UINT32 CxState, + ACPI_C_STATE_HANDLER *Handler) +{ + FUNCTION_TRACE ("HwGetCxHandler"); + + + if ((CxState == 0) || (CxState >= MAX_CX_STATES) || !Handler) + { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + *Handler = AcpiHwCxHandlers[CxState]; + + return_ACPI_STATUS(AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiHwSetCxHandler + * + * PARAMETERS: CxState - the Cx state + * Handler - new Cx state handler + * + * RETURN: Status of function + * + * DESCRIPTION: This function is called to install a new Cx state handler. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiHwSetCxHandler ( + UINT32 CxState, + ACPI_C_STATE_HANDLER Handler) +{ + FUNCTION_TRACE ("HwSetCxHandler"); + + + if ((CxState == 0) || (CxState >= MAX_CX_STATES) || !Handler) + { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + AcpiHwCxHandlers[CxState] = Handler; + + return_ACPI_STATUS(AE_OK); +} + + +/************************************************************************** + * + * FUNCTION: AcpiHwLocalPow + * + * PARAMETERS: x,y operands + * + * RETURN: result + * + * DESCRIPTION: Compute x ^ y + * + *************************************************************************/ + +NATIVE_UINT +AcpiHwLocalPow ( + NATIVE_UINT x, + NATIVE_UINT y) +{ + NATIVE_UINT i; + NATIVE_UINT Result = 1; + + + for (i = 0; i < y; i++) + { + Result = Result * x; + } + + return (Result); +} + + +/************************************************************************** + * + * FUNCTION: AcpiHwEnableThrottling + * + * PARAMETERS: PblkAddress - Address of Pcnt (Processor Control) + * register + * + * RETURN: none + * + * DESCRIPTION: Enable throttling by setting the THT_EN bit. + * + *************************************************************************/ + +void +AcpiHwEnableThrottling ( + ACPI_IO_ADDRESS PblkAddress) +{ + UINT32 PblkValue; + + + FUNCTION_TRACE ("EnableThrottling"); + + + PblkValue = AcpiOsIn32 (PblkAddress); + PblkValue = PblkValue | BIT_4; + AcpiOsOut32 (PblkAddress, PblkValue); + + return_VOID; +} + + +/************************************************************************** + * + * FUNCTION: AcpiHwDisableThrottling + * + * PARAMETERS: PblkAddress - Address of Pcnt (Processor Control) + * register + * + * RETURN: none + * + * DESCRIPTION:Disable throttling by clearing the THT_EN bit + * + *************************************************************************/ + +void +AcpiHwDisableThrottling ( + ACPI_IO_ADDRESS PblkAddress) +{ + UINT32 PblkValue; + + + FUNCTION_TRACE ("DisableThrottling"); + + + PblkValue = AcpiOsIn32 (PblkAddress); + PblkValue = PblkValue & (~(UINT32)BIT_4); + AcpiOsOut32 (PblkAddress, PblkValue); + + return_VOID; +} + + +/************************************************************************** + * + * FUNCTION: AcpiHwGetDutyCycle + * + * PARAMETERS: DutyOffset Pcnt register duty cycle field offset + * PblkAddress Pcnt register address in chipset + * NumThrottleStates # of CPU throttle states this system + * supports + * + * RETURN: none + * + * DESCRIPTION: Get the duty cycle from the chipset + * + *************************************************************************/ + +UINT32 +AcpiHwGetDutyCycle ( + UINT8 DutyOffset, + ACPI_IO_ADDRESS PblkAddress, + UINT32 NumThrottleStates) +{ + NATIVE_UINT Index; + UINT32 Duty32Value; + UINT32 PcntMaskOffDutyField; + + + FUNCTION_TRACE ("GetDutyCycle"); + + + /* + * Use NumThrottleStates - 1 as mask [ex. 8 - 1 = 7 (Fh)] + * and then shift it into the right position + */ + PcntMaskOffDutyField = NumThrottleStates - 1; + + /* + * Read in the current value from the port + */ + Duty32Value = AcpiOsIn32 ((ACPI_IO_ADDRESS) PblkAddress); + + /* + * Shift the the value to LSB + */ + for (Index = 0; Index < (NATIVE_UINT) DutyOffset; Index++) + { + Duty32Value = Duty32Value >> 1; + } + + /* + * Get the duty field only + */ + Duty32Value = Duty32Value & PcntMaskOffDutyField; + + return_VALUE ((UINT32) Duty32Value); +} + + +/************************************************************************** + * + * FUNCTION: AcpiHwProgramDutyCycle + * + * PARAMETERS: DutyOffset Pcnt register duty cycle field offset + * DutyCycle duty cycle to program into chipset + * PblkAddress Pcnt register address in chipset + * NumThrottleStates # of CPU throttle states this system + * supports + * + * RETURN: none + * + * DESCRIPTION: Program chipset with specified duty cycle by bit-shifting the + * duty cycle bits to the appropriate offset, reading the duty + * cycle register, OR-ing in the duty cycle, and writing it to + * the Pcnt register. + * + *************************************************************************/ + +void +AcpiHwProgramDutyCycle ( + UINT8 DutyOffset, + UINT32 DutyCycle, + ACPI_IO_ADDRESS PblkAddress, + UINT32 NumThrottleStates) +{ + NATIVE_UINT Index; + UINT32 Duty32Value; + UINT32 PcntMaskOffDutyField; + UINT32 PortValue; + + + FUNCTION_TRACE ("HwProgramDutyCycle"); + + + /* + * valid DutyCycle passed + */ + Duty32Value = DutyCycle; + + /* + * use NumThrottleStates - 1 as mask [ex. 8 - 1 = 7 (Fh)] + * and then shift it into the right position + */ + PcntMaskOffDutyField = NumThrottleStates - 1; + + /* + * Shift the mask + */ + for (Index = 0; Index < (NATIVE_UINT) DutyOffset; Index++) + { + PcntMaskOffDutyField = PcntMaskOffDutyField << 1; + Duty32Value = Duty32Value << 1; + } + + /* + * Read in the current value from the port + */ + PortValue = AcpiOsIn32 ((ACPI_IO_ADDRESS) PblkAddress); + + /* + * Mask off the duty field so we don't OR in junk! + */ + PortValue = PortValue & (~PcntMaskOffDutyField); + + /* + * OR in the bits we want to write out to the port + */ + PortValue = (PortValue | Duty32Value) & (~(UINT32)BIT_4); + + /* + * write it to the port + */ + AcpiOsOut32 ((ACPI_IO_ADDRESS) PblkAddress, PortValue); + + return_VOID; +} + + \ No newline at end of file diff --git a/sys/contrib/dev/acpica/Subsystem/Hardware/hwgpe.c b/sys/contrib/dev/acpica/Subsystem/Hardware/hwgpe.c new file mode 100644 index 0000000..2385116 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Hardware/hwgpe.c @@ -0,0 +1,303 @@ +/****************************************************************************** + * + * Module Name: hwgpe - Low level GPE enable/disable/clear functions + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" + +#define _COMPONENT HARDWARE + MODULE_NAME ("hwgpe") + + +UINT8 DecodeTo8bit [8] = {1,2,4,8,16,32,64,128}; + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableGpe + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Enable a single GPE. + * + ******************************************************************************/ + +void +AcpiHwEnableGpe ( + UINT32 GpeNumber) +{ + UINT8 InByte; + UINT32 RegisterIndex; + UINT8 BitMask; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Read the current value of the register, set the appropriate bit + * to enable the GPE, and write out the new register. + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, + (UINT8)(InByte | BitMask)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableGpe + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Disable a single GPE. + * + ******************************************************************************/ + +void +AcpiHwDisableGpe ( + UINT32 GpeNumber) +{ + UINT8 InByte; + UINT32 RegisterIndex; + UINT8 BitMask; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Read the current value of the register, clear the appropriate bit, + * and write out the new register value to disable the GPE. + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, + (UINT8)(InByte & ~BitMask)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpe + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Clear a single GPE. + * + ******************************************************************************/ + +void +AcpiHwClearGpe ( + UINT32 GpeNumber) +{ + UINT32 RegisterIndex; + UINT8 BitMask; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Write a one to the appropriate bit in the status register to + * clear this GPE. + */ + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, BitMask); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetGpeStatus + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Return the status of a single GPE. + * + ******************************************************************************/ + +void +AcpiHwGetGpeStatus ( + UINT32 GpeNumber, + ACPI_EVENT_STATUS *EventStatus) +{ + UINT8 InByte = 0; + UINT32 RegisterIndex = 0; + UINT8 BitMask = 0; + + if (!EventStatus) + { + return; + } + + (*EventStatus) = 0; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Enabled?: + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr); + + if (BitMask & InByte) + { + (*EventStatus) |= ACPI_EVENT_FLAG_ENABLED; + } + + /* + * Set? + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr); + + if (BitMask & InByte) + { + (*EventStatus) |= ACPI_EVENT_FLAG_SET; + } +} diff --git a/sys/contrib/dev/acpica/Subsystem/Hardware/hwregs.c b/sys/contrib/dev/acpica/Subsystem/Hardware/hwregs.c new file mode 100644 index 0000000..dab4533 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Hardware/hwregs.c @@ -0,0 +1,825 @@ + +/******************************************************************************* + * + * Module Name: hwregs - Read/write access functions for the various ACPI + * control and status registers. + * $Revision: 71 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWREGS_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" + +#define _COMPONENT HARDWARE + MODULE_NAME ("hwregs") + + +/* This matches the #defines in actypes.h. */ + +NATIVE_CHAR *SleepStateTable[] = {"\\_S0_","\\_S1_","\\_S2_","\\_S3_", + "\\_S4_","\\_S4B","\\_S5_"}; + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetBitShift + * + * PARAMETERS: Mask - Input mask to determine bit shift from. + * Must have at least 1 bit set. + * + * RETURN: Bit location of the lsb of the mask + * + * DESCRIPTION: Returns the bit number for the low order bit that's set. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetBitShift ( + UINT32 Mask) +{ + UINT32 Shift; + + + FUNCTION_TRACE ("HwGetBitShift"); + + + for (Shift = 0; ((Mask >> Shift) & 1) == 0; Shift++) + { ; } + + return_VALUE (Shift); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwClearAcpiStatus + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Clears all fixed and general purpose status bits + * + ******************************************************************************/ + +void +AcpiHwClearAcpiStatus (void) +{ + UINT16 GpeLength; + UINT16 Index; + + + FUNCTION_TRACE ("HwClearAcpiStatus"); + + + DEBUG_PRINT (TRACE_IO, ("About to write %04X to %04X\n", + ALL_FIXED_STS_BITS, (UINT16) AcpiGbl_FACP->Pm1aEvtBlk)); + + + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + + AcpiOsOut16 (AcpiGbl_FACP->Pm1aEvtBlk, (UINT16) ALL_FIXED_STS_BITS); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiOsOut16 ((UINT16) AcpiGbl_FACP->Pm1bEvtBlk, + (UINT16) ALL_FIXED_STS_BITS); + } + + /* now clear the GPE Bits */ + + if (AcpiGbl_FACP->Gpe0BlkLen) + { + GpeLength = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); + + for (Index = 0; Index < GpeLength; Index++) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe0Blk + Index), (UINT8) 0xff); + } + } + + if (AcpiGbl_FACP->Gpe1BlkLen) + { + GpeLength = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); + + for (Index = 0; Index < GpeLength; Index++) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe1Blk + Index), (UINT8) 0xff); + } + } + + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwObtainSleepTypeRegisterData + * + * PARAMETERS: SleepState - Numeric state requested + * *Slp_TypA - Pointer to byte to receive SLP_TYPa value + * *Slp_TypB - Pointer to byte to receive SLP_TYPb value + * + * RETURN: Status - ACPI status + * + * DESCRIPTION: AcpiHwObtainSleepTypeRegisterData() obtains the SLP_TYP and + * SLP_TYPb values for the sleep state requested. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwObtainSleepTypeRegisterData ( + UINT8 SleepState, + UINT8 *Slp_TypA, + UINT8 *Slp_TypB) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("HwObtainSleepTypeRegisterData"); + + + /* + * Validate parameters + */ + + if ((SleepState > ACPI_S_STATES_MAX) || + !Slp_TypA || !Slp_TypB) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * AcpiEvaluate the namespace object containing the values for this state + */ + + Status = AcpiNsEvaluateByName (SleepStateTable[SleepState], NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!ObjDesc) + { + REPORT_ERROR (("Missing Sleep State object\n")); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * We got something, now ensure it is correct. The object must + * be a package and must have at least 2 numeric values as the + * two elements + */ + + Status = AcpiCmResolvePackageReferences(ObjDesc); + + if (ObjDesc->Package.Count < 2) + { + /* Must have at least two elements */ + + REPORT_ERROR (("Sleep State package does not have at least two elements\n")); + Status = AE_ERROR; + } + + else if (((ObjDesc->Package.Elements[0])->Common.Type != + ACPI_TYPE_NUMBER) || + ((ObjDesc->Package.Elements[1])->Common.Type != + ACPI_TYPE_NUMBER)) + { + /* Must have two */ + + REPORT_ERROR (("Sleep State package elements are not both of type Number\n")); + Status = AE_ERROR; + } + + else + { + /* + * Valid _Sx_ package size, type, and value + */ + *Slp_TypA = (UINT8) (ObjDesc->Package.Elements[0])->Number.Value; + + *Slp_TypB = (UINT8) (ObjDesc->Package.Elements[1])->Number.Value; + } + + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("SleepTypeRegisterData: Bad Sleep object %p type %X\n", + ObjDesc, ObjDesc->Common.Type)); + } + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwRegisterAccess + * + * PARAMETERS: ReadWrite - Either ACPI_READ or ACPI_WRITE. + * UseLock - Lock the hardware + * RegisterId - index of ACPI register to access + * Value - (only used on write) value to write to the + * register. Shifted all the way right. + * + * RETURN: Value written to or read from specified register. This value + * is shifted all the way right. + * + * DESCRIPTION: Generic ACPI register read/write function. + * + ******************************************************************************/ + +UINT32 +AcpiHwRegisterAccess ( + NATIVE_UINT ReadWrite, + BOOLEAN UseLock, + UINT32 RegisterId, + ...) /* Value (only used on write) */ +{ + UINT32 RegisterValue = 0; + UINT32 Mask = 0; + UINT32 Value = 0; + ACPI_IO_ADDRESS GpeReg = 0; + + + FUNCTION_TRACE ("HwRegisterIO"); + + + if (ReadWrite == ACPI_WRITE) + { + va_list marker; + + va_start (marker, RegisterId); + Value = va_arg (marker, UINT32); + va_end (marker); + } + + /* + * TBD: [Restructure] May want to split the AcpiEvent code and the + * Control code + */ + + /* + * Decode the Register ID + */ + + switch (RegisterId & REGISTER_BLOCK_MASK) + { + case PM1_EVT: + + if (RegisterId < TMR_EN) + { + /* status register */ + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk); + DEBUG_PRINT (TRACE_IO, ("PM1a status: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1aEvtBlk)); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + RegisterValue |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk); + DEBUG_PRINT (TRACE_IO, ("PM1b status: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1bEvtBlk)); + } + + switch (RegisterId) + { + case TMR_STS: + Mask = TMR_STS_MASK; + break; + + case BM_STS: + Mask = BM_STS_MASK; + break; + + case GBL_STS: + Mask = GBL_STS_MASK; + break; + + case PWRBTN_STS: + Mask = PWRBTN_STS_MASK; + break; + + case SLPBTN_STS: + Mask = SLPBTN_STS_MASK; + break; + + case RTC_STS: + Mask = RTC_STS_MASK; + break; + + case WAK_STS: + Mask = WAK_STS_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + /* + * Status registers are different from the rest. Clear by + * writing 1, writing 0 has no effect. So, the only relevent + * information is the single bit we're interested in, all + * others should be written as 0 so they will be left + * unchanged + */ + + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + + if (Value) + { + DEBUG_PRINT (TRACE_IO, + ("About to write 0x%X to 0x%X\n", Value, + AcpiGbl_FACP->Pm1aEvtBlk)); + + AcpiOsOut16 (AcpiGbl_FACP->Pm1aEvtBlk, (UINT16) Value); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiOsOut16 (AcpiGbl_FACP->Pm1bEvtBlk, (UINT16) Value); + } + + RegisterValue = 0; + } + } + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + } + + else + { + /* enable register */ + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + + DEBUG_PRINT (TRACE_IO, ("PM1a enable: Read 0x%X from 0x%X\n", + RegisterValue, (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)))); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + RegisterValue |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + + DEBUG_PRINT (TRACE_IO, ("PM1b enable: Read 0x%X from 0x%X\n", + RegisterValue, (AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)))); + } + + switch (RegisterId) + { + case TMR_EN: + Mask = TMR_EN_MASK; + break; + + case GBL_EN: + Mask = GBL_EN_MASK; + break; + + case PWRBTN_EN: + Mask = PWRBTN_EN_MASK; + break; + + case SLPBTN_EN: + Mask = SLPBTN_EN_MASK; + break; + + case RTC_EN: + Mask = RTC_EN_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + DEBUG_PRINT (TRACE_IO, + ("About to write %04X to %04X\n", RegisterValue, + (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)))); + + AcpiOsOut16 ((AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)), + (UINT16) RegisterValue); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiOsOut16 ((AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)), + (UINT16) RegisterValue); + } + } + if(ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + } + break; + + + case PM1_CONTROL: + + RegisterValue = 0; + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + if (RegisterId != SLP_TYPE_B) + { + /* + * SLP_TYPx registers are written differently + * than any other control registers with + * respect to A and B registers. The value + * for A may be different than the value for B + */ + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aCntBlk); + DEBUG_PRINT (TRACE_IO, ("PM1a control: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1aCntBlk)); + } + + if (AcpiGbl_FACP->Pm1bCntBlk && RegisterId != (UINT32) SLP_TYPE_A) + { + RegisterValue |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bCntBlk); + DEBUG_PRINT (TRACE_IO, ("PM1b control: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1bCntBlk)); + } + + switch (RegisterId) + { + case SCI_EN: + Mask = SCI_EN_MASK; + break; + + case BM_RLD: + Mask = BM_RLD_MASK; + break; + + case GBL_RLS: + Mask = GBL_RLS_MASK; + break; + + case SLP_TYPE_A: + case SLP_TYPE_B: + Mask = SLP_TYPE_X_MASK; + break; + + case SLP_EN: + Mask = SLP_EN_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + /* + * SLP_TYPE_x registers are written differently + * than any other control registers with + * respect to A and B registers. The value + * for A may be different than the value for B + */ + + if (RegisterId != SLP_TYPE_B) + { + if (Mask == SLP_EN_MASK) + { + disable(); /* disable interrupts */ + } + + AcpiOsOut16 (AcpiGbl_FACP->Pm1aCntBlk, (UINT16) RegisterValue); + + if (Mask == SLP_EN_MASK) + { + /* + * Enable interrupts, the SCI handler is likely going to + * be invoked as soon as interrupts are enabled, since gpe's + * and most fixed resume events also generate SCI's. + */ + enable(); + } + } + + if (AcpiGbl_FACP->Pm1bCntBlk && RegisterId != (UINT32) SLP_TYPE_A) + { + AcpiOsOut16 (AcpiGbl_FACP->Pm1bCntBlk, (UINT16) RegisterValue); + } + } + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + break; + + + case PM2_CONTROL: + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm2CntBlk); + DEBUG_PRINT (TRACE_IO, ("PM2 control: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm2CntBlk)); + + switch (RegisterId) + { + case ARB_DIS: + Mask = ARB_DIS_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + DEBUG_PRINT (TRACE_IO, + ("About to write %04X to %04X\n", RegisterValue, + AcpiGbl_FACP->Pm2CntBlk)); + + AcpiOsOut16 (AcpiGbl_FACP->Pm2CntBlk, (UINT16) RegisterValue); + } + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + break; + + + case PM_TIMER: + + RegisterValue = AcpiOsIn32 (AcpiGbl_FACP->PmTmrBlk); + DEBUG_PRINT (TRACE_IO, ("PM_TIMER: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->PmTmrBlk)); + + Mask = ACPI_UINT32_MAX; + break; + + + case GPE1_EN_BLOCK: + + GpeReg = (AcpiGbl_FACP->Gpe1Blk + AcpiGbl_FACP->Gpe1Base) + + (GpeReg + (DIV_2 (AcpiGbl_FACP->Gpe1BlkLen))); + + + case GPE1_STS_BLOCK: + + if (!GpeReg) + { + GpeReg = (AcpiGbl_FACP->Gpe1Blk + AcpiGbl_FACP->Gpe1Base); + } + + + case GPE0_EN_BLOCK: + + if (!GpeReg) + { + GpeReg = AcpiGbl_FACP->Gpe0Blk + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); + } + + + case GPE0_STS_BLOCK: + + if (!GpeReg) + { + GpeReg = AcpiGbl_FACP->Gpe0Blk; + } + + /* Determine the bit to be accessed */ + + Mask = (((UINT32) RegisterId) & BIT_IN_REGISTER_MASK); + Mask = 1 << (Mask-1); + + /* + * The base address of the GPE 0 Register Block + * Plus 1/2 the length of the GPE 0 Register Block + * The enable register is the register following the Status Register + * and each register is defined as 1/2 of the total Register Block + */ + + /* + * This sets the bit within EnableBit that needs to be written to + * the register indicated in Mask to a 1, all others are 0 + */ + + if (Mask > LOW_BYTE) + { + /* Shift the value 1 byte to the right and add 1 to the register */ + + Mask >>= ONE_BYTE; + GpeReg++; + } + + /* Now get the current Enable Bits in the selected Reg */ + + if(ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + RegisterValue = (UINT32) AcpiOsIn8 (GpeReg); + DEBUG_PRINT (TRACE_IO, ("GPE Enable bits: Read 0x%X from 0x%X\n", + RegisterValue, GpeReg)); + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + /* This write will put the Action state into the General Purpose */ + + /* Enable Register indexed by the value in Mask */ + + DEBUG_PRINT (TRACE_IO, ("About to write %04X to %04X\n", + RegisterValue, GpeReg)); + + AcpiOsOut8 (GpeReg, (UINT8) RegisterValue); + RegisterValue = (UINT32) AcpiOsIn8 (GpeReg); + } + + if(ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + break; + + + case PROCESSOR_BLOCK: + default: + + Mask = 0; + break; + } + + + RegisterValue &= Mask; + RegisterValue >>= AcpiHwGetBitShift (Mask); + + DEBUG_PRINT (TRACE_IO, ("Register I/O: returning 0x%X\n", RegisterValue)); + return_VALUE (RegisterValue); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Hardware/hwxface.c b/sys/contrib/dev/acpica/Subsystem/Hardware/hwxface.c new file mode 100644 index 0000000..cd1f234 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Hardware/hwxface.c @@ -0,0 +1,728 @@ + +/****************************************************************************** + * + * Name: hwxface.c - Hardware access external interfaces + * $Revision: 32 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "acnamesp.h" +#include "achware.h" + +#define _COMPONENT HARDWARE + MODULE_NAME ("hwxface") + + +/****************************************************************************** + * + * Hardware globals + * + ******************************************************************************/ + + +ACPI_C_STATE_HANDLER AcpiHwCxHandlers[MAX_CX_STATES] = + {NULL, AcpiHwEnterC1, NULL, NULL}; + +UINT32 AcpiHwActiveCxState = 1; + + +/**************************************************************************** + * + * FUNCTION: AcpiGetProcessorThrottlingInfo + * + * PARAMETERS: ProcessorHandle - handle for the cpu to get info about + * UserBuffer - caller supplied buffer + * + * RETURN: Status of function + * + * DESCRIPTION: Get throttling capabilities for the processor, this routine + * builds the data directly into the callers buffer + * + ****************************************************************************/ + +ACPI_STATUS +AcpiGetProcessorThrottlingInfo ( + ACPI_HANDLE ProcessorHandle, + ACPI_BUFFER *UserBuffer) +{ + NATIVE_UINT PercentStep; + NATIVE_UINT NextPercent; + NATIVE_UINT NumThrottleStates; + NATIVE_UINT BufferSpaceNeeded; + NATIVE_UINT i; + UINT8 DutyWidth = 0; + ACPI_NAMESPACE_NODE *CpuNode; + ACPI_OPERAND_OBJECT *CpuObj; + ACPI_CPU_THROTTLING_STATE *StatePtr; + + + FUNCTION_TRACE ("AcpiGetProcessorThrottlingInfo"); + + + /* + * Have to at least have a buffer to return info in + */ + if (!UserBuffer) + { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + /* + * Convert and validate the device handle + */ + + CpuNode = AcpiNsConvertHandleToEntry (ProcessorHandle); + if (!CpuNode) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Check for an existing internal object + */ + + CpuObj = AcpiNsGetAttachedObject ((ACPI_HANDLE) CpuNode); + if (!CpuObj) + { + return_ACPI_STATUS (AE_NOT_FOUND); + } + +#ifndef _IA64 + /* + * No Duty fields in IA64 tables + */ + DutyWidth = AcpiGbl_FACP->DutyWidth; +#endif + + /* + * P0 must always have a P_BLK all others may be null + * in either case, we can't throttle a processor that has no P_BLK + * + * Also if no Duty width, one state and it is 100% + * + */ + if (!CpuObj->Processor.Length || !DutyWidth || + (ACPI_UINT16_MAX < CpuObj->Processor.Address)) + { + /* + * AcpiEven though we can't throttle, we still have one state (100%) + */ + NumThrottleStates = 1; + } + + else + { + NumThrottleStates = (int) AcpiHwLocalPow (2,DutyWidth); + } + + BufferSpaceNeeded = NumThrottleStates * sizeof (ACPI_CPU_THROTTLING_STATE); + + if ((UserBuffer->Length < BufferSpaceNeeded) || !UserBuffer->Pointer) + { + UserBuffer->Length = BufferSpaceNeeded; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + UserBuffer->Length = BufferSpaceNeeded; + StatePtr = (ACPI_CPU_THROTTLING_STATE *) UserBuffer->Pointer; + PercentStep = 1000 / NumThrottleStates; + + /* + * Build each entry in the buffer. Note that we're using the value + * 1000 and dividing each state by 10 to better avoid round-off + * accumulation. Also note that the throttling STATES are ordered + * sequentially from 100% (state 0) on down (e.g. 87.5% = state 1), + * which is exactly opposite from duty cycle values (12.5% = state 1). + */ + for (i = 0, NextPercent = 1000; i < NumThrottleStates; i++) + { + StatePtr[i].StateNumber = i; + StatePtr[i].PercentOfClock = NextPercent / 10; + NextPercent -= PercentStep; + } + + return_ACPI_STATUS(AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiGetProcessorThrottlingState + * + * PARAMETERS: ProcessorHandle - handle for the cpu to throttle + * ThrottleState - throttling state to enter + * + * RETURN: Status of function + * + * DESCRIPTION: Get current hardware throttling state + * + ****************************************************************************/ + +ACPI_STATUS +AcpiGetProcessorThrottlingState ( + ACPI_HANDLE ProcessorHandle, + UINT32 *ThrottleState) +{ + ACPI_NAMESPACE_NODE *CpuNode; + ACPI_OPERAND_OBJECT *CpuObj; + UINT32 NumThrottleStates; + UINT32 DutyCycle; + UINT8 DutyOffset = 0; + UINT8 DutyWidth = 0; + + + FUNCTION_TRACE ("AcpiGetProcessorThrottlingState"); + + + /* Convert and validate the device handle */ + + CpuNode = AcpiNsConvertHandleToEntry (ProcessorHandle); + if (!CpuNode || !ThrottleState) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check for an existing internal object */ + + CpuObj = AcpiNsGetAttachedObject ((ACPI_HANDLE) CpuNode); + if (!CpuObj) + { + return_ACPI_STATUS (AE_NOT_FOUND); + } + +#ifndef _IA64 + /* + * No Duty fields in IA64 tables + */ + DutyOffset = AcpiGbl_FACP->DutyOffset; + DutyWidth = AcpiGbl_FACP->DutyWidth; +#endif + + /* + * Must have a valid P_BLK P0 must have a P_BLK all others may be null + * in either case, we can't thottle a processor that has no P_BLK + * that means we are in the only supported state (0 - 100%) + * + * also, if DutyWidth is zero there are no additional states + */ + if (!CpuObj->Processor.Length || !DutyWidth || + (ACPI_UINT16_MAX < CpuObj->Processor.Address)) + { + *ThrottleState = 0; + return_ACPI_STATUS(AE_OK); + } + + NumThrottleStates = (UINT32) AcpiHwLocalPow (2,DutyWidth); + + /* + * Get the current duty cycle value. + */ + DutyCycle = AcpiHwGetDutyCycle (DutyOffset, + CpuObj->Processor.Address, + NumThrottleStates); + + /* + * Convert duty cycle to throttling state (invert). + */ + if (DutyCycle == 0) + { + *ThrottleState = 0; + } + + else + { + *ThrottleState = NumThrottleStates - DutyCycle; + } + + return_ACPI_STATUS(AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiSetProcessorThrottlingState + * + * PARAMETERS: ProcessorHandle - handle for the cpu to throttle + * ThrottleState - throttling state to enter + * + * RETURN: Status of function + * + * DESCRIPTION: Set hardware into requested throttling state, the handle + * passed in must have a valid P_BLK + * + ****************************************************************************/ + +ACPI_STATUS +AcpiSetProcessorThrottlingState ( + ACPI_HANDLE ProcessorHandle, + UINT32 ThrottleState) +{ + ACPI_NAMESPACE_NODE *CpuNode; + ACPI_OPERAND_OBJECT *CpuObj; + UINT32 NumThrottleStates = 0; + UINT8 DutyOffset = 0; + UINT8 DutyWidth = 0; + UINT32 DutyCycle = 0; + + + FUNCTION_TRACE ("AcpiSetProcessorThrottlingState"); + + + /* Convert and validate the device handle */ + + CpuNode = AcpiNsConvertHandleToEntry (ProcessorHandle); + if (!CpuNode) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check for an existing internal object */ + + CpuObj = AcpiNsGetAttachedObject ((ACPI_HANDLE) CpuNode); + if (!CpuObj) + { + return_ACPI_STATUS (AE_NOT_FOUND); + } + +#ifndef _IA64 + /* + * No Duty fields in IA64 tables + */ + DutyOffset = AcpiGbl_FACP->DutyOffset; + DutyWidth = AcpiGbl_FACP->DutyWidth; +#endif + + /* + * Must have a valid P_BLK P0 must have a P_BLK all others may be null + * in either case, we can't thottle a processor that has no P_BLK + * that means we are in the only supported state (0 - 100%) + * + * also, if DutyWidth is zero there are no additional states + */ + if (!CpuObj->Processor.Length || !DutyWidth || + (ACPI_UINT16_MAX < CpuObj->Processor.Address)) + { + /* + * If caller wants to set the state to the only state we handle + * we're done. + */ + if (ThrottleState == 0) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Can't set this state + */ + return_ACPI_STATUS (AE_SUPPORT); + } + + NumThrottleStates = (int) AcpiHwLocalPow (2,DutyWidth); + + /* + * Convert throttling state to duty cycle (invert). + */ + if (ThrottleState > 0) + { + DutyCycle = NumThrottleStates - ThrottleState; + } + + /* + * Turn off throttling (don't muck with the h/w while throttling). + */ + AcpiHwDisableThrottling (CpuObj->Processor.Address); + + /* + * Program the throttling state. + */ + AcpiHwProgramDutyCycle (DutyOffset, DutyCycle, + CpuObj->Processor.Address, NumThrottleStates); + + /* + * Only enable throttling for non-zero states (0 - 100%) + */ + if (ThrottleState) + { + AcpiHwEnableThrottling (CpuObj->Processor.Address); + } + + return_ACPI_STATUS(AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiGetProcessorCxInfo + * + * PARAMETERS: ProcessorHandle - handle for the cpu return info about + * UserBuffer - caller supplied buffer + * + * RETURN: Status of function + * + * DESCRIPTION: Get Cx state latencies, this routine + * builds the data directly into the callers buffer + * + * + ****************************************************************************/ + +ACPI_STATUS +AcpiGetProcessorCxInfo ( + ACPI_HANDLE ProcessorHandle, + ACPI_BUFFER *UserBuffer) +{ + ACPI_STATUS Status = AE_OK; + UINT32 CxStateLatencies[4] = {0, 0, 0, 0}; + NATIVE_UINT BufferSpaceNeeded = 0; + ACPI_CX_STATE *StatePtr = NULL; + NATIVE_UINT i = 0; + + + FUNCTION_TRACE ("AcpiGetProcessorCxInfo"); + + + /* + * Have to at least have a buffer to return info in + */ + if (!UserBuffer) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiHwGetCxInfo (CxStateLatencies); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + BufferSpaceNeeded = 4 * sizeof (ACPI_CX_STATE); + + if ((UserBuffer->Length < BufferSpaceNeeded) || !UserBuffer->Pointer) + { + UserBuffer->Length = BufferSpaceNeeded; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + UserBuffer->Length = BufferSpaceNeeded; + + StatePtr = (ACPI_CX_STATE *) UserBuffer->Pointer; + + for (i = 0; i < 4; i++) + { + StatePtr[i].StateNumber = i; + StatePtr[i].Latency = CxStateLatencies[i]; + } + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiSetProcessorSleepState + * + * PARAMETERS: ProcessorHandle - handle for the cpu return info about + * CxState - the Cx sleeping state (C1-C3) to make + * 'active' + * + * RETURN: Status of function + * + * DESCRIPTION: Sets which Cx state will be used during calls to + * AcpiProcessorSleep () + * + ****************************************************************************/ + +ACPI_STATUS +AcpiSetProcessorSleepState ( + ACPI_HANDLE ProcessorHandle, + UINT32 CxState) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiSetProcessorSleepState"); + + + Status = AcpiHwSetCx (CxState); + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiProcessorSleep + * + * PARAMETERS: ProcessorHandle - handle for the cpu to put to sleep (Cx) + * TimeSleeping - time (in microseconds) elapsed while + * sleeping + * + * RETURN: Status of function + * + * DESCRIPTION: Puts the processor into the currently active sleep state (Cx) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiProcessorSleep ( + ACPI_HANDLE ProcessorHandle, + UINT32 *PmTimerTicks) +{ + ACPI_NAMESPACE_NODE *CpuNode = NULL; + ACPI_OPERAND_OBJECT *CpuObj = NULL; + ACPI_IO_ADDRESS Address = 0; + + + /* + * Convert ProcessorHandle to PblkAddres... + */ + + /* Convert and validate the device handle */ + + CpuNode = AcpiNsConvertHandleToEntry (ProcessorHandle); + if (!CpuNode) + { + return (AE_BAD_PARAMETER); + } + + /* Check for an existing internal object */ + + CpuObj = AcpiNsGetAttachedObject ((ACPI_HANDLE) CpuNode); + if (!CpuObj) + { + return (AE_NOT_FOUND); + } + + /* Get the processor register block (P_BLK) address */ + + Address = CpuObj->Processor.Address; + if (!CpuObj->Processor.Length) + { + /* Ensure a NULL addresss (note that P_BLK isn't required for C1) */ + + Address = 0; + } + + /* + * Enter the currently active Cx sleep state. + */ + return (AcpiHwEnterCx (Address, PmTimerTicks)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimer + * + * PARAMETERS: none + * + * RETURN: Current value of the ACPI PMT (timer) + * + * DESCRIPTION: Obtains current value of ACPI PMT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimer ( + UINT32 *OutTicks) +{ + FUNCTION_TRACE ("AcpiGetTimer"); + + + if (!OutTicks) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + *OutTicks = AcpiHwPmtTicks (); + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiSetFirmwareWakingVector + * + * PARAMETERS: PhysicalAddress - Physical address of ACPI real mode + * entry point. + * + * RETURN: AE_OK or AE_ERROR + * + * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + void *PhysicalAddress) +{ + FUNCTION_TRACE ("AcpiSetFirmwareWakingVector"); + + + /* Make sure that we have an FACS */ + + if (!AcpiGbl_FACS) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Set the vector */ + + * ((void **) AcpiGbl_FACS->FirmwareWakingVector) = PhysicalAddress; + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetFirmwareWakingVector + * + * PARAMETERS: *PhysicalAddress - Output buffer where contents of + * the dFirmwareWakingVector field of + * the FACS will be stored. + * + * RETURN: Status + * + * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetFirmwareWakingVector ( + void **PhysicalAddress) +{ + FUNCTION_TRACE ("AcpiGetFirmwareWakingVector"); + + + if (!PhysicalAddress) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Make sure that we have an FACS */ + + if (!AcpiGbl_FACS) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Get the vector */ + + *PhysicalAddress = * ((void **) AcpiGbl_FACS->FirmwareWakingVector); + + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Include/accommon.h b/sys/contrib/dev/acpica/Subsystem/Include/accommon.h new file mode 100644 index 0000000..e2e1218 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/accommon.h @@ -0,0 +1,757 @@ +/****************************************************************************** + * + * Name: accommon.h -- prototypes for the common (subsystem-wide) procedures + * $Revision: 80 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACCOMMON_H +#define _ACCOMMON_H + + +#define REF_INCREMENT (UINT16) 0 +#define REF_DECREMENT (UINT16) 1 +#define REF_FORCE_DELETE (UINT16) 2 + +/* AcpiCmDumpBuffer */ + +#define DB_BYTE_DISPLAY 1 +#define DB_WORD_DISPLAY 2 +#define DB_DWORD_DISPLAY 4 +#define DB_QWORD_DISPLAY 8 + + +/* Global initialization interfaces */ + +void +AcpiCmInitGlobals ( + void); + +void +AcpiCmTerminate ( + void); + + +/* + * CmInit - miscellaneous initialization and shutdown + */ + +ACPI_STATUS +AcpiCmHardwareInitialize ( + void); + +ACPI_STATUS +AcpiCmSubsystemShutdown ( + void); + +ACPI_STATUS +AcpiCmValidateFacp ( + void); + +/* + * CmGlobal - Global data structures and procedures + */ + +NATIVE_CHAR * +AcpiCmGetMutexName ( + UINT32 MutexId); + +NATIVE_CHAR * +AcpiCmGetTypeName ( + UINT32 Type); + +BOOLEAN +AcpiCmValidObjectType ( + UINT32 Type); + +ACPI_OWNER_ID +AcpiCmAllocateOwnerId ( + UINT32 IdType); + + +/* + * CmClib - Local implementations of C library functions + */ + +NATIVE_UINT +AcpiCmStrlen ( + const NATIVE_CHAR *String); + +NATIVE_CHAR * +AcpiCmStrcpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString); + +NATIVE_CHAR * +AcpiCmStrncpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count); + +UINT32 +AcpiCmStrncmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2, + NATIVE_UINT Count); + +UINT32 +AcpiCmStrcmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2); + +NATIVE_CHAR * +AcpiCmStrcat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString); + +NATIVE_CHAR * +AcpiCmStrncat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count); + +UINT32 +AcpiCmStrtoul ( + const NATIVE_CHAR *String, + NATIVE_CHAR **Terminator, + UINT32 Base); + +NATIVE_CHAR * +AcpiCmStrstr ( + NATIVE_CHAR *String1, + NATIVE_CHAR *String2); + +NATIVE_CHAR * +AcpiCmStrupr ( + NATIVE_CHAR *SrcString); + +void * +AcpiCmMemcpy ( + void *Dest, + const void *Src, + NATIVE_UINT Count); + +void * +AcpiCmMemset ( + void *Dest, + UINT32 Value, + NATIVE_UINT Count); + +UINT32 +AcpiCmToUpper ( + UINT32 c); + +UINT32 +AcpiCmToLower ( + UINT32 c); + + +/* + * CmCopy - Object construction and conversion interfaces + */ + +ACPI_STATUS +AcpiCmBuildSimpleObject( + ACPI_OPERAND_OBJECT *Obj, + ACPI_OBJECT *UserObj, + UINT8 *DataSpace, + UINT32 *BufferSpaceUsed); + +ACPI_STATUS +AcpiCmBuildPackageObject ( + ACPI_OPERAND_OBJECT *Obj, + UINT8 *Buffer, + UINT32 *SpaceUsed); + +ACPI_STATUS +AcpiCmBuildExternalObject ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiCmBuildInternalSimpleObject( + ACPI_OBJECT *UserObj, + ACPI_OPERAND_OBJECT *Obj); + +ACPI_STATUS +AcpiCmBuildInternalObject ( + ACPI_OBJECT *Obj, + ACPI_OPERAND_OBJECT *InternalObj); + +ACPI_STATUS +AcpiCmCopyInternalSimpleObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj); + +ACPI_STATUS +AcpiCmBuildCopyInternalPackageObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj); + + +/* + * CmCreate - Object creation + */ + +ACPI_STATUS +AcpiCmUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + +ACPI_OPERAND_OBJECT * +_CmCreateInternalObject ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + OBJECT_TYPE_INTERNAL Type); + + +/* + * CmDebug - Debug interfaces + */ + +UINT32 +GetDebugLevel ( + void); + +void +SetDebugLevel ( + UINT32 level); + +void +FunctionTrace ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName); + +void +FunctionTracePtr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + void *Pointer); + +void +FunctionTraceU32 ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT32 Integer); + +void +FunctionTraceStr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_CHAR *String); + +void +FunctionExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName); + +void +FunctionStatusExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + ACPI_STATUS Status); + +void +FunctionValueExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_UINT Value); + +void +FunctionPtrExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT8 *Ptr); + +void +DebugPrintPrefix ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber); + +void +DebugPrint ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + UINT32 PrintLevel, + NATIVE_CHAR *Format, ...); + +void +DebugPrintRaw ( + NATIVE_CHAR *Format, ...); + +void +_ReportInfo ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +void +_ReportError ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +void +_ReportWarning ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +void +AcpiCmDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 componentId); + + +/* + * CmDelete - Object deletion + */ + +void +AcpiCmDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiCmDeleteInternalPackageObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiCmDeleteInternalSimpleObject ( + ACPI_OPERAND_OBJECT *Object); + +ACPI_STATUS +AcpiCmDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList); + + +/* + * CmEval - object evaluation + */ + +/* Method name strings */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" + + +ACPI_STATUS +AcpiCmEvaluateNumericObject ( + NATIVE_CHAR *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Address); + +ACPI_STATUS +AcpiCmExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Hid); + +ACPI_STATUS +AcpiCmExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *StatusFlags); + +ACPI_STATUS +AcpiCmExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Uid); + + +/* + * CmError - exception interfaces + */ + +NATIVE_CHAR * +AcpiCmFormatException ( + ACPI_STATUS Status); + + +/* + * CmMutex - mutual exclusion interfaces + */ + +ACPI_STATUS +AcpiCmMutexInitialize ( + void); + +void +AcpiCmMutexTerminate ( + void); + +ACPI_STATUS +AcpiCmCreateMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiCmDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiCmAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiCmReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/* + * CmObject - internal object create/delete/cache routines + */ + +void * +_CmAllocateObjectDesc ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +#define AcpiCmCreateInternalObject(t) _CmCreateInternalObject(_THIS_MODULE,__LINE__,_COMPONENT,t) +#define AcpiCmAllocateObjectDesc() _CmAllocateObjectDesc(_THIS_MODULE,__LINE__,_COMPONENT) + +void +AcpiCmDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object); + +BOOLEAN +AcpiCmValidInternalObject ( + void *Object); + + +/* + * CmRefCnt - Object reference count management + */ + +void +AcpiCmAddReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiCmRemoveReference ( + ACPI_OPERAND_OBJECT *Object); + +/* + * CmSize - Object size routines + */ + +ACPI_STATUS +AcpiCmGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + UINT32 *ObjLength); + +ACPI_STATUS +AcpiCmGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + UINT32 *ObjLength); + +ACPI_STATUS +AcpiCmGetObjectSize( + ACPI_OPERAND_OBJECT *Obj, + UINT32 *ObjLength); + + +/* + * CmState - Generic state creation/cache routines + */ + +void +AcpiCmPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State); + +ACPI_GENERIC_STATE * +AcpiCmPopGenericState ( + ACPI_GENERIC_STATE **ListHead); + + +ACPI_GENERIC_STATE * +AcpiCmCreateGenericState ( + void); + +ACPI_GENERIC_STATE * +AcpiCmCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + +ACPI_STATUS +AcpiCmCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList); + +ACPI_GENERIC_STATE * +AcpiCmCreateControlState ( + void); + +void +AcpiCmDeleteGenericState ( + ACPI_GENERIC_STATE *State); + +void +AcpiCmDeleteGenericStateCache ( + void); + +void +AcpiCmDeleteObjectCache ( + void); + +/* + * Cmutils + */ + +BOOLEAN +AcpiCmValidAcpiName ( + UINT32 Name); + +BOOLEAN +AcpiCmValidAcpiCharacter ( + NATIVE_CHAR Character); + +ACPI_STATUS +AcpiCmResolvePackageReferences ( + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * Memory allocation functions and related macros. + * Macros that expand to include filename and line number + */ + +void * +_CmAllocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line); + +void * +_CmCallocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line); + +void +_CmFree ( + void *Address, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line); + +void +AcpiCmInitStaticObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +#define AcpiCmAllocate(a) _CmAllocate(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define AcpiCmCallocate(a) _CmCallocate(a, _COMPONENT,_THIS_MODULE,__LINE__) +#define AcpiCmFree(a) _CmFree(a,_COMPONENT,_THIS_MODULE,__LINE__) + +#ifndef ACPI_DEBUG + +#define AcpiCmAddElementToAllocList(a,b,c,d,e,f) +#define AcpiCmDeleteElementFromAllocList(a,b,c,d) +#define AcpiCmDumpCurrentAllocations(a,b) +#define AcpiCmDumpAllocationInfo() + +#define DECREMENT_OBJECT_METRICS(a) +#define INCREMENT_OBJECT_METRICS(a) +#define INITIALIZE_ALLOCATION_METRICS() +#define DECREMENT_NAME_TABLE_METRICS(a) +#define INCREMENT_NAME_TABLE_METRICS(a) + +#else + +#define INITIALIZE_ALLOCATION_METRICS() \ + AcpiGbl_CurrentObjectCount = 0; \ + AcpiGbl_CurrentObjectSize = 0; \ + AcpiGbl_RunningObjectCount = 0; \ + AcpiGbl_RunningObjectSize = 0; \ + AcpiGbl_MaxConcurrentObjectCount = 0; \ + AcpiGbl_MaxConcurrentObjectSize = 0; \ + AcpiGbl_CurrentAllocSize = 0; \ + AcpiGbl_CurrentAllocCount = 0; \ + AcpiGbl_RunningAllocSize = 0; \ + AcpiGbl_RunningAllocCount = 0; \ + AcpiGbl_MaxConcurrentAllocSize = 0; \ + AcpiGbl_MaxConcurrentAllocCount = 0; \ + AcpiGbl_CurrentNodeCount = 0; \ + AcpiGbl_CurrentNodeSize = 0; \ + AcpiGbl_MaxConcurrentNodeCount = 0 + + +#define DECREMENT_OBJECT_METRICS(a) \ + AcpiGbl_CurrentObjectCount--; \ + AcpiGbl_CurrentObjectSize -= a + +#define INCREMENT_OBJECT_METRICS(a) \ + AcpiGbl_CurrentObjectCount++; \ + AcpiGbl_RunningObjectCount++; \ + if (AcpiGbl_MaxConcurrentObjectCount < AcpiGbl_CurrentObjectCount) \ + { \ + AcpiGbl_MaxConcurrentObjectCount = AcpiGbl_CurrentObjectCount; \ + } \ + AcpiGbl_RunningObjectSize += a; \ + AcpiGbl_CurrentObjectSize += a; \ + if (AcpiGbl_MaxConcurrentObjectSize < AcpiGbl_CurrentObjectSize) \ + { \ + AcpiGbl_MaxConcurrentObjectSize = AcpiGbl_CurrentObjectSize; \ + } + +#define DECREMENT_NAME_TABLE_METRICS(a) \ + AcpiGbl_CurrentNodeCount--; \ + AcpiGbl_CurrentNodeSize -= (a) + +#define INCREMENT_NAME_TABLE_METRICS(a) \ + AcpiGbl_CurrentNodeCount++; \ + AcpiGbl_CurrentNodeSize+= (a); \ + if (AcpiGbl_MaxConcurrentNodeCount < AcpiGbl_CurrentNodeCount) \ + { \ + AcpiGbl_MaxConcurrentNodeCount = AcpiGbl_CurrentNodeCount; \ + } \ + + +void +AcpiCmDumpAllocationInfo ( + void); + +void +AcpiCmDumpCurrentAllocations ( + UINT32 Component, + NATIVE_CHAR *Module); + +#endif + + +#endif /* _ACCOMMON_H */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acconfig.h b/sys/contrib/dev/acpica/Subsystem/Include/acconfig.h new file mode 100644 index 0000000..116c020 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acconfig.h @@ -0,0 +1,269 @@ +/****************************************************************************** + * + * Name: acconfig.h - Global configuration constants + * $Revision: 44 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACCONFIG_H +#define _ACCONFIG_H + + +/****************************************************************************** + * + * Compile-time options + * + *****************************************************************************/ + +/* + * ACPI_DEBUG - This switch enables all the debug facilities of the ACPI + * subsystem. This includes the DEBUG_PRINT output statements + * When disabled, all DEBUG_PRINT statements are compiled out. + * + * ACPI_APPLICATION - Use this switch if the subsystem is going to be run + * at the application level. + * + */ + + +/****************************************************************************** + * + * Subsystem Constants + * + *****************************************************************************/ + + +/* Version string */ + +#define ACPI_CA_VERSION __DATE__ + + +/* + * How and when control methods will be parsed + * The default action is to parse all methods at table load time to verify them, but delete the parse trees + * to conserve memory. Methods are parsed just in time before execution and the parse tree is deleted + * when execution completes. + */ +#define METHOD_PARSE_AT_INIT 0x0 /* Parse at table init, never delete the method parse tree */ +#define METHOD_PARSE_JUST_IN_TIME 0x1 /* Parse only when a method is invoked */ +#define METHOD_DELETE_AT_COMPLETION 0x2 /* Delete parse tree on method completion */ + +/* Default parsing configuration */ + +#define METHOD_PARSE_CONFIGURATION (METHOD_PARSE_JUST_IN_TIME | METHOD_DELETE_AT_COMPLETION) + + +/* Maximum objects in the various object caches */ + +#define MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */ +#define MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ +#define MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ +#define MAX_WALK_CACHE_DEPTH 2 /* Objects for parse tree walks (method execution) */ + +/* + * NameSpace Table size + * + * All tables are the same size to simplify the implementation. + * Tables may be extended by allocating additional tables that + * are in turn linked together to form a chain of tables. + */ + +#define NS_TABLE_SIZE 4 + +/* String size constants */ + +#define MAX_STRING_LENGTH 512 +#define PATHNAME_MAX 256 /* A full namespace pathname */ + + +/* Maximum count for a semaphore object */ + +#define MAX_SEMAPHORE_COUNT 256 + + +/* Max reference count (for debug only) */ + +#define MAX_REFERENCE_COUNT 0x200 + + +/* Size of cached memory mapping for system memory operation region */ + +#define SYSMEM_REGION_WINDOW_SIZE 4096 + + +/* + * Debugger threading model + * Use single threaded if the entire subsystem is contained in an application + * Use multiple threaded when the the subsystem is running in the kernel. + * + * By default the model is single threaded if ACPI_APPLICATION is set, + * multi-threaded if ACPI_APPLICATION is not set. + */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + +#ifdef ACPI_APPLICATION +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED + +#else +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#endif + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* + * Method info (in WALK_STATE), containing local variables and argumetns + */ + +#define MTH_NUM_LOCALS 8 +#define MTH_MAX_LOCAL 7 + +#define MTH_NUM_ARGS 7 +#define MTH_MAX_ARG 6 + +/* + * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG + */ + +#define OBJ_NUM_OPERANDS 8 +#define OBJ_MAX_OPERAND 7 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 INT8 for separator */ +#define PATH_SEPARATOR '.' + + +/* Constants used in searching for the RSDP in low memory */ + +#define LO_RSDP_WINDOW_BASE (void *) 0 +#define HI_RSDP_WINDOW_BASE (void *) 0xE0000 +#define LO_RSDP_WINDOW_SIZE 0x400 +#define HI_RSDP_WINDOW_SIZE 0x20000 +#define RSDP_SCAN_STEP 16 + + +/* Maximum nesting of package objects */ + +#define MAX_PACKAGE_DEPTH 16 + + +#endif /* _ACCONFIG_H */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acdebug.h b/sys/contrib/dev/acpica/Subsystem/Include/acdebug.h new file mode 100644 index 0000000..9e164ca --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acdebug.h @@ -0,0 +1,493 @@ +/****************************************************************************** + * + * Name: acdebug.h - ACPI/AML debugger + * $Revision: 37 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDEBUG_H__ +#define __ACDEBUG_H__ + + +#define DB_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define DB_COMMAND_PROMPT '-' +#define DB_EXECUTE_PROMPT '%' + + +extern int optind; +extern NATIVE_CHAR *optarg; +extern UINT8 *AmlPtr; +extern UINT32 AcpiAmlLength; + +extern BOOLEAN opt_tables; +extern BOOLEAN opt_disasm; +extern BOOLEAN opt_stats; +extern BOOLEAN opt_parse_jit; +extern BOOLEAN opt_verbose; + + +extern NATIVE_CHAR *Args[DB_MAX_ARGS]; +extern NATIVE_CHAR LineBuf[80]; +extern NATIVE_CHAR ScopeBuf[40]; +extern NATIVE_CHAR DebugFilename[40]; +extern BOOLEAN OutputToFile; +extern NATIVE_CHAR *Buffer; +extern NATIVE_CHAR *Filename; +extern NATIVE_CHAR *INDENT_STRING; +extern UINT8 AcpiGbl_DbOutputFlags; +extern UINT32 AcpiGbl_DbDebugLevel; +extern UINT32 AcpiGbl_DbConsoleDebugLevel; + +extern UINT32 NumNames; +extern UINT32 NumMethods; +extern UINT32 NumRegions; +extern UINT32 NumPackages; +extern UINT32 NumAliases; +extern UINT32 NumDevices; +extern UINT32 NumFieldDefs; +extern UINT32 NumThermalZones; +extern UINT32 NumNodes; +extern UINT32 NumGrammarElements; +extern UINT32 NumMethodElements ; +extern UINT32 NumMutexes; +extern UINT32 NumPowerResources; +extern UINT32 NumBankFields ; +extern UINT32 NumIndexFields; +extern UINT32 NumEvents; + +extern UINT32 SizeOfParseTree; +extern UINT32 SizeOfMethodTrees; +extern UINT32 SizeOfNTEs; +extern UINT32 SizeOfAcpiObjects; + + +#define BUFFER_SIZE 4196 + +#define DB_REDIRECTABLE_OUTPUT 0x01 +#define DB_CONSOLE_OUTPUT 0x02 +#define DB_DUPLICATE_OUTPUT 0x03 + + +typedef struct CommandInfo +{ + NATIVE_CHAR *Name; /* Command Name */ + UINT8 MinArgs; /* Minimum arguments required */ + +} COMMAND_INFO; + + +typedef struct ArgumentInfo +{ + NATIVE_CHAR *Name; /* Argument Name */ + +} ARGUMENT_INFO; + + +#define PARAM_LIST(pl) pl + +#define DBTEST_OUTPUT_LEVEL(lvl) if (opt_verbose) + +#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ + AcpiOsPrintf PARAM_LIST(fp);} + +#define EX_NO_SINGLE_STEP 1 +#define EX_SINGLE_STEP 2 + + +/* Prototypes */ + + +/* + * dbapi - external debugger interfaces + */ + +int +AcpiDbInitialize ( + void); + +ACPI_STATUS +AcpiDbSingleStep ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT8 OpType); + + +/* + * dbcmds - debug commands and output routines + */ + + +void +AcpiDbDisplayTableInfo ( + NATIVE_CHAR *TableArg); + +void +AcpiDbUnloadAcpiTable ( + NATIVE_CHAR *TableArg, + NATIVE_CHAR *InstanceArg); + +void +AcpiDbSetMethodBreakpoint ( + NATIVE_CHAR *Location, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDisassembleAml ( + NATIVE_CHAR *Statements, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDumpNamespace ( + NATIVE_CHAR *StartArg, + NATIVE_CHAR *DepthArg); + +void +AcpiDbDumpNamespaceByOwner ( + NATIVE_CHAR *OwnerArg, + NATIVE_CHAR *DepthArg); + +void +AcpiDbSendNotify ( + NATIVE_CHAR *Name, + UINT32 Value); + +void +AcpiDbSetMethodData ( + NATIVE_CHAR *TypeArg, + NATIVE_CHAR *IndexArg, + NATIVE_CHAR *ValueArg); + +ACPI_STATUS +AcpiDbDisplayObjects ( + NATIVE_CHAR *ObjTypeArg, + NATIVE_CHAR *DisplayCountArg); + +ACPI_STATUS +AcpiDbFindNameInNamespace ( + NATIVE_CHAR *NameArg); + +void +AcpiDbSetScope ( + NATIVE_CHAR *Name); + +void +AcpiDbFindReferences ( + NATIVE_CHAR *ObjectArg); + + +/* + * dbdisasm - AML disassembler + */ + +void +AcpiDbDisplayOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes); + +void +AcpiDbDisplayNamestring ( + NATIVE_CHAR *Name); + +void +AcpiDbDisplayPath ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDisplayOpcode ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * dbdisply - debug display commands + */ + + +void +AcpiDbDisplayMethodInfo ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDecodeAndDisplayObject ( + NATIVE_CHAR *Target, + NATIVE_CHAR *OutputType); + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDbDisplayAllMethods ( + NATIVE_CHAR *DisplayCountArg); + +void +AcpiDbDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiDbDisplayArguments ( + void); + +void +AcpiDbDisplayLocals ( + void); + +void +AcpiDbDisplayResults ( + void); + +void +AcpiDbDisplayCallingTree ( + void); + +void +AcpiDbDisplayArgumentObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * dbexec - debugger control method execution + */ + +void +AcpiDbExecute ( + NATIVE_CHAR *Name, + NATIVE_CHAR **Args, + UINT32 Flags); + +void +AcpiDbCreateExecutionThreads ( + NATIVE_CHAR *NumThreadsArg, + NATIVE_CHAR *NumLoopsArg, + NATIVE_CHAR *MethodNameArg); + + +/* + * dbfileio - Debugger file I/O commands + */ + +OBJECT_TYPE_INTERNAL +AcpiDbMatchArgument ( + NATIVE_CHAR *UserArgument, + ARGUMENT_INFO *Arguments); + + +void +AcpiDbCloseDebugFile ( + void); + +void +AcpiDbOpenDebugFile ( + NATIVE_CHAR *Name); + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + NATIVE_CHAR *Filename); + + +/* + * dbhistry - debugger HISTORY command + */ + +void +AcpiDbAddToHistory ( + NATIVE_CHAR *CommandLine); + +void +AcpiDbDisplayHistory (void); + +NATIVE_CHAR * +AcpiDbGetFromHistory ( + NATIVE_CHAR *CommandNumArg); + + +/* + * dbinput - user front-end to the AML debugger + */ + +ACPI_STATUS +AcpiDbCommandDispatch ( + NATIVE_CHAR *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbExecuteThread ( + void *Context); + +ACPI_STATUS +AcpiDbUserCommands ( + NATIVE_CHAR Prompt, + ACPI_PARSE_OBJECT *Op); + + +/* + * dbstats - Generation and display of ACPI table statistics + */ + +void +AcpiDbGenerateStatistics ( + ACPI_PARSE_OBJECT *Root, + BOOLEAN IsMethod); + + +ACPI_STATUS +AcpiDbDisplayStatistics ( + NATIVE_CHAR *TypeArg); + + +/* + * dbutils - AML debugger utilities + */ + +void +AcpiDbSetOutputDestination ( + UINT32 Where); + +void +AcpiDbDumpBuffer ( + UINT32 Address); + +void +AcpiDbDumpObject ( + ACPI_OBJECT *ObjDesc, + UINT32 Level); + +void +AcpiDbPrepNamestring ( + NATIVE_CHAR *Name); + + +ACPI_STATUS +AcpiDbSecondPassParse ( + ACPI_PARSE_OBJECT *Root); + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + NATIVE_CHAR *Name); + + +#endif /* __ACDEBUG_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acdispat.h b/sys/contrib/dev/acpica/Subsystem/Include/acdispat.h new file mode 100644 index 0000000..2266e9f --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acdispat.h @@ -0,0 +1,523 @@ +/****************************************************************************** + * + * Name: acdispat.h - dispatcher (parser to interpreter interface) + * $Revision: 31 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef _ACDISPAT_H_ +#define _ACDISPAT_H_ + + +#define NAMEOF_LOCAL_NTE "__L0" +#define NAMEOF_ARG_NTE "__A0" + + +/* For AcpiDsMethodDataSetValue */ + +#define MTH_TYPE_LOCAL 0 +#define MTH_TYPE_ARG 1 + + + + +/* Common interfaces */ + +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); + + +/* dsopcode - support for late evaluation */ + +ACPI_STATUS +AcpiDsGetFieldUnitArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *RgnDesc); + + +/* dsctrl - Parser/Interpreter interface, control stack routines */ + + +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* dsexec - Parser/Interpreter interface, method execution callbacks */ + + +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 HasResultObj); + +ACPI_STATUS +AcpiDsExecBeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op); + + +/* dsfield - Parser/Interpreter interface for AML fields */ + + +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE RegionNode, + ACPI_WALK_STATE *WalkState); + + +/* dsload - Parser/Interpreter interface, namespace load callbacks */ + +ACPI_STATUS +AcpiDsLoad1BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsLoad3BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad3EndOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op); + + +/* dsmthdat - method data (locals/args) */ + + +ACPI_STATUS +AcpiDsMethodDataGetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT ***Node); + +ACPI_STATUS +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsIsMethodValue ( + ACPI_OPERAND_OBJECT *ObjDesc); + +OBJECT_TYPE_INTERNAL +AcpiDsMethodDataGetType ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc); + +ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataDeleteValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState); + +ACPI_NAMESPACE_NODE * +AcpiDsMethodDataGetNte ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataSetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + + +/* dsmethod - Parser/Interpreter interface - control method parsing */ + +ACPI_STATUS +AcpiDsParseMethod ( + ACPI_HANDLE ObjHandle); + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_WALK_LIST *WalkList, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc); + +ACPI_STATUS +AcpiDsTerminateControlMethod ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* dsobj - Parser/Interpreter interface - object initialization and conversion */ + +ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiDsInitializeObjects ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *StartNode); + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **ObjDescPtr); + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + + +/* dsregn - Parser/Interpreter interface - Op Region parsing */ + +ACPI_STATUS +AcpiDsEvalFieldUnitOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle); + + +/* dsutils - Parser/Interpreter interface utility routines */ + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg); + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg); + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState); + +OBJECT_TYPE_INTERNAL +AcpiDsMapOpcodeToDataType ( + UINT16 Opcode, + UINT32 *OutFlags); + +OBJECT_TYPE_INTERNAL +AcpiDsMapNamedOpcodeToDataType ( + UINT16 Opcode); + + +/* + * dswscope - Scope Stack manipulation + */ + +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_WALK_STATE *WalkState); + + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState); + + +/* AcpiDswstate - parser WALK_STATE management routines */ + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_WALK_LIST *WalkList); + +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_WALK_LIST *WalkList); + +ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsResultStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsResultStackClear ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_WALK_LIST *WalkList); + +void +AcpiDsDeleteWalkStateCache ( + void); + + +#endif /* _ACDISPAT_H_ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acefi.h b/sys/contrib/dev/acpica/Subsystem/Include/acefi.h new file mode 100644 index 0000000..6875d04 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acefi.h @@ -0,0 +1,127 @@ +/****************************************************************************** + * + * Name: acefi.h - OS specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEFI_H__ +#define __ACEFI_H__ + +#define ACPI_OS_NAME "AED EFI" + +#include +#include +#include + + +#endif /* __ACEFI_H__ */ \ No newline at end of file diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acenv.h b/sys/contrib/dev/acpica/Subsystem/Include/acenv.h new file mode 100644 index 0000000..1d44537 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acenv.h @@ -0,0 +1,374 @@ +/****************************************************************************** + * + * Name: acenv.h - Generation environment specific items + * $Revision: 61 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACENV_H__ +#define __ACENV_H__ + + +/* + * Configuration for ACPI Utilities + */ + +#ifdef _ACPI_DUMP_APP +#define ACPI_DEBUG +#define ACPI_APPLICATION +#define ENABLE_DEBUGGER +#define ACPI_USE_SYSTEM_CLIBRARY +#define PARSER_ONLY +#endif + +#ifdef _ACPI_EXEC_APP +#undef DEBUGGER_THREADING +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED +#define ACPI_DEBUG +#define ACPI_APPLICATION +#define ENABLE_DEBUGGER +#define ACPI_USE_SYSTEM_CLIBRARY +#endif + + +/* + * Environment configuration. The purpose of this file is to interface to the + * local generation environment. + * + * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. + * Otherwise, local versions of string/memory functions will be used. + * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and + * the standard header files may be used. + * + * The ACPI subsystem only uses low level C library functions that do not call + * operating system services and may therefore be inlined in the code. + * + * It may be necessary to tailor these include files to the target + * generation environment. + * + * + * Functions and constants used from each header: + * + * string.h: memcpy + * memset + * strcat + * strcmp + * strcpy + * strlen + * strncmp + * strncat + * strncpy + * + * stdlib.h: strtoul + * + * stdarg.h: va_list + * va_arg + * va_start + * va_end + * + */ + +/*! [Begin] no source code translation */ + +#ifdef _LINUX +#include "aclinux.h" + +#elif _AED_EFI +#include "acefi.h" + +#elif WIN32 +#include "acwin.h" + +#elif __FreeBSD__ +#include "acfreebsd.h" + +#else + +/* All other environments */ + +#define ACPI_USE_STANDARD_HEADERS + +/* Name of host operating system (returned by the _OS_ namespace object) */ + +#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" + +#endif + + +/*! [End] no source code translation !*/ + +/****************************************************************************** + * + * C library configuration + * + *****************************************************************************/ + +#ifdef ACPI_USE_SYSTEM_CLIBRARY +/* + * Use the standard C library headers. + * We want to keep these to a minimum. + * + */ + +#ifdef ACPI_USE_STANDARD_HEADERS +/* + * Use the standard headers from the standard locations + */ +#include +#include +#include +#include + +#endif /* ACPI_USE_STANDARD_HEADERS */ + +/* + * We will be linking to the standard Clib functions + */ + +#define STRSTR(s1,s2) strstr((s1), (s2)) +#define STRUPR(s) strupr((s)) +#define STRLEN(s) strlen((s)) +#define STRCPY(d,s) strcpy((d), (s)) +#define STRNCPY(d,s,n) strncpy((d), (s), (n)) +#define STRNCMP(d,s,n) strncmp((d), (s), (n)) +#define STRCMP(d,s) strcmp((d), (s)) +#define STRCAT(d,s) strcat((d), (s)) +#define STRNCAT(d,s,n) strncat((d), (s), (n)) +#define STRTOUL(d,s,n) strtoul((d), (s), (n)) +#define MEMCPY(d,s,n) memcpy((d), (s), (n)) +#define MEMSET(d,s,n) memset((d), (s), (n)) +#define TOUPPER toupper +#define TOLOWER tolower + + +/****************************************************************************** + * + * Not using native C library, use local implementations + * + *****************************************************************************/ +#else + +/* + * Use local definitions of C library macros and functions + * NOTE: The function implementations may not be as efficient + * as an inline or assembly code implementation provided by a + * native C library. + */ + +#ifndef va_arg + +#ifndef _VALIST +#define _VALIST +typedef char *va_list; +#endif /* _VALIST */ + +/* + * Storage alignment properties + */ + +#define _AUPBND (sizeof(int) - 1) +#define _ADNBND (sizeof(int) - 1) + +/* + * Variable argument list macro definitions + */ + +#define _Bnd(X, bnd) (((sizeof(X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap)+=((_Bnd(T, _AUPBND)))-(_Bnd(T,_ADNBND))))) +#define va_end(ap) (void)0 +#define va_start(ap, A) (void)((ap)=(((char*)&(A))+(_Bnd(A,_AUPBND)))) + +#endif /* va_arg */ + + +#define STRSTR(s1,s2) AcpiCmStrstr ((s1), (s2)) +#define STRUPR(s) AcpiCmStrupr ((s)) +#define STRLEN(s) AcpiCmStrlen ((s)) +#define STRCPY(d,s) AcpiCmStrcpy ((d), (s)) +#define STRNCPY(d,s,n) AcpiCmStrncpy ((d), (s), (n)) +#define STRNCMP(d,s,n) AcpiCmStrncmp ((d), (s), (n)) +#define STRCMP(d,s) AcpiCmStrcmp ((d), (s)) +#define STRCAT(d,s) AcpiCmStrcat ((d), (s)) +#define STRNCAT(d,s,n) AcpiCmStrncat ((d), (s), (n)) +#define STRTOUL(d,s,n) AcpiCmStrtoul ((d), (s),(n)) +#define MEMCPY(d,s,n) AcpiCmMemcpy ((d), (s), (n)) +#define MEMSET(d,v,n) AcpiCmMemset ((d), (v), (n)) +#define TOUPPER AcpiCmToUpper +#define TOLOWER AcpiCmToLower + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + + +/****************************************************************************** + * + * Assembly code macros + * + *****************************************************************************/ + +/* + * Handle platform- and compiler-specific assembly language differences. + * These should already have been defined by the platform includes above. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +/* Unrecognized compiler, use defaults */ +#ifndef ACPI_ASM_MACROS + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() +#define enable() +#define halt() +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) + +#endif /* ACPI_ASM_MACROS */ + + +#ifdef ACPI_APPLICATION + +/* Don't want software interrupts within a ring3 application */ + +#undef causeinterrupt +#undef BREAKPOINT3 +#define causeinterrupt(level) +#define BREAKPOINT3 +#endif + + +/****************************************************************************** + * + * Compiler-specific + * + *****************************************************************************/ + +/* this has been moved to compiler-specific headers, which are included from the + platform header. */ + + + +/* TBD: move this elsewhere! */ + +#ifdef __ia64__ +/* Look at interim FADT to determine IO or memory mapped */ +#define IoAddressSpace(flag) (AcpiGbl_FACP->AddressSpace & flag) +#else +/* always IO space */ +#define IoAddressSpace(flag) (1) +#endif + + +#endif /* __ACENV_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acevents.h b/sys/contrib/dev/acpica/Subsystem/Include/acevents.h new file mode 100644 index 0000000..5253b95 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acevents.h @@ -0,0 +1,306 @@ +/****************************************************************************** + * + * Name: acevents.h - Event subcomponent prototypes and defines + * $Revision: 59 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEVENTS_H__ +#define __ACEVENTS_H__ + + +ACPI_STATUS +AcpiEvInitialize ( + void); + + +/* + * AcpiEvfixed - Fixed event handling + */ + +ACPI_STATUS +AcpiEvFixedEventInitialize ( + void); + +UINT32 +AcpiEvFixedEventDetect ( + void); + +UINT32 +AcpiEvFixedEventDispatch ( + UINT32 AcpiEvent); + + +/* + * AcpiEvglock - Global Lock support + */ + +ACPI_STATUS +AcpiEvAcquireGlobalLock( + void); + +void +AcpiEvReleaseGlobalLock( + void); + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void); + + +/* + * AcpiEvgpe - GPE handling and dispatch + */ + +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + +ACPI_STATUS +AcpiEvInitGpeControlMethods ( + void); + +UINT32 +AcpiEvGpeDispatch ( + UINT32 GpeNumber); + +UINT32 +AcpiEvGpeDetect ( + void); + + +/* + * AcpiEvnotify - Device Notify handling and dispatch + */ + +void +AcpiEvNotifyDispatch ( + ACPI_HANDLE Device, + UINT32 NotifyValue); + + +/* + * AcpiEvregion - Address Space handling + */ + +ACPI_STATUS +AcpiEvInstallDefaultAddressSpaceHandlers ( + void); + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value); + + +ACPI_STATUS +AcpiEvAddrHandlerHelper ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +void +AcpiEvDisassociateRegionFromHandler( + ACPI_OPERAND_OBJECT *RegionObj); + + +ACPI_STATUS +AcpiEvAssociateRegionAndHandler ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + + +/* + * AcpiEvregini - Region initialization and setup + */ + +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked); + + +/* + * Evsci - SCI (System Control Interrupt) handling/dispatch + */ + +UINT32 +AcpiEvInstallSciHandler ( + void); + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void); + +UINT32 +AcpiEvInitializeSCI ( + UINT32 ProgramSCI); + +void +AcpiEvRestoreAcpiState ( + void); + +void +AcpiEvTerminate ( + void); + + +/* Debug support */ + +#ifdef ACPI_DEBUG + +UINT32 +AcpiEvSciCount ( + UINT32 AcpiEvent); + +#define DEBUG_INCREMENT_EVENT_COUNT(a) AcpiGbl_EventCount[a]++; + +#else + +#define DEBUG_INCREMENT_EVENT_COUNT(a) +#endif + + +#endif /* __ACEVENTS_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acexcep.h b/sys/contrib/dev/acpica/Subsystem/Include/acexcep.h new file mode 100644 index 0000000..87b2ecc --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acexcep.h @@ -0,0 +1,312 @@ +/****************************************************************************** + * + * Name: acexcep.h - Exception codes returned by the ACPI subsystem + * $Revision: 36 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEXCEP_H__ +#define __ACEXCEP_H__ + + +/* + * Exceptions returned by external ACPI interfaces + */ + +#define AE_CODE_ENVIRONMENTAL 0x0000 +#define AE_CODE_PROGRAMMER 0x1000 +#define AE_CODE_ACPI_TABLES 0x2000 +#define AE_CODE_AML 0x3000 +#define AE_CODE_CONTROL 0x4000 +#define AE_CODE_MASK 0xF000 + + +#define ACPI_SUCCESS(a) (!(a)) +#define ACPI_FAILURE(a) (a) + + +#define AE_OK (ACPI_STATUS) 0x0000 + +/* + * Environmental exceptions + */ +#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL) +#define AE_EXIST (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL) +#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL) +#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) +#define AE_VERSION_MISMATCH (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) +#define AE_SUPPORT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) +#define AE_SHARE (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) +#define AE_LIMIT (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) +#define AE_TIME (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) +#define AE_UNKNOWN_STATUS (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x0014 + +/* + * Programmer exceptions + */ +#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER) +#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) +#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) +#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) +#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) + +#define AE_CODE_PGM_MAX 0x0005 + + +/* + * Acpi table exceptions + */ +#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES) +#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) +#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) +#define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES) + +#define AE_CODE_TBL_MAX 0x0003 + + +/* + * AML exceptions. These are caused by problems with + * the actual AML byte stream + */ +#define AE_AML_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_AML) +#define AE_AML_PARSE (ACPI_STATUS) (0x0002 | AE_CODE_AML) +#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0003 | AE_CODE_AML) +#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0004 | AE_CODE_AML) +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0005 | AE_CODE_AML) +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0006 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0007 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0008 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0009 | AE_CODE_AML) +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x000A | AE_CODE_AML) +#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000C | AE_CODE_AML) +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000D | AE_CODE_AML) +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000E | AE_CODE_AML) +#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000F | AE_CODE_AML) +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x0010 | AE_CODE_AML) +#define AE_AML_INTERNAL (ACPI_STATUS) (0x0011 | AE_CODE_AML) + +#define AE_CODE_AML_MAX 0x0011 + +/* + * Internal exceptions used for control + */ +#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL) +#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL) +#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL) +#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL) +#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL) +#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL) +#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL) +#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL) + +#define AE_CODE_CTRL_MAX 0x0008 + + +#ifdef DEFINE_ACPI_GLOBALS + +/* + * String versions of the exception codes above + * These strings must match the corresponding defines exactly + */ +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Env[] = +{ + "AE_OK", + "AE_ERROR", + "AE_NO_ACPI_TABLES", + "AE_NO_NAMESPACE", + "AE_NO_MEMORY", + "AE_NOT_FOUND", + "AE_NOT_EXIST", + "AE_EXIST", + "AE_TYPE", + "AE_NULL_OBJECT", + "AE_NULL_ENTRY", + "AE_BUFFER_OVERFLOW", + "AE_STACK_OVERFLOW", + "AE_STACK_UNDERFLOW", + "AE_NOT_IMPLEMENTED", + "AE_VERSION_MISMATCH", + "AE_SUPPORT", + "AE_SHARE", + "AE_LIMIT", + "AE_TIME", + "AE_UNKNOWN_STATUS", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Pgm[] = +{ + "AE_BAD_PARAMETER", + "AE_BAD_CHARACTER", + "AE_BAD_PATHNAME", + "AE_BAD_DATA", + "AE_BAD_ADDRESS", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Tbl[] = +{ + "AE_BAD_SIGNATURE", + "AE_BAD_HEADER", + "AE_BAD_CHECKSUM", + "AE_BAD_VALUE", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Aml[] = +{ + "AE_AML_ERROR", + "AE_AML_PARSE", + "AE_AML_BAD_OPCODE", + "AE_AML_NO_OPERAND", + "AE_AML_OPERAND_TYPE", + "AE_AML_OPERAND_VALUE", + "AE_AML_UNINITIALIZED_LOCAL", + "AE_AML_UNINITIALIZED_ARG", + "AE_AML_UNINITIALIZED_ELEMENT", + "AE_AML_NUMERIC_OVERFLOW", + "AE_AML_REGION_LIMIT", + "AE_AML_BUFFER_LIMIT", + "AE_AML_PACKAGE_LIMIT", + "AE_AML_DIVIDE_BY_ZERO", + "AE_AML_BAD_NAME", + "AE_AML_NAME_NOT_FOUND", + "AE_AML_INTERNAL", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Ctrl[] = +{ + "AE_CTRL_RETURN_VALUE", + "AE_CTRL_PENDING", + "AE_CTRL_TERMINATE", + "AE_CTRL_TRUE", + "AE_CTRL_FALSE", + "AE_CTRL_DEPTH", + "AE_CTRL_END", + "AE_CTRL_TRANSFER", +}; + + +#endif /* DEFINE_ACPI_GLOBALS */ + + +#endif /* __ACEXCEP_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acfreebsd.h b/sys/contrib/dev/acpica/Subsystem/Include/acfreebsd.h new file mode 100644 index 0000000..36ba77a --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acfreebsd.h @@ -0,0 +1,134 @@ +/****************************************************************************** + * + * Name: acfreebsd.h - OS specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACFREEBSD_H__ +#define __ACFREEBSD_H__ + +#define ACPI_OS_NAME "FreeBSD" + +#ifdef _KERNEL +#include +#include +#include +#include +#include + +#define asm __asm +#define __cli() disable_intr() +#define __sti() enable_intr() + + +#endif /* __ACFREEBSD_H__ */ \ No newline at end of file diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acgcc.h b/sys/contrib/dev/acpica/Subsystem/Include/acgcc.h new file mode 100644 index 0000000..9689664 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acgcc.h @@ -0,0 +1,240 @@ +/****************************************************************************** + * + * Name: acgcc.h - GCC specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGCC_H__ +#define __ACGCC_H__ + +#define COMPILER_DEPENDENT_UINT64 unsigned long long + + +#ifdef __ia64__ +#define _IA64 + +/* Single threaded */ +#define ACPI_APPLICATION + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() __cli() +#define enable() __sti() +#define wbinvd() + +/*! [Begin] no source code translation */ + +#include + +#define halt() ia64_pal_halt_light() /* PAL_HALT[_LIGHT] */ +#define safe_halt() ia64_pal_halt(1) /* PAL_HALT */ + + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + __asm__ volatile ("1: ld4 r29=%1\n" \ + ";;\n" \ + "mov ar.ccv=r29\n" \ + "mov r2=r29\n" \ + "shr.u r30=r29,1\n" \ + "and r29=-4,r29\n" \ + ";;\n" \ + "add r29=2,r29\n" \ + "and r30=1,r30\n" \ + ";;\n" \ + "add r29=r29,r30\n" \ + ";;\n" \ + "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ + ";;\n" \ + "cmp.eq p6,p7=r2,r30\n" \ + "(p7) br.dpnt.few 1b\n" \ + "cmp.gt p8,p9=3,r29\n" \ + ";;\n" \ + "(p8) mov %0=-1\n" \ + "(p9) mov %0=r0\n" \ + :"=r"(Acq):"m" __atomic_fool_gcc((GLptr)):"r2","r29","r30","memory"); \ + } while (0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + __asm__ volatile ("1: ld4 r29=%1\n" \ + ";;\n" \ + "mov ar.ccv=r29\n" \ + "mov r2=r29\n" \ + "and r29=-4,r29\n" \ + ";;\n" \ + "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ + ";;\n" \ + "cmp.eq p6,p7=r2,r30\n" \ + "(p7) br.dpnt.few 1b\n" \ + "and %0=1,r2\n" \ + ";;\n" \ + :"=r"(Acq):"m" __atomic_fool_gcc((GLptr)):"r2","r29","r30","memory"); \ + } while (0) +/*! [End] no source code translation !*/ + + +#else /* DO IA32 */ + + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() __cli() +#define enable() __sti() +#define halt() __asm__ __volatile__ ("sti; hlt":::"memory") +#define wbinvd() + +/*! [Begin] no source code translation + * + * A brief explanation as GNU inline assembly is a bit hairy + * %0 is the output parameter in EAX ("=a") + * %1 and %2 are the input parameters in ECX ("c") + * and an immediate value ("i") respectively + * All actual register references are preceded with "%%" as in "%%edx" + * Immediate values in the assembly are preceded by "$" as in "$0x1" + * The final asm parameter are the operation altered non-output registers. + */ +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "btsl $0x1,%%edx;" \ + "adcl $0x0,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "cmpb $0x3,%%dl;" \ + "sbbl %%eax,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + } while(0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "andl $0x1,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + } while(0) + +/*! [End] no source code translation !*/ + +#endif /* IA 32 */ + +#endif /* __ACGCC_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acglobal.h b/sys/contrib/dev/acpica/Subsystem/Include/acglobal.h new file mode 100644 index 0000000..45bfa70 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acglobal.h @@ -0,0 +1,410 @@ +/****************************************************************************** + * + * Name: acglobal.h - Declarations for global variables + * $Revision: 85 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGLOBAL_H__ +#define __ACGLOBAL_H__ + + +/* + * Ensure that the globals are actually defined only once. + * + * The use of these defines allows a single list of globals (here) in order + * to simplify maintenance of the code. + */ +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_EXTERN +#else +#define ACPI_EXTERN extern +#endif + + +extern NATIVE_CHAR *MsgAcpiErrorBreak; + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Runtime configuration of debug print levels */ + +extern UINT32 AcpiDbgLevel; +extern UINT32 AcpiDbgLayer; + + +/* Procedure nesting level for debug output */ + +extern UINT32 AcpiGbl_NestingLevel; + + +/***************************************************************************** + * + * ACPI Table globals + * + ****************************************************************************/ + +/* + * Table pointers. + * Although these pointers are somewhat redundant with the global AcpiTable, + * they are convenient because they are typed pointers. + * + * These tables are single-table only; meaning that there can be at most one + * of each in the system. Each global points to the actual table. + * + */ +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTOR_POINTER *AcpiGbl_RSDP; +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTION_TABLE *AcpiGbl_RSDT; +ACPI_EXTERN FIRMWARE_ACPI_CONTROL_STRUCTURE *AcpiGbl_FACS; +ACPI_EXTERN FIXED_ACPI_DESCRIPTION_TABLE *AcpiGbl_FACP; +ACPI_EXTERN APIC_TABLE *AcpiGbl_APIC; +ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; +ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_SBST; +/* + * Since there may be multiple SSDTs and PSDTS, a single pointer is not + * sufficient; Therefore, there isn't one! + */ + + +/* + * ACPI Table info arrays + */ +extern ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES]; +extern ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES]; + +/* + * Predefined mutex objects. This array contains the + * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. + * (The table maps local handles to the real OS handles) + */ +ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_AcpiMutexInfo [NUM_MTX]; + + +/***************************************************************************** + * + * Miscellaneous globals + * + ****************************************************************************/ + + +ACPI_EXTERN UINT8 *AcpiGbl_Gpe0EnableRegisterSave; +ACPI_EXTERN UINT8 *AcpiGbl_Gpe1EnableRegisterSave; +ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; +ACPI_EXTERN ACPI_GENERIC_STATE *AcpiGbl_GenericStateCache; +ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParseCache; +ACPI_EXTERN ACPI_PARSE2_OBJECT *AcpiGbl_ExtParseCache; +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_ObjectCache; +ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_WalkStateCache; +ACPI_EXTERN ACPI_HANDLE AcpiGbl_GlobalLockSemaphore; + + +ACPI_EXTERN UINT32 AcpiGbl_GlobalLockThreadCount; +ACPI_EXTERN UINT32 AcpiGbl_RestoreAcpiChipset; +ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; +ACPI_EXTERN UINT32 AcpiGbl_EdgeLevelSave; +ACPI_EXTERN UINT32 AcpiGbl_IrqEnableSave; +ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; + +ACPI_EXTERN UINT32 AcpiGbl_StateCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_StateCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_ParseCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_ParseCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_ExtParseCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_ExtParseCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_ObjectCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_ObjectCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_WalkStateCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_WalkStateCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; +ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; + + +ACPI_EXTERN UINT16 AcpiGbl_GenericStateCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_ParseCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_ExtParseCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_ObjectCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_WalkStateCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; +ACPI_EXTERN UINT16 AcpiGbl_NextTableOwnerId; +ACPI_EXTERN UINT16 AcpiGbl_NextMethodOwnerId; + +ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockSet; /* TBD: [Restructure] OBSOLETE?? */ +ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; +ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; + + +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DrvNotify; +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SysNotify; + + +extern BOOLEAN AcpiGbl_Shutdown; +extern UINT32 AcpiGbl_SystemFlags; +extern UINT32 AcpiGbl_StartupFlags; + + +/***************************************************************************** + * + * Namespace globals + * + ****************************************************************************/ + +#define NUM_NS_TYPES INTERNAL_TYPE_INVALID+1 +#define NUM_PREDEFINED_NAMES 9 + + +ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; + +extern UINT8 AcpiGbl_NsProperties[NUM_NS_TYPES]; +extern PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; + + +/* Used to detect memory leaks (DEBUG ONLY) */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN ALLOCATION_INFO *AcpiGbl_HeadAllocPtr; +ACPI_EXTERN ALLOCATION_INFO *AcpiGbl_TailAllocPtr; +#endif + + +/***************************************************************************** + * + * Interpreter globals + * + ****************************************************************************/ + + +ACPI_EXTERN UINT32 AcpiGbl_WhenToParseMethods; +ACPI_EXTERN ACPI_WALK_LIST *AcpiGbl_CurrentWalkList; + +/* Base of AML block, and pointer to current location in it */ + +ACPI_EXTERN UINT8 *AcpiGbl_PCodeBase; +ACPI_EXTERN UINT8 *AcpiGbl_PCode; + +/* + * Length of AML block, and remaining length of current package. + */ +ACPI_EXTERN UINT32 AcpiGbl_PCodeBlockLen; +ACPI_EXTERN UINT32 AcpiGbl_PCodeLen; + +ACPI_EXTERN UINT32 AcpiGbl_BufSeq; /* Counts allocated Buffer descriptors */ +ACPI_EXTERN UINT32 AcpiGbl_NodeErr; /* Indicate if inc_error should be called */ + +/* + * Handle to the last method found - used during pass1 of load + */ +ACPI_EXTERN ACPI_HANDLE AcpiGbl_LastMethod; + +/* + * Table of Address Space handlers + */ + +ACPI_EXTERN ACPI_ADDRESS_SPACE_INFO AcpiGbl_AddressSpaces[ACPI_NUM_ADDRESS_SPACES]; + + +/* Control method single step flag */ + +ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; + + +/***************************************************************************** + * + * Parser globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; + +extern ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[]; +extern UINT8 AcpiGbl_AmlOpInfoIndex[256]; + + +/***************************************************************************** + * + * Hardware globals + * + ****************************************************************************/ + +extern ACPI_C_STATE_HANDLER AcpiHwCxHandlers[MAX_CX_STATES]; +extern UINT32 AcpiHwActiveCxState; + + +/***************************************************************************** + * + * Event globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventHandlers[NUM_FIXED_EVENTS]; + +ACPI_EXTERN ACPI_HANDLE AcpiGbl_GpeObjHandle; +ACPI_EXTERN UINT32 AcpiGbl_GpeRegisterCount; +ACPI_EXTERN ACPI_GPE_REGISTERS *AcpiGbl_GpeRegisters; +ACPI_EXTERN ACPI_GPE_LEVEL_INFO *AcpiGbl_GpeInfo; + +/* + * Gpe validation and translation table + * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported. + * Otherwise, returns a valid index into the global GPE table. + * + * This table is needed because the GPE numbers supported by block 1 do not + * have to be contiguous with the GPE numbers supported by block 0. + */ +ACPI_EXTERN UINT8 AcpiGbl_GpeValid [NUM_GPE]; + +/* AcpiEvent counter for debug only */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN UINT32 AcpiGbl_EventCount[NUM_FIXED_EVENTS]; +#endif + + +/***************************************************************************** + * + * Debugger globals + * + ****************************************************************************/ + +ACPI_EXTERN BOOLEAN AcpiGbl_MethodExecuting; +ACPI_EXTERN BOOLEAN AcpiGbl_DbTerminateThreads; + + +/* Memory allocation metrics - Debug Only! */ + +#ifdef ACPI_DEBUG + +ACPI_EXTERN UINT32 AcpiGbl_CurrentAllocSize; +ACPI_EXTERN UINT32 AcpiGbl_CurrentAllocCount; +ACPI_EXTERN UINT32 AcpiGbl_RunningAllocSize; +ACPI_EXTERN UINT32 AcpiGbl_RunningAllocCount; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentAllocSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentAllocCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentObjectCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentObjectSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentObjectCount; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentObjectSize; +ACPI_EXTERN UINT32 AcpiGbl_RunningObjectCount; +ACPI_EXTERN UINT32 AcpiGbl_RunningObjectSize; +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentNodeCount; + +#endif + + +#endif /* __ACGLOBAL_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/achware.h b/sys/contrib/dev/acpica/Subsystem/Include/achware.h new file mode 100644 index 0000000..046bbaf --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/achware.h @@ -0,0 +1,260 @@ +/****************************************************************************** + * + * Name: achware.h -- hardware specific interfaces + * $Revision: 42 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACHWARE_H__ +#define __ACHWARE_H__ + + +/* Prototypes */ + + +ACPI_STATUS +AcpiHwInitialize ( + void); + +ACPI_STATUS +AcpiHwShutdown ( + void); + +ACPI_STATUS +AcpiHwInitializeSystemInfo ( + void); + +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode); + +UINT32 +AcpiHwGetMode ( + void); + +UINT32 +AcpiHwGetModeCapabilities ( + void); + +/* Register I/O Prototypes */ + +UINT32 +AcpiHwRegisterAccess ( + NATIVE_UINT ReadWrite, + BOOLEAN UseLock, + UINT32 RegisterId, ... /* DWORD Value */); + +void +AcpiHwClearAcpiStatus ( + void); + + +/* GPE support */ + +void +AcpiHwEnableGpe ( + UINT32 GpeIndex); + +void +AcpiHwDisableGpe ( + UINT32 GpeIndex); + +void +AcpiHwClearGpe ( + UINT32 GpeIndex); + +void +AcpiHwGetGpeStatus ( + UINT32 GpeNumber, + ACPI_EVENT_STATUS *EventStatus); + +/* Sleep Prototypes */ + +ACPI_STATUS +AcpiHwObtainSleepTypeRegisterData ( + UINT8 SleepState, + UINT8 *Slp_TypA, + UINT8 *Slp_TypB); + + +/* Cx State Prototypes */ + +ACPI_STATUS +AcpiHwEnterC1( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwEnterC2( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwEnterC3( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwEnterCx ( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwSetCx ( + UINT32 CxState); + +ACPI_STATUS +AcpiHwGetCxInfo ( + UINT32 CxStates[]); + + +/* Throttling Prototypes */ + +void +AcpiHwEnableThrottling ( + ACPI_IO_ADDRESS PblkAddress); + +void +AcpiHwDisableThrottling ( + ACPI_IO_ADDRESS PblkAddress); + +UINT32 +AcpiHwGetDutyCycle ( + UINT8 DutyOffset, + ACPI_IO_ADDRESS PblkAddress, + UINT32 NumThrottleStates); + +void +AcpiHwProgramDutyCycle ( + UINT8 DutyOffset, + UINT32 DutyCycle, + ACPI_IO_ADDRESS PblkAddress, + UINT32 NumThrottleStates); + +NATIVE_UINT +AcpiHwLocalPow ( + NATIVE_UINT x, + NATIVE_UINT y); + + +/* ACPI Timer prototypes */ + +UINT32 +AcpiHwPmtTicks ( + void); + +UINT32 +AcpiHwPmtResolution ( + void); + + +#endif /* __ACHWARE_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acinterp.h b/sys/contrib/dev/acpica/Subsystem/Include/acinterp.h new file mode 100644 index 0000000..0a4e7a8 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acinterp.h @@ -0,0 +1,624 @@ +/****************************************************************************** + * + * Name: acinterp.h - Interpreter subcomponent prototypes and defines + * $Revision: 82 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACINTERP_H__ +#define __ACINTERP_H__ + + +#define WALK_OPERANDS &(WalkState->Operands [WalkState->NumOperands -1]) + + +/* Interpreter constants */ + +#define AML_END_OF_BLOCK -1 +#define PUSH_PKG_LENGTH 1 +#define DO_NOT_PUSH_PKG_LENGTH 0 + + +#define STACK_TOP 0 +#define STACK_BOTTOM (UINT32) -1 + +/* Constants for global "WhenToParseMethods" */ + +#define METHOD_PARSE_AT_INIT 0x0 +#define METHOD_PARSE_JUST_IN_TIME 0x1 +#define METHOD_DELETE_AT_COMPLETION 0x2 + + +ACPI_STATUS +AcpiAmlResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * amxface - External interpreter interfaces + */ + +ACPI_STATUS +AcpiAmlLoadTable ( + ACPI_TABLE_TYPE TableId); + +ACPI_STATUS +AcpiAmlExecuteMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + + +/* + * amfield - ACPI AML (p-code) execution - field manipulation + */ + + +ACPI_STATUS +AcpiAmlReadField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity); + +ACPI_STATUS +AcpiAmlWriteField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity); + +ACPI_STATUS +AcpiAmlSetupField ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *RgnDesc, + UINT32 FieldBitWidth); + +ACPI_STATUS +AcpiAmlReadFieldData ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldByteOffset, + UINT32 FieldBitWidth, + UINT32 *Value); + +ACPI_STATUS +AcpiAmlAccessNamedField ( + UINT32 Mode, + ACPI_HANDLE NamedField, + void *Buffer, + UINT32 Length); + +/* + * ammisc - ACPI AML (p-code) execution - specific opcodes + */ + +ACPI_STATUS +AcpiAmlExecCreateField ( + UINT8 *AmlPtr, + UINT32 AmlLength, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecReconfiguration ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecFatal ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecIndex ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecMatch ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecCreateMutex ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateProcessor ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE ProcessorNTE); + +ACPI_STATUS +AcpiAmlExecCreatePowerResource ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE ProcessorNTE); + +ACPI_STATUS +AcpiAmlExecCreateRegion ( + UINT8 *AmlPtr, + UINT32 AcpiAmlLength, + UINT32 RegionSpace, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateEvent ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateAlias ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateMethod ( + UINT8 *AmlPtr, + UINT32 AcpiAmlLength, + UINT32 MethodFlags, + ACPI_HANDLE Method); + + +/* + * amprep - ACPI AML (p-code) execution - prep utilities + */ + +ACPI_STATUS +AcpiAmlPrepDefFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength); + +ACPI_STATUS +AcpiAmlPrepBankFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + ACPI_HANDLE BankReg, + UINT32 BankVal, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength); + +ACPI_STATUS +AcpiAmlPrepIndexFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE IndexReg, + ACPI_HANDLE DataReg, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength); + + +/* + * amsystem - Interface to OS services + */ + +UINT16 +AcpiAmlSystemThreadId ( + void); + +ACPI_STATUS +AcpiAmlSystemDoNotifyOp ( + ACPI_OPERAND_OBJECT *Value, + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiAmlSystemDoSuspend( + UINT32 Time); + +void +AcpiAmlSystemDoStall ( + UINT32 Time); + +ACPI_STATUS +AcpiAmlSystemAcquireMutex( + ACPI_OPERAND_OBJECT *Time, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemReleaseMutex( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemSignalEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemWaitEvent( + ACPI_OPERAND_OBJECT *Time, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemResetEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemWaitSemaphore ( + ACPI_HANDLE Semaphore, + UINT32 Timeout); + + +/* + * ammonadic - ACPI AML (p-code) execution, monadic operators + */ + +ACPI_STATUS +AcpiAmlExecMonadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecMonadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecMonadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * amdyadic - ACPI AML (p-code) execution, dyadic operators + */ + +ACPI_STATUS +AcpiAmlExecDyadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecDyadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecDyadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecDyadic2S ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * amresolv - Object resolution and get value functions + */ + +ACPI_STATUS +AcpiAmlResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlResolveNodeToValue ( + ACPI_NAMESPACE_NODE **StackPtr); + +ACPI_STATUS +AcpiAmlResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlGetFieldUnitValue ( + ACPI_OPERAND_OBJECT *FieldDesc, + ACPI_OPERAND_OBJECT *ResultDesc); + + +/* + * amdump - Scanner debug output routines + */ + +void +AcpiAmlShowHexValue ( + UINT32 ByteCount, + UINT8 *AmlPtr, + UINT32 LeadSpace); + + +ACPI_STATUS +AcpiAmlDumpOperand ( + ACPI_OPERAND_OBJECT *EntryDesc); + +void +AcpiAmlDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + OPERATING_MODE InterpreterMode, + NATIVE_CHAR *Ident, + UINT32 NumLevels, + NATIVE_CHAR *Note, + NATIVE_CHAR *ModuleName, + UINT32 LineNumber); + +void +AcpiAmlDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Flags); + + +void +AcpiAmlDumpNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags); + + +/* + * amnames - interpreter/scanner name load/execute + */ + +NATIVE_CHAR * +AcpiAmlAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs); + +UINT32 +AcpiAmlGoodChar ( + UINT32 Character); + +ACPI_STATUS +AcpiAmlExecNameSegment ( + UINT8 **InAmlAddress, + NATIVE_CHAR *NameString); + +ACPI_STATUS +AcpiAmlGetNameString ( + OBJECT_TYPE_INTERNAL DataType, + UINT8 *InAmlAddress, + NATIVE_CHAR **OutNameString, + UINT32 *OutNameLength); + +ACPI_STATUS +AcpiAmlDoName ( + ACPI_OBJECT_TYPE DataType, + OPERATING_MODE LoadExecMode); + + +/* + * amstore - Object store support + */ + +ACPI_STATUS +AcpiAmlExecStore ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlStoreObjectToObject ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlStoreObjectToNode ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState); + + +/* + * amutils - interpreter/scanner utilities + */ + +void +AcpiAmlEnterInterpreter ( + void); + +void +AcpiAmlExitInterpreter ( + void); + +BOOLEAN +AcpiAmlValidateObjectType ( + ACPI_OBJECT_TYPE Type); + +BOOLEAN +AcpiAmlAcquireGlobalLock ( + UINT32 Rule); + +ACPI_STATUS +AcpiAmlReleaseGlobalLock ( + BOOLEAN Locked); + +UINT32 +AcpiAmlBufSeq ( + void); + +UINT32 +AcpiAmlDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base); + +ACPI_STATUS +AcpiAmlEisaIdToString ( + UINT32 NumericId, + NATIVE_CHAR *OutString); + +ACPI_STATUS +AcpiAmlUnsignedIntegerToString ( + ACPI_INTEGER Value, + NATIVE_CHAR *OutString); + +ACPI_STATUS +AcpiAmlBuildCopyInternalPackageObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); + + +/* + * amregion - default OpRegion handlers + */ + +ACPI_STATUS +AcpiAmlSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlSystemIoSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlPciConfigSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlEmbeddedControllerSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlSmBusSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + + +#endif /* __INTERP_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/aclinux.h b/sys/contrib/dev/acpica/Subsystem/Include/aclinux.h new file mode 100644 index 0000000..163c290 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/aclinux.h @@ -0,0 +1,150 @@ +/****************************************************************************** + * + * Name: aclinux.h - OS specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACLINUX_H__ +#define __ACLINUX_H__ + + +#define ACPI_OS_NAME "Linux" + +#include +#include +#include +#include +#include +#include + +/* Linux uses GCC */ + +#include "acgcc.h" + +#if 0 + +/* Use native Linux string library */ + +#define ACPI_USE_SYSTEM_CLIBRARY + +/* Special functions */ + +#define strtoul simple_strtoul + +/* Linux clib doesn't to strupr, but we do. */ +char * +strupr(char *str); + +#endif /* 0 */ + +#endif /* __ACLINUX_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/aclocal.h b/sys/contrib/dev/acpica/Subsystem/Include/aclocal.h new file mode 100644 index 0000000..0a3868b --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/aclocal.h @@ -0,0 +1,963 @@ +/****************************************************************************** + * + * Name: aclocal.h - Internal data types used across the ACPI subsystem + * $Revision: 82 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACLOCAL_H__ +#define __ACLOCAL_H__ + + +#define WAIT_FOREVER ((UINT32) -1) + +typedef void* ACPI_MUTEX; +typedef UINT32 ACPI_MUTEX_HANDLE; + + +/* Object descriptor types */ + +#define ACPI_CACHED_OBJECT 0x11 /* ORed in when object is cached */ +#define ACPI_DESC_TYPE_STATE 0x22 +#define ACPI_DESC_TYPE_WALK 0x44 +#define ACPI_DESC_TYPE_PARSER 0x66 +#define ACPI_DESC_TYPE_INTERNAL 0x88 +#define ACPI_DESC_TYPE_NAMED 0xAA + + +/***************************************************************************** + * + * Mutex typedefs and structs + * + ****************************************************************************/ + + +/* + * Predefined handles for the mutex objects used within the subsystem + * All mutex objects are automatically created by AcpiCmMutexInitialize. + * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also! + */ + +#define ACPI_MTX_HARDWARE 0 +#define ACPI_MTX_MEMORY 1 +#define ACPI_MTX_CACHES 2 +#define ACPI_MTX_TABLES 3 +#define ACPI_MTX_PARSER 4 +#define ACPI_MTX_DISPATCHER 5 +#define ACPI_MTX_INTERPRETER 6 +#define ACPI_MTX_EXECUTE 7 +#define ACPI_MTX_NAMESPACE 8 +#define ACPI_MTX_EVENTS 9 +#define ACPI_MTX_OP_REGIONS 10 +#define ACPI_MTX_DEBUG_CMD_READY 11 +#define ACPI_MTX_DEBUG_CMD_COMPLETE 12 + +#define MAX_MTX 12 +#define NUM_MTX MAX_MTX+1 + + +#ifdef ACPI_DEBUG +#ifdef DEFINE_ACPI_GLOBALS + +/* Names for the mutexes used in the subsystem */ + +static NATIVE_CHAR *AcpiGbl_MutexNames[] = +{ + "ACPI_MTX_Hardware", + "ACPI_MTX_Memory", + "ACPI_MTX_Caches", + "ACPI_MTX_Tables", + "ACPI_MTX_Parser", + "ACPI_MTX_Dispatcher", + "ACPI_MTX_Interpreter", + "ACPI_MTX_Execute", + "ACPI_MTX_Namespace", + "ACPI_MTX_Events", + "ACPI_MTX_OpRegions", + "ACPI_MTX_DebugCmdReady", + "ACPI_MTX_DebugCmdComplete" +}; + +#endif +#endif + + +/* Table for the global mutexes */ + +typedef struct AcpiMutexInfo +{ + ACPI_MUTEX Mutex; + UINT32 UseCount; + BOOLEAN Locked; + +} ACPI_MUTEX_INFO; + + +/* Lock flag parameter for various interfaces */ + +#define ACPI_MTX_DO_NOT_LOCK 0 +#define ACPI_MTX_LOCK 1 + + +typedef UINT16 ACPI_OWNER_ID; +#define OWNER_TYPE_TABLE 0x0 +#define OWNER_TYPE_METHOD 0x1 +#define FIRST_METHOD_ID 0x0000 +#define FIRST_TABLE_ID 0x8000 + +/* TBD: [Restructure] get rid of the need for this! */ + +#define TABLE_ID_DSDT (ACPI_OWNER_ID) 0x8000 + +/***************************************************************************** + * + * Namespace typedefs and structs + * + ****************************************************************************/ + + +/* Operational modes of the AML interpreter/scanner */ + +typedef enum +{ + IMODE_LOAD_PASS1 = 0x01, + IMODE_LOAD_PASS2 = 0x02, + IMODE_EXECUTE = 0x0E + +} OPERATING_MODE; + + +/* + * The Node describes a named object that appears in the AML + * An AcpiNode is used to store Nodes. + * + * DataType is used to differentiate between internal descriptors, and MUST + * be the first byte in this structure. + */ + +typedef struct acpi_node +{ + UINT8 DataType; + UINT8 Type; /* Type associated with this name */ + UINT16 OwnerId; + UINT32 Name; /* ACPI Name, always 4 chars per ACPI spec */ + + + void *Object; /* Pointer to attached ACPI object (optional) */ + struct acpi_node *Child; /* first child */ + struct acpi_node *Peer; /* Next peer*/ + UINT16 ReferenceCount; /* Current count of references and children */ + UINT8 Flags; + +} ACPI_NAMESPACE_NODE; + + +#define ENTRY_NOT_FOUND NULL + + +/* Node flags */ + +#define ANOBJ_AML_ATTACHMENT 0x1 +#define ANOBJ_END_OF_PEER_LIST 0x2 + + +/* + * ACPI Table Descriptor. One per ACPI table + */ +typedef struct AcpiTableDesc +{ + struct AcpiTableDesc *Prev; + struct AcpiTableDesc *Next; + struct AcpiTableDesc *InstalledDesc; + ACPI_TABLE_HEADER *Pointer; + void *BasePointer; + UINT8 *AmlPointer; + UINT32 AmlLength; + UINT32 Length; + UINT32 Count; + ACPI_OWNER_ID TableId; + UINT8 Type; + UINT8 Allocation; + BOOLEAN LoadedIntoNamespace; + +} ACPI_TABLE_DESC; + + +typedef struct +{ + NATIVE_CHAR *SearchFor; + ACPI_HANDLE *List; + UINT32 *Count; + +} FIND_CONTEXT; + + +typedef struct +{ + ACPI_NAMESPACE_NODE *Node; +} NS_SEARCH_DATA; + + +/* + * Predefined Namespace items + */ +#define ACPI_MAX_ADDRESS_SPACE 255 +#define ACPI_NUM_ADDRESS_SPACES 256 + + +typedef struct +{ + NATIVE_CHAR *Name; + ACPI_OBJECT_TYPE Type; + NATIVE_CHAR *Val; + +} PREDEFINED_NAMES; + + +/***************************************************************************** + * + * Event typedefs and structs + * + ****************************************************************************/ + + +/* Status bits. */ + +#define ACPI_STATUS_PMTIMER 0x0001 +#define ACPI_STATUS_GLOBAL 0x0020 +#define ACPI_STATUS_POWER_BUTTON 0x0100 +#define ACPI_STATUS_SLEEP_BUTTON 0x0200 +#define ACPI_STATUS_RTC_ALARM 0x0400 + +/* Enable bits. */ + +#define ACPI_ENABLE_PMTIMER 0x0001 +#define ACPI_ENABLE_GLOBAL 0x0020 +#define ACPI_ENABLE_POWER_BUTTON 0x0100 +#define ACPI_ENABLE_SLEEP_BUTTON 0x0200 +#define ACPI_ENABLE_RTC_ALARM 0x0400 + + +/* + * Entry in the AddressSpace (AKA Operation Region) table + */ + +typedef struct +{ + ADDRESS_SPACE_HANDLER Handler; + void *Context; + +} ACPI_ADDRESS_SPACE_INFO; + + +/* Values and addresses of the GPE registers (both banks) */ + +typedef struct +{ + UINT8 Status; /* Current value of status reg */ + UINT8 Enable; /* Current value of enable reg */ + UINT16 StatusAddr; /* Address of status reg */ + UINT16 EnableAddr; /* Address of enable reg */ + UINT8 GpeBase; /* Base GPE number */ + +} ACPI_GPE_REGISTERS; + + +#define ACPI_GPE_LEVEL_TRIGGERED 1 +#define ACPI_GPE_EDGE_TRIGGERED 2 + + +/* Information about each particular GPE level */ + +typedef struct +{ + UINT8 Type; /* Level or Edge */ + + ACPI_HANDLE MethodHandle; /* Method handle for direct (fast) execution */ + GPE_HANDLER Handler; /* Address of handler, if any */ + void *Context; /* Context to be passed to handler */ + +} ACPI_GPE_LEVEL_INFO; + + +/* Information about each particular fixed event */ + +typedef struct +{ + FIXED_EVENT_HANDLER Handler; /* Address of handler. */ + void *Context; /* Context to be passed to handler */ + +} ACPI_FIXED_EVENT_INFO; + + +/* Information used during field processing */ + +typedef struct +{ + UINT8 SkipField; + UINT8 FieldFlag; + UINT32 PkgLength; + +} ACPI_FIELD_INFO; + + +/***************************************************************************** + * + * Generic "state" object for stacks + * + ****************************************************************************/ + + +#define CONTROL_NORMAL 0xC0 +#define CONTROL_CONDITIONAL_EXECUTING 0xC1 +#define CONTROL_PREDICATE_EXECUTING 0xC2 +#define CONTROL_PREDICATE_FALSE 0xC3 +#define CONTROL_PREDICATE_TRUE 0xC4 + + +/* Forward declaration */ +struct acpi_walk_state; +struct acpi_parse_obj ; + + +#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ + UINT8 DataType; /* To differentiate various internal objs */\ + UINT8 Flags; \ + UINT16 Value; \ + UINT16 State; \ + UINT16 AcpiEval; \ + void *Next; \ + +typedef struct acpi_common_state +{ + ACPI_STATE_COMMON +} ACPI_COMMON_STATE; + + +/* + * Update state - used to traverse complex objects such as packages + */ +typedef struct acpi_update_state +{ + ACPI_STATE_COMMON + union acpi_operand_obj *Object; + +} ACPI_UPDATE_STATE; + +/* + * Control state - one per if/else and while constructs. + * Allows nesting of these constructs + */ +typedef struct acpi_control_state +{ + ACPI_STATE_COMMON + struct acpi_parse_obj *PredicateOp; + UINT8 *AmlPredicateStart; /* Start of if/while predicate */ + +} ACPI_CONTROL_STATE; + + +/* + * Scope state - current scope during namespace lookups + */ + +typedef struct acpi_scope_state +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + +} ACPI_SCOPE_STATE; + + +typedef struct acpi_pscope_state +{ + ACPI_STATE_COMMON + struct acpi_parse_obj *Op; /* current op being parsed */ + UINT8 *ArgEnd; /* current argument end */ + UINT8 *PkgEnd; /* current package end */ + UINT32 ArgList; /* next argument to parse */ + UINT32 ArgCount; /* Number of fixed arguments */ + +} ACPI_PSCOPE_STATE; + + +typedef union acpi_gen_state +{ + ACPI_COMMON_STATE Common; + ACPI_CONTROL_STATE Control; + ACPI_UPDATE_STATE Update; + ACPI_SCOPE_STATE Scope; + ACPI_PSCOPE_STATE ParseScope; + +} ACPI_GENERIC_STATE; + + +typedef +ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( + UINT16 Opcode, + struct acpi_parse_obj *Op, + struct acpi_walk_state *WalkState, + struct acpi_parse_obj **OutOp); + +typedef +ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( + struct acpi_walk_state *WalkState, + struct acpi_parse_obj *Op); + + +/***************************************************************************** + * + * Parser typedefs and structs + * + ****************************************************************************/ + + +#define ACPI_OP_CLASS_MASK 0x1F +#define ACPI_OP_ARGS_MASK 0x20 +#define ACPI_OP_TYPE_MASK 0xC0 + +#define ACPI_OP_TYPE_OPCODE 0x00 +#define ACPI_OP_TYPE_ASCII 0x40 +#define ACPI_OP_TYPE_PREFIX 0x80 +#define ACPI_OP_TYPE_UNKNOWN 0xC0 + +#define ACPI_GET_OP_CLASS(a) ((a)->Flags & ACPI_OP_CLASS_MASK) +#define ACPI_GET_OP_ARGS(a) ((a)->Flags & ACPI_OP_ARGS_MASK) +#define ACPI_GET_OP_TYPE(a) ((a)->Flags & ACPI_OP_TYPE_MASK) + + +/* + * AML opcode, name, and argument layout + */ +typedef struct acpi_opcode_info +{ + UINT8 Flags; /* Opcode type, HasArgs flag */ + UINT32 ParseArgs; /* Grammar/Parse time arguments */ + UINT32 RuntimeArgs; /* Interpret time arguments */ + + DEBUG_ONLY_MEMBERS ( + NATIVE_CHAR *Name) /* op name (debug only) */ + +} ACPI_OPCODE_INFO; + + +typedef union acpi_parse_val +{ + UINT32 Integer; /* integer constant */ + UINT32 Size; /* bytelist or field size */ + NATIVE_CHAR *String; /* NULL terminated string */ + UINT8 *Buffer; /* buffer or string */ + NATIVE_CHAR *Name; /* NULL terminated string */ + struct acpi_parse_obj *Arg; /* arguments and contained ops */ + +} ACPI_PARSE_VALUE; + + +#define ACPI_PARSE_COMMON \ + UINT8 DataType; /* To differentiate various internal objs */\ + UINT8 Flags; /* Type of Op */\ + UINT16 Opcode; /* AML opcode */\ + UINT32 AmlOffset; /* offset of declaration in AML */\ + struct acpi_parse_obj *Parent; /* parent op */\ + struct acpi_parse_obj *Next; /* next op */\ + DEBUG_ONLY_MEMBERS (\ + NATIVE_CHAR OpName[16]) /* op name (debug only) */\ + /* NON-DEBUG members below: */\ + ACPI_NAMESPACE_NODE *Node;/* for use by interpreter */\ + ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ + + +/* + * generic operation (eg. If, While, Store) + */ +typedef struct acpi_parse_obj +{ + ACPI_PARSE_COMMON +} ACPI_PARSE_OBJECT; + + +/* + * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions), + * and bytelists. + */ +typedef struct acpi_parse2_obj +{ + ACPI_PARSE_COMMON + UINT8 *Data; /* AML body or bytelist data */ + UINT32 Length; /* AML length */ + UINT32 Name; /* 4-byte name or zero if no name */ + +} ACPI_PARSE2_OBJECT; + + +/* + * Parse state - one state per parser invocation and each control + * method. + */ + +typedef struct acpi_parse_state +{ + UINT8 *AmlStart; /* first AML byte */ + UINT8 *Aml; /* next AML byte */ + UINT8 *AmlEnd; /* (last + 1) AML byte */ + UINT8 *PkgStart; /* current package begin */ + UINT8 *PkgEnd; /* current package end */ + ACPI_PARSE_OBJECT *StartOp; /* root of parse tree */ + struct acpi_node *StartNode; + ACPI_GENERIC_STATE *Scope; /* current scope */ + struct acpi_parse_state *Next; + +} ACPI_PARSE_STATE; + + +/***************************************************************************** + * + * Tree walking typedefs and structs + * + ****************************************************************************/ + + +/* + * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through + * the tree (for whatever reason), and for control method execution. + */ + +#define NEXT_OP_DOWNWARD 1 +#define NEXT_OP_UPWARD 2 + +#define WALK_NON_METHOD 0 +#define WALK_METHOD 1 +#define WALK_METHOD_RESTART 2 + +typedef struct acpi_walk_state +{ + UINT8 DataType; /* To differentiate various internal objs */\ + ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ + BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 NextOpInfo; /* Info about NextOp */ + UINT8 NumOperands; /* Stack pointer for Operands[] array */ + UINT8 NumResults; /* Stack pointer for Results[] array */ + UINT8 CurrentResult; /* */ + + struct acpi_walk_state *Next; /* Next WalkState in list */ + ACPI_PARSE_OBJECT *Origin; /* Start of walk */ + +/* TBD: Obsolete with removal of WALK procedure ? */ + ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ + ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ + + + ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ + ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ + ACPI_PARSE_STATE *ParserState; /* Current state of parser */ + UINT8 *AmlLastWhile; + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; + + union acpi_operand_obj *ReturnDesc; /* Return object, if any */ + union acpi_operand_obj *MethodDesc; /* Method descriptor if running a method */ + struct acpi_node *MethodNode; /* Method Node if running a method */ + ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ + struct acpi_node *MethodCallNode; /* Called method Node*/ + union acpi_operand_obj *Operands[OBJ_NUM_OPERANDS]; /* Operands passed to the interpreter */ + union acpi_operand_obj *Results[OBJ_NUM_OPERANDS]; /* Accumulated results */ + struct acpi_node Arguments[MTH_NUM_ARGS]; /* Control method arguments */ + struct acpi_node LocalVariables[MTH_NUM_LOCALS]; /* Control method locals */ + UINT32 ParseFlags; + UINT8 WalkType; + UINT8 ReturnUsed; + UINT32 PrevArgTypes; + + /* Debug support */ + + UINT32 MethodBreakpoint; + + +} ACPI_WALK_STATE; + + +/* + * Walk list - head of a tree of walk states. Multiple walk states are created when there + * are nested control methods executing. + */ +typedef struct acpi_walk_list +{ + + ACPI_WALK_STATE *WalkState; + +} ACPI_WALK_LIST; + + +/* Info used by AcpiPsInitObjects */ + +typedef struct acpi_init_walk_info +{ + UINT16 MethodCount; + UINT16 OpRegionCount; + UINT16 FieldCount; + UINT16 OpRegionInit; + UINT16 FieldInit; + UINT16 ObjectCount; + ACPI_TABLE_DESC *TableDesc; + +} ACPI_INIT_WALK_INFO; + + +/* Info used by TBD */ + +typedef struct acpi_device_walk_info +{ + UINT32 Flags; + UINT16 DeviceCount; + UINT16 Num_STA; + UINT16 Num_INI; + UINT16 Num_HID; + UINT16 Num_PCI; + ACPI_TABLE_DESC *TableDesc; + +} ACPI_DEVICE_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + UINT32 DebugLevel; + UINT32 OwnerId; + +} ACPI_WALK_INFO; + +typedef struct acpi_get_devices_info +{ + WALK_CALLBACK UserFunction; + void *Context; + NATIVE_CHAR *Hid; + +} ACPI_GET_DEVICES_INFO; + + +/***************************************************************************** + * + * Hardware and PNP + * + ****************************************************************************/ + + +/* PCI */ + +#define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_ROOT_HID_VALUE 0x030AD041 /* EISAID("PNP0A03") */ + + +/* Sleep states */ + +#define SLWA_DEBUG_LEVEL 4 +#define GTS_CALL 0 +#define GTS_WAKE 1 + +/* Cx States */ + +#define MAX_CX_STATE_LATENCY 0xFFFFFFFF +#define MAX_CX_STATES 4 + +/* + * The #define's and enum below establish an abstract way of identifying what + * register block and register is to be accessed. Do not change any of the + * values as they are used in switch statements and offset calculations. + */ + +#define REGISTER_BLOCK_MASK 0xFF00 +#define BIT_IN_REGISTER_MASK 0x00FF +#define PM1_EVT 0x0100 +#define PM1_CONTROL 0x0200 +#define PM2_CONTROL 0x0300 +#define PM_TIMER 0x0400 +#define PROCESSOR_BLOCK 0x0500 +#define GPE0_STS_BLOCK 0x0600 +#define GPE0_EN_BLOCK 0x0700 +#define GPE1_STS_BLOCK 0x0800 +#define GPE1_EN_BLOCK 0x0900 + +enum +{ + /* PM1 status register ids */ + + TMR_STS = (PM1_EVT | 0x01), + BM_STS, + GBL_STS, + PWRBTN_STS, + SLPBTN_STS, + RTC_STS, + WAK_STS, + + /* PM1 enable register ids */ + + TMR_EN, + /* need to skip 1 enable number since there's no bus master enable register */ + GBL_EN = (PM1_EVT | 0x0A), + PWRBTN_EN, + SLPBTN_EN, + RTC_EN, + + /* PM1 control register ids */ + + SCI_EN = (PM1_CONTROL | 0x01), + BM_RLD, + GBL_RLS, + SLP_TYPE_A, + SLP_TYPE_B, + SLP_EN, + + /* PM2 control register ids */ + + ARB_DIS = (PM2_CONTROL | 0x01), + + /* PM Timer register ids */ + + TMR_VAL = (PM_TIMER | 0x01), + + GPE0_STS = (GPE0_STS_BLOCK | 0x01), + GPE0_EN = (GPE0_EN_BLOCK | 0x01), + + GPE1_STS = (GPE1_STS_BLOCK | 0x01), + GPE1_EN = (GPE0_EN_BLOCK | 0x01), + + /* Last register value is one less than LAST_REG */ + + LAST_REG +}; + + +#define TMR_STS_MASK 0x0001 +#define BM_STS_MASK 0x0010 +#define GBL_STS_MASK 0x0020 +#define PWRBTN_STS_MASK 0x0100 +#define SLPBTN_STS_MASK 0x0200 +#define RTC_STS_MASK 0x0400 +#define WAK_STS_MASK 0x8000 + +#define ALL_FIXED_STS_BITS (TMR_STS_MASK | BM_STS_MASK | GBL_STS_MASK | PWRBTN_STS_MASK | \ + SLPBTN_STS_MASK | RTC_STS_MASK | WAK_STS_MASK) + +#define TMR_EN_MASK 0x0001 +#define GBL_EN_MASK 0x0020 +#define PWRBTN_EN_MASK 0x0100 +#define SLPBTN_EN_MASK 0x0200 +#define RTC_EN_MASK 0x0400 + +#define SCI_EN_MASK 0x0001 +#define BM_RLD_MASK 0x0002 +#define GBL_RLS_MASK 0x0004 +#define SLP_TYPE_X_MASK 0x1C00 +#define SLP_EN_MASK 0x2000 + +#define ARB_DIS_MASK 0x0001 + +#define GPE0_STS_MASK +#define GPE0_EN_MASK + +#define GPE1_STS_MASK +#define GPE1_EN_MASK + + +#define ACPI_READ 1 +#define ACPI_WRITE 2 + +#define LOW_BYTE 0x00FF +#define ONE_BYTE 0x08 + +#ifndef SET + #define SET 1 +#endif +#ifndef CLEAR + #define CLEAR 0 +#endif + + +/* Plug and play */ + +/* Pnp and ACPI data */ + +#define VERSION_NO 0x01 +#define LOGICAL_DEVICE_ID 0x02 +#define COMPATIBLE_DEVICE_ID 0x03 +#define IRQ_FORMAT 0x04 +#define DMA_FORMAT 0x05 +#define START_DEPENDENT_TAG 0x06 +#define END_DEPENDENT_TAG 0x07 +#define IO_PORT_DESCRIPTOR 0x08 +#define FIXED_LOCATION_IO_DESCRIPTOR 0x09 +#define RESERVED_TYPE0 0x0A +#define RESERVED_TYPE1 0x0B +#define RESERVED_TYPE2 0x0C +#define RESERVED_TYPE3 0x0D +#define SMALL_VENDOR_DEFINED 0x0E +#define END_TAG 0x0F + +/* Pnp and ACPI data */ + +#define MEMORY_RANGE_24 0x81 +#define ISA_MEMORY_RANGE 0x81 +#define LARGE_VENDOR_DEFINED 0x84 +#define EISA_MEMORY_RANGE 0x85 +#define MEMORY_RANGE_32 0x85 +#define FIXED_EISA_MEMORY_RANGE 0x86 +#define FIXED_MEMORY_RANGE_32 0x86 + +/* ACPI only data */ + +#define DWORD_ADDRESS_SPACE 0x87 +#define WORD_ADDRESS_SPACE 0x88 +#define EXTENDED_IRQ 0x89 + +/* MUST HAVES */ + +#define DEVICE_ID_LENGTH 0x09 + +typedef struct +{ + NATIVE_CHAR Buffer[DEVICE_ID_LENGTH]; + +} DEVICE_ID; + + +/***************************************************************************** + * + * Debug + * + ****************************************************************************/ + + +/* Entry for a memory allocation (debug only) */ + +#ifdef ACPI_DEBUG + +#define MEM_MALLOC 0 +#define MEM_CALLOC 1 +#define MAX_MODULE_NAME 16 + +typedef struct AllocationInfo +{ + struct AllocationInfo *Previous; + struct AllocationInfo *Next; + void *Address; + UINT32 Size; + UINT32 Component; + UINT32 Line; + NATIVE_CHAR Module[MAX_MODULE_NAME]; + UINT8 AllocType; + +} ALLOCATION_INFO; + +#endif + +#endif /* __ACLOCAL_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acmacros.h b/sys/contrib/dev/acpica/Subsystem/Include/acmacros.h new file mode 100644 index 0000000..e594b50 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acmacros.h @@ -0,0 +1,536 @@ +/****************************************************************************** + * + * Name: acmacros.h - C macros for the entire subsystem. + * $Revision: 50 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACMACROS_H__ +#define __ACMACROS_H__ + +/* + * Data manipulation macros + */ + +#ifndef LOWORD +#define LOWORD(l) ((UINT16)(NATIVE_UINT)(l)) +#endif + +#ifndef HIWORD +#define HIWORD(l) ((UINT16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) +#endif + +#ifndef LOBYTE +#define LOBYTE(l) ((UINT8)(UINT16)(l)) +#endif + +#ifndef HIBYTE +#define HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF)) +#endif + +#define BIT0(x) ((((x) & 0x01) > 0) ? 1 : 0) +#define BIT1(x) ((((x) & 0x02) > 0) ? 1 : 0) +#define BIT2(x) ((((x) & 0x04) > 0) ? 1 : 0) + +#define BIT3(x) ((((x) & 0x08) > 0) ? 1 : 0) +#define BIT4(x) ((((x) & 0x10) > 0) ? 1 : 0) +#define BIT5(x) ((((x) & 0x20) > 0) ? 1 : 0) +#define BIT6(x) ((((x) & 0x40) > 0) ? 1 : 0) +#define BIT7(x) ((((x) & 0x80) > 0) ? 1 : 0) + +#define LOW_BASE(w) ((UINT16) ((w) & 0x0000FFFF)) +#define MID_BASE(b) ((UINT8) (((b) & 0x00FF0000) >> 16)) +#define HI_BASE(b) ((UINT8) (((b) & 0xFF000000) >> 24)) +#define LOW_LIMIT(w) ((UINT16) ((w) & 0x0000FFFF)) +#define HI_LIMIT(b) ((UINT8) (((b) & 0x00FF0000) >> 16)) + + + /* + * Extract a byte of data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below + */ +#define GET8(addr) (*(UINT8*)(addr)) + + +/* + * Macros for moving data around to/from buffers that are possibly unaligned. + * If the hardware supports the transfer of unaligned data, just do the store. + * Otherwise, we have to move one byte at a time. + */ + +#ifdef _HW_ALIGNMENT_SUPPORT + +/* The hardware supports unaligned transfers, just do the move */ + +#define MOVE_UNALIGNED16_TO_16(d,s) *(UINT16*)(d) = *(UINT16*)(s) +#define MOVE_UNALIGNED32_TO_32(d,s) *(UINT32*)(d) = *(UINT32*)(s) +#define MOVE_UNALIGNED16_TO_32(d,s) *(UINT32*)(d) = *(UINT16*)(s) + +#else +/* + * The hardware does not support unaligned transfers. We must move the + * data one byte at a time. These macros work whether the source or + * the destination (or both) is/are unaligned. + */ + +#define MOVE_UNALIGNED16_TO_16(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ + ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];} + +#define MOVE_UNALIGNED32_TO_32(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ + ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];\ + ((UINT8 *)(d))[2] = ((UINT8 *)(s))[2];\ + ((UINT8 *)(d))[3] = ((UINT8 *)(s))[3];} + +#define MOVE_UNALIGNED16_TO_32(d,s) {(*(UINT32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);} + +#endif + + +/* + * Fast power-of-two math macros for non-optimized compilers + */ + +#define _DIV(value,PowerOf2) ((UINT32) ((value) >> (PowerOf2))) +#define _MUL(value,PowerOf2) ((UINT32) ((value) << (PowerOf2))) +#define _MOD(value,Divisor) ((UINT32) ((value) & ((Divisor) -1))) + +#define DIV_2(a) _DIV(a,1) +#define MUL_2(a) _MUL(a,1) +#define MOD_2(a) _MOD(a,2) + +#define DIV_4(a) _DIV(a,2) +#define MUL_4(a) _MUL(a,2) +#define MOD_4(a) _MOD(a,4) + +#define DIV_8(a) _DIV(a,3) +#define MUL_8(a) _MUL(a,3) +#define MOD_8(a) _MOD(a,8) + +#define DIV_16(a) _DIV(a,4) +#define MUL_16(a) _MUL(a,4) +#define MOD_16(a) _MOD(a,16) + + +/* + * Rounding macros (Power of two boundaries only) + */ + +#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) +#define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) + +#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4) +#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) + +#define ROUND_UP_TO_32BITS(a) ROUND_UP(a,4) +#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) + +#define ROUND_PTR_UP_TO_4(a,b) ((b *)(((NATIVE_UINT)(a) + 3) & ~3)) + +#ifdef DEBUG_ASSERT +#undef DEBUG_ASSERT +#endif + + +/* + * An ACPI_HANDLE (which is actually an ACPI_NAMESPACE_NODE *) can appear in some contexts, + * such as on apObjStack, where a pointer to an ACPI_OPERAND_OBJECT can also + * appear. This macro is used to distinguish them. + * + * The DataType field is the first field in both structures. + */ + +#define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMESPACE_NODE *)d)->DataType == t) + + +/* Macro to test the object type */ + +#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OPERAND_OBJECT *)d)->Common.Type == (UINT8)t) + +/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ + +#define IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0) + +/* + * Macro to check if a pointer is within an ACPI table. + * Parameter (a) is the pointer to check. Parameter (b) must be defined + * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, + * and ((UINT8 *)b+b->Length) points one byte past the end of the table. + */ + +#ifndef _IA16 +#define IS_IN_ACPI_TABLE(a,b) (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ + ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) + +#else +#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ + (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ + ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) +#endif + +/* + * Macros for the master AML opcode table + */ + +#ifdef ACPI_DEBUG +#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs,Name} +#else +#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs} +#endif + +#define ARG_TYPE_WIDTH 5 +#define ARG_1(x) ((UINT32)(x)) +#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) +#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH)) +#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH)) +#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH)) +#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH)) + +#define ARGI_LIST1(a) (ARG_1(a)) +#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) +#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) +#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) +#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) +#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) + +#define ARGP_LIST1(a) (ARG_1(a)) +#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) +#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) +#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) +#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) +#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) + +#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) +#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) + + +/* + * Reporting macros that are never compiled out + */ + +#define PARAM_LIST(pl) pl + +/* + * Error reporting. These versions add callers module and line#. Since + * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only + * use it in debug mode. + */ + +#ifdef ACPI_DEBUG + +#define REPORT_INFO(fp) {_ReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_ERROR(fp) {_ReportError(_THIS_MODULE,__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_WARNING(fp) {_ReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} + +#else + +#define REPORT_INFO(fp) {_ReportInfo("",__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_ERROR(fp) {_ReportError("",__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_WARNING(fp) {_ReportWarning("",__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} + +#endif + +/* Error reporting. These versions pass thru the module and line# */ + +#define _REPORT_INFO(a,b,c,fp) {_ReportInfo(a,b,c); \ + DebugPrintRaw PARAM_LIST(fp);} +#define _REPORT_ERROR(a,b,c,fp) {_ReportError(a,b,c); \ + DebugPrintRaw PARAM_LIST(fp);} +#define _REPORT_WARNING(a,b,c,fp) {_ReportWarning(a,b,c); \ + DebugPrintRaw PARAM_LIST(fp);} + +/* Buffer dump macros */ + +#define DUMP_BUFFER(a,b) AcpiCmDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) + +/* + * Debug macros that are conditionally compiled + */ + +#ifdef ACPI_DEBUG + +#define MODULE_NAME(name) static char *_THIS_MODULE = name; + +/* + * Function entry tracing. + * The first parameter should be the procedure name as a quoted string. This is declared + * as a local string ("_ProcName) so that it can be also used by the function exit macros below. + */ + +#define FUNCTION_TRACE(a) char * _ProcName = a;\ + FunctionTrace(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define FUNCTION_TRACE_PTR(a,b) char * _ProcName = a;\ + FunctionTracePtr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b) +#define FUNCTION_TRACE_U32(a,b) char * _ProcName = a;\ + FunctionTraceU32(_THIS_MODULE,__LINE__,_COMPONENT,a,(UINT32)b) +#define FUNCTION_TRACE_STR(a,b) char * _ProcName = a;\ + FunctionTraceStr(_THIS_MODULE,__LINE__,_COMPONENT,a,(NATIVE_CHAR *)b) +/* + * Function exit tracing. + * WARNING: These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro is very ugly and difficult to maintain. + * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros + * so that "_ProcName" is defined. + */ +#define return_VOID {FunctionExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName);return;} +#define return_ACPI_STATUS(s) {FunctionStatusExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,s);return(s);} +#define return_VALUE(s) {FunctionValueExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(NATIVE_UINT)s);return(s);} +#define return_PTR(s) {FunctionPtrExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(UINT8 *)s);return(s);} + + +/* Conditional execution */ + +#define DEBUG_EXEC(a) a; +#define NORMAL_EXEC(a) + +#define DEBUG_DEFINE(a) a; +#define DEBUG_ONLY_MEMBERS(a) a; + + +/* Stack and buffer dumping */ + +#define DUMP_STACK_ENTRY(a) AcpiAmlDumpOperand(a) +#define DUMP_OPERANDS(a,b,c,d,e) AcpiAmlDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) + + +#define DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b) +#define DUMP_TABLES(a,b) AcpiNsDumpTables(a,b) +#define DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d) +#define DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a) +#define BREAK_MSG(a) AcpiOsBreakpoint (a) + +/* + * Generate INT3 on ACPI_ERROR (Debug only!) + */ + +#define ERROR_BREAK +#ifdef ERROR_BREAK +#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) AcpiOsBreakpoint("Fatal error encountered\n") +#else +#define BREAK_ON_ERROR(lvl) +#endif + +/* + * Master debug print macros + * Print iff: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + * + */ + +#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)) + +#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + DebugPrintPrefix (_THIS_MODULE,__LINE__);\ + DebugPrintRaw PARAM_LIST(fp);\ + BREAK_ON_ERROR(lvl);} + +#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + DebugPrintRaw PARAM_LIST(fp);} + + +/* Assert macros */ + +#define ACPI_ASSERT(exp) if(!(exp)) \ + AcpiOsDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion") + +#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ + AcpiOsDbgAssert(#exp, __FILE__, __LINE__, msg) + + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ + +#define MODULE_NAME(name) +#define _THIS_MODULE "" + +#define DEBUG_EXEC(a) +#define NORMAL_EXEC(a) a; + +#define DEBUG_DEFINE(a) +#define DEBUG_ONLY_MEMBERS(a) +#define FUNCTION_TRACE(a) +#define FUNCTION_TRACE_PTR(a,b) +#define FUNCTION_TRACE_U32(a,b) +#define FUNCTION_TRACE_STR(a,b) +#define FUNCTION_EXIT +#define FUNCTION_STATUS_EXIT(s) +#define FUNCTION_VALUE_EXIT(s) +#define DUMP_STACK_ENTRY(a) +#define DUMP_OPERANDS(a,b,c,d,e) +#define DUMP_ENTRY(a,b) +#define DUMP_TABLES(a,b) +#define DUMP_PATHNAME(a,b,c,d) +#define DUMP_RESOURCE_LIST(a) +#define DEBUG_PRINT(l,f) +#define DEBUG_PRINT_RAW(l,f) +#define BREAK_MSG(a) + +#define return_VOID return +#define return_ACPI_STATUS(s) return(s) +#define return_VALUE(s) return(s) +#define return_PTR(s) return(s) + +#define ACPI_ASSERT(exp) +#define DEBUG_ASSERT(msg, exp) + +#endif + +/* + * Some code only gets executed when the debugger is built in. + * Note that this is entirely independent of whether the + * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not. + */ +#ifdef ENABLE_DEBUGGER +#define DEBUGGER_EXEC(a) a; +#else +#define DEBUGGER_EXEC(a) +#endif + + +/* + * For 16-bit code, we want to shrink some things even though + * we are using ACPI_DEBUG to get the debug output + */ +#ifdef _IA16 +#undef DEBUG_ONLY_MEMBERS +#define DEBUG_ONLY_MEMBERS(a) +#undef OP_INFO_ENTRY +#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs} +#endif + + +#ifdef ACPI_DEBUG + +/* + * 1) Set name to blanks + * 2) Copy the object name + */ + +#define ADD_OBJECT_NAME(a,b) MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\ + STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name)) + +#else + +#define ADD_OBJECT_NAME(a,b) + +#endif + +#endif /* ACMACROS_H */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acmsvc.h b/sys/contrib/dev/acpica/Subsystem/Include/acmsvc.h new file mode 100644 index 0000000..3ca121d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acmsvc.h @@ -0,0 +1,129 @@ +/****************************************************************************** + * + * Name: acmsvc.h - VC specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACMSVC_H__ +#define __ACMSVC_H__ + +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* warn C4100: unreferenced formal parameter */ +#pragma warning(disable:4100) + +/* warn C4127: conditional expression is constant */ +#pragma warning(disable:4127) + + +#endif /* __ACMSVC_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h b/sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h new file mode 100644 index 0000000..8681df7 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acnamesp.h @@ -0,0 +1,519 @@ +/****************************************************************************** + * + * Name: acnamesp.h - Namespace subcomponent prototypes and defines + * $Revision: 97 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNAMESP_H__ +#define __ACNAMESP_H__ + + +/* To search the entire name space, pass this as SearchBase */ + +#define NS_ALL ((ACPI_HANDLE)0) + +/* + * Elements of AcpiNsProperties are bit significant + * and should be one-to-one with values of ACPI_OBJECT_TYPE + */ +#define NSP_NORMAL 0 +#define NSP_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define NSP_LOCAL 2 /* suppress search of enclosing scopes */ + + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (UINT32) 0x2F202020 /* Root name is "/ " */ +#define ACPI_SYS_BUS_NAME (UINT32) 0x5F53425F /* Sys bus name is "_SB_" */ + +#define NS_ROOT_PATH "/" +#define NS_SYSTEM_BUS "_SB_" + + +/* Flags for AcpiNsLookup, AcpiNsSearchAndEnter */ + +#define NS_NO_UPSEARCH 0 +#define NS_SEARCH_PARENT 0x01 +#define NS_DONT_OPEN_SCOPE 0x02 +#define NS_NO_PEER_SEARCH 0x04 + +#define NS_WALK_UNLOCK TRUE +#define NS_WALK_NO_UNLOCK FALSE + + +ACPI_STATUS +AcpiNsLoadNamespace ( + void); + +ACPI_STATUS +AcpiNsInitializeObjects ( + void); + +ACPI_STATUS +AcpiNsInitializeDevices ( + UINT32 Flags); + + +/* Namespace init - nsxfinit */ + +ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + + +ACPI_STATUS +AcpiNsWalkNamespace ( + OBJECT_TYPE_INTERNAL Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + BOOLEAN UnlockBeforeCallback, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue); + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextObject ( + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + + +ACPI_STATUS +AcpiNsDeleteNamespaceByOwner ( + UINT16 TableId); + + +/* Namespace loading - nsload */ + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiNsParseTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Scope); + +ACPI_STATUS +AcpiNsLoadTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiNsLoadTableByType ( + ACPI_TABLE_TYPE TableType); + + +/* + * Top-level namespace access - nsaccess + */ + + +ACPI_STATUS +AcpiNsRootInitialize ( + void); + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + NATIVE_CHAR *Name, + OBJECT_TYPE_INTERNAL Type, + OPERATING_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **RetNode); + + +/* + * Named object allocation/deallocation - nsalloc + */ + + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 AcpiName); + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentHandle); + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *Parent); + + +/* + * Namespace modification - nsmodify + */ + +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle); + +ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle); + + +/* + * Namespace dump/print utilities - nsdump + */ + +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth); + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel); + +ACPI_STATUS +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + NATIVE_CHAR *Msg, + UINT32 Level, + UINT32 Component); + +void +AcpiNsDumpRootDevices ( + void); + +void +AcpiNsDumpObjects ( + OBJECT_TYPE_INTERNAL Type, + UINT32 MaxDepth, + UINT32 OwnderId, + ACPI_HANDLE StartHandle); + + +/* + * Namespace evaluation functions - nseval + */ + +ACPI_STATUS +AcpiNsEvaluateByHandle ( + ACPI_NAMESPACE_NODE *PrefixNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject); + +ACPI_STATUS +AcpiNsEvaluateByName ( + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject); + +ACPI_STATUS +AcpiNsEvaluateRelative ( + ACPI_NAMESPACE_NODE *PrefixNode, + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject); + +ACPI_STATUS +AcpiNsExecuteControlMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + +ACPI_STATUS +AcpiNsGetObjectValue ( + ACPI_NAMESPACE_NODE *ObjectNode, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + + +/* + * Parent/Child/Peer utility functions - nsfamily + */ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *NodeToSearch); + +BOOLEAN +AcpiNsExistDownstreamSibling ( + ACPI_NAMESPACE_NODE *ThisNode); + + +/* + * Scope manipulation - nsscope + */ + +UINT32 +AcpiNsOpensScope ( + OBJECT_TYPE_INTERNAL Type); + +NATIVE_CHAR * +AcpiNsGetTablePathname ( + ACPI_NAMESPACE_NODE *Node); + +NATIVE_CHAR * +AcpiNsNameOfCurrentScope ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE ObjHandle, + UINT32 *BufSize, + NATIVE_CHAR *UserBuffer); + +BOOLEAN +AcpiNsPatternMatch ( + ACPI_NAMESPACE_NODE *ObjNode, + NATIVE_CHAR *SearchFor); + +ACPI_STATUS +AcpiNsNameCompare ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiNsGetNode ( + NATIVE_CHAR *Pathname, + ACPI_NAMESPACE_NODE *InPrefixNode, + ACPI_NAMESPACE_NODE **OutNode); + +/* + * Object management for NTEs - nsobject + */ + +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + OBJECT_TYPE_INTERNAL Type); + + +void * +AcpiNsCompareValue ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc); + + +/* + * Namespace searching and entry - nssearch + */ + +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 EntryName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + OPERATING_MODE InterpreterMode, + OBJECT_TYPE_INTERNAL Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **RetNode); + +ACPI_STATUS +AcpiNsSearchNode ( + UINT32 EntryName, + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE **RetNode); + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 AcpiName); + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ + ACPI_NAMESPACE_NODE *Node, /* New Child*/ + OBJECT_TYPE_INTERNAL Type); + + +/* + * Utility functions - nsutils + */ + +BOOLEAN +AcpiNsValidRootPrefix ( + NATIVE_CHAR Prefix); + +BOOLEAN +AcpiNsValidPathSeparator ( + NATIVE_CHAR Sep); + +OBJECT_TYPE_INTERNAL +AcpiNsGetType ( + ACPI_HANDLE ObjHandle); + +void * +AcpiNsGetAttachedObject ( + ACPI_HANDLE ObjHandle); + +UINT32 +AcpiNsLocal ( + OBJECT_TYPE_INTERNAL Type); + +ACPI_STATUS +AcpiNsInternalizeName ( + NATIVE_CHAR *DottedName, + NATIVE_CHAR **ConvertedName); + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + NATIVE_CHAR *InternalName, + UINT32 *ConvertedNameLength, + NATIVE_CHAR **ConvertedName); + +ACPI_NAMESPACE_NODE * +AcpiNsConvertHandleToEntry ( + ACPI_HANDLE Handle); + +ACPI_HANDLE +AcpiNsConvertEntryToHandle( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsTerminate ( + void); + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentObject ( + ACPI_NAMESPACE_NODE *Node); + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidObject ( + ACPI_NAMESPACE_NODE *Node); + + +#endif /* __ACNAMESP_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acobject.h b/sys/contrib/dev/acpica/Subsystem/Include/acobject.h new file mode 100644 index 0000000..a3b9d40 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acobject.h @@ -0,0 +1,515 @@ + +/****************************************************************************** + * + * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) + * $Revision: 74 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACOBJECT_H +#define _ACOBJECT_H + + +/* + * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher + * to the interpreter, and to keep track of the various handlers such as + * address space handlers and notify handlers. The object is a constant + * size in order to allow them to be cached and reused. + * + * All variants of the ACPI_OPERAND_OBJECT are defined with the same + * sequence of field types, with fields that are not used in a particular + * variant being named "Reserved". This is not strictly necessary, but + * may in some circumstances simplify understanding if these structures + * need to be displayed in a debugger having limited (or no) support for + * union types. It also simplifies some debug code in DumpTable() which + * dumps multi-level values: fetching Buffer.Pointer suffices to pick up + * the value or next level for any of several types. + */ + +/****************************************************************************** + * + * Common Descriptors + * + *****************************************************************************/ + +/* + * Common area for all objects. + * + * DataType is used to differentiate between internal descriptors, and MUST + * be the first byte in this structure. + */ + + +#define ACPI_OBJECT_COMMON_HEADER /* 32-bits plus 8-bit flag */\ + UINT8 DataType; /* To differentiate various internal objs */\ + UINT8 Type; /* ACPI_OBJECT_TYPE */\ + UINT16 ReferenceCount; /* For object deletion management */\ + UINT8 Flags; \ + +/* Defines for flag byte above */ + +#define AOPOBJ_STATIC_ALLOCATION 0x1 +#define AOPOBJ_DATA_VALID 0x2 +#define AOPOBJ_INITIALIZED 0x4 + + +/* + * Common bitfield for the field objects + */ +#define ACPI_COMMON_FIELD_INFO /* Three 32-bit values plus 8*/\ + UINT8 Granularity;\ + UINT16 Length; \ + UINT32 Offset; /* Byte offset within containing object */\ + UINT8 BitOffset; /* Bit offset within min read/write data unit */\ + UINT8 Access; /* AccessType */\ + UINT8 LockRule;\ + UINT8 UpdateRule;\ + UINT8 AccessAttribute; + + +/****************************************************************************** + * + * Individual Object Descriptors + * + *****************************************************************************/ + + +typedef struct /* COMMON */ +{ + ACPI_OBJECT_COMMON_HEADER + +} ACPI_OBJECT_COMMON; + + +typedef struct /* CACHE_LIST */ +{ + ACPI_OBJECT_COMMON_HEADER + union acpi_operand_obj *Next; /* Link for object cache and internal lists*/ + +} ACPI_OBJECT_CACHE_LIST; + + +typedef struct /* NUMBER - has value */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_INTEGER Value; + +} ACPI_OBJECT_NUMBER; + + +typedef struct /* STRING - has length and pointer */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 Length; + NATIVE_CHAR *Pointer; /* String value in AML stream or in allocated space */ + +} ACPI_OBJECT_STRING; + + +typedef struct /* BUFFER - has length, sequence, and pointer */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 Length; + UINT32 Sequence; /* Sequential count of buffers created */ + + UINT8 *Pointer; /* points to the buffer in allocated space */ + +} ACPI_OBJECT_BUFFER; + + +typedef struct /* PACKAGE - has count, elements, next element */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 Count; /* # of elements in package */ + + union acpi_operand_obj **Elements; /* Array of pointers to AcpiObjects */ + union acpi_operand_obj **NextElement; /* used only while initializing */ + +} ACPI_OBJECT_PACKAGE; + + +typedef struct /* FIELD UNIT */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + + union acpi_operand_obj *Extra; /* Pointer to executable AML (in field definition) */ + ACPI_NAMESPACE_NODE *Node; /* containing object */ + union acpi_operand_obj *Container; /* Containing object (Buffer) */ + +} ACPI_OBJECT_FIELD_UNIT; + + +typedef struct /* DEVICE - has handle and notification handler/context */ +{ + ACPI_OBJECT_COMMON_HEADER + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + union acpi_operand_obj *AddrHandler; /* Handler for Address space */ + +} ACPI_OBJECT_DEVICE; + + +typedef struct /* EVENT */ +{ + ACPI_OBJECT_COMMON_HEADER + + void *Semaphore; + +} ACPI_OBJECT_EVENT; + + +#define INFINITE_CONCURRENCY 0xFF + +typedef struct /* METHOD */ +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 MethodFlags; + UINT8 ParamCount; + + UINT32 PcodeLength; + + void *Semaphore; + UINT8 *Pcode; + + UINT8 Concurrency; + UINT8 ThreadCount; + ACPI_OWNER_ID OwningId; + +} ACPI_OBJECT_METHOD; + + +typedef struct /* MUTEX */ +{ + ACPI_OBJECT_COMMON_HEADER + UINT16 SyncLevel; + + void *Semaphore; + +} ACPI_OBJECT_MUTEX; + + +typedef struct /* REGION */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT8 SpaceId; + UINT32 Length; + ACPI_INTEGER Address; + union acpi_operand_obj *Extra; /* Pointer to executable AML (in region definition) */ + + union acpi_operand_obj *AddrHandler; /* Handler for system notifies */ + ACPI_NAMESPACE_NODE *Node; /* containing object */ + union acpi_operand_obj *Next; + +} ACPI_OBJECT_REGION; + + +typedef struct /* POWER RESOURCE - has Handle and notification handler/context*/ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 SystemLevel; + UINT32 ResourceOrder; + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + +} ACPI_OBJECT_POWER_RESOURCE; + + +typedef struct /* PROCESSOR - has Handle and notification handler/context*/ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 ProcId; + UINT32 Length; + ACPI_IO_ADDRESS Address; + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + union acpi_operand_obj *AddrHandler; /* Handler for Address space */ + +} ACPI_OBJECT_PROCESSOR; + + +typedef struct /* THERMAL ZONE - has Handle and Handler/Context */ +{ + ACPI_OBJECT_COMMON_HEADER + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + union acpi_operand_obj *AddrHandler; /* Handler for Address space */ + +} ACPI_OBJECT_THERMAL_ZONE; + + +/* + * Internal types + */ + + +typedef struct /* FIELD */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + + union acpi_operand_obj *Container; /* Containing object */ + +} ACPI_OBJECT_FIELD; + + +typedef struct /* BANK FIELD */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + UINT32 Value; /* Value to store into BankSelect */ + + ACPI_HANDLE BankSelect; /* Bank select register */ + union acpi_operand_obj *Container; /* Containing object */ + +} ACPI_OBJECT_BANK_FIELD; + + +typedef struct /* INDEX FIELD */ +{ + /* + * No container pointer needed since the index and data register definitions + * will define how to access the respective registers + */ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + UINT32 Value; /* Value to store into Index register */ + + ACPI_HANDLE Index; /* Index register */ + ACPI_HANDLE Data; /* Data register */ + +} ACPI_OBJECT_INDEX_FIELD; + + +typedef struct /* NOTIFY HANDLER */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + NOTIFY_HANDLER Handler; + void *Context; + +} ACPI_OBJECT_NOTIFY_HANDLER; + + +/* Flags for address handler */ + +#define ADDR_HANDLER_DEFAULT_INSTALLED 0x1 + + +typedef struct /* ADDRESS HANDLER */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT8 SpaceId; + UINT16 Hflags; + ADDRESS_SPACE_HANDLER Handler; + + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + void *Context; + ADDRESS_SPACE_SETUP Setup; + union acpi_operand_obj *RegionList; /* regions using this handler */ + union acpi_operand_obj *Next; + +} ACPI_OBJECT_ADDR_HANDLER; + + +/* + * The Reference object type is used for these opcodes: + * Arg[0-6], Local[0-7], IndexOp, NameOp, ZeroOp, OneOp, OnesOp, DebugOp + */ + +typedef struct /* Reference - Local object type */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT8 TargetType; /* Used for IndexOp */ + UINT16 OpCode; + UINT32 Offset; /* Used for ArgOp, LocalOp, and IndexOp */ + + void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *Node; + union acpi_operand_obj **Where; + +} ACPI_OBJECT_REFERENCE; + + +/* + * Extra object is used as additional storage for types that + * have AML code in their declarations (TermArgs) that must be + * evaluated at run time. + * + * Currently: Region and FieldUnit types + */ + +typedef struct /* EXTRA */ +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 ByteFill1; + UINT16 WordFill1; + UINT32 PcodeLength; + UINT8 *Pcode; + ACPI_NAMESPACE_NODE *Method_REG; /* _REG method for this region (if any) */ + void *RegionContext; /* Region-specific data */ + +} ACPI_OBJECT_EXTRA; + + +/****************************************************************************** + * + * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above + * + *****************************************************************************/ + +typedef union acpi_operand_obj +{ + ACPI_OBJECT_COMMON Common; + ACPI_OBJECT_CACHE_LIST Cache; + ACPI_OBJECT_NUMBER Number; + ACPI_OBJECT_STRING String; + ACPI_OBJECT_BUFFER Buffer; + ACPI_OBJECT_PACKAGE Package; + ACPI_OBJECT_FIELD_UNIT FieldUnit; + ACPI_OBJECT_DEVICE Device; + ACPI_OBJECT_EVENT Event; + ACPI_OBJECT_METHOD Method; + ACPI_OBJECT_MUTEX Mutex; + ACPI_OBJECT_REGION Region; + ACPI_OBJECT_POWER_RESOURCE PowerResource; + ACPI_OBJECT_PROCESSOR Processor; + ACPI_OBJECT_THERMAL_ZONE ThermalZone; + ACPI_OBJECT_FIELD Field; + ACPI_OBJECT_BANK_FIELD BankField; + ACPI_OBJECT_INDEX_FIELD IndexField; + ACPI_OBJECT_REFERENCE Reference; + ACPI_OBJECT_NOTIFY_HANDLER NotifyHandler; + ACPI_OBJECT_ADDR_HANDLER AddrHandler; + ACPI_OBJECT_EXTRA Extra; + +} ACPI_OPERAND_OBJECT; + +#endif /* _ACOBJECT_H */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acoutput.h b/sys/contrib/dev/acpica/Subsystem/Include/acoutput.h new file mode 100644 index 0000000..93da0e8 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acoutput.h @@ -0,0 +1,217 @@ +/****************************************************************************** + * + * Name: acoutput.h -- debug output + * $Revision: 66 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOUTPUT_H__ +#define __ACOUTPUT_H__ + +/* + * Debug levels and component IDs. These are used to control the + * granularity of the output of the DEBUG_PRINT macro -- on a per- + * component basis and a per-exception-type basis. + */ + +/* Component IDs -- used in the global "DebugLayer" */ + +#define GLOBAL 0x00000001 +#define COMMON 0x00000002 +#define PARSER 0x00000004 +#define DISPATCHER 0x00000008 +#define INTERPRETER 0x00000010 +#define NAMESPACE 0x00000020 +#define RESOURCE_MANAGER 0x00000040 +#define TABLE_MANAGER 0x00000080 +#define EVENT_HANDLING 0x00000100 +#define HARDWARE 0x00000200 +#define MISCELLANEOUS 0x00000400 +#define OS_DEPENDENT 0x00000800 + +#define BUS_MANAGER 0x00001000 + +#define PROCESSOR_CONTROL 0x00002000 +#define SYSTEM_CONTROL 0x00004000 +#define THERMAL_CONTROL 0x00008000 +#define POWER_CONTROL 0x00010000 + +#define EMBEDDED_CONTROLLER 0x00020000 +#define BATTERY 0x00040000 + +#define DEBUGGER 0x00100000 +#define ALL_COMPONENTS 0x001FFFFF + +#define COMPONENT_DEFAULT (ALL_COMPONENTS) + + +/* Exception level -- used in the global "DebugLevel" */ + +#define ACPI_OK 0x00000001 +#define ACPI_INFO 0x00000002 +#define ACPI_WARN 0x00000004 +#define ACPI_ERROR 0x00000008 +#define ACPI_FATAL 0x00000010 +#define ACPI_DEBUG_OBJECT 0x00000020 +#define ACPI_ALL 0x0000003F + + +/* Trace level -- also used in the global "DebugLevel" */ + +#define TRACE_PARSE 0x00000100 +#define TRACE_DISPATCH 0x00000200 +#define TRACE_LOAD 0x00000400 +#define TRACE_EXEC 0x00000800 +#define TRACE_NAMES 0x00001000 +#define TRACE_OPREGION 0x00002000 +#define TRACE_BFIELD 0x00004000 +#define TRACE_TRASH 0x00008000 +#define TRACE_TABLES 0x00010000 +#define TRACE_FUNCTIONS 0x00020000 +#define TRACE_VALUES 0x00040000 +#define TRACE_OBJECTS 0x00080000 +#define TRACE_ALLOCATIONS 0x00100000 +#define TRACE_RESOURCES 0x00200000 +#define TRACE_IO 0x00400000 +#define TRACE_INTERRUPTS 0x00800000 +#define TRACE_USER_REQUESTS 0x01000000 +#define TRACE_PACKAGE 0x02000000 +#define TRACE_MUTEX 0x04000000 + +#define TRACE_ALL 0x0FFFFF00 + + +/* Exceptionally verbose output -- also used in the global "DebugLevel" */ + +#define VERBOSE_AML_DISASSEMBLE 0x10000000 +#define VERBOSE_INFO 0x20000000 +#define VERBOSE_TABLES 0x40000000 +#define VERBOSE_EVENTS 0x80000000 + +#define VERBOSE_ALL 0xF0000000 + + +/* Defaults for DebugLevel, debug and normal */ + +#define DEBUG_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) +#define NORMAL_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) +#define DEBUG_ALL (VERBOSE_AML_DISASSEMBLE | TRACE_ALL | ACPI_ALL) + +/* Misc defines */ + +#define HEX 0x01 +#define ASCII 0x02 +#define FULL_ADDRESS 0x04 +#define CHARS_PER_LINE 16 /* used in DumpBuf function */ + + +#endif /* __ACOUTPUT_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acparser.h b/sys/contrib/dev/acpica/Subsystem/Include/acparser.h new file mode 100644 index 0000000..876c1de --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acparser.h @@ -0,0 +1,437 @@ +/****************************************************************************** + * + * Module Name: acparser.h - AML Parser subcomponent prototypes and defines + * $Revision: 47 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACPARSER_H__ +#define __ACPARSER_H__ + + +#define OP_HAS_RETURN_VALUE 1 + +/* variable # arguments */ + +#define ACPI_VAR_ARGS ACPI_UINT32_MAX + +/* maximum virtual address */ + +#define ACPI_MAX_AML ((UINT8 *)(~0UL)) + + +#define ACPI_PARSE_DELETE_TREE 0x0001 +#define ACPI_PARSE_NO_TREE_DELETE 0x0000 +#define ACPI_PARSE_TREE_MASK 0x0001 + +#define ACPI_PARSE_LOAD_PASS1 0x0010 +#define ACPI_PARSE_LOAD_PASS2 0x0020 +#define ACPI_PARSE_EXECUTE 0x0030 +#define ACPI_PARSE_MODE_MASK 0x0030 + +/* psapi - Parser external interfaces */ + +ACPI_STATUS +AcpiPsxLoadTable ( + UINT8 *PcodeAddr, + UINT32 PcodeLength); + +ACPI_STATUS +AcpiPsxExecute ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + + +BOOLEAN +AcpiPsIsNamespaceObjectOp ( + UINT16 Opcode); +BOOLEAN +AcpiPsIsNamespaceOp ( + UINT16 Opcode); + + +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* psargs - Parse AML opcode arguments */ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState); + +UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState); + +NATIVE_CHAR * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, /* type of argument */ + ACPI_PARSE_OBJECT *Arg); /* (OUT) argument data */ + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall); + +ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState); + +ACPI_PARSE_OBJECT * +AcpiPsGetNextArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + UINT32 *ArgCount); + + +/* psopcode - AML Opcode information */ + +ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode); + +NATIVE_CHAR * +AcpiPsGetOpcodeName ( + UINT16 Opcode); + + +/* psparse - top level parsing routines */ + +ACPI_STATUS +AcpiPsFindObject ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *root); + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_PARSE_OBJECT *StartScope, + UINT8 *Aml, + UINT32 AmlSize, + UINT32 ParseFlags, + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsParseTable ( + UINT8 *aml, + UINT32 amlSize, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback, + ACPI_PARSE_OBJECT **RootObject); + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *state); + + +/* psscope - Scope stack management routines */ + + +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Root); + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *state); + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount); + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount); + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *state); + + +/* pstree - parse tree manipulation routines */ + +void +AcpiPsAppendArg( + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_OBJECT *arg); + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR *Path, + UINT16 Opcode, + UINT32 Create); + +ACPI_PARSE_OBJECT * +AcpiPsGetArg( + ACPI_PARSE_OBJECT *op, + UINT32 argn); + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *op); + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op); + + +/* pswalk - parse tree walk routines */ + +ACPI_STATUS +AcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback); + + +/* psutils - parser utilities */ + + +ACPI_PARSE_STATE * +AcpiPsCreateState ( + UINT8 *Aml, + UINT32 AmlSize); + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *op, + UINT16 opcode); + +ACPI_PARSE_OBJECT * +AcpiPsAllocOp ( + UINT16 opcode); + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiPsDeleteParseCache ( + void); + +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c); + +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c); + +BOOLEAN +AcpiPsIsNamedOp ( + UINT16 opcode); + +BOOLEAN +AcpiPsIsNodeOp ( + UINT16 opcode); + +BOOLEAN +AcpiPsIsDeferredOp ( + UINT16 opcode); + +BOOLEAN +AcpiPsIsBytelistOp( + UINT16 opcode); + +BOOLEAN +AcpiPsIsFieldOp( + UINT16 opcode); + +BOOLEAN +AcpiPsIsCreateFieldOp ( + UINT16 Opcode); + +ACPI_PARSE2_OBJECT* +AcpiPsToExtendedOp( + ACPI_PARSE_OBJECT *op); + +UINT32 +AcpiPsGetName( + ACPI_PARSE_OBJECT *op); + +void +AcpiPsSetName( + ACPI_PARSE_OBJECT *op, + UINT32 name); + + +/* psdump - display parser tree */ + +UINT32 +AcpiPsSprintPath ( + NATIVE_CHAR *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +UINT32 +AcpiPsSprintOp ( + NATIVE_CHAR *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +void +AcpiPsShow ( + ACPI_PARSE_OBJECT *op); + + +#endif /* __ACPARSER_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acpi.h b/sys/contrib/dev/acpica/Subsystem/Include/acpi.h new file mode 100644 index 0000000..e8591d4 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acpi.h @@ -0,0 +1,141 @@ +/****************************************************************************** + * + * Name: acpi.h - Master include file, Publics and external data. + * $Revision: 48 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPI_H__ +#define __ACPI_H__ + +/* + * Common includes for all ACPI driver files + * We put them here because we don't want to duplicate them + * in the rest of the source code again and again. + */ +#include "acconfig.h" /* Configuration constants */ +#include "acenv.h" /* Target environment specific items */ +#include "actypes.h" /* Fundamental data types */ +#include "acexcep.h" /* Local exception codes */ +#include "acmacros.h" /* C macros */ +#include "actbl.h" /* Acpi table definitions */ +#include "aclocal.h" /* Internal data types */ +#include "acoutput.h" /* Error output and Debug macros */ +#include "acpiosxf.h" /* Interfaces to the Acpi-to-OS layer*/ +#include "acpixf.h" /* Acpi core external interfaces */ +#include "acobject.h" /* Acpi internal object */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "accommon.h" /* Common (global) interfaces */ + + +#endif /* __ACPI_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acpiosxf.h b/sys/contrib/dev/acpica/Subsystem/Include/acpiosxf.h new file mode 100644 index 0000000..c371c49 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acpiosxf.h @@ -0,0 +1,419 @@ + +/****************************************************************************** + * + * Name: acpiosd.h - All interfaces to the OS-dependent layer. These + * interfaces must be implemented by the OS-dependent + * front-end to the ACPI subsystem. + * + *****************************************************************************/ + + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPIOSD_H__ +#define __ACPIOSD_H__ + +#include "acenv.h" +#include "actypes.h" + + +/* Priorities for AcpiOsQueueForExecution */ + +#define OSD_PRIORITY_HIGH 1 +#define OSD_PRIORITY_MED 2 +#define OSD_PRIORITY_LO 3 +#define OSD_PRIORITY_GPE OSD_PRIORITY_HIGH + +#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) +#define ACPI_MUTEX_SEM 1 + + +/* + * Types specific to the OS-dependent layer interfaces + */ + +typedef +UINT32 (*OSD_HANDLER) ( + void *Context); + +typedef +void (*OSD_EXECUTION_CALLBACK) ( + void *Context); + + +/* + * Initialization and shutdown primitives (Optional) + */ + +ACPI_STATUS +AcpiOsInitialize ( + void); + +ACPI_STATUS +AcpiOsTerminate ( + void); + +/* + * Synchronization primitives + */ + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle); + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_HANDLE Handle); + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units, + UINT32 Timeout); + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units); + +/* + * Memory allocation and mapping + */ + +void * +AcpiOsAllocate ( + UINT32 Size); + +void * +AcpiOsCallocate ( + UINT32 Size); + +void +AcpiOsFree ( + void * Memory); + +ACPI_STATUS +AcpiOsMapMemory ( + void *PhysicalAddress, + UINT32 Length, + void **LogicalAddress); + +void +AcpiOsUnmapMemory ( + void *LogicalAddress, + UINT32 Length); + + +/* + * Interrupt handlers + */ + +ACPI_STATUS +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + OSD_HANDLER ServiceRoutine, + void *Context); + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + OSD_HANDLER ServiceRoutine); + + +/* + * Scheduling + */ + +ACPI_STATUS +AcpiOsQueueForExecution ( + UINT32 Priority, + OSD_EXECUTION_CALLBACK Function, + void *Context); + +void +AcpiOsSleep ( + UINT32 Seconds, + UINT32 Milliseconds); + +void +AcpiOsSleepUsec ( + UINT32 Microseconds); + +/* + * Platform/Hardware independent I/O interfaces + */ + +UINT8 +AcpiOsIn8 ( + ACPI_IO_ADDRESS InPort); + + +UINT16 +AcpiOsIn16 ( + ACPI_IO_ADDRESS InPort); + +UINT32 +AcpiOsIn32 ( + ACPI_IO_ADDRESS InPort); + +void +AcpiOsOut8 ( + ACPI_IO_ADDRESS OutPort, + UINT8 Value); + +void +AcpiOsOut16 ( + ACPI_IO_ADDRESS OutPort, + UINT16 Value); + +void +AcpiOsOut32 ( + ACPI_IO_ADDRESS OutPort, + UINT32 Value); + +/* + * Platform/Hardware independent physical memory interfaces + */ + +UINT8 +AcpiOsMemIn8 ( + ACPI_MEM_ADDRESS InAddr); + + +UINT16 +AcpiOsMemIn16 ( + ACPI_MEM_ADDRESS InAddr); + +UINT32 +AcpiOsMemIn32 ( + ACPI_MEM_ADDRESS InAddr); + +void +AcpiOsMemOut8 ( + ACPI_MEM_ADDRESS OutAddr, + UINT8 Value); + +void +AcpiOsMemOut16 ( + ACPI_MEM_ADDRESS OutAddr, + UINT16 Value); + +void +AcpiOsMemOut32 ( + ACPI_MEM_ADDRESS OutAddr, + UINT32 Value); + + +/* + * Standard access to PCI configuration space + */ + +ACPI_STATUS +AcpiOsReadPciCfgByte ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT8 *Value); + +ACPI_STATUS +AcpiOsReadPciCfgWord ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT16 *Value); + +ACPI_STATUS +AcpiOsReadPciCfgDword ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT32 *Value); + +ACPI_STATUS +AcpiOsWritePciCfgByte ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT8 Value); + +ACPI_STATUS +AcpiOsWritePciCfgWord ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT16 Value); + + +ACPI_STATUS +AcpiOsWritePciCfgDword ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT32 Value); + + +/* + * Miscellaneous + */ + +ACPI_STATUS +AcpiOsBreakpoint ( + NATIVE_CHAR *Message); + +BOOLEAN +AcpiOsReadable ( + void *Pointer, + UINT32 Length); + + +BOOLEAN +AcpiOsWritable ( + void *Pointer, + UINT32 Length); + + +/* + * Debug print routines + */ + +INT32 +AcpiOsPrintf ( + const NATIVE_CHAR *Format, + ...); + +INT32 +AcpiOsVprintf ( + const NATIVE_CHAR *Format, + va_list Args); + +/* + * Debug input + */ + +UINT32 +AcpiOsGetLine ( + NATIVE_CHAR *Buffer); + + +/* + * Debug + */ + +void +AcpiOsDbgAssert( + void *FailedAssertion, + void *FileName, + UINT32 LineNumber, + NATIVE_CHAR *Message); + + +#endif /* __ACPIOSD_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acpixf.h b/sys/contrib/dev/acpica/Subsystem/Include/acpixf.h new file mode 100644 index 0000000..b1c52c8 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acpixf.h @@ -0,0 +1,410 @@ + +/****************************************************************************** + * + * Name: acxface.h - External interfaces to the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACXFACE_H__ +#define __ACXFACE_H__ + +#include "actypes.h" +#include "actbl.h" + +/* + * Global interfaces + */ + +ACPI_STATUS +AcpiInitializeSubsystem ( + void); + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags); + +ACPI_STATUS +AcpiTerminate ( + void); + +ACPI_STATUS +AcpiEnable ( + void); + +ACPI_STATUS +AcpiDisable ( + void); + +ACPI_STATUS +AcpiGetSystemInfo( + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiFormatException ( + ACPI_STATUS Exception, + ACPI_BUFFER *OutBuffer); + + +/* + * ACPI table manipulation interfaces + */ + +ACPI_STATUS +AcpiFindRootPointer ( + void **RsdpPhysicalAddress); + +ACPI_STATUS +AcpiLoadTables ( + void *RsdpPhysicalAddress); + +ACPI_STATUS +AcpiLoadTable ( + ACPI_TABLE_HEADER *TablePtr); + +ACPI_STATUS +AcpiUnloadTable ( + ACPI_TABLE_TYPE TableType); + +ACPI_STATUS +AcpiGetTableHeader ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader); + +ACPI_STATUS +AcpiGetTable ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_BUFFER *RetBuffer); + + +/* + * Namespace and name interfaces + */ + +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + WALK_CALLBACK UserFunction, + void *Context, + void * *ReturnValue); + + +ACPI_STATUS +AcpiGetDevices ( + NATIVE_CHAR *HID, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *RetPathPtr); + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle); + + +/* + * Object manipulation and enumeration + */ + +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ParameterObjects, + ACPI_BUFFER *ReturnObjectBuffer); + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Device, + ACPI_DEVICE_INFO *Info); + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *OutHandle); + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Object, + ACPI_OBJECT_TYPE *OutType); + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Object, + ACPI_HANDLE *OutHandle); + + +/* + * AcpiEvent handler interfaces + */ + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 AcpiEvent, + FIXED_EVENT_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 AcpiEvent, + FIXED_EVENT_HANDLER Handler); + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler); + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_SPACE_HANDLER Handler, + ADDRESS_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_SPACE_HANDLER Handler); + +ACPI_STATUS +AcpiInstallGpeHandler ( + UINT32 GpeNumber, + UINT32 Type, + GPE_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiAcquireGlobalLock ( + void); + +ACPI_STATUS +AcpiReleaseGlobalLock ( + void); + +ACPI_STATUS +AcpiRemoveGpeHandler ( + UINT32 GpeNumber, + GPE_HANDLER Handler); + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 AcpiEvent, + UINT32 Type); + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 AcpiEvent, + UINT32 Type); + +ACPI_STATUS +AcpiClearEvent ( + UINT32 AcpiEvent, + UINT32 Type); + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 AcpiEvent, + UINT32 Type, + ACPI_EVENT_STATUS *EventStatus); + +/* + * Resource interfaces + */ + +ACPI_STATUS +AcpiGetCurrentResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetPossibleResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer); + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE BusDeviceHandle, + ACPI_BUFFER *RetBuffer); + + +/* + * Hardware (ACPI device) interfaces + */ + +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + void *PhysicalAddress); + +ACPI_STATUS +AcpiGetFirmwareWakingVector ( + void **PhysicalAddress); + +ACPI_STATUS +AcpiGetProcessorThrottlingInfo ( + ACPI_HANDLE ProcessorHandle, + ACPI_BUFFER *UserBuffer); + +ACPI_STATUS +AcpiSetProcessorThrottlingState ( + ACPI_HANDLE ProcessorHandle, + UINT32 ThrottleState); + +ACPI_STATUS +AcpiGetProcessorThrottlingState ( + ACPI_HANDLE ProcessorHandle, + UINT32 *ThrottleState); + +ACPI_STATUS +AcpiGetProcessorCxInfo ( + ACPI_HANDLE ProcessorHandle, + ACPI_BUFFER *UserBuffer); + +ACPI_STATUS +AcpiSetProcessorSleepState ( + ACPI_HANDLE ProcessorHandle, + UINT32 CxState); + +ACPI_STATUS +AcpiProcessorSleep ( + ACPI_HANDLE ProcessorHandle, + UINT32 *PmTimerTicks); + + +#endif /* __ACXFACE_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acresrc.h b/sys/contrib/dev/acpica/Subsystem/Include/acresrc.h new file mode 100644 index 0000000..c5d8add --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acresrc.h @@ -0,0 +1,396 @@ +/****************************************************************************** + * + * Name: acresrc.h - Resource Manager function prototypes + * $Revision: 20 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACRESRC_H__ +#define __ACRESRC_H__ + + +/* + * Function prototypes called from Acpi* APIs + */ + +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *ByteStreamBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength); + +ACPI_STATUS +AcpiRsCreateByteStream ( + RESOURCE *LinkedListBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength); + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *MethodReturnObject, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength); + + +/* + *Function prototypes called from AcpiRsCreate*APIs + */ + +void +AcpiRsDumpResourceList ( + RESOURCE *Resource); + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable); + +ACPI_STATUS +AcpiRsGetByteStreamStart ( + UINT8 *ByteStreamBuffer, + UINT8 **ByteStreamStart, + UINT32 *Size); + +ACPI_STATUS +AcpiRsCalculateListLength ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT32 *SizeNeeded); + +ACPI_STATUS +AcpiRsCalculateByteStreamLength ( + RESOURCE *LinkedListBuffer, + UINT32 *SizeNeeded); + +ACPI_STATUS +AcpiRsCalculatePciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + UINT32 *BufferSizeNeeded); + +ACPI_STATUS +AcpiRsByteStreamToList ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT8 **OutputBuffer); + +ACPI_STATUS +AcpiRsListToByteStream ( + RESOURCE *LinkedList, + UINT32 ByteStreamSizeNeeded, + UINT8 **OutputBuffer); + +ACPI_STATUS +AcpiRsIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsFixedIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsFixedIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsDmaResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsDmaStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsAddress16Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsAddress16Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsAddress32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsAddress32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsStartDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsEndDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsStartDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsEndDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsMemory24Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsMemory24Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsMemory32RangeResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize +); + +ACPI_STATUS +AcpiRsFixedMemory32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsMemory32RangeStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsFixedMemory32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsExtendedIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsExtendedIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsEndTagResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsEndTagStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsVendorResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsVendorStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + + +#endif /* __ACRESRC_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/actables.h b/sys/contrib/dev/acpica/Subsystem/Include/actables.h new file mode 100644 index 0000000..18fe18b --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/actables.h @@ -0,0 +1,259 @@ +/****************************************************************************** + * + * Name: actables.h - ACPI table management + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTABLES_H__ +#define __ACTABLES_H__ + + +/* Used in AcpiTbMapAcpiTable for size parameter if table header is to be used */ + +#define SIZE_IN_HEADER 0 + + +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **TableDesc); + + +/* + * tbget - Table "get" routines + */ + +ACPI_STATUS +AcpiTbGetTablePtr ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER **TablePtrLoc); + +ACPI_STATUS +AcpiTbGetTable ( + void *PhysicalAddress, + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo); + +ACPI_STATUS +AcpiTbVerifyRsdp ( + void *RSDP_PhysicalAddress); + +ACPI_STATUS +AcpiTbGetTableFacs ( + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbgetall - Get all firmware ACPI tables + */ + +ACPI_STATUS +AcpiTbGetAllTables ( + UINT32 NumberOfTables, + ACPI_TABLE_HEADER *BufferPtr); + + +/* + * tbinstall - Table installation + */ + +ACPI_STATUS +AcpiTbInstallTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo); + +ACPI_STATUS +AcpiTbRecognizeTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo); + +ACPI_STATUS +AcpiTbInitTableDescriptor ( + ACPI_TABLE_TYPE TableType, + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbremove - Table removal and deletion + */ + +void +AcpiTbDeleteAcpiTables ( + void); + +void +AcpiTbDeleteAcpiTable ( + ACPI_TABLE_TYPE Type); + +void +AcpiTbDeleteSingleTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_TABLE_DESC * +AcpiTbUninstallTable ( + ACPI_TABLE_DESC *TableDesc); + +void +AcpiTbFreeAcpiTablesOfType ( + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbrsd - RSDP, RSDT utilities + */ + +ACPI_STATUS +AcpiTbGetTableRsdt ( + UINT32 *NumberOfTables); + +UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length); + +ACPI_STATUS +AcpiTbFindRsdp ( + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbutils - common table utilities + */ + +BOOLEAN +AcpiTbSystemTablePointer ( + void *Where); + +ACPI_STATUS +AcpiTbMapAcpiTable ( + void *PhysicalAddress, + UINT32 *Size, + void **LogicalAddress); + +ACPI_STATUS +AcpiTbVerifyTableChecksum ( + ACPI_TABLE_HEADER *TableHeader); + +UINT8 +AcpiTbChecksum ( + void *Buffer, + UINT32 Length); + +ACPI_STATUS +AcpiTbValidateTableHeader ( + ACPI_TABLE_HEADER *TableHeader); + + +#endif /* __ACTABLES_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/actbl.h b/sys/contrib/dev/acpica/Subsystem/Include/actbl.h new file mode 100644 index 0000000..53232e3 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/actbl.h @@ -0,0 +1,282 @@ +/****************************************************************************** + * + * Name: actbl.h - Table data structures defined in ACPI specification + * $Revision: 35 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL_H__ +#define __ACTBL_H__ + + +/* + * Values for description table header signatures + */ + +#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ +#define APIC_SIG "APIC" /* Multiple APIC Description Table */ +#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ +#define FACP_SIG "FACP" /* Fixed ACPI Description Table */ +#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ +#define PSDT_SIG "PSDT" /* Persistent System Description Table */ +#define RSDT_SIG "RSDT" /* Root System Description Table */ +#define SSDT_SIG "SSDT" /* Secondary System Description Table */ +#define SBST_SIG "SBST" /* Smart Battery Specification Table */ +#define SPIC_SIG "SPIC" /* iosapic table */ +#define BOOT_SIG "BOOT" /* Boot table */ + + +#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ + +/* values of Mapic.Model */ + +#define DUAL_PIC 0 +#define MULTIPLE_APIC 1 + +/* values of Type in APIC_HEADER */ + +#define APIC_PROC 0 +#define APIC_IO 1 + + +/* + * Architecture-independent tables + * The architecture dependent tables are in separate files + */ + +typedef struct /* Root System Descriptor Pointer */ +{ + NATIVE_CHAR Signature [8]; /* contains "RSD PTR " */ + UINT8 Checksum; /* to make sum of struct == 0 */ + NATIVE_CHAR OemId [6]; /* OEM identification */ + UINT8 Reserved; /* reserved - must be zero */ + UINT32 RsdtPhysicalAddress; /* physical address of RSDT */ + +} ROOT_SYSTEM_DESCRIPTOR_POINTER; + + +typedef struct /* ACPI common table header */ +{ + NATIVE_CHAR Signature [4]; /* identifies type of table */ + UINT32 Length; /* length of table, in bytes, + * including header */ + UINT8 Revision; /* specification minor version # */ + UINT8 Checksum; /* to make sum of entire table == 0 */ + NATIVE_CHAR OemId [6]; /* OEM identification */ + NATIVE_CHAR OemTableId [8]; /* OEM table identification */ + UINT32 OemRevision; /* OEM revision number */ + NATIVE_CHAR AslCompilerId [4]; /* ASL compiler vendor ID */ + UINT32 AslCompilerRevision; /* ASL compiler revision number */ + +} ACPI_TABLE_HEADER; + + +typedef struct /* APIC Table */ +{ + ACPI_TABLE_HEADER header; /* table header */ + UINT32 LocalApicAddress; /* Physical address for accessing local APICs */ + UINT32_BIT PCATCompat : 1; /* a one indicates system also has dual 8259s */ + UINT32_BIT Reserved1 : 31; + +} APIC_TABLE; + + +typedef struct /* APIC Header */ +{ + UINT8 Type; /* APIC type. Either APIC_PROC or APIC_IO */ + UINT8 Length; /* Length of APIC structure */ + +} APIC_HEADER; + + +typedef struct /* Processor APIC */ +{ + APIC_HEADER header; + UINT8 ProcessorApicId; /* ACPI processor id */ + UINT8 LocalApicId; /* processor's local APIC id */ + UINT32_BIT ProcessorEnabled: 1; /* Processor is usable if set */ + UINT32_BIT Reserved1 : 32; + +} PROCESSOR_APIC; + + +typedef struct /* IO APIC */ +{ + APIC_HEADER header; + UINT8 IoApicId; /* I/O APIC ID */ + UINT8 Reserved; /* reserved - must be zero */ + UINT32 IoApicAddress; /* APIC's physical address */ + UINT32 Vector; /* interrupt vector index where INTI + * lines start */ +} IO_APIC; + + +/* +** IA64 TODO: Add SAPIC Tables +*/ + +/* +** IA64 TODO: Modify Smart Battery Description to comply with ACPI IA64 +** extensions. +*/ +typedef struct /* Smart Battery Description Table */ +{ + ACPI_TABLE_HEADER header; + UINT32 WarningLevel; + UINT32 LowLevel; + UINT32 CriticalLevel; + +} SMART_BATTERY_DESCRIPTION_TABLE; + + +/* + * ACPI Table information. We save the table address, length, + * and type of memory allocation (mapped or allocated) for each + * table for 1) when we exit, and 2) if a new table is installed + */ + +#define ACPI_MEM_NOT_ALLOCATED 0 +#define ACPI_MEM_ALLOCATED 1 +#define ACPI_MEM_MAPPED 2 + +/* Definitions for the Flags bitfield member of ACPI_TABLE_SUPPORT */ + +#define ACPI_TABLE_SINGLE 0 +#define ACPI_TABLE_MULTIPLE 1 + + +/* Data about each known table type */ + +typedef struct _AcpiTableSupport +{ + NATIVE_CHAR *Name; + NATIVE_CHAR *Signature; + UINT8 SigLength; + UINT8 Flags; + UINT16 Status; + void **GlobalPtr; + +} ACPI_TABLE_SUPPORT; + + +/* + * Get the architecture-specific tables + */ + +#ifdef IA64 +#include "actbl64.h" +#else +#include "actbl32.h" +#endif + + +#endif /* __ACTBL_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/actbl32.h b/sys/contrib/dev/acpica/Subsystem/Include/actbl32.h new file mode 100644 index 0000000..271655d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/actbl32.h @@ -0,0 +1,206 @@ +/****************************************************************************** + * + * Name: actbl32.h - ACPI tables specific to IA32 + * $Revision: 11 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL32_H__ +#define __ACTBL32_H__ + + +/* IA32 Root System Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* Table header */ + void *TableOffsetEntry [1]; /* Array of pointers to other */ + /* tables' headers */ +} ROOT_SYSTEM_DESCRIPTION_TABLE; + + +/* IA32 Firmware ACPI Control Structure */ + +typedef struct +{ + NATIVE_CHAR Signature[4]; /* signature "FACS" */ + UINT32 Length; /* length of structure, in bytes */ + UINT32 HardwareSignature; /* hardware configuration signature */ + UINT32 FirmwareWakingVector; /* ACPI OS waking vector */ + UINT32 GlobalLock; /* Global Lock */ + UINT32_BIT S4Bios_f : 1; /* Indicates if S4BIOS support is present */ + UINT32_BIT Reserved1 : 31; /* must be 0 */ + UINT8 Resverved3 [40]; /* reserved - must be zero */ + +} FIRMWARE_ACPI_CONTROL_STRUCTURE; + + +/* IA32 Fixed ACPI Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* table header */ + ACPI_TBLPTR FirmwareCtrl; /* Physical address of FACS */ + ACPI_TBLPTR Dsdt; /* Physical address of DSDT */ + UINT8 Model; /* System Interrupt Model */ + UINT8 Reserved1; /* reserved */ + UINT16 SciInt; /* System vector of SCI interrupt */ + ACPI_IO_ADDRESS SmiCmd; /* Port address of SMI command port */ + UINT8 AcpiEnable; /* value to write to smi_cmd to enable ACPI */ + UINT8 AcpiDisable; /* value to write to smi_cmd to disable ACPI */ + UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ + UINT8 Reserved2; /* reserved - must be zero */ + ACPI_IO_ADDRESS Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ + ACPI_IO_ADDRESS Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ + ACPI_IO_ADDRESS Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ + ACPI_IO_ADDRESS Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ + ACPI_IO_ADDRESS Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ + ACPI_IO_ADDRESS PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + ACPI_IO_ADDRESS Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ + ACPI_IO_ADDRESS Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ + UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ + UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ + UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ + UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ + UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ + UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ + UINT8 Gpe1Base; /* offset in gpe model where gpe1 events start */ + UINT8 Reserved3; /* reserved */ + UINT16 Plvl2Lat; /* worst case HW latency to enter/exit C2 state */ + UINT16 Plvl3Lat; /* worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Size of area read to flush caches */ + UINT16 FlushStride; /* Stride used in flushing caches */ + UINT8 DutyOffset; /* bit location of duty cycle field in p_cnt reg */ + UINT8 DutyWidth; /* bit width of duty cycle field in p_cnt reg */ + UINT8 DayAlrm; /* index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonAlrm; /* index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* index to century in RTC CMOS RAM */ + UINT8 Reserved4; /* reserved */ + UINT8 Reserved4a; /* reserved */ + UINT8 Reserved4b; /* reserved */ + UINT32_BIT WbInvd : 1; /* wbinvd instruction works properly */ + UINT32_BIT WbInvdFlush : 1; /* wbinvd flushes but does not invalidate */ + UINT32_BIT ProcC1 : 1; /* all processors support C1 state */ + UINT32_BIT Plvl2Up : 1; /* C2 state works on MP system */ + UINT32_BIT PwrButton : 1; /* Power button is handled as a generic feature */ + UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */ + UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */ + UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ + UINT32_BIT TmrValExt : 1; /* tmr_val is 32 bits */ + UINT32_BIT Reserved5 : 23; /* reserved - must be zero */ + +} FIXED_ACPI_DESCRIPTION_TABLE; + + +#endif /* __ACTBL32_H__ */ + + diff --git a/sys/contrib/dev/acpica/Subsystem/Include/actbl64.h b/sys/contrib/dev/acpica/Subsystem/Include/actbl64.h new file mode 100644 index 0000000..1f44806 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/actbl64.h @@ -0,0 +1,206 @@ +/****************************************************************************** + * + * Name: actbl64.h - ACPI tables specific to IA64 + * $Revision: 12 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL64_H__ +#define __ACTBL64_H__ + + +typedef UINT64 IO_ADDRESS; /* Only for clarity in declarations */ + + +/* IA64 Root System Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* Table header */ + UINT32 ReservedPad; /* IA64 alignment, must be 0 */ + void *TableOffsetEntry [1]; /* Array of pointers to other */ + /* tables' headers */ +} ROOT_SYSTEM_DESCRIPTION_TABLE; + + +/* IA64 Firmware ACPI Control Structure */ + +typedef struct +{ + NATIVE_CHAR Signature[4]; /* signature "FACS" */ + UINT32 Length; /* length of structure, in bytes */ + UINT32 HardwareSignature; /* hardware configuration signature */ + UINT32 Reserved4; /* must be 0 */ + UINT64 FirmwareWakingVector; /* ACPI OS waking vector */ + UINT64 GlobalLock; /* Global Lock */ + UINT32_BIT S4Bios_f : 1; /* Indicates if S4BIOS support is present */ + UINT32_BIT Reserved1 : 31; /* must be 0 */ + UINT8 Resverved3 [28]; /* reserved - must be zero */ + +} FIRMWARE_ACPI_CONTROL_STRUCTURE; + + +/* IA64 Fixed ACPI Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* table header */ + UINT32 ReservedPad; /* IA64 alignment, must be 0 */ + ACPI_TBLPTR FirmwareCtrl; /* Physical address of FACS */ + ACPI_TBLPTR Dsdt; /* Physical address of DSDT */ + UINT8 Model; /* System Interrupt Model */ + UINT8 AddressSpace; /* Address Space Bitmask */ + UINT16 SciInt; /* System vector of SCI interrupt */ + UINT8 AcpiEnable; /* value to write to smi_cmd to enable ACPI */ + UINT8 AcpiDisable; /* value to write to smi_cmd to disable ACPI */ + UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ + UINT8 Reserved2; /* reserved - must be zero */ + UINT64 SmiCmd; /* Port address of SMI command port */ + UINT64 Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ + UINT64 Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ + UINT64 Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ + UINT64 Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ + UINT64 Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ + UINT64 PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT64 Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ + UINT64 Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ + UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ + UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ + UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ + UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ + UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ + UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ + UINT8 Gpe1Base; /* offset in gpe model where gpe1 events start */ + UINT8 Reserved3; /* reserved */ + UINT16 Plvl2Lat; /* worst case HW latency to enter/exit C2 state */ + UINT16 Plvl3Lat; /* worst case HW latency to enter/exit C3 state */ + UINT8 DayAlrm; /* index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonAlrm; /* index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* index to century in RTC CMOS RAM */ + UINT8 Reserved4; /* reserved */ + UINT32_BIT FlushCash : 1; /* PAL_FLUSH_CACHE is correctly supported */ + UINT32_BIT Reserved5 : 1; /* reserved - must be zero */ + UINT32_BIT ProcC1 : 1; /* all processors support C1 state */ + UINT32_BIT Plvl2Up : 1; /* C2 state works on MP system */ + UINT32_BIT PwrButton : 1; /* Power button is handled as a generic feature */ + UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */ + UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */ + UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ + UINT32_BIT TmrValExt : 1; /* tmr_val is 32 bits */ + UINT32_BIT DockCap : 1; /* Supports Docking */ + UINT32_BIT Reserved6 : 22; /* reserved - must be zero */ + +} FIXED_ACPI_DESCRIPTION_TABLE; + + +#endif /* __ACTBL64_H__ */ + diff --git a/sys/contrib/dev/acpica/Subsystem/Include/actypes.h b/sys/contrib/dev/acpica/Subsystem/Include/actypes.h new file mode 100644 index 0000000..446f01f --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/actypes.h @@ -0,0 +1,1111 @@ +/****************************************************************************** + * + * Name: actypes.h - Common data types for the entire ACPI subsystem + * $Revision: 143 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTYPES_H__ +#define __ACTYPES_H__ + +/*! [Begin] no source code translation (keep the typedefs) */ + +/* + * Data types - Fixed across all compilation models + * + * BOOLEAN Logical Boolean. + * 1 byte value containing a 0 for FALSE or a 1 for TRUE. + * Other values are undefined. + * + * INT8 8-bit (1 byte) signed value + * UINT8 8-bit (1 byte) unsigned value + * INT16 16-bit (2 byte) signed value + * UINT16 16-bit (2 byte) unsigned value + * INT32 32-bit (4 byte) signed value + * UINT32 32-bit (4 byte) unsigned value + * INT64 64-bit (8 byte) signed value + * UINT64 64-bit (8 byte) unsigned value + * NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value + * NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value + * UCHAR Character. 1 byte unsigned value. + */ + + +#ifdef _IA64 +/* + * 64-bit type definitions + */ +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned char UCHAR; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef long INT64; +typedef unsigned long UINT64; + +typedef UINT64 NATIVE_UINT; +typedef INT64 NATIVE_INT; + +typedef NATIVE_UINT ACPI_TBLPTR; +typedef UINT64 ACPI_IO_ADDRESS; +typedef UINT64 ACPI_MEM_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 + +/* (No hardware alignment support in IA64) */ + + +#elif _IA16 +/* + * 16-bit type definitions + */ +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned char UCHAR; +typedef unsigned int UINT16; +typedef long INT32; +typedef int INT16; +typedef unsigned long UINT32; + +typedef UINT16 NATIVE_UINT; +typedef INT16 NATIVE_INT; + +typedef UINT32 ACPI_TBLPTR; +typedef UINT32 ACPI_IO_ADDRESS; +typedef UINT32 ACPI_MEM_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 +#define _HW_ALIGNMENT_SUPPORT + +/* (16-bit only) Force internal integers to be 32, not 64 bits */ + +#define ACPI_VERSION_1 + + +#else +/* + * 32-bit type definitions (default) + */ +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned char UCHAR; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef COMPILER_DEPENDENT_UINT64 UINT64; + +typedef UINT32 NATIVE_UINT; +typedef INT32 NATIVE_INT; + +typedef NATIVE_UINT ACPI_TBLPTR; +typedef UINT32 ACPI_IO_ADDRESS; +typedef UINT32 ACPI_MEM_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 +#define _HW_ALIGNMENT_SUPPORT + +#endif + + + +/* + * Miscellaneous common types + */ + +typedef UINT32 UINT32_BIT; +typedef NATIVE_UINT ACPI_PTRDIFF; +typedef char NATIVE_CHAR; + + +/* + * Data type ranges + */ + +#define ACPI_UINT8_MAX (UINT8) 0xFF +#define ACPI_UINT16_MAX (UINT16) 0xFFFF +#define ACPI_UINT32_MAX (UINT32) 0xFFFFFFFF +#define ACPI_UINT64_MAX (UINT64) 0xFFFFFFFFFFFFFFFF + + +#ifdef DEFINE_ALTERNATE_TYPES +/* + * Types used only in translated source + */ +typedef INT32 s32; +typedef UINT8 u8; +typedef UINT16 u16; +typedef UINT32 u32; +typedef UINT64 u64; +#endif +/*! [End] no source code translation !*/ + + +/* + * Useful defines + */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE (1 == 0) + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE (1 == 1) + +#ifndef NULL +#define NULL (void *) 0 +#endif + + +/* + * Local datatypes + */ + +typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ +typedef UINT32 ACPI_NAME; /* 4-INT8 ACPI name */ +typedef char* ACPI_STRING; /* Null terminated ASCII string */ +typedef void* ACPI_HANDLE; /* Actually a ptr to an Node */ + + +/* TBD: TEMP ONLY! */ + +#define ACPI_VERSION_1 + +/* + * Acpi integer width. In ACPI version 1, integers are + * 32 bits. In ACPI version 2, integers are 64 bits. Period. + * Note that this pertains to the ACPI integer type only, not + * other integers used in the implementation of the ACPI CA + * subsystem. + */ + +#ifdef ACPI_VERSION_1 + +/* 32-bit Integers */ + +typedef UINT32 ACPI_INTEGER; +#define ACPI_INTEGER_MAX ACPI_UINT32_MAX; +#define ACPI_INTEGER_BIT_SIZE 32 + +#else + +/* 64-bit Integers */ + +typedef UINT64 ACPI_INTEGER; +#define ACPI_INTEGER_MAX ACPI_UINT64_MAX; +#define ACPI_INTEGER_BIT_SIZE 64 +#endif + + +/* + * Constants with special meanings + */ + +#define ACPI_ROOT_OBJECT (ACPI_HANDLE)(-1) + +#define ACPI_FULL_INITIALIZATION 0x00 +#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 +#define ACPI_NO_HARDWARE_INIT 0x02 +#define ACPI_NO_EVENT_INIT 0x04 +#define ACPI_NO_ACPI_ENABLE 0x08 +#define ACPI_NO_DEVICE_INIT 0x10 +#define ACPI_NO_PCI_INIT 0x20 +#define ACPI_NO_OBJECT_INIT 0x40 + + +/* + * Sleep state constants + */ +#define ACPI_STATE_S0 (UINT8) 0 +#define ACPI_STATE_S1 (UINT8) 1 +#define ACPI_STATE_S2 (UINT8) 2 +#define ACPI_STATE_S3 (UINT8) 3 +#define ACPI_STATE_S4 (UINT8) 4 +#define ACPI_STATE_S4BIOS (UINT8) 5 +#define ACPI_STATE_S5 (UINT8) 6 +#define ACPI_S_STATES_MAX ACPI_STATE_S5 + + +/* + * Table types. These values are passed to the table related APIs + */ + +typedef UINT32 ACPI_TABLE_TYPE; + +#define ACPI_TABLE_RSDP (ACPI_TABLE_TYPE) 0 +#define ACPI_TABLE_APIC (ACPI_TABLE_TYPE) 1 +#define ACPI_TABLE_DSDT (ACPI_TABLE_TYPE) 2 +#define ACPI_TABLE_FACP (ACPI_TABLE_TYPE) 3 +#define ACPI_TABLE_FACS (ACPI_TABLE_TYPE) 4 +#define ACPI_TABLE_PSDT (ACPI_TABLE_TYPE) 5 +#define ACPI_TABLE_RSDT (ACPI_TABLE_TYPE) 6 +#define ACPI_TABLE_SSDT (ACPI_TABLE_TYPE) 7 +#define ACPI_TABLE_SBST (ACPI_TABLE_TYPE) 8 +#define ACPI_TABLE_SPIC (ACPI_TABLE_TYPE) 9 +#define ACPI_TABLE_BOOT (ACPI_TABLE_TYPE) 10 +#define ACPI_TABLE_MAX 10 +#define NUM_ACPI_TABLES (ACPI_TABLE_MAX+1) + + +/* + * Types associated with names. The first group of + * values correspond to the definition of the ACPI + * ObjectType operator (See the ACPI Spec). Therefore, + * only add to the first group if the spec changes! + * + * Types must be kept in sync with the AcpiNsProperties + * and AcpiNsTypeNames arrays + */ + +typedef UINT32 ACPI_OBJECT_TYPE; +typedef UINT8 OBJECT_TYPE_INTERNAL; + +#define ACPI_TYPE_ANY 0 /* 0x00 */ +#define ACPI_TYPE_NUMBER 1 /* 0x01 Byte/Word/Dword/Zero/One/Ones */ +#define ACPI_TYPE_STRING 2 /* 0x02 */ +#define ACPI_TYPE_BUFFER 3 /* 0x03 */ +#define ACPI_TYPE_PACKAGE 4 /* 0x04 ByteConst, multiple DataTerm/Constant/SuperName */ +#define ACPI_TYPE_FIELD_UNIT 5 /* 0x05 */ +#define ACPI_TYPE_DEVICE 6 /* 0x06 Name, multiple Node */ +#define ACPI_TYPE_EVENT 7 /* 0x07 */ +#define ACPI_TYPE_METHOD 8 /* 0x08 Name, ByteConst, multiple Code */ +#define ACPI_TYPE_MUTEX 9 /* 0x09 */ +#define ACPI_TYPE_REGION 10 /* 0x0A */ +#define ACPI_TYPE_POWER 11 /* 0x0B Name,ByteConst,WordConst,multi Node */ +#define ACPI_TYPE_PROCESSOR 12 /* 0x0C Name,ByteConst,DWordConst,ByteConst,multi NmO */ +#define ACPI_TYPE_THERMAL 13 /* 0x0D Name, multiple Node */ +#define ACPI_TYPE_BUFFER_FIELD 14 /* 0x0E */ +#define ACPI_TYPE_DDB_HANDLE 15 /* 0x0F */ +#define ACPI_TYPE_DEBUG_OBJECT 16 /* 0x10 */ + +#define ACPI_TYPE_MAX 16 + +/* + * This section contains object types that do not relate to the ACPI ObjectType operator. + * They are used for various internal purposes only. If new predefined ACPI_TYPEs are + * added (via the ACPI specification), these internal types must move upwards. + * Also, values exceeding the largest official ACPI ObjectType must not overlap with + * defined AML opcodes. + */ +#define INTERNAL_TYPE_BEGIN 17 + +#define INTERNAL_TYPE_DEF_FIELD 17 /* 0x11 */ +#define INTERNAL_TYPE_BANK_FIELD 18 /* 0x12 */ +#define INTERNAL_TYPE_INDEX_FIELD 19 /* 0x13 */ +#define INTERNAL_TYPE_REFERENCE 20 /* 0x14 Arg#, Local#, Name, Debug; used only in descriptors */ +#define INTERNAL_TYPE_ALIAS 21 /* 0x15 */ +#define INTERNAL_TYPE_NOTIFY 22 /* 0x16 */ +#define INTERNAL_TYPE_ADDRESS_HANDLER 23 /* 0x17 */ + +#define INTERNAL_TYPE_NODE_MAX 23 + +/* These are pseudo-types because there are never any namespace nodes with these types */ + +#define INTERNAL_TYPE_DEF_FIELD_DEFN 24 /* 0x18 Name, ByteConst, multiple FieldElement */ +#define INTERNAL_TYPE_BANK_FIELD_DEFN 25 /* 0x19 2 Name,DWordConst,ByteConst,multi FieldElement */ +#define INTERNAL_TYPE_INDEX_FIELD_DEFN 26 /* 0x1A 2 Name, ByteConst, multiple FieldElement */ +#define INTERNAL_TYPE_IF 27 /* 0x1B OpCode, multiple Code */ +#define INTERNAL_TYPE_ELSE 28 /* 0x1C multiple Code */ +#define INTERNAL_TYPE_WHILE 29 /* 0x1D OpCode, multiple Code */ +#define INTERNAL_TYPE_SCOPE 30 /* 0x1E Name, multiple Node */ +#define INTERNAL_TYPE_DEF_ANY 31 /* 0x1F type is Any, suppress search of enclosing scopes */ +#define INTERNAL_TYPE_METHOD_ARGUMENT 32 /* 0x20 */ +#define INTERNAL_TYPE_METHOD_LOCAL_VAR 33 /* 0x21 */ +#define INTERNAL_TYPE_EXTRA 34 /* 0x22 */ + +#define INTERNAL_TYPE_MAX 34 + +#define INTERNAL_TYPE_INVALID 35 +#define ACPI_TYPE_NOT_FOUND 0xFF + +/* + * AcpiEvent Types: + * ------------ + * Fixed & general purpose... + */ + +typedef UINT32 ACPI_EVENT_TYPE; + +#define ACPI_EVENT_FIXED (ACPI_EVENT_TYPE) 0 +#define ACPI_EVENT_GPE (ACPI_EVENT_TYPE) 1 + +/* + * Fixed events + */ + +#define ACPI_EVENT_PMTIMER (ACPI_EVENT_TYPE) 0 + /* + * There's no bus master event so index 1 is used for IRQ's that are not + * handled by the SCI handler + */ +#define ACPI_EVENT_NOT_USED (ACPI_EVENT_TYPE) 1 +#define ACPI_EVENT_GLOBAL (ACPI_EVENT_TYPE) 2 +#define ACPI_EVENT_POWER_BUTTON (ACPI_EVENT_TYPE) 3 +#define ACPI_EVENT_SLEEP_BUTTON (ACPI_EVENT_TYPE) 4 +#define ACPI_EVENT_RTC (ACPI_EVENT_TYPE) 5 +#define ACPI_EVENT_GENERAL (ACPI_EVENT_TYPE) 6 +#define ACPI_EVENT_MAX 6 +#define NUM_FIXED_EVENTS (ACPI_EVENT_TYPE) 7 + +#define ACPI_GPE_INVALID 0xFF +#define ACPI_GPE_MAX 0xFF +#define NUM_GPE 256 + +#define ACPI_EVENT_LEVEL_TRIGGERED (ACPI_EVENT_TYPE) 1 +#define ACPI_EVENT_EDGE_TRIGGERED (ACPI_EVENT_TYPE) 2 + +/* + * AcpiEvent Status: + * ------------- + * The encoding of ACPI_EVENT_STATUS is illustrated below. + * Note that a set bit (1) indicates the property is TRUE + * (e.g. if bit 0 is set then the event is enabled). + * +---------------+-+-+ + * | Bits 31:2 |1|0| + * +---------------+-+-+ + * | | | + * | | +- Enabled? + * | +--- Set? + * +----------- + */ +typedef UINT32 ACPI_EVENT_STATUS; + +#define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 +#define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x02 + + +/* Notify types */ + +#define ACPI_SYSTEM_NOTIFY 0 +#define ACPI_DEVICE_NOTIFY 1 +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 1 + +#define MAX_SYS_NOTIFY 0x7f + + +/* Address Space (Operation Region) Types */ + +typedef UINT32 ACPI_ADDRESS_SPACE_TYPE; + +#define ADDRESS_SPACE_SYSTEM_MEMORY (ACPI_ADDRESS_SPACE_TYPE) 0 +#define ADDRESS_SPACE_SYSTEM_IO (ACPI_ADDRESS_SPACE_TYPE) 1 +#define ADDRESS_SPACE_PCI_CONFIG (ACPI_ADDRESS_SPACE_TYPE) 2 +#define ADDRESS_SPACE_EC (ACPI_ADDRESS_SPACE_TYPE) 3 +#define ADDRESS_SPACE_SMBUS (ACPI_ADDRESS_SPACE_TYPE) 4 + + +/* + * External ACPI object definition + */ + +typedef union AcpiObj +{ + ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ + struct + { + ACPI_OBJECT_TYPE Type; + ACPI_INTEGER Value; /* The actual number */ + } Number; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Length; /* # of bytes in string, excluding trailing null */ + NATIVE_CHAR *Pointer; /* points to the string value */ + } String; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Length; /* # of bytes in buffer */ + UINT8 *Pointer; /* points to the buffer */ + } Buffer; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Fill1; + ACPI_HANDLE Handle; /* object reference */ + } Reference; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Count; /* # of elements in package */ + union AcpiObj *Elements; /* Pointer to an array of ACPI_OBJECTs */ + } Package; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 ProcId; + UINT32 PblkAddress; + UINT32 PblkLength; + } Processor; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 SystemLevel; + UINT32 ResourceOrder; + } PowerResource; + +} ACPI_OBJECT, *PACPI_OBJECT; + + +/* + * List of objects, used as a parameter list for control method evaluation + */ + +typedef struct AcpiObjList +{ + UINT32 Count; + ACPI_OBJECT *Pointer; + +} ACPI_OBJECT_LIST, *PACPI_OBJECT_LIST; + + +/* + * Miscellaneous common Data Structures used by the interfaces + */ + +typedef struct +{ + UINT32 Length; /* Length in bytes of the buffer */ + void *Pointer; /* pointer to buffer */ + +} ACPI_BUFFER; + + +/* + * NameType for AcpiGetName + */ + +#define ACPI_FULL_PATHNAME 0 +#define ACPI_SINGLE_NAME 1 +#define ACPI_NAME_TYPE_MAX 1 + + +/* + * Structure and flags for AcpiGetSystemInfo + */ + +#define SYS_MODE_UNKNOWN 0x0000 +#define SYS_MODE_ACPI 0x0001 +#define SYS_MODE_LEGACY 0x0002 +#define SYS_MODES_MASK 0x0003 + +/* + * ACPI CPU Cx state handler + */ +typedef +ACPI_STATUS (*ACPI_SET_C_STATE_HANDLER) ( + NATIVE_UINT PblkAddress); + +/* + * ACPI Cx State info + */ +typedef struct +{ + UINT32 StateNumber; + UINT32 Latency; +} ACPI_CX_STATE; + +/* + * ACPI CPU throttling info + */ +typedef struct +{ + UINT32 StateNumber; + UINT32 PercentOfClock; +} ACPI_CPU_THROTTLING_STATE; + +/* + * ACPI Table Info. One per ACPI table _type_ + */ +typedef struct AcpiTableInfo +{ + UINT32 Count; + +} ACPI_TABLE_INFO; + + +/* + * System info returned by AcpiGetSystemInfo() + */ + +typedef struct _AcpiSysInfo +{ + UINT32 AcpiCaVersion; + UINT32 Flags; + UINT32 TimerResolution; + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 DebugLevel; + UINT32 DebugLayer; + UINT32 NumTableTypes; + ACPI_TABLE_INFO TableInfo [NUM_ACPI_TABLES]; + +} ACPI_SYSTEM_INFO; + + +/* + * System Initiailization data. This data is passed to ACPIInitialize + * copyied to global data and retained by ACPI CA + */ + +typedef struct _AcpiInitData +{ + void *RSDP_PhysicalAddress; /* Address of RSDP, needed it it is */ + /* not found in the IA32 manner */ +} ACPI_INIT_DATA; + +/* + * Various handlers and callback procedures + */ + +typedef +UINT32 (*FIXED_EVENT_HANDLER) ( + void *Context); + +typedef +void (*GPE_HANDLER) ( + void *Context); + +typedef +void (*NOTIFY_HANDLER) ( + ACPI_HANDLE Device, + UINT32 Value, + void *Context); + +#define ADDRESS_SPACE_READ 1 +#define ADDRESS_SPACE_WRITE 2 + +typedef +ACPI_STATUS (*ADDRESS_SPACE_HANDLER) ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +#define ACPI_DEFAULT_HANDLER ((ADDRESS_SPACE_HANDLER) NULL) + + +typedef +ACPI_STATUS (*ADDRESS_SPACE_SETUP) ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +#define ACPI_REGION_ACTIVATE 0 +#define ACPI_REGION_DEACTIVATE 1 + +typedef +ACPI_STATUS (*WALK_CALLBACK) ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/* Interrupt handler return values */ + +#define INTERRUPT_NOT_HANDLED 0x00 +#define INTERRUPT_HANDLED 0x01 + + +/* Structure and flags for AcpiGetDeviceInfo */ + +#define ACPI_VALID_HID 0x1 +#define ACPI_VALID_UID 0x2 +#define ACPI_VALID_ADR 0x4 +#define ACPI_VALID_STA 0x8 + + +#define ACPI_COMMON_OBJ_INFO \ + ACPI_OBJECT_TYPE Type; /* ACPI object type */ \ + ACPI_NAME Name /* ACPI object Name */ + + +typedef struct +{ + ACPI_COMMON_OBJ_INFO; +} ACPI_OBJ_INFO_HEADER; + + +typedef struct +{ + ACPI_COMMON_OBJ_INFO; + + UINT32 Valid; /* Are the next bits legit? */ + NATIVE_CHAR HardwareId [9]; /* _HID value if any */ + NATIVE_CHAR UniqueId[9]; /* _UID value if any */ + ACPI_INTEGER Address; /* _ADR value if any */ + UINT32 CurrentStatus; /* _STA value */ +} ACPI_DEVICE_INFO; + + +/* Context structs for address space handlers */ + +typedef struct +{ + UINT32 Seg; + UINT32 Bus; + UINT32 DevFunc; +} PCI_HANDLER_CONTEXT; + + +typedef struct +{ + UINT8 *MappedPhysicalAddress; + UINT8 *MappedLogicalAddress; + UINT32 MappedLength; +} MEM_HANDLER_CONTEXT; + + +/* + * C-state handler + */ + +typedef ACPI_STATUS (*ACPI_C_STATE_HANDLER) (ACPI_IO_ADDRESS, UINT32*); + + +/* + * Definitions for Resource Attributes + */ + +/* + * Memory Attributes + */ +#define READ_ONLY_MEMORY (UINT8) 0x00 +#define READ_WRITE_MEMORY (UINT8) 0x01 + +#define NON_CACHEABLE_MEMORY (UINT8) 0x00 +#define CACHABLE_MEMORY (UINT8) 0x01 +#define WRITE_COMBINING_MEMORY (UINT8) 0x02 +#define PREFETCHABLE_MEMORY (UINT8) 0x03 + +/* + * IO Attributes + * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. + * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. + */ +#define NON_ISA_ONLY_RANGES (UINT8) 0x01 +#define ISA_ONLY_RANGES (UINT8) 0x02 +#define ENTIRE_RANGE (NON_ISA_ONLY_RANGES | ISA_ONLY_RANGES) + +/* + * IO Port Descriptor Decode + */ +#define DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ +#define DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ + +/* + * IRQ Attributes + */ +#define EDGE_SENSITIVE (UINT8) 0x00 +#define LEVEL_SENSITIVE (UINT8) 0x01 + +#define ACTIVE_HIGH (UINT8) 0x00 +#define ACTIVE_LOW (UINT8) 0x01 + +#define EXCLUSIVE (UINT8) 0x00 +#define SHARED (UINT8) 0x01 + +/* + * DMA Attributes + */ +#define COMPATIBILITY (UINT8) 0x00 +#define TYPE_A (UINT8) 0x01 +#define TYPE_B (UINT8) 0x02 +#define TYPE_F (UINT8) 0x03 + +#define NOT_BUS_MASTER (UINT8) 0x00 +#define BUS_MASTER (UINT8) 0x01 + +#define TRANSFER_8 (UINT8) 0x00 +#define TRANSFER_8_16 (UINT8) 0x01 +#define TRANSFER_16 (UINT8) 0x02 + +/* + * Start Dependent Functions Priority definitions + */ +#define GOOD_CONFIGURATION (UINT8) 0x00 +#define ACCEPTABLE_CONFIGURATION (UINT8) 0x01 +#define SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 + +/* + * 16, 32 and 64-bit Address Descriptor resource types + */ +#define MEMORY_RANGE (UINT8) 0x00 +#define IO_RANGE (UINT8) 0x01 +#define BUS_NUMBER_RANGE (UINT8) 0x02 + +#define ADDRESS_NOT_FIXED (UINT8) 0x00 +#define ADDRESS_FIXED (UINT8) 0x01 + +#define POS_DECODE (UINT8) 0x00 +#define SUB_DECODE (UINT8) 0x01 + +#define PRODUCER (UINT8) 0x00 +#define CONSUMER (UINT8) 0x01 + + +/* + * Structures used to describe device resources + */ +typedef struct +{ + UINT32 EdgeLevel; + UINT32 ActiveHighLow; + UINT32 SharedExclusive; + UINT32 NumberOfInterrupts; + UINT32 Interrupts[1]; + +} IRQ_RESOURCE; + +typedef struct +{ + UINT32 Type; + UINT32 BusMaster; + UINT32 Transfer; + UINT32 NumberOfChannels; + UINT32 Channels[1]; + +} DMA_RESOURCE; + +typedef struct +{ + UINT32 CompatibilityPriority; + UINT32 PerformanceRobustness; + +} START_DEPENDENT_FUNCTIONS_RESOURCE; + +/* + * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not + * needed because it has no fields + */ + +typedef struct +{ + UINT32 IoDecode; + UINT32 MinBaseAddress; + UINT32 MaxBaseAddress; + UINT32 Alignment; + UINT32 RangeLength; + +} IO_RESOURCE; + +typedef struct +{ + UINT32 BaseAddress; + UINT32 RangeLength; + +} FIXED_IO_RESOURCE; + +typedef struct +{ + UINT32 Length; + UINT8 Reserved[1]; + +} VENDOR_RESOURCE; + +typedef struct +{ + UINT32 ReadWriteAttribute; + UINT32 MinBaseAddress; + UINT32 MaxBaseAddress; + UINT32 Alignment; + UINT32 RangeLength; + +} MEMORY24_RESOURCE; + +typedef struct +{ + UINT32 ReadWriteAttribute; + UINT32 MinBaseAddress; + UINT32 MaxBaseAddress; + UINT32 Alignment; + UINT32 RangeLength; + +} MEMORY32_RESOURCE; + +typedef struct +{ + UINT32 ReadWriteAttribute; + UINT32 RangeBaseAddress; + UINT32 RangeLength; + +} FIXED_MEMORY32_RESOURCE; + +typedef struct +{ + UINT16 CacheAttribute; + UINT16 ReadWriteAttribute; + +} MEMORY_ATTRIBUTE; + +typedef struct +{ + UINT16 RangeAttribute; + UINT16 Reserved; + +} IO_ATTRIBUTE; + +typedef struct +{ + UINT16 Reserved1; + UINT16 Reserved2; + +} BUS_ATTRIBUTE; + +typedef union +{ + MEMORY_ATTRIBUTE Memory; + IO_ATTRIBUTE Io; + BUS_ATTRIBUTE Bus; + +} ATTRIBUTE_DATA; + +typedef struct +{ + UINT32 ResourceType; + UINT32 ProducerConsumer; + UINT32 Decode; + UINT32 MinAddressFixed; + UINT32 MaxAddressFixed; + ATTRIBUTE_DATA Attribute; + UINT32 Granularity; + UINT32 MinAddressRange; + UINT32 MaxAddressRange; + UINT32 AddressTranslationOffset; + UINT32 AddressLength; + UINT32 ResourceSourceIndex; + UINT32 ResourceSourceStringLength; + NATIVE_CHAR ResourceSource[1]; + +} ADDRESS16_RESOURCE; + +typedef struct +{ + UINT32 ResourceType; + UINT32 ProducerConsumer; + UINT32 Decode; + UINT32 MinAddressFixed; + UINT32 MaxAddressFixed; + ATTRIBUTE_DATA Attribute; + UINT32 Granularity; + UINT32 MinAddressRange; + UINT32 MaxAddressRange; + UINT32 AddressTranslationOffset; + UINT32 AddressLength; + UINT32 ResourceSourceIndex; + UINT32 ResourceSourceStringLength; + NATIVE_CHAR ResourceSource[1]; + +} ADDRESS32_RESOURCE; + +typedef struct +{ + UINT32 ProducerConsumer; + UINT32 EdgeLevel; + UINT32 ActiveHighLow; + UINT32 SharedExclusive; + UINT32 NumberOfInterrupts; + UINT32 Interrupts[1]; + UINT32 ResourceSourceIndex; + UINT32 ResourceSourceStringLength; + NATIVE_CHAR ResourceSource[1]; + +} EXTENDED_IRQ_RESOURCE; + +typedef enum +{ + Irq, + Dma, + StartDependentFunctions, + EndDependentFunctions, + Io, + FixedIo, + VendorSpecific, + EndTag, + Memory24, + Memory32, + FixedMemory32, + Address16, + Address32, + ExtendedIrq +} RESOURCE_TYPE; + +typedef union +{ + IRQ_RESOURCE Irq; + DMA_RESOURCE Dma; + START_DEPENDENT_FUNCTIONS_RESOURCE StartDependentFunctions; + IO_RESOURCE Io; + FIXED_IO_RESOURCE FixedIo; + VENDOR_RESOURCE VendorSpecific; + MEMORY24_RESOURCE Memory24; + MEMORY32_RESOURCE Memory32; + FIXED_MEMORY32_RESOURCE FixedMemory32; + ADDRESS16_RESOURCE Address16; + ADDRESS32_RESOURCE Address32; + EXTENDED_IRQ_RESOURCE ExtendedIrq; +} RESOURCE_DATA; + +typedef struct _resource_tag +{ + RESOURCE_TYPE Id; + UINT32 Length; + RESOURCE_DATA Data; +} RESOURCE; + +#define RESOURCE_LENGTH 12 +#define RESOURCE_LENGTH_NO_DATA 8 + +#define NEXT_RESOURCE(Res) (RESOURCE*)((UINT8*) Res + Res->length) + +/* + * END: Definitions for Resource Attributes + */ + +/* + * Definitions for PCI Routing tables + */ +typedef struct +{ + ACPI_INTEGER Address; + UINT32 Pin; + UINT32 SourceIndex; + NATIVE_CHAR Source[1]; + +} PRT_ENTRY; + +typedef struct _prt_tag +{ + UINT32 Length; + PRT_ENTRY Data; + +} PCI_ROUTING_TABLE; + + +/* + * END: Definitions for PCI Routing tables + */ + +#endif /* __ACTYPES_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/acwin.h b/sys/contrib/dev/acpica/Subsystem/Include/acwin.h new file mode 100644 index 0000000..ac04fe9 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/acwin.h @@ -0,0 +1,190 @@ +/****************************************************************************** + * + * Name: acwin.h - OS specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACWIN_H__ +#define __ACWIN_H__ + +/* Windows uses VC */ +#ifdef _MSC_VER +#include "acmsvc.h" +#endif + +#define ACPI_OS_NAME "Windows" + +#define strupr _strupr +#define ACPI_USE_STANDARD_HEADERS + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +/*! [Begin] no source code translation */ + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) __asm {int level} +#define BREAKPOINT3 __asm {int 3} +#define disable() __asm {cli} +#define enable() __asm {sti} +#define halt() __asm {hlt} +#define wbinvd() __asm {WBINVD} + + +/* + * For Acpi applications, we don't want to try to access the global lock + */ +#ifdef ACPI_APPLICATION +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) (Acq = 0xFF) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) (Pnd = 0) +#else + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) __asm { \ + __asm mov ecx, GLptr \ + __asm acq10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFE \ + __asm bts edx, 1 \ + __asm adc edx, 0 \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz acq10 \ + \ + __asm cmp dl, 3 \ + __asm sbb eax, eax \ + __asm mov Acq, al \ +} + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) __asm { \ + __asm mov ecx, GLptr \ + __asm Rel10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFC \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz Rel10 \ + \ + __asm cmp dl, 3 \ + __asm and eax, 1 \ + __asm mov Pnd, al \ +} + +#endif + + +#endif /* __ACWIN_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Include/amlcode.h b/sys/contrib/dev/acpica/Subsystem/Include/amlcode.h new file mode 100644 index 0000000..7a3674c --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Include/amlcode.h @@ -0,0 +1,553 @@ +/****************************************************************************** + * + * Name: amlcode.h - Definitions for AML, as included in "definition blocks" + * Declarations and definitions contained herein are derived + * directly from the ACPI specification. + * $Revision: 40 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __AMLCODE_H__ +#define __AMLCODE_H__ + + +/* primary opcodes */ + +#define AML_NULL_CHAR (UINT16) 0x00 + +#define AML_ZERO_OP (UINT16) 0x00 +#define AML_ONE_OP (UINT16) 0x01 +#define AML_UNASSIGNED (UINT16) 0x02 +#define AML_ALIAS_OP (UINT16) 0x06 +#define AML_NAME_OP (UINT16) 0x08 +#define AML_BYTE_OP (UINT16) 0x0a +#define AML_WORD_OP (UINT16) 0x0b +#define AML_DWORD_OP (UINT16) 0x0c +#define AML_STRING_OP (UINT16) 0x0d +#define AML_QWORD_OP (UINT16) 0x0e /* ACPI 2.0 */ +#define AML_SCOPE_OP (UINT16) 0x10 +#define AML_BUFFER_OP (UINT16) 0x11 +#define AML_PACKAGE_OP (UINT16) 0x12 +#define AML_VAR_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */ +#define AML_METHOD_OP (UINT16) 0x14 +#define AML_DUAL_NAME_PREFIX (UINT16) 0x2e +#define AML_MULTI_NAME_PREFIX_OP (UINT16) 0x2f +#define AML_NAME_CHAR_SUBSEQ (UINT16) 0x30 +#define AML_NAME_CHAR_FIRST (UINT16) 0x41 +#define AML_OP_PREFIX (UINT16) 0x5b +#define AML_ROOT_PREFIX (UINT16) 0x5c +#define AML_PARENT_PREFIX (UINT16) 0x5e +#define AML_LOCAL_OP (UINT16) 0x60 +#define AML_LOCAL0 (UINT16) 0x60 +#define AML_LOCAL1 (UINT16) 0x61 +#define AML_LOCAL2 (UINT16) 0x62 +#define AML_LOCAL3 (UINT16) 0x63 +#define AML_LOCAL4 (UINT16) 0x64 +#define AML_LOCAL5 (UINT16) 0x65 +#define AML_LOCAL6 (UINT16) 0x66 +#define AML_LOCAL7 (UINT16) 0x67 +#define AML_ARG_OP (UINT16) 0x68 +#define AML_ARG0 (UINT16) 0x68 +#define AML_ARG1 (UINT16) 0x69 +#define AML_ARG2 (UINT16) 0x6a +#define AML_ARG3 (UINT16) 0x6b +#define AML_ARG4 (UINT16) 0x6c +#define AML_ARG5 (UINT16) 0x6d +#define AML_ARG6 (UINT16) 0x6e +#define AML_STORE_OP (UINT16) 0x70 +#define AML_REF_OF_OP (UINT16) 0x71 +#define AML_ADD_OP (UINT16) 0x72 +#define AML_CONCAT_OP (UINT16) 0x73 +#define AML_SUBTRACT_OP (UINT16) 0x74 +#define AML_INCREMENT_OP (UINT16) 0x75 +#define AML_DECREMENT_OP (UINT16) 0x76 +#define AML_MULTIPLY_OP (UINT16) 0x77 +#define AML_DIVIDE_OP (UINT16) 0x78 +#define AML_SHIFT_LEFT_OP (UINT16) 0x79 +#define AML_SHIFT_RIGHT_OP (UINT16) 0x7a +#define AML_BIT_AND_OP (UINT16) 0x7b +#define AML_BIT_NAND_OP (UINT16) 0x7c +#define AML_BIT_OR_OP (UINT16) 0x7d +#define AML_BIT_NOR_OP (UINT16) 0x7e +#define AML_BIT_XOR_OP (UINT16) 0x7f +#define AML_BIT_NOT_OP (UINT16) 0x80 +#define AML_FIND_SET_LEFT_BIT_OP (UINT16) 0x81 +#define AML_FIND_SET_RIGHT_BIT_OP (UINT16) 0x82 +#define AML_DEREF_OF_OP (UINT16) 0x83 +#define AML_CONCAT_RES_OP (UINT16) 0x84 /* ACPI 2.0 */ +#define AML_MOD_OP (UINT16) 0x85 /* ACPI 2.0 */ +#define AML_NOTIFY_OP (UINT16) 0x86 +#define AML_SIZE_OF_OP (UINT16) 0x87 +#define AML_INDEX_OP (UINT16) 0x88 +#define AML_MATCH_OP (UINT16) 0x89 +#define AML_DWORD_FIELD_OP (UINT16) 0x8a +#define AML_WORD_FIELD_OP (UINT16) 0x8b +#define AML_BYTE_FIELD_OP (UINT16) 0x8c +#define AML_BIT_FIELD_OP (UINT16) 0x8d +#define AML_TYPE_OP (UINT16) 0x8e +#define AML_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */ +#define AML_LAND_OP (UINT16) 0x90 +#define AML_LOR_OP (UINT16) 0x91 +#define AML_LNOT_OP (UINT16) 0x92 +#define AML_LEQUAL_OP (UINT16) 0x93 +#define AML_LGREATER_OP (UINT16) 0x94 +#define AML_LLESS_OP (UINT16) 0x95 +#define AML_BUFF_OP (UINT16) 0x96 /* ACPI 2.0 */ +#define AML_DEC_STR_OP (UINT16) 0x97 /* ACPI 2.0 */ +#define AML_HEX_STR_OP (UINT16) 0x98 /* ACPI 2.0 */ +#define AML_INT_OP (UINT16) 0x99 /* ACPI 2.0 */ +#define AML_COPY_OP (UINT16) 0x9d /* ACPI 2.0 */ +#define AML_MID_OP (UINT16) 0x9e /* ACPI 2.0 */ +#define AML_CONTINUE_OP (UINT16) 0x9f /* ACPI 2.0 */ +#define AML_IF_OP (UINT16) 0xa0 +#define AML_ELSE_OP (UINT16) 0xa1 +#define AML_WHILE_OP (UINT16) 0xa2 +#define AML_NOOP_OP (UINT16) 0xa3 +#define AML_RETURN_OP (UINT16) 0xa4 +#define AML_BREAK_OP (UINT16) 0xa5 +#define AML_BREAK_POINT_OP (UINT16) 0xcc +#define AML_ONES_OP (UINT16) 0xff + +/* prefixed opcodes */ + +#define AML_EXTOP (UINT16) 0x005b + + +#define AML_MUTEX_OP (UINT16) 0x5b01 +#define AML_EVENT_OP (UINT16) 0x5b02 +#define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10 +#define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11 +#define AML_COND_REF_OF_OP (UINT16) 0x5b12 +#define AML_CREATE_FIELD_OP (UINT16) 0x5b13 +#define AML_LOAD_TABLE_OP (UINT16) 0x5b1f /* ACPI 2.0 */ +#define AML_LOAD_OP (UINT16) 0x5b20 +#define AML_STALL_OP (UINT16) 0x5b21 +#define AML_SLEEP_OP (UINT16) 0x5b22 +#define AML_ACQUIRE_OP (UINT16) 0x5b23 +#define AML_SIGNAL_OP (UINT16) 0x5b24 +#define AML_WAIT_OP (UINT16) 0x5b25 +#define AML_RESET_OP (UINT16) 0x5b26 +#define AML_RELEASE_OP (UINT16) 0x5b27 +#define AML_FROM_BCD_OP (UINT16) 0x5b28 +#define AML_TO_BCD_OP (UINT16) 0x5b29 +#define AML_UNLOAD_OP (UINT16) 0x5b2a +#define AML_REVISION_OP (UINT16) 0x5b30 +#define AML_DEBUG_OP (UINT16) 0x5b31 +#define AML_FATAL_OP (UINT16) 0x5b32 +#define AML_REGION_OP (UINT16) 0x5b80 +#define AML_DEF_FIELD_OP (UINT16) 0x5b81 +#define AML_DEVICE_OP (UINT16) 0x5b82 +#define AML_PROCESSOR_OP (UINT16) 0x5b83 +#define AML_POWER_RES_OP (UINT16) 0x5b84 +#define AML_THERMAL_ZONE_OP (UINT16) 0x5b85 +#define AML_INDEX_FIELD_OP (UINT16) 0x5b86 +#define AML_BANK_FIELD_OP (UINT16) 0x5b87 +#define AML_DATA_REGION_OP (UINT16) 0x5b88 /* ACPI 2.0 */ + + +/* Bogus opcodes (they are actually two separate opcodes) */ + +#define AML_LGREATEREQUAL_OP (UINT16) 0x9295 +#define AML_LLESSEQUAL_OP (UINT16) 0x9294 +#define AML_LNOTEQUAL_OP (UINT16) 0x9293 + + +/* + * Internal opcodes + * Use only "Unknown" AML opcodes, don't attempt to use + * any valid ACPI ASCII values (A-Z, 0-9, '-') + */ + +#define AML_NAMEPATH_OP (UINT16) 0x002d +#define AML_NAMEDFIELD_OP (UINT16) 0x0030 +#define AML_RESERVEDFIELD_OP (UINT16) 0x0031 +#define AML_ACCESSFIELD_OP (UINT16) 0x0032 +#define AML_BYTELIST_OP (UINT16) 0x0033 +#define AML_STATICSTRING_OP (UINT16) 0x0034 +#define AML_METHODCALL_OP (UINT16) 0x0035 +#define AML_RETURN_VALUE_OP (UINT16) 0x0036 + + +#define ARG_NONE 0x0 + +/* + * Argument types for the AML Parser + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + */ + +#define ARGP_BYTEDATA 0x01 +#define ARGP_BYTELIST 0x02 +#define ARGP_CHARLIST 0x03 +#define ARGP_DATAOBJ 0x04 +#define ARGP_DATAOBJLIST 0x05 +#define ARGP_DWORDDATA 0x06 +#define ARGP_FIELDLIST 0x07 +#define ARGP_NAME 0x08 +#define ARGP_NAMESTRING 0x09 +#define ARGP_OBJLIST 0x0A +#define ARGP_PKGLENGTH 0x0B +#define ARGP_SUPERNAME 0x0C +#define ARGP_TARGET 0x0D +#define ARGP_TERMARG 0x0E +#define ARGP_TERMLIST 0x0F +#define ARGP_WORDDATA 0x10 + +/* + * Resolved argument types for the AML Interpreter + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + */ + +#define ARGI_ANYTYPE 0x01 +#define ARGI_TARGETREF 0x02 +#define ARGI_REFERENCE 0x03 +#define ARGI_IF 0x04 +#define ARGI_NUMBER 0x05 +#define ARGI_STRING 0x06 +#define ARGI_BUFFER 0x07 +#define ARGI_PACKAGE 0x08 +#define ARGI_DATAOBJECT 0x09 /* Buffer, string, package or reference to a Node - Used only by SizeOf operator*/ +#define ARGI_COMPLEXOBJ 0x0A /* Buffer or package */ +#define ARGI_MUTEX 0x0B +#define ARGI_EVENT 0x0C +#define ARGI_REGION 0x0D +#define ARGI_DDBHANDLE 0x0E + +#define ARGI_INVALID_OPCODE 0xFFFFFFFF + + +/* + * hash offsets + */ +#define AML_EXTOP_HASH_OFFSET 22 +#define AML_LNOT_HASH_OFFSET 19 + + +/* + * opcode groups and types + */ + +#define OPGRP_NAMED 0x01 +#define OPGRP_FIELD 0x02 +#define OPGRP_BYTELIST 0x04 + +#define OPTYPE_UNDEFINED 0 + + +#define OPTYPE_LITERAL 1 +#define OPTYPE_CONSTANT 2 +#define OPTYPE_METHOD_ARGUMENT 3 +#define OPTYPE_LOCAL_VARIABLE 4 +#define OPTYPE_DATA_TERM 5 + +/* Type 1 opcodes */ + +#define OPTYPE_MONADIC1 6 +#define OPTYPE_DYADIC1 7 + + +/* Type 2 opcodes */ + +#define OPTYPE_MONADIC2 8 +#define OPTYPE_MONADIC2R 9 +#define OPTYPE_DYADIC2 10 +#define OPTYPE_DYADIC2R 11 +#define OPTYPE_DYADIC2S 12 +#define OPTYPE_INDEX 13 +#define OPTYPE_MATCH 14 + +/* Generic for an op that returns a value */ + +#define OPTYPE_METHOD_CALL 15 + + +/* Misc */ + +#define OPTYPE_CREATE_FIELD 16 +#define OPTYPE_FATAL 17 +#define OPTYPE_CONTROL 18 +#define OPTYPE_RECONFIGURATION 19 +#define OPTYPE_NAMED_OBJECT 20 +#define OPTYPE_RETURN 21 + +#define OPTYPE_BOGUS 22 + + +/* Predefined Operation Region SpaceIDs */ + +typedef enum +{ + REGION_MEMORY = 0, + REGION_IO, + REGION_PCI_CONFIG, + REGION_EC, + REGION_SMBUS, + REGION_CMOS, + REGION_PCI_BAR + +} AML_REGION_TYPES; + + +/* Comparison operation codes for MatchOp operator */ + +typedef enum +{ + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5 + +} AML_MATCH_OPERATOR; + +#define MAX_MATCH_OPERATOR 5 + + +/* Field Access Types */ + +#define ACCESS_TYPE_MASK 0x0f +#define ACCESS_TYPE_SHIFT 0 + +typedef enum +{ + ACCESS_ANY_ACC = 0, + ACCESS_BYTE_ACC = 1, + ACCESS_WORD_ACC = 2, + ACCESS_DWORD_ACC = 3, + ACCESS_BLOCK_ACC = 4, + ACCESS_SMBSEND_RECV_ACC = 5, + ACCESS_SMBQUICK_ACC = 6 + +} AML_ACCESS_TYPE; + + +/* Field Lock Rules */ + +#define LOCK_RULE_MASK 0x10 +#define LOCK_RULE_SHIFT 4 + +typedef enum +{ + GLOCK_NEVER_LOCK = 0, + GLOCK_ALWAYS_LOCK = 1 + +} AML_LOCK_RULE; + + +/* Field Update Rules */ + +#define UPDATE_RULE_MASK 0x060 +#define UPDATE_RULE_SHIFT 5 + +typedef enum +{ + UPDATE_PRESERVE = 0, + UPDATE_WRITE_AS_ONES = 1, + UPDATE_WRITE_AS_ZEROS = 2 + +} AML_UPDATE_RULE; + + +/* bit fields in MethodFlags byte */ + +#define METHOD_FLAGS_ARG_COUNT 0x07 +#define METHOD_FLAGS_SERIALIZED 0x08 + + +/* Array sizes. Used for range checking also */ + +#define NUM_REGION_TYPES 5 +#define NUM_ACCESS_TYPES 7 +#define NUM_UPDATE_RULES 3 +#define NUM_MATCH_OPS 7 +#define NUM_OPCODES 256 +#define NUM_FIELD_NAMES 2 + +/* External declarations of the AML tables */ + +extern UINT8 AcpiGbl_Aml [NUM_OPCODES]; +extern UINT16 AcpiGbl_Pfx [NUM_OPCODES]; +extern NATIVE_CHAR *AcpiGbl_RegionTypes [NUM_REGION_TYPES]; +extern NATIVE_CHAR *AcpiGbl_MatchOps [NUM_MATCH_OPS]; +extern NATIVE_CHAR *AcpiGbl_AccessTypes [NUM_ACCESS_TYPES]; +extern NATIVE_CHAR *AcpiGbl_UpdateRules [NUM_UPDATE_RULES]; +extern NATIVE_CHAR *AcpiGbl_FENames [NUM_FIELD_NAMES]; + + +/* + * AML tables + */ + +#ifdef DEFINE_AML_GLOBALS + +/* Data used in keeping track of fields */ + +NATIVE_CHAR *AcpiGbl_FENames[NUM_FIELD_NAMES] = +{ + "skip", + "?access?" +}; /* FE = Field Element */ + + +/* Region type decoding */ + +NATIVE_CHAR *AcpiGbl_RegionTypes[NUM_REGION_TYPES] = +{ + "SystemMemory", + "SystemIO", + "PCIConfig", + "EmbeddedControl", + "SMBus" +}; + + +NATIVE_CHAR *AcpiGbl_MatchOps[NUM_MATCH_OPS] = +{ + "Error", + "MTR", + "MEQ", + "MLE", + "MLT", + "MGE", + "MGT" +}; + + +/* Access type decoding */ + +NATIVE_CHAR *AcpiGbl_AccessTypes[NUM_ACCESS_TYPES] = +{ + "AnyAcc", + "ByteAcc", + "WordAcc", + "DWordAcc", + "BlockAcc", + "SMBSendRecvAcc", + "SMBQuickAcc" +}; + + +/* Update rule decoding */ + +NATIVE_CHAR *AcpiGbl_UpdateRules[NUM_UPDATE_RULES] = +{ + "Preserve", + "WriteAsOnes", + "WriteAsZeros" +}; + + +#endif /* DEFINE_AML_GLOBALS */ + +#endif /* __AMLCODE_H__ */ diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c new file mode 100644 index 0000000..835bc76 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amconfig.c @@ -0,0 +1,433 @@ +/****************************************************************************** + * + * Module Name: amconfig - Namespace reconfiguration (Load/Unload opcodes) + * $Revision: 24 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMCONFIG_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amconfig") + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecLoadTable + * + * PARAMETERS: RgnDesc - Op region where the table will be obtained + * DdbHandle - Where a handle to the table will be returned + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecLoadTable ( + ACPI_OPERAND_OBJECT *RgnDesc, + ACPI_HANDLE *DdbHandle) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *TableDesc = NULL; + UINT8 *TablePtr; + UINT8 *TableDataPtr; + ACPI_TABLE_HEADER TableHeader; + ACPI_TABLE_DESC TableInfo; + UINT32 i; + + + FUNCTION_TRACE ("AmlExecLoadTable"); + + /* TBD: [Unhandled] Object can be either a field or an opregion */ + + + /* Get the table header */ + + TableHeader.Length = 0; + for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) + { + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, + i, 8, (UINT32 *) ((UINT8 *) &TableHeader + i)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Allocate a buffer for the entire table */ + + TablePtr = AcpiCmAllocate (TableHeader.Length); + if (!TablePtr) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the header to the buffer */ + + MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + TableDataPtr = TablePtr + sizeof (ACPI_TABLE_HEADER); + + + /* Get the table from the op region */ + + for (i = 0; i < TableHeader.Length; i++) + { + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, + i, 8, (UINT32 *) (TableDataPtr + i)); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + + /* Table must be either an SSDT or a PSDT */ + + if ((!STRNCMP (TableHeader.Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].SigLength)) && + (!STRNCMP (TableHeader.Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].SigLength))) + { + DEBUG_PRINT (ACPI_ERROR, + ("Table has invalid signature [%4.4s], must be SSDT or PSDT\n", + TableHeader.Signature)); + Status = AE_BAD_SIGNATURE; + goto Cleanup; + } + + /* Create an object to be the table handle */ + + TableDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!TableDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + + /* Install the new table into the local data structures */ + + TableInfo.Pointer = (ACPI_TABLE_HEADER *) TablePtr; + TableInfo.Length = TableHeader.Length; + TableInfo.Allocation = ACPI_MEM_ALLOCATED; + TableInfo.BasePointer = TablePtr; + + Status = AcpiTbInstallTable (NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Add the table to the namespace */ + + /* TBD: [Restructure] - change to whatever new interface is appropriate */ +/* + Status = AcpiLoadNamespace (); + if (ACPI_FAILURE (Status)) + { +*/ + /* TBD: [Errors] Unload the table on failure ? */ +/* + goto Cleanup; + } +*/ + + + /* TBD: [Investigate] we need a pointer to the table desc */ + + /* Init the table handle */ + + TableDesc->Reference.OpCode = AML_LOAD_OP; + TableDesc->Reference.Object = TableInfo.InstalledDesc; + + *DdbHandle = TableDesc; + + return_ACPI_STATUS (Status); + + +Cleanup: + + AcpiCmFree (TableDesc); + AcpiCmFree (TablePtr); + return_ACPI_STATUS (Status); + +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecUnloadTable + * + * PARAMETERS: DdbHandle - Handle to a previously loaded table + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecUnloadTable ( + ACPI_HANDLE DdbHandle) +{ + ACPI_STATUS Status = AE_NOT_IMPLEMENTED; + ACPI_OPERAND_OBJECT *TableDesc = (ACPI_OPERAND_OBJECT *) DdbHandle; + ACPI_TABLE_DESC *TableInfo; + + + FUNCTION_TRACE ("AmlExecUnloadTable"); + + + /* Validate the handle */ + /* Although the handle is partially validated in AcpiAmlExecReconfiguration(), + * when it calls AcpiAmlResolveOperands(), the handle is more completely + * validated here. + */ + + if ((!DdbHandle) || + (!VALID_DESCRIPTOR_TYPE (DdbHandle, ACPI_DESC_TYPE_INTERNAL)) || + (((ACPI_OPERAND_OBJECT *)DdbHandle)->Common.Type != + INTERNAL_TYPE_REFERENCE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get the actual table descriptor from the DdbHandle */ + + TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object; + + /* + * Delete the entire namespace under this table Node + * (Offset contains the TableId) + */ + + Status = AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Delete the table itself */ + + AcpiTbUninstallTable (TableInfo->InstalledDesc); + + /* Delete the table descriptor (DdbHandle) */ + + AcpiCmRemoveReference (TableDesc); + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecReconfiguration + * + * PARAMETERS: Opcode - The opcode to be executed + * WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Reconfiguration opcodes such as LOAD and UNLOAD + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecReconfiguration ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RegionDesc = NULL; + ACPI_HANDLE *DdbHandle; + + + FUNCTION_TRACE ("AmlExecReconfiguration"); + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get the table handle, common for both opcodes */ + + Status |= AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &DdbHandle, + WalkState); + + switch (Opcode) + { + + case AML_LOAD_OP: + + /* Get the region or field descriptor */ + + Status |= AcpiDsObjStackPopObject (&RegionDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecReconfiguration/AML_LOAD_OP: bad operand(s) (0x%X)\n", + Status)); + + AcpiCmRemoveReference (RegionDesc); + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlExecLoadTable (RegionDesc, DdbHandle); + break; + + + case AML_UNLOAD_OP: + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecReconfiguration/AML_UNLOAD_OP: bad operand(s) (0x%X)\n", + Status)); + + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlExecUnloadTable (DdbHandle); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, ("AmlExecReconfiguration: bad opcode=%X\n", + Opcode)); + + Status = AE_AML_BAD_OPCODE; + break; + } + + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c new file mode 100644 index 0000000..e1c93d9 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amcreate.c @@ -0,0 +1,1216 @@ +/****************************************************************************** + * + * Module Name: amcreate - Named object creation + * $Revision: 48 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMCREATE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amcreate") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecCreateField + * + * PARAMETERS: Opcode - The opcode to be executed + * Operands - List of operands for the opcode + * + * RETURN: Status + * + * DESCRIPTION: Execute CreateField operators: CreateBitFieldOp, + * CreateByteFieldOp, CreateWordFieldOp, CreateDWordFieldOp, + * CreateFieldOp (which define fields in buffers) + * + * ALLOCATION: Deletes CreateFieldOp's count operand descriptor + * + * + * ACPI SPECIFICATION REFERENCES: + * DefCreateBitField := CreateBitFieldOp SrcBuf BitIdx NameString + * DefCreateByteField := CreateByteFieldOp SrcBuf ByteIdx NameString + * DefCreateDWordField := CreateDWordFieldOp SrcBuf ByteIdx NameString + * DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString + * DefCreateWordField := CreateWordFieldOp SrcBuf ByteIdx NameString + * BitIndex := TermArg=>Integer + * ByteIndex := TermArg=>Integer + * NumBits := TermArg=>Integer + * SourceBuff := TermArg=>Buffer + * + ******************************************************************************/ + + +ACPI_STATUS +AcpiAmlExecCreateField ( + UINT8 *AmlPtr, + UINT32 AmlLength, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *TmpDesc; + + + FUNCTION_TRACE ("AmlExecCreateField"); + + + /* Create the region descriptor */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Construct the field object */ + + ObjDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC; + ObjDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK; + ObjDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE; + + /* + * Allocate a method object for this field unit + */ + + ObjDesc->FieldUnit.Extra = AcpiCmCreateInternalObject ( + INTERNAL_TYPE_EXTRA); + if (!ObjDesc->FieldUnit.Extra) + { + 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. + */ + + ObjDesc->FieldUnit.Extra->Extra.Pcode = AmlPtr; + ObjDesc->FieldUnit.Extra->Extra.PcodeLength = AmlLength; + ObjDesc->FieldUnit.Node = Node; + + +/* + Status = AcpiNsAttachObject (Node, ObjDesc, + (UINT8) ACPI_TYPE_FIELD_UNIT); + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } +*/ + + /* + * This operation is supposed to cause the destination Name to refer + * to the defined FieldUnit -- it must not store the constructed + * FieldUnit object (or its current value) in some location that the + * Name may already be pointing to. So, if the Name currently contains + * a reference which would cause AcpiAmlExecStore() to perform an indirect + * store rather than setting the value of the Name itself, clobber that + * reference before calling AcpiAmlExecStore(). + */ + + /* Type of Name's existing value */ + + switch (AcpiNsGetType (Node)) + { + + case ACPI_TYPE_FIELD_UNIT: + + case INTERNAL_TYPE_ALIAS: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_DEF_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + + TmpDesc = AcpiNsGetAttachedObject (Node); + if (TmpDesc) + { + /* + * There is an existing object here; delete it and zero out the + * object field within the Node + */ + + DUMP_PATHNAME (Node, + "AmlExecCreateField: Removing Current Reference", + TRACE_BFIELD, _COMPONENT); + + DUMP_ENTRY (Node, TRACE_BFIELD); + DUMP_STACK_ENTRY (TmpDesc); + + AcpiCmRemoveReference (TmpDesc); + AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Node, NULL, + ACPI_TYPE_ANY); + } + + /* Set the type to ANY (or the store below will fail) */ + + ((ACPI_NAMESPACE_NODE *) Node)->Type = ACPI_TYPE_ANY; + + break; + + + default: + + break; + } + + + /* Store constructed field descriptor in result location */ + + Status = AcpiAmlExecStore (ObjDesc, (ACPI_OPERAND_OBJECT *) Node, WalkState); + + /* + * If the field descriptor was not physically stored (or if a failure + * above), we must delete it + */ + if (ObjDesc->Common.ReferenceCount <= 1) + { + AcpiCmRemoveReference (ObjDesc); + } + + + return_ACPI_STATUS (AE_OK); + + +Cleanup: + + /* Delete region object and method subobject */ + + if (ObjDesc) + { + /* Remove deletes both objects! */ + + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + + return_ACPI_STATUS (Status); +} + + +ACPI_STATUS +AcpiAmlExecCreateField_original ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ResDesc = NULL; + ACPI_OPERAND_OBJECT *CntDesc = NULL; + ACPI_OPERAND_OBJECT *OffDesc = NULL; + ACPI_OPERAND_OBJECT *SrcDesc = NULL; + ACPI_OPERAND_OBJECT *FieldDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + OBJECT_TYPE_INTERNAL ResType; + ACPI_STATUS Status; + UINT32 NumOperands = 3; + UINT32 Offset; + UINT32 BitOffset; + UINT16 BitCount; + UINT8 TypeFound; + + + FUNCTION_TRACE ("AmlExecCreateField"); + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + NumOperands, "after AcpiAmlResolveOperands"); + + + /* Get the operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + if (AML_CREATE_FIELD_OP == Opcode) + { + NumOperands = 4; + Status |= AcpiDsObjStackPopObject (&CntDesc, WalkState); + } + + Status |= AcpiDsObjStackPopObject (&OffDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&SrcDesc, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecCreateField/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + Offset = (UINT32) OffDesc->Number.Value; + + + /* + * If ResDesc is a Name, it will be a direct name pointer after + * AcpiAmlResolveOperands() + */ + + if (!VALID_DESCRIPTOR_TYPE (ResDesc, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField (%s): destination must be a Node\n", + AcpiPsGetOpcodeName (Opcode))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + + switch (Opcode) + { + + /* DefCreateBitField */ + + case AML_BIT_FIELD_OP: + + /* Offset is in bits, Field is a bit */ + + BitOffset = Offset; + BitCount = 1; + break; + + + /* DefCreateByteField */ + + case AML_BYTE_FIELD_OP: + + /* Offset is in bytes, field is a byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + break; + + + /* DefCreateWordField */ + + case AML_WORD_FIELD_OP: + + /* Offset is in bytes, field is a word */ + + BitOffset = 8 * Offset; + BitCount = 16; + break; + + + /* DefCreateDWordField */ + + case AML_DWORD_FIELD_OP: + + /* Offset is in bytes, field is a dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + break; + + + /* DefCreateField */ + + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + BitOffset = Offset; + BitCount = (UINT16) CntDesc->Number.Value; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Internal error - unknown field creation opcode %02x\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Setup field according to the object type + */ + + switch (SrcDesc->Common.Type) + { + + /* SourceBuff := TermArg=>Buffer */ + + case ACPI_TYPE_BUFFER: + + if (BitOffset + (UINT32) BitCount > + (8 * (UINT32) SrcDesc->Buffer.Length)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Field exceeds Buffer %d > %d\n", + BitOffset + (UINT32) BitCount, + 8 * (UINT32) SrcDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + + /* Allocate an object for the field */ + + FieldDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT); + if (!FieldDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Construct the field object */ + + FieldDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC; + FieldDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK; + FieldDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE; + FieldDesc->FieldUnit.Length = BitCount; + FieldDesc->FieldUnit.BitOffset = (UINT8) (BitOffset % 8); + FieldDesc->FieldUnit.Offset = DIV_8 (BitOffset); + FieldDesc->FieldUnit.Container = SrcDesc; + + /* An additional reference for SrcDesc */ + + AcpiCmAddReference (SrcDesc); + + break; + + + /* Improper object type */ + + default: + + TypeFound = SrcDesc->Common.Type; + + if ((TypeFound > (UINT8) INTERNAL_TYPE_REFERENCE) || + !AcpiCmValidObjectType (TypeFound)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in invalid object type - 0x%X\n", + TypeFound)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in improper object type - %s\n", + AcpiCmGetTypeName (TypeFound))); + } + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + if (AML_CREATE_FIELD_OP == Opcode) + { + /* Delete object descriptor unique to CreateField */ + + AcpiCmRemoveReference (CntDesc); + CntDesc = NULL; + } + + /* + * This operation is supposed to cause the destination Name to refer + * to the defined FieldUnit -- it must not store the constructed + * FieldUnit object (or its current value) in some location that the + * Name may already be pointing to. So, if the Name currently contains + * a reference which would cause AcpiAmlExecStore() to perform an indirect + * store rather than setting the value of the Name itself, clobber that + * reference before calling AcpiAmlExecStore(). + */ + + ResType = AcpiNsGetType (ResDesc); + + /* Type of Name's existing value */ + + switch (ResType) + { + + case ACPI_TYPE_FIELD_UNIT: + + case INTERNAL_TYPE_ALIAS: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_DEF_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + + ObjDesc = AcpiNsGetAttachedObject (ResDesc); + if (ObjDesc) + { + /* + * There is an existing object here; delete it and zero out the + * object field within the Node + */ + + DUMP_PATHNAME (ResDesc, + "AmlExecCreateField: Removing Current Reference", + TRACE_BFIELD, _COMPONENT); + + DUMP_ENTRY (ResDesc, TRACE_BFIELD); + DUMP_STACK_ENTRY (ObjDesc); + + AcpiCmRemoveReference (ObjDesc); + AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) ResDesc, NULL, + ACPI_TYPE_ANY); + } + + /* Set the type to ANY (or the store below will fail) */ + + ((ACPI_NAMESPACE_NODE *) ResDesc)->Type = ACPI_TYPE_ANY; + + break; + + + default: + + break; + } + + + /* Store constructed field descriptor in result location */ + + Status = AcpiAmlExecStore (FieldDesc, ResDesc, WalkState); + + /* + * If the field descriptor was not physically stored (or if a failure + * above), we must delete it + */ + if (FieldDesc->Common.ReferenceCount <= 1) + { + AcpiCmRemoveReference (FieldDesc); + } + + +Cleanup: + + /* Always delete the operands */ + + AcpiCmRemoveReference (OffDesc); + AcpiCmRemoveReference (SrcDesc); + + if (AML_CREATE_FIELD_OP == Opcode) + { + AcpiCmRemoveReference (CntDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); /* Result descriptor */ + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateAlias + * + * PARAMETERS: Operands - List of operands for the opcode + * + * RETURN: Status + * + * DESCRIPTION: Create a new named alias + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateAlias ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_NAMESPACE_NODE *SourceNode; + ACPI_NAMESPACE_NODE *AliasNode; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecCreateAlias"); + + + /* Get the source/alias operands (both NTEs) */ + + Status = AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &SourceNode, + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Don't pop it, it gets removed in the calling routine + */ + + AliasNode = AcpiDsObjStackGetValue (0, WalkState); + + /* Add an additional reference to the object */ + + AcpiCmAddReference (SourceNode->Object); + + /* + * Attach the original source Node to the new Alias Node. + */ + Status = AcpiNsAttachObject (AliasNode, SourceNode->Object, + SourceNode->Type); + + + /* + * The new alias assumes the type of the source, but it points + * to the same object. The reference count of the object has two + * additional references to prevent deletion out from under either the + * source or the alias Node + */ + + /* Since both operands are NTEs, we don't need to delete them */ + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateEvent + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a new event object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateEvent ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("AmlExecCreateEvent"); + + + BREAKPOINT3; + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_EVENT); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS semaphore */ + + /* TBD: [Investigate] should be created with 0 or 1 units? */ + + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 1, + &ObjDesc->Event.Semaphore); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + /* Attach object to the Node */ + + Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), + ObjDesc, (UINT8) ACPI_TYPE_EVENT); + if (ACPI_FAILURE (Status)) + { + AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore); + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateMutex + * + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) + * Operands - List of operands for the opcode + * + * RETURN: Status + * + * DESCRIPTION: Create a new mutex object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateMutex ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *SyncDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("AmlExecCreateMutex", WALK_OPERANDS); + + + /* Get the operand */ + + Status = AcpiDsObjStackPopObject (&SyncDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Attempt to allocate a new object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_MUTEX); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS semaphore */ + + Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Number.Value; + + /* ObjDesc was on the stack top, and the name is below it */ + + Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), + ObjDesc, (UINT8) ACPI_TYPE_MUTEX); + if (ACPI_FAILURE (Status)) + { + AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore); + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + +Cleanup: + + /* Always delete the operand */ + + AcpiCmRemoveReference (SyncDesc); + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateRegion + * + * PARAMETERS: AmlPtr - Pointer to the region declaration AML + * AmlLength - Max length of the declaration AML + * Operands - List of operands for the opcode + * InterpreterMode - Load1/Load2/Execute + * + * RETURN: Status + * + * DESCRIPTION: Create a new operation region object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateRegion ( + UINT8 *AmlPtr, + UINT32 AmlLength, + UINT32 RegionSpace, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + FUNCTION_TRACE ("AmlExecCreateRegion"); + + + if (RegionSpace >= NUM_REGION_TYPES) + { + /* TBD: [Future] In ACPI 2.0, valid region space + * includes types 0-6 (Adding CMOS and PCIBARTarget). + * Also, types 0x80-0xff are defined as "OEM Region + * Space handler" + * + * Should this return an error, or should we just keep + * going? How do we handle the OEM region handlers? + */ + REPORT_WARNING (("Invalid AddressSpace type %X\n", RegionSpace)); + } + + DEBUG_PRINT (TRACE_LOAD, ("AmlDoNode: Region Type [%s]\n", + AcpiGbl_RegionTypes[RegionSpace])); + + + /* Get the Node from the object stack */ + + Node = (ACPI_NAMESPACE_NODE *) AcpiDsObjStackGetValue (0, WalkState); + + /* Create the region descriptor */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_REGION); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Allocate a method object for this region. + */ + + ObjDesc->Region.Extra = AcpiCmCreateInternalObject ( + INTERNAL_TYPE_EXTRA); + if (!ObjDesc->Region.Extra) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of address & length + * operands since they need to be evaluated at run time. + */ + + ObjDesc->Region.Extra->Extra.Pcode = AmlPtr; + ObjDesc->Region.Extra->Extra.PcodeLength = AmlLength; + + /* Init the region from the operands */ + + ObjDesc->Region.SpaceId = (UINT8) RegionSpace; + ObjDesc->Region.Address = 0; + ObjDesc->Region.Length = 0; + + + /* Install the new region object in the parent Node */ + + ObjDesc->Region.Node = Node; + + Status = AcpiNsAttachObject (Node, ObjDesc, + (UINT8) ACPI_TYPE_REGION); + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * If we have a valid region, initialize it + * Namespace is NOT locked at this point. + */ + + Status = AcpiEvInitializeRegion (ObjDesc, FALSE); + + if (ACPI_FAILURE (Status)) + { + /* + * If AE_NOT_EXIST is returned, it is not fatal + * because many regions get created before a handler + * is installed for said region. + */ + if (AE_NOT_EXIST == Status) + { + Status = AE_OK; + } + } + +Cleanup: + + if (ACPI_FAILURE (Status)) + { + /* Delete region object and method subobject */ + + if (ObjDesc) + { + /* Remove deletes both objects! */ + + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateProcessor + * + * PARAMETERS: Op - Op containing the Processor definition and + * args + * ProcessorNTE - Node for the containing Node + * + * RETURN: Status + * + * DESCRIPTION: Create a new processor object and populate the fields + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateProcessor ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE ProcessorNTE) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("AmlExecCreateProcessor", Op); + + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_PROCESSOR); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + return_ACPI_STATUS (Status); + } + + /* Install the new processor object in the parent Node */ + + Status = AcpiNsAttachObject (ProcessorNTE, ObjDesc, + (UINT8) ACPI_TYPE_PROCESSOR); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS(Status); + } + + Arg = Op->Value.Arg; + + /* check existence */ + + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* First arg is the Processor ID */ + + ObjDesc->Processor.ProcId = (UINT8) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Second arg is the PBlock Address */ + + ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Third arg is the PBlock Length */ + + ObjDesc->Processor.Length = (UINT8) Arg->Value.Integer; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreatePowerResource + * + * PARAMETERS: Op - Op containing the PowerResource definition + * and args + * PowerResNTE - Node for the containing Node + * + * RETURN: Status + * + * DESCRIPTION: Create a new PowerResource object and populate the fields + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreatePowerResource ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE PowerResNTE) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("AmlExecCreatePowerResource", Op); + + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_POWER); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + return_ACPI_STATUS (Status); + } + + /* Install the new power resource object in the parent Node */ + + Status = AcpiNsAttachObject (PowerResNTE, ObjDesc, + (UINT8) ACPI_TYPE_POWER); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS(Status); + } + + Arg = Op->Value.Arg; + + /* check existence */ + + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* First arg is the SystemLevel */ + + ObjDesc->PowerResource.SystemLevel = (UINT8) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Second arg is the PBlock Address */ + + ObjDesc->PowerResource.ResourceOrder = (UINT16) Arg->Value.Integer; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateMethod + * + * PARAMETERS: AmlPtr - First byte of the method's AML + * AmlLength - AML byte count for this method + * MethodFlags - AML method flag byte + * Method - Method Node + * + * RETURN: Status + * + * DESCRIPTION: Create a new method object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateMethod ( + UINT8 *AmlPtr, + UINT32 AmlLength, + UINT32 MethodFlags, + ACPI_HANDLE Method) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("AmlExecCreateMethod", Method); + + + /* Create a new method object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_METHOD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Get the method's AML pointer/length from the Op */ + + ObjDesc->Method.Pcode = AmlPtr; + ObjDesc->Method.PcodeLength = AmlLength; + + /* + * First argument is the Method Flags (contains parameter count for the + * method) + */ + + ObjDesc->Method.MethodFlags = (UINT8) MethodFlags; + ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & + METHOD_FLAGS_ARG_COUNT); + + /* + * Get the concurrency count. If required, a semaphore will be + * created for this method when it is parsed. + * + * TBD: [Future] for APCI 2.0, there will be a SyncLevel value, not + * just a flag + * Concurrency = SyncLevel + 1;. + */ + + if (MethodFlags & METHOD_FLAGS_SERIALIZED) + { + ObjDesc->Method.Concurrency = 1; + } + + else + { + ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; + } + + /* Attach the new object to the method Node */ + + Status = AcpiNsAttachObject (Method, ObjDesc, (UINT8) ACPI_TYPE_METHOD); + if (ACPI_FAILURE (Status)) + { + AcpiCmDeleteObjectDesc (ObjDesc); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c new file mode 100644 index 0000000..a3662d7 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdump.c @@ -0,0 +1,992 @@ +/****************************************************************************** + * + * Module Name: amdump - Interpreter debug output routines + * $Revision: 94 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMDUMP_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amdump") + + +/* + * The following routines are used for debug output only + */ + +#ifdef ACPI_DEBUG + +/***************************************************************************** + * + * FUNCTION: AcpiAmlShowHexValue + * + * PARAMETERS: ByteCount - Number of bytes to print (1, 2, or 4) + * *AmlPtr - Address in AML stream of bytes to print + * InterpreterMode - Current running mode (load1/Load2/Exec) + * LeadSpace - # of spaces to print ahead of value + * 0 => none ahead but one behind + * + * DESCRIPTION: Print ByteCount byte(s) starting at AcpiAmlPtr as a single + * value, in hex. If ByteCount > 1 or the value printed is > 9, also + * print in decimal. + * + ****************************************************************************/ + +void +AcpiAmlShowHexValue ( + UINT32 ByteCount, + UINT8 *AmlPtr, + UINT32 LeadSpace) +{ + UINT32 Value; /* Value retrieved from AML stream */ + UINT32 ShowDecimalValue; + UINT32 Length; /* Length of printed field */ + UINT8 *CurrentAmlPtr = NULL; /* Pointer to current byte of AML value */ + + + FUNCTION_TRACE ("AmlShowHexValue"); + + + if (!AmlPtr) + { + REPORT_ERROR (("AmlShowHexValue: null pointer\n")); + } + + /* + * AML numbers are always stored little-endian, + * even if the processor is big-endian. + */ + for (CurrentAmlPtr = AmlPtr + ByteCount, + Value = 0; + CurrentAmlPtr > AmlPtr; ) + { + Value = (Value << 8) + (UINT32)* --CurrentAmlPtr; + } + + Length = LeadSpace * ByteCount + 2; + if (ByteCount > 1) + { + Length += (ByteCount - 1); + } + + ShowDecimalValue = (ByteCount > 1 || Value > 9); + if (ShowDecimalValue) + { + Length += 3 + AcpiAmlDigitsNeeded (Value, 10); + } + + DEBUG_PRINT (TRACE_LOAD, ("")); + + for (Length = LeadSpace; Length; --Length ) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" ")); + } + + while (ByteCount--) + { + DEBUG_PRINT_RAW (TRACE_LOAD, ("%02x", *AmlPtr++)); + + if (ByteCount) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" ")); + } + } + + if (ShowDecimalValue) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" [%ld]", Value)); + } + + if (0 == LeadSpace) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" ")); + } + + DEBUG_PRINT_RAW (TRACE_LOAD, ("\n")); + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpOperand + * + * PARAMETERS: *EntryDesc - Pointer to entry to be dumped + * + * RETURN: Status + * + * DESCRIPTION: Dump a stack entry + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlDumpOperand ( + ACPI_OPERAND_OBJECT *EntryDesc) +{ + UINT8 *Buf = NULL; + UINT32 Length; + UINT32 i; + + + if (!EntryDesc) + { + /* + * This usually indicates that something serious is wrong -- + * since most (if not all) + * code that dumps the stack expects something to be there! + */ + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: *** Possible error: Null stack entry ptr\n")); + return (AE_OK); + } + + if (VALID_DESCRIPTOR_TYPE (EntryDesc, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: Node: \n")); + DUMP_ENTRY (EntryDesc, ACPI_INFO); + return (AE_OK); + } + + if (AcpiTbSystemTablePointer (EntryDesc)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: %p is a Pcode pointer\n", + EntryDesc)); + return (AE_OK); + } + + if (!VALID_DESCRIPTOR_TYPE (EntryDesc, ACPI_DESC_TYPE_INTERNAL)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: %p Not a local object \n", EntryDesc)); + DUMP_BUFFER (EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + return (AE_OK); + } + + /* EntryDesc is a valid object */ + + DEBUG_PRINT (ACPI_INFO, ("AmlDumpOperand: %p ", EntryDesc)); + + switch (EntryDesc->Common.Type) + { + case INTERNAL_TYPE_REFERENCE: + + switch (EntryDesc->Reference.OpCode) + { + case AML_ZERO_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Zero\n")); + break; + + + case AML_ONE_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: One\n")); + break; + + + case AML_ONES_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Ones\n")); + break; + + + case AML_DEBUG_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Debug\n")); + break; + + + case AML_NAME_OP: + + DUMP_PATHNAME (EntryDesc->Reference.Object, "Reference: Name: ", + ACPI_INFO, _COMPONENT); + DUMP_ENTRY (EntryDesc->Reference.Object, ACPI_INFO); + break; + + + case AML_INDEX_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Index %p\n", + EntryDesc->Reference.Object)); + break; + + + case AML_ARG_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Arg%d", + EntryDesc->Reference.Offset)); + + if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type) + { + /* Value is a Number */ + + DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]", + EntryDesc->Number.Value)); + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + break; + + + case AML_LOCAL_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Local%d", + EntryDesc->Reference.Offset)); + + if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type) + { + + /* Value is a Number */ + + DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]", + EntryDesc->Number.Value)); + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + break; + + + case AML_NAMEPATH_OP: + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference.Node->Name %x\n", + EntryDesc->Reference.Node->Name)); + break; + + default: + + /* unknown opcode */ + + DEBUG_PRINT_RAW (ACPI_INFO, ("Unknown opcode=%X\n", + EntryDesc->Reference.OpCode)); + break; + + } + + break; + + + case ACPI_TYPE_BUFFER: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Buffer[%d] seq %lx @ %p \n", + EntryDesc->Buffer.Length, EntryDesc->Buffer.Sequence, + EntryDesc->Buffer.Pointer)); + + Length = EntryDesc->Buffer.Length; + + if (Length > 64) + { + Length = 64; + } + + /* Debug only -- dump the buffer contents */ + + if (EntryDesc->Buffer.Pointer) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("Buffer Contents: ")); + + for (Buf = EntryDesc->Buffer.Pointer; Length--; ++Buf) + { + DEBUG_PRINT_RAW (ACPI_INFO, + (Length ? " %02x" : " %02x", *Buf)); + } + DEBUG_PRINT_RAW (ACPI_INFO,("\n")); + } + + break; + + + case ACPI_TYPE_NUMBER: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Number 0x%lx\n", + EntryDesc->Number.Value)); + break; + + + case INTERNAL_TYPE_IF: + + DEBUG_PRINT_RAW (ACPI_INFO, ("If [Number] 0x%lx\n", + EntryDesc->Number.Value)); + break; + + + case INTERNAL_TYPE_WHILE: + + DEBUG_PRINT_RAW (ACPI_INFO, ("While [Number] 0x%lx\n", + EntryDesc->Number.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Package[%d] @ %p\n", + EntryDesc->Package.Count, EntryDesc->Package.Elements)); + + + /* + * If elements exist, package vector pointer is valid, + * and debug_level exceeds 1, dump package's elements. + */ + if (EntryDesc->Package.Count && + EntryDesc->Package.Elements && + GetDebugLevel () > 1) + { + ACPI_OPERAND_OBJECT**Element; + UINT16 ElementIndex; + + for (ElementIndex = 0, Element = EntryDesc->Package.Elements; + ElementIndex < EntryDesc->Package.Count; + ++ElementIndex, ++Element) + { + AcpiAmlDumpOperand (*Element); + } + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + + break; + + + case ACPI_TYPE_REGION: + + if (EntryDesc->Region.SpaceId >= NUM_REGION_TYPES) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("Region **** Unknown ID=0x%X", + EntryDesc->Region.SpaceId)); + } + else + { + DEBUG_PRINT_RAW (ACPI_INFO, ("Region %s", + AcpiGbl_RegionTypes[EntryDesc->Region.SpaceId])); + } + + /* + * If the address and length have not been evaluated, + * don't print them. + */ + if (!(EntryDesc->Region.Flags & AOPOBJ_DATA_VALID)) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + } + else + { + DEBUG_PRINT_RAW (ACPI_INFO, (" base %p Length 0x%X\n", + EntryDesc->Region.Address, EntryDesc->Region.Length)); + } + break; + + + case ACPI_TYPE_STRING: + + DEBUG_PRINT_RAW (ACPI_INFO, ("String[%d] @ %p\n\n", + EntryDesc->String.Length, EntryDesc->String.Pointer)); + + for (i=0; i < EntryDesc->String.Length; i++) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("%c", + EntryDesc->String.Pointer[i])); + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n\n")); + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + DEBUG_PRINT_RAW (ACPI_INFO, ("BankField\n")); + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + DEBUG_PRINT_RAW (ACPI_INFO, + ("DefField: bits=%d acc=%d lock=%d update=%d at byte=%lx bit=%d of below:\n", + EntryDesc->Field.Length, EntryDesc->Field.Access, + EntryDesc->Field.LockRule, EntryDesc->Field.UpdateRule, + EntryDesc->Field.Offset, EntryDesc->Field.BitOffset)); + DUMP_STACK_ENTRY (EntryDesc->Field.Container); + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + DEBUG_PRINT_RAW (ACPI_INFO, ("IndexField\n")); + break; + + + case ACPI_TYPE_FIELD_UNIT: + + DEBUG_PRINT_RAW (ACPI_INFO, + ("FieldUnit: %d bits acc %d lock %d update %d at byte %lx bit %d of \n", + EntryDesc->FieldUnit.Length, EntryDesc->FieldUnit.Access, + EntryDesc->FieldUnit.LockRule, EntryDesc->FieldUnit.UpdateRule, + EntryDesc->FieldUnit.Offset, EntryDesc->FieldUnit.BitOffset)); + + if (!EntryDesc->FieldUnit.Container) + { + DEBUG_PRINT (ACPI_INFO, ("*NULL* \n")); + } + + else if (ACPI_TYPE_BUFFER != + EntryDesc->FieldUnit.Container->Common.Type) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("*not a Buffer* \n")); + } + + else + { + DUMP_STACK_ENTRY (EntryDesc->FieldUnit.Container); + } + + break; + + + case ACPI_TYPE_EVENT: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Event\n")); + break; + + + case ACPI_TYPE_METHOD: + + DEBUG_PRINT_RAW (ACPI_INFO, + ("Method(%d) @ %p:%lx\n", + EntryDesc->Method.ParamCount, + EntryDesc->Method.Pcode, EntryDesc->Method.PcodeLength)); + break; + + + case ACPI_TYPE_MUTEX: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Mutex\n")); + break; + + + case ACPI_TYPE_DEVICE: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Device\n")); + break; + + + case ACPI_TYPE_POWER: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Power\n")); + break; + + + case ACPI_TYPE_PROCESSOR: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Processor\n")); + break; + + + case ACPI_TYPE_THERMAL: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Thermal\n")); + break; + + + default: + /* unknown EntryDesc->Common.Type value */ + + DEBUG_PRINT_RAW (ACPI_INFO, ("Unknown Type 0x%X\n", + EntryDesc->Common.Type)); + + /* Back up to previous entry */ + + EntryDesc--; + + + /* TBD: [Restructure] Change to use dump object routine !! */ + /* What is all of this?? */ + + DUMP_BUFFER (EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + DUMP_BUFFER (++EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + DUMP_BUFFER (++EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + break; + + } + + return (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpOperands + * + * PARAMETERS: InterpreterMode - Load or Exec + * *Ident - Identification + * NumLevels - # of stack entries to dump above line + * *Note - Output notation + * + * DESCRIPTION: Dump the object stack + * + ****************************************************************************/ + +void +AcpiAmlDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + OPERATING_MODE InterpreterMode, + NATIVE_CHAR *Ident, + UINT32 NumLevels, + NATIVE_CHAR *Note, + NATIVE_CHAR *ModuleName, + UINT32 LineNumber) +{ + NATIVE_UINT i; + ACPI_OPERAND_OBJECT **EntryDesc; + + + if (!Ident) + { + Ident = "?"; + } + + if (!Note) + { + Note = "?"; + } + + + DEBUG_PRINT (ACPI_INFO, + ("************* AcpiAmlDumpOperands Mode=%X ******************\n", + InterpreterMode)); + DEBUG_PRINT (ACPI_INFO, + ("From %12s(%d) %s: %s\n", ModuleName, LineNumber, Ident, Note)); + + if (NumLevels == 0) + NumLevels = 1; + + /* Dump the stack starting at the top, working down */ + + for (i = 0; NumLevels > 0; i--, NumLevels--) + { + EntryDesc = &Operands[i]; + + if (ACPI_FAILURE (AcpiAmlDumpOperand (*EntryDesc))) + { + break; + } + } + + return; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpNode + * + * PARAMETERS: *Node - Descriptor to dump + * Flags - Force display + * + * DESCRIPTION: Dumps the members of the given.Node + * + ****************************************************************************/ + +void +AcpiAmlDumpNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags) +{ + + if (!Flags) + { + if (!((TRACE_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + } + + + AcpiOsPrintf ("%20s : %4.4s\n", "Name", &Node->Name); + AcpiOsPrintf ("%20s : %s\n", "Type", AcpiCmGetTypeName (Node->Type)); + AcpiOsPrintf ("%20s : 0x%X\n", "Flags", Node->Flags); + AcpiOsPrintf ("%20s : 0x%X\n", "Owner Id", Node->OwnerId); + AcpiOsPrintf ("%20s : 0x%X\n", "Reference Count", Node->ReferenceCount); + AcpiOsPrintf ("%20s : 0x%p\n", "Attached Object", Node->Object); + AcpiOsPrintf ("%20s : 0x%p\n", "ChildList", Node->Child); + AcpiOsPrintf ("%20s : 0x%p\n", "NextPeer", Node->Peer); + AcpiOsPrintf ("%20s : 0x%p\n", "Parent", AcpiNsGetParentObject (Node)); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpObjectDescriptor + * + * PARAMETERS: *Object - Descriptor to dump + * Flags - Force display + * + * DESCRIPTION: Dumps the members of the object descriptor given. + * + ****************************************************************************/ + +void +AcpiAmlDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Flags) +{ + FUNCTION_TRACE ("AmlDumpObjectDescriptor"); + + + if (!Flags) + { + if (!((TRACE_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + } + + if (!(VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))) + { + AcpiOsPrintf ("0x%p is not a valid ACPI object\n", ObjDesc); + return; + } + + /* Common Fields */ + + AcpiOsPrintf ("%20s : 0x%X\n", "Reference Count", ObjDesc->Common.ReferenceCount); + AcpiOsPrintf ("%20s : 0x%X\n", "Flags", ObjDesc->Common.Flags); + + /* Object-specific Fields */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Number"); + AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->Number.Value); + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("%20s : %s\n", "Type", "String"); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->String.Length); + AcpiOsPrintf ("%20s : 0x%p\n", "Pointer", ObjDesc->String.Pointer); + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Buffer"); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Buffer.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "Sequence", ObjDesc->Buffer.Sequence); + AcpiOsPrintf ("%20s : 0x%p\n", "Pointer", ObjDesc->Buffer.Pointer); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Package"); + AcpiOsPrintf ("%20s : 0x%X\n", "Count", ObjDesc->Package.Count); + AcpiOsPrintf ("%20s : 0x%p\n", "Elements", ObjDesc->Package.Elements); + AcpiOsPrintf ("%20s : 0x%p\n", "NextElement", ObjDesc->Package.NextElement); + break; + + + case ACPI_TYPE_FIELD_UNIT: + + AcpiOsPrintf ("%20s : %s\n", "Type", "FieldUnit"); + AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->FieldUnit.Access); + AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->FieldUnit.LockRule); + AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->FieldUnit.UpdateRule); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->FieldUnit.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->FieldUnit.BitOffset); + AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->FieldUnit.Offset); + AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->FieldUnit.Container); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Device"); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Device.AddrHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->Device.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->Device.DrvHandler); + break; + + case ACPI_TYPE_EVENT: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Event"); + AcpiOsPrintf ("%20s : 0x%X\n", "Semaphore", ObjDesc->Event.Semaphore); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Method"); + AcpiOsPrintf ("%20s : 0x%X\n", "ParamCount", ObjDesc->Method.ParamCount); + AcpiOsPrintf ("%20s : 0x%X\n", "Concurrency", ObjDesc->Method.Concurrency); + AcpiOsPrintf ("%20s : 0x%p\n", "Semaphore", ObjDesc->Method.Semaphore); + AcpiOsPrintf ("%20s : 0x%X\n", "PcodeLength", ObjDesc->Method.PcodeLength); + AcpiOsPrintf ("%20s : 0x%X\n", "Pcode", ObjDesc->Method.Pcode); + break; + + + case ACPI_TYPE_MUTEX: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Mutex"); + AcpiOsPrintf ("%20s : 0x%X\n", "SyncLevel", ObjDesc->Mutex.SyncLevel); + AcpiOsPrintf ("%20s : 0x%p\n", "Semaphore", ObjDesc->Mutex.Semaphore); + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Region"); + AcpiOsPrintf ("%20s : 0x%X\n", "SpaceId", ObjDesc->Region.SpaceId); + AcpiOsPrintf ("%20s : 0x%X\n", "Flags", ObjDesc->Region.Flags); + AcpiOsPrintf ("%20s : 0x%X\n", "Address", ObjDesc->Region.Address); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Region.Length); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Region.AddrHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "Next", ObjDesc->Region.Next); + break; + + + case ACPI_TYPE_POWER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "PowerResource"); + AcpiOsPrintf ("%20s : 0x%X\n", "SystemLevel", ObjDesc->PowerResource.SystemLevel); + AcpiOsPrintf ("%20s : 0x%X\n", "ResourceOrder", ObjDesc->PowerResource.ResourceOrder); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->PowerResource.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->PowerResource.DrvHandler); + break; + + + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Processor"); + AcpiOsPrintf ("%20s : 0x%X\n", "Processor ID", ObjDesc->Processor.ProcId); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Processor.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "Address", ObjDesc->Processor.Address); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->Processor.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->Processor.DrvHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Processor.AddrHandler); + break; + + + case ACPI_TYPE_THERMAL: + + AcpiOsPrintf ("%20s : %s\n", "Type", "ThermalZone"); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->ThermalZone.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->ThermalZone.DrvHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->ThermalZone.AddrHandler); + break; + + case INTERNAL_TYPE_BANK_FIELD: + + AcpiOsPrintf ("%20s : %s\n", "Type", "BankField"); + AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->BankField.Access); + AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->BankField.LockRule); + AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->BankField.UpdateRule); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->BankField.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->BankField.BitOffset); + AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->BankField.Offset); + AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->BankField.Value); + AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->BankField.Container); + AcpiOsPrintf ("%20s : 0x%X\n", "BankSelect", ObjDesc->BankField.BankSelect); + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + AcpiOsPrintf ("%20s : %s\n", "Type", "IndexField"); + AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->IndexField.Access); + AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->IndexField.LockRule); + AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->IndexField.UpdateRule); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->IndexField.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->IndexField.BitOffset); + AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->IndexField.Value); + AcpiOsPrintf ("%20s : 0x%X\n", "Index", ObjDesc->IndexField.Index); + AcpiOsPrintf ("%20s : 0x%X\n", "Data", ObjDesc->IndexField.Data); + break; + + + case INTERNAL_TYPE_REFERENCE: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Reference"); + AcpiOsPrintf ("%20s : 0x%X\n", "TargetType", ObjDesc->Reference.TargetType); + AcpiOsPrintf ("%20s : 0x%X\n", "OpCode", ObjDesc->Reference.OpCode); + AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->Reference.Offset); + AcpiOsPrintf ("%20s : 0x%p\n", "ObjDesc", ObjDesc->Reference.Object); + AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->Reference.Node); + AcpiOsPrintf ("%20s : 0x%p\n", "Where", ObjDesc->Reference.Where); + break; + + + case INTERNAL_TYPE_ADDRESS_HANDLER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Address Handler"); + AcpiOsPrintf ("%20s : 0x%X\n", "SpaceId", ObjDesc->AddrHandler.SpaceId); + AcpiOsPrintf ("%20s : 0x%p\n", "Next", ObjDesc->AddrHandler.Next); + AcpiOsPrintf ("%20s : 0x%p\n", "RegionList", ObjDesc->AddrHandler.RegionList); + AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->AddrHandler.Node); + AcpiOsPrintf ("%20s : 0x%p\n", "Handler", ObjDesc->AddrHandler.Handler); + AcpiOsPrintf ("%20s : 0x%p\n", "Context", ObjDesc->AddrHandler.Context); + break; + + + case INTERNAL_TYPE_NOTIFY: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Notify Handler"); + AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->NotifyHandler.Node); + AcpiOsPrintf ("%20s : 0x%p\n", "Handler", ObjDesc->NotifyHandler.Handler); + AcpiOsPrintf ("%20s : 0x%p\n", "Context", ObjDesc->NotifyHandler.Context); + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + AcpiOsPrintf ("%20s : 0x%p\n", "Granularity", ObjDesc->Field.Granularity); + AcpiOsPrintf ("%20s : 0x%p\n", "Length", ObjDesc->Field.Length); + AcpiOsPrintf ("%20s : 0x%p\n", "Offset", ObjDesc->Field.Offset); + AcpiOsPrintf ("%20s : 0x%p\n", "BitOffset", ObjDesc->Field.BitOffset); + AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->Field.Container); + break; + + + case INTERNAL_TYPE_ALIAS: + case INTERNAL_TYPE_DEF_FIELD_DEFN: + case INTERNAL_TYPE_BANK_FIELD_DEFN: + case INTERNAL_TYPE_INDEX_FIELD_DEFN: + case INTERNAL_TYPE_IF: + case INTERNAL_TYPE_ELSE: + case INTERNAL_TYPE_WHILE: + case INTERNAL_TYPE_SCOPE: + case INTERNAL_TYPE_DEF_ANY: + + AcpiOsPrintf ("*** Structure display not implemented for type 0x%X! ***\n", + ObjDesc->Common.Type); + break; + + + default: + + AcpiOsPrintf ("*** Cannot display unknown type 0x%X! ***\n", ObjDesc->Common.Type); + break; + } + + return_VOID; +} + +#endif + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c new file mode 100644 index 0000000..fdc998b --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amdyadic.c @@ -0,0 +1,906 @@ +/****************************************************************************** + * + * Module Name: amdyadic - ACPI AML (p-code) execution for dyadic operators + * $Revision: 65 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMDYADIC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amdyadic") + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic1 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 1 dyadic operator with numeric operands: + * NotifyOp + * + * ALLOCATION: Deletes both operands + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_OPERAND_OBJECT *ValDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AmlExecDyadic1", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get the operands */ + + Status |= AcpiDsObjStackPopObject (&ValDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic1/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Examine the opcode */ + + switch (Opcode) + { + + /* DefNotify := NotifyOp NotifyObject NotifyValue */ + + case AML_NOTIFY_OP: + + /* The ObjDesc is actually an Node */ + + Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + ObjDesc = NULL; + + /* Object must be a device or thermal zone */ + + if (Node && ValDesc) + { + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + /* + * Requires that Device and ThermalZone be compatible + * mappings + */ + + /* Dispatch the notify to the appropriate handler */ + + AcpiEvNotifyDispatch (Node, (UINT32) ValDesc->Number.Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecDyadic1/NotifyOp: unexpected notify object type %d\n", + ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + } + } + break; + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic1: Unknown dyadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + } + + +Cleanup: + + /* Always delete both operands */ + + AcpiCmRemoveReference (ValDesc); + AcpiCmRemoveReference (ObjDesc); + + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic2R + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and + * one or two result operands. + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_OPERAND_OBJECT *ObjDesc2 = NULL; + ACPI_OPERAND_OBJECT *ResDesc = NULL; + ACPI_OPERAND_OBJECT *ResDesc2 = NULL; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_OPERAND_OBJECT *RetDesc2 = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Remainder; + UINT32 NumOperands = 3; + NATIVE_CHAR *NewBuf; + + + FUNCTION_TRACE_U32 ("AmlExecDyadic2R", Opcode); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + NumOperands, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + if (AML_DIVIDE_OP == Opcode) + { + NumOperands = 4; + Status |= AcpiDsObjStackPopObject (&ResDesc2, WalkState); + } + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic2R/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create an internal return object if necessary */ + + switch (Opcode) + { + case AML_ADD_OP: + case AML_BIT_AND_OP: + case AML_BIT_NAND_OP: + case AML_BIT_OR_OP: + case AML_BIT_NOR_OP: + case AML_BIT_XOR_OP: + case AML_DIVIDE_OP: + case AML_MULTIPLY_OP: + case AML_SHIFT_LEFT_OP: + case AML_SHIFT_RIGHT_OP: + case AML_SUBTRACT_OP: + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + break; + } + + + /* + * Execute the opcode + */ + + switch (Opcode) + { + + /* DefAdd := AddOp Operand1 Operand2 Result */ + + case AML_ADD_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value + + ObjDesc2->Number.Value; + break; + + + /* DefAnd := AndOp Operand1 Operand2 Result */ + + case AML_BIT_AND_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value & + ObjDesc2->Number.Value; + break; + + + /* DefNAnd := NAndOp Operand1 Operand2 Result */ + + case AML_BIT_NAND_OP: + + RetDesc->Number.Value = ~(ObjDesc->Number.Value & + ObjDesc2->Number.Value); + break; + + + /* DefOr := OrOp Operand1 Operand2 Result */ + + case AML_BIT_OR_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value | + ObjDesc2->Number.Value; + break; + + + /* DefNOr := NOrOp Operand1 Operand2 Result */ + + case AML_BIT_NOR_OP: + + RetDesc->Number.Value = ~(ObjDesc->Number.Value | + ObjDesc2->Number.Value); + break; + + + /* DefXOr := XOrOp Operand1 Operand2 Result */ + + case AML_BIT_XOR_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value ^ + ObjDesc2->Number.Value; + break; + + + /* DefDivide := DivideOp Dividend Divisor Remainder Quotient */ + + case AML_DIVIDE_OP: + + if ((UINT32) 0 == ObjDesc2->Number.Value) + { + REPORT_ERROR + (("AmlExecDyadic2R/DivideOp: Divide by zero\n")); + + Status = AE_AML_DIVIDE_BY_ZERO; + goto Cleanup; + } + + RetDesc2 = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc2) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Remainder = ObjDesc->Number.Value % + ObjDesc2->Number.Value; + RetDesc->Number.Value = Remainder; + + /* Result (what we used to call the quotient) */ + + RetDesc2->Number.Value = ObjDesc->Number.Value / + ObjDesc2->Number.Value; + break; + + + /* DefMultiply := MultiplyOp Operand1 Operand2 Result */ + + case AML_MULTIPLY_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value * + ObjDesc2->Number.Value; + break; + + + /* DefShiftLeft := ShiftLeftOp Operand ShiftCount Result */ + + case AML_SHIFT_LEFT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value << + ObjDesc2->Number.Value; + break; + + + /* DefShiftRight := ShiftRightOp Operand ShiftCount Result */ + + case AML_SHIFT_RIGHT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value >> + ObjDesc2->Number.Value; + break; + + + /* DefSubtract := SubtractOp Operand1 Operand2 Result */ + + case AML_SUBTRACT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value - + ObjDesc2->Number.Value; + break; + + + /* DefConcat := ConcatOp Data1 Data2 Result */ + + case AML_CONCAT_OP: + + if (ObjDesc2->Common.Type != ObjDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecDyadic2R/ConcatOp: operand type mismatch %d %d\n", + ObjDesc->Common.Type, ObjDesc2->Common.Type)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* Both operands are now known to be the same */ + + if (ACPI_TYPE_STRING == ObjDesc->Common.Type) + { + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Operand1 is string */ + + NewBuf = AcpiCmAllocate (ObjDesc->String.Length + + ObjDesc2->String.Length + 1); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: String allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + STRCPY (NewBuf, ObjDesc->String.Pointer); + STRCPY (NewBuf + ObjDesc->String.Length, + ObjDesc2->String.Pointer); + + /* Point the return object to the new string */ + + RetDesc->String.Pointer = NewBuf; + RetDesc->String.Length = ObjDesc->String.Length += + ObjDesc2->String.Length; + } + + else + { + /* Operand1 is not a string ==> must be a buffer */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = AcpiCmAllocate (ObjDesc->Buffer.Length + + ObjDesc2->Buffer.Length); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + MEMCPY (NewBuf, ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length); + MEMCPY (NewBuf + ObjDesc->Buffer.Length, ObjDesc2->Buffer.Pointer, + ObjDesc2->Buffer.Length); + + /* + * Point the return object to the new buffer + */ + + RetDesc->Buffer.Pointer = (UINT8 *) NewBuf; + RetDesc->Buffer.Length = ObjDesc->Buffer.Length + + ObjDesc2->Buffer.Length; + } + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic2R: Unknown dyadic opcode %X\n", Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Store the result of the operation (which is now in ObjDesc) into + * the result descriptor, or the location pointed to by the result + * descriptor (ResDesc). + */ + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (AML_DIVIDE_OP == Opcode) + { + Status = AcpiAmlExecStore (RetDesc2, ResDesc2, WalkState); + + /* + * Since the remainder is not returned, remove a reference to + * the object we created earlier + */ + + AcpiCmRemoveReference (RetDesc2); + } + + +Cleanup: + + /* Always delete the operands */ + + AcpiCmRemoveReference (ObjDesc); + AcpiCmRemoveReference (ObjDesc2); + + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + /* On failure, delete the result ops */ + + AcpiCmRemoveReference (ResDesc); + AcpiCmRemoveReference (ResDesc2); + + if (RetDesc) + { + /* And delete the internal return object */ + + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + } + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic2S + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 dyadic synchronization operator + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic2S ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *TimeDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("AmlExecDyadic2S", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&TimeDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic2S/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create the internal return object */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Default return value is FALSE, operation did not time out */ + + RetDesc->Number.Value = 0; + + + /* Examine the opcode */ + + switch (Opcode) + { + + /* DefAcquire := AcquireOp MutexObject Timeout */ + + case AML_ACQUIRE_OP: + + Status = AcpiAmlSystemAcquireMutex (TimeDesc, ObjDesc); + break; + + + /* DefWait := WaitOp AcpiEventObject Timeout */ + + case AML_WAIT_OP: + + Status = AcpiAmlSystemWaitEvent (TimeDesc, ObjDesc); + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic2S: Unknown dyadic synchronization opcode %X\n", Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Return a boolean indicating if operation timed out + * (TRUE) or not (FALSE) + */ + + if (Status == AE_TIME) + { + RetDesc->Number.Value = ACPI_INTEGER_MAX; /* TRUE, op timed out */ + Status = AE_OK; + } + + +Cleanup: + + /* Delete params */ + + AcpiCmRemoveReference (TimeDesc); + AcpiCmRemoveReference (ObjDesc); + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic2 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and + * no result operands + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * containing result value + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *ObjDesc2; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS Status; + BOOLEAN Lboolean; + + + FUNCTION_TRACE_PTR ("AmlExecDyadic2", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic2/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create the internal return object */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Execute the Opcode + */ + + Lboolean = FALSE; + switch (Opcode) + { + + /* DefLAnd := LAndOp Operand1 Operand2 */ + + case AML_LAND_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value && + ObjDesc2->Number.Value); + break; + + + /* DefLEqual := LEqualOp Operand1 Operand2 */ + + case AML_LEQUAL_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value == + ObjDesc2->Number.Value); + break; + + + /* DefLGreater := LGreaterOp Operand1 Operand2 */ + + case AML_LGREATER_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value > + ObjDesc2->Number.Value); + break; + + + /* DefLLess := LLessOp Operand1 Operand2 */ + + case AML_LLESS_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value < + ObjDesc2->Number.Value); + break; + + + /* DefLOr := LOrOp Operand1 Operand2 */ + + case AML_LOR_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value || + ObjDesc2->Number.Value); + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic2: Unknown dyadic opcode %X\n", Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + break; + } + + + /* Set return value to logical TRUE (all ones) or FALSE (zero) */ + + if (Lboolean) + { + RetDesc->Number.Value = ACPI_INTEGER_MAX; + } + else + { + RetDesc->Number.Value = 0; + } + + +Cleanup: + + /* Always delete operands */ + + AcpiCmRemoveReference (ObjDesc); + AcpiCmRemoveReference (ObjDesc2); + + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c new file mode 100644 index 0000000..d450fbf --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfield.c @@ -0,0 +1,446 @@ +/****************************************************************************** + * + * Module Name: amfield - ACPI AML (p-code) execution - field manipulation + * $Revision: 73 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMFIELD_C__ + +#include "acpi.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amfield") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSetupField + * + * PARAMETERS: *ObjDesc - Field to be read or written + * *RgnDesc - Region containing field + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Common processing for AcpiAmlReadField and AcpiAmlWriteField + * + * ACPI SPECIFICATION REFERENCES: + * Each of the Type1Opcodes is defined as specified in in-line + * comments below. For each one, use the following definitions. + * + * DefBitField := BitFieldOp SrcBuf BitIdx Destination + * DefByteField := ByteFieldOp SrcBuf ByteIdx Destination + * DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString + * DefDWordField := DWordFieldOp SrcBuf ByteIdx Destination + * DefWordField := WordFieldOp SrcBuf ByteIdx Destination + * BitIndex := TermArg=>Integer + * ByteIndex := TermArg=>Integer + * Destination := NameString + * NumBits := TermArg=>Integer + * SourceBuf := TermArg=>Buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSetupField ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *RgnDesc, + UINT32 FieldBitWidth) +{ + ACPI_STATUS Status = AE_OK; + UINT32 FieldByteWidth; + + + FUNCTION_TRACE ("AmlSetupField"); + + + /* Parameter validation */ + + if (!ObjDesc || !RgnDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Internal error - null handle\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (ACPI_TYPE_REGION != RgnDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Needed Region, found type %x %s\n", + RgnDesc->Common.Type, AcpiCmGetTypeName (RgnDesc->Common.Type))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* + * TBD: [Future] Acpi 2.0 supports Qword fields + * + * Init and validate Field width + * Possible values are 1, 2, 4 + */ + + FieldByteWidth = DIV_8 (FieldBitWidth); + + if ((FieldBitWidth != 8) && + (FieldBitWidth != 16) && + (FieldBitWidth != 32)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Internal error - bad width %d\n", FieldBitWidth)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them and save the results. + */ + if (!(RgnDesc->Region.Flags & AOPOBJ_DATA_VALID)) + { + + Status = AcpiDsGetRegionArguments (RgnDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + if ((ObjDesc->Common.Type == ACPI_TYPE_FIELD_UNIT) && + (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))) + { + /* + * Field Buffer and Index have not been previously evaluated, + */ + DEBUG_PRINT (ACPI_ERROR, ("Uninitialized field!\n")); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + if (RgnDesc->Region.Length < + (ObjDesc->Field.Offset & ~((UINT32) FieldByteWidth - 1)) + + FieldByteWidth) + { + /* + * Offset rounded up to next multiple of field width + * exceeds region length, indicate an error + */ + + DUMP_STACK_ENTRY (RgnDesc); + DUMP_STACK_ENTRY (ObjDesc); + + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Operation at %08lX width %d bits exceeds len %08lX field=%p region=%p\n", + ObjDesc->Field.Offset, FieldBitWidth, RgnDesc->Region.Length, + ObjDesc, RgnDesc)); + + return_ACPI_STATUS (AE_AML_REGION_LIMIT); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlAccessNamedField + * + * PARAMETERS: Mode - ACPI_READ or ACPI_WRITE + * NamedField - Handle for field to be accessed + * *Buffer - Value(s) to be read or written + * BufferLength - Number of bytes to transfer + * + * RETURN: Status + * + * DESCRIPTION: Read or write a named field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlAccessNamedField ( + UINT32 Mode, + ACPI_HANDLE NamedField, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_STATUS Status = AE_OK; + BOOLEAN Locked = FALSE; + UINT32 BitGranularity = 0; + UINT32 ByteGranularity; + UINT32 DatumLength; + UINT32 ActualByteLength; + UINT32 ByteFieldLength; + + + FUNCTION_TRACE_PTR ("AmlAccessNamedField", NamedField); + + + /* Basic data checking */ + if ((!NamedField) || (ACPI_READ == Mode && !Buffer)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AcpiAmlAccessNamedField: Internal error - null parameter\n")); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Get the attached field object */ + + ObjDesc = AcpiNsGetAttachedObject (NamedField); + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlAccessNamedField: Internal error - null value pointer\n")); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Check the type */ + + if (INTERNAL_TYPE_DEF_FIELD != AcpiNsGetType (NamedField)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlAccessNamedField: Name %4.4s type %x is not a defined field\n", + &(((ACPI_NAMESPACE_NODE *) NamedField)->Name), + AcpiNsGetType (NamedField))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* ObjDesc valid and NamedField is a defined field */ + + DEBUG_PRINT (ACPI_INFO, + ("AccessNamedField: Obj=%p Type=%x Buf=%p Len=%x\n", + ObjDesc, ObjDesc->Common.Type, Buffer, BufferLength)); + DEBUG_PRINT (ACPI_INFO, + ("AccessNamedField: Mode=%d FieldLen=%d, BitOffset=%d\n", + Mode, ObjDesc->FieldUnit.Length, ObjDesc->FieldUnit.BitOffset)); + DUMP_ENTRY (NamedField, ACPI_INFO); + + + /* Double-check that the attached object is also a field */ + + if (INTERNAL_TYPE_DEF_FIELD != ObjDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlAccessNamedField: Internal error - Name %4.4s type %x does not match value-type %x at %p\n", + &(((ACPI_NAMESPACE_NODE *) NamedField)->Name), + AcpiNsGetType (NamedField), ObjDesc->Common.Type, ObjDesc)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* + * Granularity was decoded from the field access type + * (AnyAcc will be the same as ByteAcc) + */ + + BitGranularity = ObjDesc->FieldUnit.Granularity; + ByteGranularity = DIV_8 (BitGranularity); + + /* + * Check if request is too large for the field, and silently truncate + * if necessary + */ + + /* TBD: [Errors] should an error be returned in this case? */ + + ByteFieldLength = (UINT32) DIV_8 (ObjDesc->FieldUnit.Length + 7); + + + ActualByteLength = BufferLength; + if (BufferLength > ByteFieldLength) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlAccessNamedField: Byte length %d too large, truncated to %x\n", + ActualByteLength, ByteFieldLength)); + + ActualByteLength = ByteFieldLength; + } + + /* TBD: should these round down to a power of 2? */ + + if (DIV_8(BitGranularity) > ByteFieldLength) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlAccessNamedField: Bit granularity %d too large, truncated to %x\n", + BitGranularity, MUL_8(ByteFieldLength))); + + BitGranularity = MUL_8(ByteFieldLength); + } + + if (ByteGranularity > ByteFieldLength) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlAccessNamedField: Byte granularity %d too large, truncated to %x\n", + ByteGranularity, ByteFieldLength)); + + ByteGranularity = ByteFieldLength; + } + + + /* Convert byte count to datum count, round up if necessary */ + + DatumLength = (ActualByteLength + (ByteGranularity-1)) / ByteGranularity; + + DEBUG_PRINT (ACPI_INFO, + ("ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n", + ActualByteLength, DatumLength, BitGranularity, ByteGranularity)); + + + /* Get the global lock if needed */ + + Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule); + + + /* Perform the actual read or write of the buffer */ + + switch (Mode) + { + case ACPI_READ: + + Status = AcpiAmlReadField (ObjDesc, Buffer, BufferLength, + ActualByteLength, DatumLength, + BitGranularity, ByteGranularity); + break; + + + case ACPI_WRITE: + + Status = AcpiAmlWriteField (ObjDesc, Buffer, BufferLength, + ActualByteLength, DatumLength, + BitGranularity, ByteGranularity); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AccessNamedField: Unknown I/O Mode: %X\n", Mode)); + Status = AE_BAD_PARAMETER; + break; + } + + + /* Release global lock if we acquired it earlier */ + + AcpiAmlReleaseGlobalLock (Locked); + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c new file mode 100644 index 0000000..ce7bb28 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amfldio.c @@ -0,0 +1,857 @@ +/****************************************************************************** + * + * Module Name: amfldio - Aml Field I/O + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMFLDIO_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amfldio") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlReadFieldData + * + * PARAMETERS: *ObjDesc - Field to be read + * *Value - Where to store value + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value of the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlReadFieldData ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldByteOffset, + UINT32 FieldBitWidth, + UINT32 *Value) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RgnDesc = NULL; + ACPI_INTEGER Address; + UINT32 LocalValue = 0; + UINT32 FieldByteWidth; + + + FUNCTION_TRACE ("AmlReadFieldData"); + + + /* ObjDesc is validated by callers */ + + if (ObjDesc) + { + RgnDesc = ObjDesc->Field.Container; + } + + + FieldByteWidth = DIV_8 (FieldBitWidth); + Status = AcpiAmlSetupField (ObjDesc, RgnDesc, FieldBitWidth); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* SetupField validated RgnDesc and FieldBitWidth */ + + if (!Value) + { + Value = &LocalValue; /* support reads without saving value */ + } + + + /* + * Set offset to next multiple of field width, + * add region base address and offset within the field + */ + Address = RgnDesc->Region.Address + + (ObjDesc->Field.Offset * FieldByteWidth) + + FieldByteOffset; + + + if (RgnDesc->Region.SpaceId >= NUM_REGION_TYPES) + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlReadFieldData: **** Unknown OpRegion SpaceID %d at %08lx width %d\n", + RgnDesc->Region.SpaceId, Address, FieldBitWidth)); + } + + else + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlReadFieldData: OpRegion %s at %08lx width %d\n", + AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId], Address, + FieldBitWidth)); + } + + + /* Invoke the appropriate AddressSpace/OpRegion handler */ + + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, + Address, FieldBitWidth, Value); + + if (Status == AE_NOT_IMPLEMENTED) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlReadFieldData: **** OpRegion type %s not implemented\n", + AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId])); + } + + else if (Status == AE_NOT_EXIST) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlReadFieldData: **** Unknown OpRegion SpaceID %d\n", + RgnDesc->Region.SpaceId)); + } + + DEBUG_PRINT (TRACE_OPREGION, + ("AmlReadField: Returned value=%08lx \n", *Value)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlReadField + * + * PARAMETERS: *ObjDesc - Field to be read + * *Value - Where to store value + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value of the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlReadField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity) +{ + ACPI_STATUS Status; + UINT32 ThisFieldByteOffset; + UINT32 ThisFieldDatumOffset; + UINT32 PreviousRawDatum; + UINT32 ThisRawDatum; + UINT32 ValidFieldBits; + UINT32 Mask; + UINT32 MergedDatum = 0; + + + FUNCTION_TRACE ("AmlReadField"); + + /* + * Clear the caller's buffer (the whole buffer length as given) + * This is very important, especially in the cases where a byte is read, + * but the buffer is really a UINT32 (4 bytes). + */ + + MEMSET (Buffer, 0, BufferLength); + + /* Read the first raw datum to prime the loop */ + + ThisFieldByteOffset = 0; + ThisFieldDatumOffset= 0; + + Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, BitGranularity, + &PreviousRawDatum); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* We might actually be done if the request fits in one datum */ + + if ((DatumLength == 1) && + ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) <= + (UINT16) BitGranularity)) + { + MergedDatum = PreviousRawDatum; + + MergedDatum = (MergedDatum >> ObjDesc->Field.BitOffset); + + ValidFieldBits = ObjDesc->FieldUnit.Length % BitGranularity; + if (ValidFieldBits) + { + Mask = (((UINT32) 1 << ValidFieldBits) - (UINT32) 1); + MergedDatum &= Mask; + } + + + /* + * Place the MergedDatum into the proper format and return buffer + * field + */ + + switch (ByteGranularity) + { + case 1: + ((UINT8 *) Buffer) [ThisFieldDatumOffset] = (UINT8) MergedDatum; + break; + + case 2: + MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[ThisFieldDatumOffset]), &MergedDatum); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[ThisFieldDatumOffset]), &MergedDatum); + break; + } + + ThisFieldByteOffset = 1; + ThisFieldDatumOffset = 1; + } + + else + { + /* We need to get more raw data to complete one or more field data */ + + while (ThisFieldDatumOffset < DatumLength) + { + /* + * Get the next raw datum, it contains bits of the current + * field datum + */ + + Status = AcpiAmlReadFieldData (ObjDesc, + ThisFieldByteOffset + ByteGranularity, + BitGranularity, &ThisRawDatum); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Before merging the data, make sure the unused bits are clear */ + + switch (ByteGranularity) + { + case 1: + ThisRawDatum &= 0x000000FF; + PreviousRawDatum &= 0x000000FF; + break; + + case 2: + ThisRawDatum &= 0x0000FFFF; + PreviousRawDatum &= 0x0000FFFF; + break; + } + + /* + * Put together bits of the two raw data to make a complete + * field datum + */ + + + if (ObjDesc->Field.BitOffset != 0) + { + MergedDatum = + (PreviousRawDatum >> ObjDesc->Field.BitOffset) | + (ThisRawDatum << (BitGranularity - ObjDesc->Field.BitOffset)); + } + + else + { + MergedDatum = PreviousRawDatum; + } + + /* + * Prepare the merged datum for storing into the caller's + * buffer. It is possible to have a 32-bit buffer + * (ByteGranularity == 4), but a ObjDesc->Field.Length + * of 8 or 16, meaning that the upper bytes of merged data + * are undesired. This section fixes that. + */ + switch (ObjDesc->Field.Length) + { + case 8: + MergedDatum &= 0x000000FF; + break; + + case 16: + MergedDatum &= 0x0000FFFF; + break; + } + + /* + * Now store the datum in the caller's buffer, according to + * the data type + */ + switch (ByteGranularity) + { + case 1: + ((UINT8 *) Buffer) [ThisFieldDatumOffset] = (UINT8) MergedDatum; + break; + + case 2: + MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer) [ThisFieldDatumOffset]), &MergedDatum); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer) [ThisFieldDatumOffset]), &MergedDatum); + break; + } + + /* + * Save the most recent datum since it contains bits of + * the *next* field datum + */ + + PreviousRawDatum = ThisRawDatum; + + ThisFieldByteOffset += ByteGranularity; + ThisFieldDatumOffset++; + + } /* while */ + } + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlWriteFieldData + * + * PARAMETERS: *ObjDesc - Field to be set + * Value - Value to store + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Store the value into the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlWriteFieldData ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldByteOffset, + UINT32 FieldBitWidth, + UINT32 Value) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RgnDesc = NULL; + ACPI_INTEGER Address; + UINT32 FieldByteWidth; + + + FUNCTION_TRACE ("AmlWriteFieldData"); + + + /* ObjDesc is validated by callers */ + + if (ObjDesc) + { + RgnDesc = ObjDesc->Field.Container; + } + + FieldByteWidth = DIV_8 (FieldBitWidth); + Status = AcpiAmlSetupField (ObjDesc, RgnDesc, FieldBitWidth); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* + * Set offset to next multiple of field width, + * add region base address and offset within the field + */ + Address = RgnDesc->Region.Address + + (ObjDesc->Field.Offset * FieldByteWidth) + + FieldByteOffset; + + + if (RgnDesc->Region.SpaceId >= NUM_REGION_TYPES) + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlWriteField: **** Store %lx in unknown OpRegion SpaceID %d at %p width %d ** \n", + Value, RgnDesc->Region.SpaceId, Address, FieldBitWidth)); + } + else + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlWriteField: Store %lx in OpRegion %s at %p width %d\n", + Value, AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId], Address, + FieldBitWidth)); + } + + /* Invoke the appropriate AddressSpace/OpRegion handler */ + + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_WRITE, + Address, FieldBitWidth, &Value); + + if (Status == AE_NOT_IMPLEMENTED) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlWriteField: **** OpRegion type %s not implemented\n", + AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId])); + } + + else if (Status == AE_NOT_EXIST) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlWriteField: **** Unknown OpRegion SpaceID %x\n", + RgnDesc->Region.SpaceId)); + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlWriteFieldDataWithUpdateRule + * + * PARAMETERS: *ObjDesc - Field to be set + * Value - Value to store + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Apply the field update rule to a field write + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlWriteFieldDataWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Mask, + UINT32 FieldValue, + UINT32 ThisFieldByteOffset, + UINT32 BitGranularity) +{ + ACPI_STATUS Status = AE_OK; + UINT32 MergedValue; + UINT32 CurrentValue; + + + /* Start with the new bits */ + + MergedValue = FieldValue; + + /* Check if update rule needs to be applied (not if mask is all ones) */ + + + /* Decode the update rule */ + + switch (ObjDesc->Field.UpdateRule) + { + + case UPDATE_PRESERVE: + + /* + * Read the current contents of the byte/word/dword containing + * the field, and merge with the new field value. + */ + Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, + BitGranularity, &CurrentValue); + MergedValue |= (CurrentValue & ~Mask); + break; + + + case UPDATE_WRITE_AS_ONES: + + /* Set positions outside the field to all ones */ + + MergedValue |= ~Mask; + break; + + + case UPDATE_WRITE_AS_ZEROS: + + /* Set positions outside the field to all zeros */ + + MergedValue &= Mask; + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, + ("WriteFieldDataWithUpdateRule: Unknown UpdateRule setting: %x\n", + ObjDesc->Field.UpdateRule)); + Status = AE_AML_OPERAND_VALUE; + } + + + /* Write the merged value */ + + if (ACPI_SUCCESS (Status)) + { + Status = AcpiAmlWriteFieldData (ObjDesc, ThisFieldByteOffset, + BitGranularity, MergedValue); + } + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlWriteField + * + * PARAMETERS: *ObjDesc - Field to be set + * Value - Value to store + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Store the value into the given field + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlWriteField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity) +{ + ACPI_STATUS Status; + UINT32 ThisFieldByteOffset; + UINT32 ThisFieldDatumOffset; + UINT32 Mask; + UINT32 MergedDatum; + UINT32 PreviousRawDatum; + UINT32 ThisRawDatum; + UINT32 FieldValue; + UINT32 ValidFieldBits; + + + FUNCTION_TRACE ("AmlWriteField"); + + + /* + * Break the request into up to three parts: + * non-aligned part at start, aligned part in middle, non-aligned part + * at end --- Just like an I/O request --- + */ + + ThisFieldByteOffset = 0; + ThisFieldDatumOffset= 0; + + /* Get a datum */ + + switch (ByteGranularity) + { + case 1: + PreviousRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset]; + break; + + case 2: + MOVE_UNALIGNED16_TO_32 (&PreviousRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset])); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&PreviousRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset])); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ("AmlWriteField: Invalid granularity: %x\n", + ByteGranularity)); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + + /* + * Write a partial field datum if field does not begin on a datum boundary + * + * Construct Mask with 1 bits where the field is, 0 bits elsewhere + * + * 1) Bits above the field + */ + + Mask = (((UINT32)(-1)) << (UINT32)ObjDesc->Field.BitOffset); + + /* 2) Only the bottom 5 bits are valid for a shift operation. */ + + if ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) < 32) + { + /* Bits above the field */ + + Mask &= (~(((UINT32)(-1)) << ((UINT32)ObjDesc->Field.BitOffset + + (UINT32)ObjDesc->FieldUnit.Length))); + } + + /* 3) Shift and mask the value into the field position */ + + FieldValue = (PreviousRawDatum << ObjDesc->Field.BitOffset) & Mask; + + Status = AcpiAmlWriteFieldDataWithUpdateRule (ObjDesc, Mask, FieldValue, + ThisFieldByteOffset, + BitGranularity); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* If the field fits within one datum, we are done. */ + + if ((DatumLength == 1) && + ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) <= + (UINT16) BitGranularity)) + { + goto Cleanup; + } + + /* + * We don't need to worry about the update rule for these data, because + * all of the bits are part of the field. + * + * Can't write the last datum, however, because it might contain bits that + * are not part of the field -- the update rule must be applied. + */ + + while (ThisFieldDatumOffset < (DatumLength - 1)) + { + ThisFieldDatumOffset++; + + /* Get the next raw datum, it contains bits of the current field datum... */ + + switch (ByteGranularity) + { + case 1: + ThisRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset]; + break; + + case 2: + MOVE_UNALIGNED16_TO_32 (&ThisRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset])); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&ThisRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset])); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ("AmlWriteField: Invalid Byte Granularity: %x\n", + ByteGranularity)); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + /* + * Put together bits of the two raw data to make a complete field + * datum + */ + + if (ObjDesc->Field.BitOffset != 0) + { + MergedDatum = + (PreviousRawDatum >> (BitGranularity - ObjDesc->Field.BitOffset)) | + (ThisRawDatum << ObjDesc->Field.BitOffset); + } + + else + { + MergedDatum = ThisRawDatum; + } + + /* Now write the completed datum */ + + + Status = AcpiAmlWriteFieldData (ObjDesc, + ThisFieldByteOffset + ByteGranularity, + BitGranularity, MergedDatum); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* + * Save the most recent datum since it contains bits of + * the *next* field datum + */ + + PreviousRawDatum = ThisRawDatum; + + ThisFieldByteOffset += ByteGranularity; + + } /* while */ + + + /* Write a partial field datum if field does not end on a datum boundary */ + + if ((ObjDesc->FieldUnit.Length + ObjDesc->FieldUnit.BitOffset) % + BitGranularity) + { + switch (ByteGranularity) + { + case 1: + ThisRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset]; + break; + + case 2: + MOVE_UNALIGNED16_TO_32 (&ThisRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset])); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&ThisRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset])); + break; + } + + /* Construct Mask with 1 bits where the field is, 0 bits elsewhere */ + + ValidFieldBits = ((ObjDesc->FieldUnit.Length % BitGranularity) + + ObjDesc->Field.BitOffset); + + Mask = (((UINT32) 1 << ValidFieldBits) - (UINT32) 1); + + /* Shift and mask the value into the field position */ + + FieldValue = (PreviousRawDatum >> + (BitGranularity - ObjDesc->Field.BitOffset)) & Mask; + + Status = AcpiAmlWriteFieldDataWithUpdateRule (ObjDesc, Mask, FieldValue, + ThisFieldByteOffset + ByteGranularity, + BitGranularity); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c new file mode 100644 index 0000000..7decf64 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammisc.c @@ -0,0 +1,682 @@ + +/****************************************************************************** + * + * Module Name: ammisc - ACPI AML (p-code) execution - specific opcodes + * $Revision: 70 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMMISC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("ammisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecFatal + * + * PARAMETERS: none + * + * RETURN: Status. If the OS returns from the OSD call, we just keep + * on going. + * + * DESCRIPTION: Execute Fatal operator + * + * ACPI SPECIFICATION REFERENCES: + * DefFatal := FatalOp FatalType FatalCode FatalArg + * FatalType := ByteData + * FatalCode := DWordData + * FatalArg := TermArg=>Integer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecFatal ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *TypeDesc; + ACPI_OPERAND_OBJECT *CodeDesc; + ACPI_OPERAND_OBJECT *ArgDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecFatal"); + + + /* Resolve operands */ + + Status = AcpiAmlResolveOperands (AML_FATAL_OP, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (AML_FATAL_OP), + 3, "after AcpiAmlResolveOperands"); + + /* Get operands */ + + Status |= AcpiDsObjStackPopObject (&ArgDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&CodeDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&TypeDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("AcpiAmlExecFatal/AML_FATAL_OP: bad operand(s) (0x%X)\n", + Status)); + + goto Cleanup; + } + + + /* DefFatal := FatalOp FatalType FatalCode FatalArg */ + + + DEBUG_PRINT (ACPI_INFO, + ("FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + TypeDesc->Number.Value, CodeDesc->Number.Value, ArgDesc->Number.Value)); + + + /* + * TBD: [Unhandled] call OSD interface to notify OS of fatal error + * requiring shutdown! + */ + + +Cleanup: + + /* Free the operands */ + + AcpiCmRemoveReference (ArgDesc); + AcpiCmRemoveReference (CodeDesc); + AcpiCmRemoveReference (TypeDesc); + + + /* If we get back from the OS call, we might as well keep going. */ + + REPORT_WARNING (("An AML \"Fatal\" Opcode (FatalOp) was executed\n")); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecIndex + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Execute Index operator + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * + * ACPI SPECIFICATION REFERENCES: + * DefIndex := IndexOp BuffPkgObj IndexValue Result + * IndexValue := TermArg=>Integer + * NameString := | + * Result := SuperName + * SuperName := NameString | ArgObj | LocalObj | DebugObj | DefIndex + * Local4Op | Local5Op | Local6Op | Local7Op + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecIndex ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *IdxDesc; + ACPI_OPERAND_OBJECT *ResDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_OPERAND_OBJECT *TmpDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecIndex"); + + + /* Resolve operands */ + /* First operand can be either a package or a buffer */ + + Status = AcpiAmlResolveOperands (AML_INDEX_OP, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (AML_INDEX_OP), + 3, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&IdxDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("AcpiAmlExecIndex/AML_INDEX_OP: bad operand(s) (0x%X)\n", + Status)); + + goto Cleanup; + } + + + /* Create the internal return object */ + + RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + + /* + * At this point, the ObjDesc operand is either a Package or a Buffer + */ + + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + /* Object to be indexed is a Package */ + + if (IdxDesc->Number.Value >= ObjDesc->Package.Count) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecIndex: Index value out of range\n")); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } + + if ((ResDesc->Common.Type == INTERNAL_TYPE_REFERENCE) && + (ResDesc->Reference.OpCode == AML_ZERO_OP)) + { + /* + * There is no actual result descriptor (the ZeroOp Result + * descriptor is a placeholder), so just delete the placeholder and + * return a reference to the package element + */ + + AcpiCmRemoveReference (ResDesc); + } + + else + { + /* + * Each element of the package is an internal object. Get the one + * we are after. + */ + + TmpDesc = ObjDesc->Package.Elements[IdxDesc->Number.Value]; + RetDesc->Reference.OpCode = AML_INDEX_OP; + RetDesc->Reference.TargetType = TmpDesc->Common.Type; + RetDesc->Reference.Object = TmpDesc; + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + RetDesc->Reference.Object = NULL; + } + + /* + * The local return object must always be a reference to the package element, + * not the element itself. + */ + RetDesc->Reference.OpCode = AML_INDEX_OP; + RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Number.Value]; + } + + else + { + /* Object to be indexed is a Buffer */ + + if (IdxDesc->Number.Value >= ObjDesc->Buffer.Length) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecIndex: Index value out of range\n")); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + RetDesc->Reference.OpCode = AML_INDEX_OP; + RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + RetDesc->Reference.Object = ObjDesc; + RetDesc->Reference.Offset = (UINT32) IdxDesc->Number.Value; + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + } + + +Cleanup: + + /* Always delete operands */ + + AcpiCmRemoveReference (ObjDesc); + AcpiCmRemoveReference (IdxDesc); + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); + + if (RetDesc) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + } + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMatch + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Execute Match operator + * + * ACPI SPECIFICATION REFERENCES: + * DefMatch := MatchOp SearchPkg Opcode1 Operand1 + * Opcode2 Operand2 StartIndex + * Opcode1 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT + * Opcode2 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT + * Operand1 := TermArg=>Integer + * Operand2 := TermArg=>Integer + * SearchPkg := TermArg=>PackageObject + * StartIndex := TermArg=>Integer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMatch ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *PkgDesc; + ACPI_OPERAND_OBJECT *Op1Desc; + ACPI_OPERAND_OBJECT *V1Desc; + ACPI_OPERAND_OBJECT *Op2Desc; + ACPI_OPERAND_OBJECT *V2Desc; + ACPI_OPERAND_OBJECT *StartDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS Status; + UINT32 Index; + UINT32 MatchValue = (UINT32) -1; + + + FUNCTION_TRACE ("AmlExecMatch"); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (AML_MATCH_OP, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (AML_MATCH_OP), + 6, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&StartDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&V2Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&Op2Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&V1Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&Op1Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&PkgDesc, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecMatch/AML_MATCH_OP: bad operand(s) (0x%X)\n", + Status)); + + goto Cleanup; + } + + /* Validate match comparison sub-opcodes */ + + if ((Op1Desc->Number.Value > MAX_MATCH_OPERATOR) || + (Op2Desc->Number.Value > MAX_MATCH_OPERATOR)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMatch: operation encoding out of range\n")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + Index = (UINT32) StartDesc->Number.Value; + if (Index >= (UINT32) PkgDesc->Package.Count) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMatch: start position value out of range\n")); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + + } + + /* + * Examine each element until a match is found. Within the loop, + * "continue" signifies that the current element does not match + * and the next should be examined. + * Upon finding a match, the loop will terminate via "break" at + * the bottom. If it terminates "normally", MatchValue will be -1 + * (its initial value) indicating that no match was found. When + * returned as a Number, this will produce the Ones value as specified. + */ + + for ( ; Index < PkgDesc->Package.Count; ++Index) + { + /* + * Treat any NULL or non-numeric elements as non-matching. + * TBD [Unhandled] - if an element is a Name, + * should we examine its value? + */ + if (!PkgDesc->Package.Elements[Index] || + ACPI_TYPE_NUMBER != PkgDesc->Package.Elements[Index]->Common.Type) + { + continue; + } + + /* + * Within these switch statements: + * "break" (exit from the switch) signifies a match; + * "continue" (proceed to next iteration of enclosing + * "for" loop) signifies a non-match. + */ + switch (Op1Desc->Number.Value) + { + + case MATCH_MTR: /* always true */ + + break; + + + case MATCH_MEQ: /* true if equal */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + != V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLE: /* true if less than or equal */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + > V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLT: /* true if less than */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + >= V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGE: /* true if greater than or equal */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + < V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGT: /* true if greater than */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + <= V1Desc->Number.Value) + { + continue; + } + break; + + + default: /* undefined */ + + continue; + } + + + switch(Op2Desc->Number.Value) + { + + case MATCH_MTR: + + break; + + + case MATCH_MEQ: + + if (PkgDesc->Package.Elements[Index]->Number.Value + != V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLE: + + if (PkgDesc->Package.Elements[Index]->Number.Value + > V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLT: + + if (PkgDesc->Package.Elements[Index]->Number.Value + >= V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGE: + + if (PkgDesc->Package.Elements[Index]->Number.Value + < V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGT: + + if (PkgDesc->Package.Elements[Index]->Number.Value + <= V2Desc->Number.Value) + { + continue; + } + break; + + + default: + + continue; + } + + /* Match found: exit from loop */ + + MatchValue = Index; + break; + } + + /* MatchValue is the return value */ + + RetDesc->Number.Value = MatchValue; + + +Cleanup: + + /* Free the operands */ + + AcpiCmRemoveReference (StartDesc); + AcpiCmRemoveReference (V2Desc); + AcpiCmRemoveReference (Op2Desc); + AcpiCmRemoveReference (V1Desc); + AcpiCmRemoveReference (Op1Desc); + AcpiCmRemoveReference (PkgDesc); + + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c new file mode 100644 index 0000000..dbba804 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/ammonad.c @@ -0,0 +1,1183 @@ + +/****************************************************************************** + * + * Module Name: ammonad - ACPI AML (p-code) execution for monadic operators + * $Revision: 81 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMMONAD_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("ammonad") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlGetObjectReference + * + * PARAMETERS: ObjDesc - Create a reference to this object + * RetDesc - Where to store the reference + * + * RETURN: Status + * + * DESCRIPTION: Obtain and return a "reference" to the target object + * Common code for the RefOfOp and the CondRefOfOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AmlGetObjectReference", ObjDesc); + + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) + { + if (ObjDesc->Common.Type != INTERNAL_TYPE_REFERENCE) + { + *RetDesc = NULL; + Status = AE_TYPE; + goto Cleanup; + } + + /* + * Not a Name -- an indirect name pointer would have + * been converted to a direct name pointer in AcpiAmlResolveOperands + */ + switch (ObjDesc->Reference.OpCode) + { + case AML_LOCAL_OP: + + *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_LOCAL, + (ObjDesc->Reference.Offset), WalkState); + break; + + + case AML_ARG_OP: + + *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_ARG, + (ObjDesc->Reference.Offset), WalkState); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetObjectReference: (Internal) Unknown Ref subtype %02x\n", + ObjDesc->Reference.OpCode)); + *RetDesc = NULL; + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Must be a named object; Just return the Node */ + + *RetDesc = ObjDesc; + } + + else + { + *RetDesc = NULL; + Status = AE_TYPE; + } + + +Cleanup: + + DEBUG_PRINT (TRACE_EXEC, + ("AmlGetObjectReference: Obj=%p Ref=%p\n", ObjDesc, *RetDesc)); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMonadic1 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on + * object stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMonadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("AmlExecMonadic1", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (Opcode), + 1, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic1/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Examine the opcode */ + + switch (Opcode) + { + + /* DefRelease := ReleaseOp MutexObject */ + + case AML_RELEASE_OP: + + Status = AcpiAmlSystemReleaseMutex (ObjDesc); + break; + + + /* DefReset := ResetOp AcpiEventObject */ + + case AML_RESET_OP: + + Status = AcpiAmlSystemResetEvent (ObjDesc); + break; + + + /* DefSignal := SignalOp AcpiEventObject */ + + case AML_SIGNAL_OP: + + Status = AcpiAmlSystemSignalEvent (ObjDesc); + break; + + + /* DefSleep := SleepOp MsecTime */ + + case AML_SLEEP_OP: + + AcpiAmlSystemDoSuspend ((UINT32) ObjDesc->Number.Value); + break; + + + /* DefStall := StallOp UsecTime */ + + case AML_STALL_OP: + + AcpiAmlSystemDoStall ((UINT32) ObjDesc->Number.Value); + break; + + + /* Unknown opcode */ + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic1: Unknown monadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + + } /* switch */ + + +Cleanup: + + /* Always delete the operand */ + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMonadic2R + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 monadic operator with numeric operand and + * result operand on operand stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMonadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *ResDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_OPERAND_OBJECT *RetDesc2 = NULL; + UINT32 ResVal; + ACPI_STATUS Status; + UINT32 d0; + UINT32 d1; + UINT32 d2; + UINT32 d3; + + + FUNCTION_TRACE_PTR ("AmlExecMonadic2R", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2R/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create a return object of type NUMBER for most opcodes */ + + switch (Opcode) + { + case AML_BIT_NOT_OP: + case AML_FIND_SET_LEFT_BIT_OP: + case AML_FIND_SET_RIGHT_BIT_OP: + case AML_FROM_BCD_OP: + case AML_TO_BCD_OP: + case AML_COND_REF_OF_OP: + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + break; + } + + + switch (Opcode) + { + /* DefNot := NotOp Operand Result */ + + case AML_BIT_NOT_OP: + + RetDesc->Number.Value = ~ObjDesc->Number.Value; + break; + + + /* DefFindSetLeftBit := FindSetLeftBitOp Operand Result */ + + case AML_FIND_SET_LEFT_BIT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value; + + /* + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundry condition is valid. + */ + for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) + { + RetDesc->Number.Value >>= 1; + } + + RetDesc->Number.Value = ResVal; + break; + + + /* DefFindSetRightBit := FindSetRightBitOp Operand Result */ + + case AML_FIND_SET_RIGHT_BIT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value; + + /* + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundry condition is valid. + */ + for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) + { + RetDesc->Number.Value <<= 1; + } + + /* Since returns must be 1-based, subtract from 33 (65) */ + + RetDesc->Number.Value = ResVal == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - ResVal; + break; + + + /* DefFromBDC := FromBCDOp BCDValue Result */ + + case AML_FROM_BCD_OP: + + d0 = (UINT32) (ObjDesc->Number.Value & 15); + d1 = (UINT32) (ObjDesc->Number.Value >> 4 & 15); + d2 = (UINT32) (ObjDesc->Number.Value >> 8 & 15); + d3 = (UINT32) (ObjDesc->Number.Value >> 12 & 15); + + if (d0 > 9 || d1 > 9 || d2 > 9 || d3 > 9) + { + DEBUG_PRINT (ACPI_ERROR, + ("Monadic2R/FromBCDOp: BCD digit too large %d %d %d %d\n", + d3, d2, d1, d0)); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + RetDesc->Number.Value = d0 + d1 * 10 + d2 * 100 + d3 * 1000; + break; + + + /* DefToBDC := ToBCDOp Operand Result */ + + case AML_TO_BCD_OP: + + + if (ObjDesc->Number.Value > 9999) + { + DEBUG_PRINT (ACPI_ERROR, ("Monadic2R/ToBCDOp: BCD overflow: %d\n", + ObjDesc->Number.Value)); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + RetDesc->Number.Value + = ObjDesc->Number.Value % 10 + + (ObjDesc->Number.Value / 10 % 10 << 4) + + (ObjDesc->Number.Value / 100 % 10 << 8) + + (ObjDesc->Number.Value / 1000 % 10 << 12); + + break; + + + /* DefCondRefOf := CondRefOfOp SourceObject Result */ + + case AML_COND_REF_OF_OP: + + /* + * This op is a little strange because the internal return value is + * different than the return value stored in the result descriptor + * (There are really two return values) + */ + + if ((ACPI_NAMESPACE_NODE *) ObjDesc == AcpiGbl_RootNode) + { + /* + * This means that the object does not exist in the namespace, + * return FALSE + */ + + RetDesc->Number.Value = 0; + + /* + * Must delete the result descriptor since there is no reference + * being returned + */ + + AcpiCmRemoveReference (ResDesc); + goto Cleanup; + } + + /* Get the object reference and store it */ + + Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc2, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecStore (RetDesc2, ResDesc, WalkState); + + /* The object exists in the namespace, return TRUE */ + + RetDesc->Number.Value = ACPI_INTEGER_MAX + goto Cleanup; + break; + + + case AML_STORE_OP: + + /* + * A store operand is typically a number, string, buffer or lvalue + * TBD: [Unhandled] What about a store to a package? + */ + + /* + * Do the store, and be careful about deleting the source object, + * since the object itself may have been stored. + */ + + Status = AcpiAmlExecStore (ObjDesc, ResDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* On failure, just delete the ObjDesc */ + + AcpiCmRemoveReference (ObjDesc); + } + + else + { + /* + * Normally, we would remove a reference on the ObjDesc parameter; + * But since it is being used as the internal return object + * (meaning we would normally increment it), the two cancel out, + * and we simply don't do anything. + */ + *ReturnDesc = ObjDesc; + } + + ObjDesc = NULL; + return_ACPI_STATUS (Status); + + break; + + + case AML_DEBUG_OP: + + /* Reference, returning an Reference */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2R: DebugOp should never get here!\n")); + return_ACPI_STATUS (AE_OK); + break; + + + /* + * These are obsolete opcodes + */ + + /* DefShiftLeftBit := ShiftLeftBitOp Source BitNum */ + /* DefShiftRightBit := ShiftRightBitOp Source BitNum */ + + case AML_SHIFT_LEFT_BIT_OP: + case AML_SHIFT_RIGHT_BIT_OP: + + DEBUG_PRINT (ACPI_ERROR, ("AmlExecMonadic2R: %s unimplemented\n", + AcpiPsGetOpcodeName (Opcode))); + Status = AE_SUPPORT; + goto Cleanup; + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic2R: Unknown monadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + + +Cleanup: + /* Always delete the operand object */ + + AcpiCmRemoveReference (ObjDesc); + + /* Delete return object(s) on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); /* Result descriptor */ + if (RetDesc) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + } + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMonadic2 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 monadic operator with numeric operand: + * DerefOfOp, RefOfOp, SizeOfOp, TypeOp, IncrementOp, + * DecrementOp, LNotOp, + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMonadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *TmpDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS ResolveStatus; + ACPI_STATUS Status; + UINT32 Type; + ACPI_INTEGER Value; + + + FUNCTION_TRACE_PTR ("AmlExecMonadic2", WALK_OPERANDS); + + + /* Attempt to resolve the operands */ + + ResolveStatus = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (Opcode), + 1, "after AcpiAmlResolveOperands"); + + /* Always get all operands */ + + Status = AcpiDsObjStackPopObject (&ObjDesc, WalkState); + + + /* Now we can check the status codes */ + + if (ACPI_FAILURE (ResolveStatus)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2[%s]: Could not resolve operands, %s\n", + AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (ResolveStatus))); + + goto Cleanup; + } + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2[%s]: Bad operand(s), %s\n", + AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (Status))); + + goto Cleanup; + } + + + /* Get the operand and decode the opcode */ + + + switch (Opcode) + { + + /* DefLNot := LNotOp Operand */ + + case AML_LNOT_OP: + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Number.Value = !ObjDesc->Number.Value; + break; + + + /* DefDecrement := DecrementOp Target */ + /* DefIncrement := IncrementOp Target */ + + case AML_DECREMENT_OP: + case AML_INCREMENT_OP: + + /* + * Since we are expecting an Reference on the top of the stack, it + * can be either an Node or an internal object. + * + * TBD: [Future] This may be the prototype code for all cases where + * an Reference is expected!! 10/99 + */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + RetDesc = ObjDesc; + } + + else + { + /* + * Duplicate the Reference in a new object so that we can resolve it + * without destroying the original Reference object + */ + + RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Reference.OpCode = ObjDesc->Reference.OpCode; + RetDesc->Reference.Offset = ObjDesc->Reference.Offset; + RetDesc->Reference.Object = ObjDesc->Reference.Object; + } + + + /* + * Convert the RetDesc Reference to a Number + * (This deletes the original RetDesc) + */ + + Status = AcpiAmlResolveOperands (AML_LNOT_OP, &RetDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + /* Do the actual increment or decrement */ + + if (AML_INCREMENT_OP == Opcode) + { + RetDesc->Number.Value++; + } + else + { + RetDesc->Number.Value--; + } + + /* Store the result back in the original descriptor */ + + Status = AcpiAmlExecStore (RetDesc, ObjDesc, WalkState); + + /* Objdesc was just deleted (because it is an Reference) */ + + ObjDesc = NULL; + + break; + + + /* DefObjectType := ObjectTypeOp SourceObject */ + + case AML_TYPE_OP: + + if (INTERNAL_TYPE_REFERENCE == ObjDesc->Common.Type) + { + /* + * Not a Name -- an indirect name pointer would have + * been converted to a direct name pointer in ResolveOperands + */ + switch (ObjDesc->Reference.OpCode) + { + case AML_ZERO_OP: + case AML_ONE_OP: + case AML_ONES_OP: + + /* Constants are of type Number */ + + Type = ACPI_TYPE_NUMBER; + break; + + + case AML_DEBUG_OP: + + /* Per 1.0b spec, Debug object is of type DebugObject */ + + Type = ACPI_TYPE_DEBUG_OBJECT; + break; + + + case AML_INDEX_OP: + + /* Get the type of this reference (index into another object) */ + + Type = ObjDesc->Reference.TargetType; + if (Type == ACPI_TYPE_PACKAGE) + { + /* + * The main object is a package, we want to get the type + * of the individual package element that is referenced by + * the index. + */ + Type = (*(ObjDesc->Reference.Where))->Common.Type; + } + + break; + + + case AML_LOCAL_OP: + + Type = AcpiDsMethodDataGetType (MTH_TYPE_LOCAL, + (ObjDesc->Reference.Offset), WalkState); + break; + + + case AML_ARG_OP: + + Type = AcpiDsMethodDataGetType (MTH_TYPE_ARG, + (ObjDesc->Reference.Offset), WalkState); + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic2/TypeOp: Internal error - Unknown Reference subtype %X\n", + ObjDesc->Reference.OpCode)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + } + + else + { + /* + * It's not a Reference, so it must be a direct name pointer. + */ + Type = AcpiNsGetType ((ACPI_HANDLE) ObjDesc); + } + + /* Allocate a descriptor to hold the type. */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Number.Value = Type; + break; + + + /* DefSizeOf := SizeOfOp SourceObject */ + + case AML_SIZE_OF_OP: + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + ObjDesc = AcpiNsGetAttachedObject (ObjDesc); + } + + if (!ObjDesc) + { + Value = 0; + } + + else + { + switch (ObjDesc->Common.Type) + { + + case ACPI_TYPE_BUFFER: + + Value = ObjDesc->Buffer.Length; + break; + + + case ACPI_TYPE_STRING: + + Value = ObjDesc->String.Length; + break; + + + case ACPI_TYPE_PACKAGE: + + Value = ObjDesc->Package.Count; + break; + + case INTERNAL_TYPE_REFERENCE: + + Value = 4; + break; + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: Not Buf/Str/Pkg - found type 0x%X\n", + ObjDesc->Common.Type)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + + /* + * Now that we have the size of the object, create a result + * object to hold the value + */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Number.Value = Value; + break; + + + /* DefRefOf := RefOfOp SourceObject */ + + case AML_REF_OF_OP: + + Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + /* DefDerefOf := DerefOfOp ObjReference */ + + case AML_DEREF_OF_OP: + + + /* Check for a method local or argument */ + + if (!VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* + * Must resolve/dereference the local/arg reference first + */ + switch (ObjDesc->Reference.OpCode) + { + /* Set ObjDesc to the value of the local/arg */ + + case AML_LOCAL_OP: + + AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL, + (ObjDesc->Reference.Offset), WalkState, &TmpDesc); + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiCmRemoveReference (ObjDesc); + ObjDesc = TmpDesc; + break; + + + case AML_ARG_OP: + + AcpiDsMethodDataGetValue (MTH_TYPE_ARG, + (ObjDesc->Reference.Offset), WalkState, &TmpDesc); + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiCmRemoveReference (ObjDesc); + ObjDesc = TmpDesc; + break; + + default: + + /* Index op - handled below */ + break; + } + } + + + /* ObjDesc may have changed from the code above */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Get the actual object from the Node (This is the dereference) */ + + RetDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object; + + /* Returning a pointer to the object, add another reference! */ + + AcpiCmAddReference (RetDesc); + } + + else + { + /* + * This must be a reference object produced by the Index + * ASL operation -- check internal opcode + */ + + if ((ObjDesc->Reference.OpCode != AML_INDEX_OP) && + (ObjDesc->Reference.OpCode != AML_REF_OF_OP)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: DerefOf, invalid obj ref %p\n", + ObjDesc)); + + Status = AE_TYPE; + goto Cleanup; + } + + + switch (ObjDesc->Reference.OpCode) + { + case AML_INDEX_OP: + + /* + * Supported target types for the Index operator are + * 1) A Buffer + * 2) A Package + */ + + if (ObjDesc->Reference.TargetType == ACPI_TYPE_BUFFER_FIELD) + { + /* + * The target is a buffer, we must create a new object that + * contains one element of the buffer, the element pointed + * to by the index. + * + * NOTE: index into a buffer is NOT a pointer to a + * sub-buffer of the main buffer, it is only a pointer to a + * single element (byte) of the buffer! + */ + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + TmpDesc = ObjDesc->Reference.Object; + RetDesc->Number.Value = + TmpDesc->Buffer.Pointer[ObjDesc->Reference.Offset]; + + /* TBD: [Investigate] (see below) Don't add an additional + * ref! + */ + } + + else if (ObjDesc->Reference.TargetType == ACPI_TYPE_PACKAGE) + { + /* + * The target is a package, we want to return the referenced + * element of the package. We must add another reference to + * this object, however. + */ + + RetDesc = *(ObjDesc->Reference.Where); + if (!RetDesc) + { + /* + * We can't return a NULL dereferenced value. This is + * an uninitialized package element and is thus a + * severe error. + */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: DerefOf, NULL package element obj %p\n", + ObjDesc)); + Status = AE_AML_UNINITIALIZED_ELEMENT; + goto Cleanup; + } + + AcpiCmAddReference (RetDesc); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: DerefOf, Unknown TargetType %X in obj %p\n", + ObjDesc->Reference.TargetType, ObjDesc)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + break; + + + case AML_REF_OF_OP: + + RetDesc = ObjDesc->Reference.Object; + + /* Add another reference to the object! */ + + AcpiCmAddReference (RetDesc); + break; + } + } + + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic2: Unknown monadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + if (ObjDesc) + { + AcpiCmRemoveReference (ObjDesc); + } + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c new file mode 100644 index 0000000..60de051 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amnames.c @@ -0,0 +1,551 @@ + +/****************************************************************************** + * + * Module Name: amnames - interpreter/scanner name load/execute + * $Revision: 71 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMNAMES_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amnames") + + +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlAllocateNameString + * + * PARAMETERS: PrefixCount - Count of parent levels. Special cases: + * (-1) = root, 0 = none + * NumNameSegs - count of 4-character name segments + * + * RETURN: A pointer to the allocated string segment. This segment must + * be deleted by the caller. + * + * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name + * string is long enough, and set up prefix if any. + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiAmlAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs) +{ + NATIVE_CHAR *TempPtr; + NATIVE_CHAR *NameString; + UINT32 SizeNeeded; + + FUNCTION_TRACE ("AmlAllocateNameString"); + + + /* + * 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 == (UINT32) -1) + { + /* 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 = AcpiCmAllocate (SizeNeeded); + if (!NameString) + { + REPORT_ERROR (("AmlAllocateNameString: name allocation failure\n")); + return_PTR (NULL); + } + + TempPtr = NameString; + + /* Set up Root or Parent prefixes if needed */ + + if (PrefixCount == (UINT32) -1) + { + *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. AcpiAmlExecNameSegment() will + * append the segment(s) + */ + + *TempPtr = 0; + + return_PTR (NameString); +} + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecNameSegment + * + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) + * + * RETURN: Status + * + * DESCRIPTION: Execute a name segment (4 bytes) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecNameSegment ( + UINT8 **InAmlAddress, + NATIVE_CHAR *NameString) +{ + UINT8 *AmlAddress = *InAmlAddress; + ACPI_STATUS Status = AE_OK; + UINT32 Index; + NATIVE_CHAR CharBuf[5]; + + + FUNCTION_TRACE ("AmlExecNameSegment"); + + + /* + * 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') + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecNameSegment: leading digit: %c\n", CharBuf[0])); + return_ACPI_STATUS (AE_CTRL_PENDING); + } + + DEBUG_PRINT (TRACE_LOAD, ("AmlExecNameSegment: Bytes from stream:\n")); + + for (Index = 4; + (Index > 0) && (AcpiCmValidAcpiCharacter (*AmlAddress)); + --Index) + { + CharBuf[4 - Index] = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("%c\n", CharBuf[4 - Index])); + } + + + /* Valid name segment */ + + if (0 == Index) + { + /* Found 4 valid characters */ + + CharBuf[4] = '\0'; + + if (NameString) + { + STRCAT (NameString, CharBuf); + DEBUG_PRINT (TRACE_NAMES, + ("AmlExecNameSegment: Appended to - %s \n", NameString)); + } + + else + { + DEBUG_PRINT (TRACE_NAMES, + ("AmlExecNameSegment: No Name string - %s \n", CharBuf)); + } + } + + else if (4 == Index) + { + /* + * First character was not a valid name character, + * so we are looking at something other than a name. + */ + DEBUG_PRINT (ACPI_INFO, + ("AmlExecNameSegment: Leading INT8 not alpha: %02Xh (not a name)\n", + CharBuf[0])); + Status = AE_CTRL_PENDING; + } + + else + { + /* Segment started with one or more valid characters, but fewer than 4 */ + + Status = AE_AML_BAD_NAME; + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecNameSegment: Bad INT8 %02x in name, at %p\n", + *AmlAddress, AmlAddress)); + } + + DEBUG_PRINT (TRACE_EXEC, ("Leave AcpiAmlExecNameSegment %s \n", + AcpiCmFormatException (Status))); + + *InAmlAddress = AmlAddress; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlGetNameString + * + * PARAMETERS: DataType - Data type to be associated with this name + * + * RETURN: Status + * + * DESCRIPTION: Get a name, including any prefixes. + * + ******************************************************************************/ + + +ACPI_STATUS +AcpiAmlGetNameString ( + OBJECT_TYPE_INTERNAL DataType, + UINT8 *InAmlAddress, + NATIVE_CHAR **OutNameString, + UINT32 *OutNameLength) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *AmlAddress = InAmlAddress; + NATIVE_CHAR *NameString = NULL; + UINT32 NumSegments; + UINT32 PrefixCount = 0; + UINT8 Prefix = 0; + BOOLEAN HasPrefix = FALSE; + + + FUNCTION_TRACE_PTR ("AmlGetNameString", AmlAddress); + + + if (INTERNAL_TYPE_DEF_FIELD == DataType || + INTERNAL_TYPE_BANK_FIELD == DataType || + INTERNAL_TYPE_INDEX_FIELD == DataType) + { + /* Disallow prefixes for types associated with field names */ + + NameString = AcpiAmlAllocateNameString (0, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + } + else + { + Status = AcpiAmlExecNameSegment (&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: + + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("RootPrefix: %x\n", Prefix)); + + /* + * Remember that we have a RootPrefix -- + * see comment in AcpiAmlAllocateNameString() + */ + PrefixCount = (UINT32) -1; + HasPrefix = TRUE; + break; + + + case AML_PARENT_PREFIX: + + /* Increment past possibly multiple parent prefixes */ + + do + { + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("ParentPrefix: %x\n", Prefix)); + + ++PrefixCount; + + } while (*AmlAddress == AML_PARENT_PREFIX); + HasPrefix = TRUE; + break; + + + default: + + break; + } + + + /* Examine first character of name for name segment prefix operator */ + + switch (*AmlAddress) + { + + case AML_DUAL_NAME_PREFIX: + + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("DualNamePrefix: %x\n", Prefix)); + + NameString = AcpiAmlAllocateNameString (PrefixCount, 2); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + HasPrefix = TRUE; + + Status = AcpiAmlExecNameSegment (&AmlAddress, NameString); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiAmlExecNameSegment (&AmlAddress, NameString); + } + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("MultiNamePrefix: %x\n", Prefix)); + + /* Fetch count of segments remaining in name path */ + + NumSegments = *AmlAddress++; + + NameString = AcpiAmlAllocateNameString (PrefixCount, NumSegments); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + HasPrefix = TRUE; + + while (NumSegments && + (Status = AcpiAmlExecNameSegment (&AmlAddress, NameString)) == AE_OK) + { + --NumSegments; + } + + break; + + + case 0: + + /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ + + if (-1 == PrefixCount) + { + DEBUG_PRINT (TRACE_EXEC, + ("AmlDoName: NameSeg is \"\\\" followed by NULL\n")); + } + + /* Consume the NULL byte */ + + AmlAddress++; + NameString = AcpiAmlAllocateNameString (PrefixCount, 0); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + break; + + + default: + + /* Name segment string */ + + NameString = AcpiAmlAllocateNameString (PrefixCount, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + Status = AcpiAmlExecNameSegment (&AmlAddress, NameString); + break; + + } /* Switch (PeekOp ()) */ + } + + + if (AE_CTRL_PENDING == Status && HasPrefix) + { + /* Ran out of segments after processing a prefix */ + + REPORT_ERROR ( + ("AmlDoName: Malformed Name at %p\n", NameString)); + Status = AE_AML_BAD_NAME; + } + + + *OutNameString = NameString; + *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c new file mode 100644 index 0000000..5771610 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amprep.c @@ -0,0 +1,580 @@ + +/****************************************************************************** + * + * Module Name: amprep - ACPI AML (p-code) execution - field prep utilities + * $Revision: 67 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMPREP_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amprep") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlDecodeFieldAccessType + * + * PARAMETERS: Access - Encoded field access bits + * + * RETURN: Field granularity (8, 16, or 32) + * + * DESCRIPTION: Decode the AccessType bits of a field definition. + * + ******************************************************************************/ + +UINT32 +AcpiAmlDecodeFieldAccessType ( + UINT32 Access) +{ + + switch (Access) + { + case ACCESS_ANY_ACC: + return (8); + break; + + case ACCESS_BYTE_ACC: + return (8); + break; + + case ACCESS_WORD_ACC: + return (16); + break; + + case ACCESS_DWORD_ACC: + return (32); + break; + + default: + /* Invalid field access type */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlDecodeFieldAccessType: Unknown field access type %x\n", + Access)); + return (0); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepCommonFieldObjec + * + * PARAMETERS: ObjDesc - The field object + * FieldFlags - Access, LockRule, or UpdateRule. + * The format of a FieldFlag is described + * in the ACPI specification + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Initialize the areas of the field object that are common + * to the various types of fields. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + UINT32 Granularity; + + + FUNCTION_TRACE ("AmlPrepCommonFieldObject"); + + + /* + * Note: the structure being initialized is the + * ACPI_COMMON_FIELD_INFO; Therefore, we can just use the Field union to + * access this common area. No structure fields outside of the common area + * are initialized by this procedure. + */ + + /* Decode the FieldFlags */ + + ObjDesc->Field.Access = (UINT8) ((FieldFlags & ACCESS_TYPE_MASK) + >> ACCESS_TYPE_SHIFT); + ObjDesc->Field.LockRule = (UINT8) ((FieldFlags & LOCK_RULE_MASK) + >> LOCK_RULE_SHIFT); + ObjDesc->Field.UpdateRule = (UINT8) ((FieldFlags & UPDATE_RULE_MASK) + >> UPDATE_RULE_SHIFT); + + /* Other misc fields */ + + ObjDesc->Field.Length = (UINT16) FieldLength; + ObjDesc->Field.AccessAttribute = FieldAttribute; + + /* Decode the access type so we can compute offsets */ + + Granularity = AcpiAmlDecodeFieldAccessType (ObjDesc->Field.Access); + if (!Granularity) + { + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + /* Access granularity based fields */ + + ObjDesc->Field.Granularity = (UINT8) Granularity; + ObjDesc->Field.BitOffset = (UINT8) (FieldPosition % Granularity); + ObjDesc->Field.Offset = (UINT32) FieldPosition / Granularity; + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepDefFieldValue + * + * PARAMETERS: Node - Owning Node + * Region - Region in which field is being defined + * FieldFlags - Access, LockRule, or UpdateRule. + * The format of a FieldFlag is described + * in the ACPI specification + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepDefFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Type; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlPrepDefFieldValue"); + + + /* Parameter validation */ + + if (!Region) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlPrepDefFieldValue: null Region\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + Type = AcpiNsGetType (Region); + if (Type != ACPI_TYPE_REGION) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlPrepDefFieldValue: Needed Region, found %d %s\n", + Type, AcpiCmGetTypeName (Type))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Allocate a new object */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_DEF_FIELD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + /* ObjDesc and Region valid */ + + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE, + "AmlPrepDefFieldValue", 1, "case DefField"); + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE, + "AmlPrepDefFieldValue", 1, "case DefField"); + + /* Initialize areas of the object that are common to all fields */ + + Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, + FieldPosition, FieldLength); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to this field type */ + + ObjDesc->Field.Container = AcpiNsGetAttachedObject (Region); + + /* An additional reference for the container */ + + AcpiCmAddReference (ObjDesc->Field.Container); + + + /* Debug info */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepDefFieldValue: bitoff=%X off=%X gran=%X\n", + ObjDesc->Field.BitOffset, ObjDesc->Field.Offset, + ObjDesc->Field.Granularity)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepDefFieldValue: set NamedObj %p (%4.4s) val = %p\n", + Node, &(Node->Name), ObjDesc)); + + DUMP_STACK_ENTRY (ObjDesc); + DUMP_ENTRY (Region, ACPI_INFO); + DEBUG_PRINT (ACPI_INFO, ("\t%p \n", ObjDesc->Field.Container)); + if (ObjDesc->Field.Container) + { + DUMP_STACK_ENTRY (ObjDesc->Field.Container); + } + DEBUG_PRINT (ACPI_INFO, + ("============================================================\n")); + + /* + * Store the constructed descriptor (ObjDesc) into the NamedObj whose + * handle is on TOS, preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepBankFieldValue + * + * PARAMETERS: Node - Owning Node + * Region - Region in which field is being defined + * BankReg - Bank selection register + * BankVal - Value to store in selection register + * FieldFlags - Access, LockRule, or UpdateRule + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type BankField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepBankFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + ACPI_HANDLE BankReg, + UINT32 BankVal, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Type; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlPrepBankFieldValue"); + + + /* Parameter validation */ + + if (!Region) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlPrepBankFieldValue: null Region\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + Type = AcpiNsGetType (Region); + if (Type != ACPI_TYPE_REGION) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlPrepBankFieldValue: Needed Region, found %d %s\n", + Type, AcpiCmGetTypeName (Type))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Allocate a new object */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_BANK_FIELD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* ObjDesc and Region valid */ + + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE, + "AmlPrepBankFieldValue", 1, "case BankField"); + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE, + "AmlPrepBankFieldValue", 1, "case BankField"); + + /* Initialize areas of the object that are common to all fields */ + + Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, + FieldPosition, FieldLength); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to this field type */ + + ObjDesc->BankField.Value = BankVal; + ObjDesc->BankField.Container = AcpiNsGetAttachedObject (Region); + ObjDesc->BankField.BankSelect = AcpiNsGetAttachedObject (BankReg); + + /* An additional reference for the container and bank select */ + /* TBD: [Restructure] is "BankSelect" ever a real internal object?? */ + + AcpiCmAddReference (ObjDesc->BankField.Container); + AcpiCmAddReference (ObjDesc->BankField.BankSelect); + + /* Debug info */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepBankFieldValue: bitoff=%X off=%X gran=%X\n", + ObjDesc->BankField.BitOffset, ObjDesc->BankField.Offset, + ObjDesc->Field.Granularity)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepBankFieldValue: set NamedObj %p (%4.4s) val = %p\n", + Node, &(Node->Name), ObjDesc)); + + DUMP_STACK_ENTRY (ObjDesc); + DUMP_ENTRY (Region, ACPI_INFO); + DUMP_ENTRY (BankReg, ACPI_INFO); + DEBUG_PRINT (ACPI_INFO, + ("============================================================\n")); + + /* + * Store the constructed descriptor (ObjDesc) into the NamedObj whose + * handle is on TOS, preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepIndexFieldValue + * + * PARAMETERS: Node - Owning Node + * IndexReg - Index register + * DataReg - Data register + * FieldFlags - Access, LockRule, or UpdateRule + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type IndexField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepIndexFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE IndexReg, + ACPI_HANDLE DataReg, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlPrepIndexFieldValue"); + + + /* Parameter validation */ + + if (!IndexReg || !DataReg) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlPrepIndexFieldValue: null handle\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* Allocate a new object descriptor */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_INDEX_FIELD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize areas of the object that are common to all fields */ + + Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, + FieldPosition, FieldLength); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to this field type */ + + ObjDesc->IndexField.Value = (UINT32) (FieldPosition / + ObjDesc->Field.Granularity); + ObjDesc->IndexField.Index = IndexReg; + ObjDesc->IndexField.Data = DataReg; + + /* Debug info */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepIndexFieldValue: bitoff=%X off=%X gran=%X\n", + ObjDesc->IndexField.BitOffset, ObjDesc->IndexField.Offset, + ObjDesc->Field.Granularity)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepIndexFieldValue: set NamedObj %p (%4.4s) val = %p\n", + Node, &(Node->Name), ObjDesc)); + + DUMP_STACK_ENTRY (ObjDesc); + DUMP_ENTRY (IndexReg, ACPI_INFO); + DUMP_ENTRY (DataReg, ACPI_INFO); + DEBUG_PRINT (ACPI_INFO, + ("============================================================\n")); + + /* + * Store the constructed descriptor (ObjDesc) into the NamedObj whose + * handle is on TOS, preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node)); + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c new file mode 100644 index 0000000..181ef59 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amregion.c @@ -0,0 +1,561 @@ + +/****************************************************************************** + * + * Module Name: amregion - ACPI default OpRegion (address space) handlers + * $Revision: 36 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMREGION_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amregion") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemMemorySpaceHandler + * + * 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 +AcpiAmlSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + void *LogicalAddrPtr = NULL; + MEM_HANDLER_CONTEXT *MemInfo = RegionContext; + UINT32 Length; + + + FUNCTION_TRACE ("AmlSystemMemorySpaceHandler"); + + + /* Validate and translate the bit width */ + + switch (BitWidth) + { + case 8: + Length = 1; + break; + + case 16: + Length = 2; + break; + + case 32: + Length = 4; + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlSystemMemorySpaceHandler: Invalid SystemMemory width %d\n", + BitWidth)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + break; + } + + + /* + * 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 < (ACPI_INTEGER) MemInfo->MappedPhysicalAddress) || + ((Address + Length) > + (ACPI_INTEGER) (MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + { + /* + * The request cannot be resolved by the current memory mapping; + * Delete the existing mapping and create a new one. + */ + + if (MemInfo->MappedLength) + { + /* Valid mapping, delete it */ + + AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress, + MemInfo->MappedLength); + } + + MemInfo->MappedLength = 0; /* In case of failure below */ + + /* Create a new mapping starting at the address given */ + + Status = AcpiOsMapMemory ((void *) (UINT32) Address, SYSMEM_REGION_WINDOW_SIZE, + (void **) &MemInfo->MappedLogicalAddress); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* TBD: should these pointers go to 64-bit in all cases ? */ + + MemInfo->MappedPhysicalAddress = (UINT8 *) (UINT32) Address; + MemInfo->MappedLength = SYSMEM_REGION_WINDOW_SIZE; + } + + + /* + * Generate a logical pointer corresponding to the address we want to + * access + */ + + /* TBD: should these pointers go to 64-bit in all cases ? */ + + LogicalAddrPtr = MemInfo->MappedLogicalAddress + + ((UINT8 *) (UINT32) Address - MemInfo->MappedPhysicalAddress); + + /* Perform the memory read or write */ + + switch (Function) + { + + case ADDRESS_SPACE_READ: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Read (%d width) Address:0x%X\n", BitWidth, Address)); + + switch (BitWidth) + { + case 8: + *Value = (UINT32)* (UINT8 *) LogicalAddrPtr; + break; + + case 16: + MOVE_UNALIGNED16_TO_32 (Value, LogicalAddrPtr); + break; + + case 32: + MOVE_UNALIGNED32_TO_32 (Value, LogicalAddrPtr); + break; + } + + break; + + + case ADDRESS_SPACE_WRITE: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Write (%d width) Address:0x%p Value 0x%X\n", + BitWidth, Address, *Value)); + + switch (BitWidth) + { + case 8: + *(UINT8 *) LogicalAddrPtr = (UINT8) *Value; + break; + + case 16: + MOVE_UNALIGNED16_TO_16 (LogicalAddrPtr, Value); + break; + + case 32: + MOVE_UNALIGNED32_TO_32 (LogicalAddrPtr, Value); + break; + } + + break; + + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemIoSpaceHandler + * + * 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 +AcpiAmlSystemIoSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AmlSystemIoSpaceHandler"); + + + /* Decode the function parameter */ + + switch (Function) + { + + case ADDRESS_SPACE_READ: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Read(%d width) Address:0x%08x\n", BitWidth, Address)); + + switch (BitWidth) + { + /* I/O Port width */ + + case 8: + *Value = (UINT32) AcpiOsIn8 ((ACPI_IO_ADDRESS) Address); + break; + + case 16: + *Value = (UINT32) AcpiOsIn16 ((ACPI_IO_ADDRESS) Address); + break; + + case 32: + *Value = AcpiOsIn32 ((ACPI_IO_ADDRESS) Address); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlSystemIoSpaceHandler: Invalid SystemIO width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + } + + break; + + + case ADDRESS_SPACE_WRITE: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Write(%d width) Address:0x%08x Value 0x%08x\n", + BitWidth, Address, *Value)); + + switch (BitWidth) + { + /* I/O Port width */ + case 8: + AcpiOsOut8 ((ACPI_IO_ADDRESS) Address, (UINT8) *Value); + break; + + case 16: + AcpiOsOut16 ((ACPI_IO_ADDRESS) Address, (UINT16) *Value); + break; + + case 32: + AcpiOsOut32 ((ACPI_IO_ADDRESS) Address, *Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ( + "AmlSystemIoSpaceHandler: Invalid SystemIO width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + } + + break; + + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPciConfigSpaceHandler + * + * 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 +AcpiAmlPciConfigSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + UINT32 PciBus; + UINT32 DevFunc; + UINT8 PciReg; + PCI_HANDLER_CONTEXT *PCIContext; + + + FUNCTION_TRACE ("AmlPciConfigSpaceHandler"); + + /* + * The arguments to AcpiOs(Read|Write)PciCfg(Byte|Word|Dword) are: + * + * SegBus - 0xSSSSBBBB - SSSS is the PCI bus segment + * BBBB is the PCI bus number + * + * DevFunc - 0xDDDDFFFF - DDDD is the PCI device number + * FFFF is the PCI device function number + * + * RegNum - Config space register must be < 40h + * + * Value - input value for write, output for read + * + */ + + PCIContext = (PCI_HANDLER_CONTEXT *) RegionContext; + + PciBus = LOWORD(PCIContext->Seg) << 16; + PciBus |= LOWORD(PCIContext->Bus); + + DevFunc = PCIContext->DevFunc; + + PciReg = (UINT8) Address; + + switch (Function) + { + + case ADDRESS_SPACE_READ: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("R%d S(%04x) B(%04x) DF(%08x) R(%04x)\n", BitWidth, + PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc, PciReg)); + + *Value = 0; + + switch (BitWidth) + { + /* PCI Register width */ + + case 8: + Status = AcpiOsReadPciCfgByte (PciBus, DevFunc, PciReg, + (UINT8 *) Value); + break; + + case 16: + Status = AcpiOsReadPciCfgWord (PciBus, DevFunc, PciReg, + (UINT16 *) Value); + break; + + case 32: + Status = AcpiOsReadPciCfgDword (PciBus, DevFunc, PciReg, + Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlPciConfigSpaceHandler: Invalid PCIConfig width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + + } /* Switch bitWidth */ + + break; + + + case ADDRESS_SPACE_WRITE: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("W%d S(%04x) B(%04x) DF(%08x) R(%04x) D(%08x)\n", BitWidth, + PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc, + PciReg,*Value)); + + switch (BitWidth) + { + /* PCI Register width */ + + case 8: + Status = AcpiOsWritePciCfgByte (PciBus, DevFunc, PciReg, + *(UINT8 *) Value); + break; + + case 16: + Status = AcpiOsWritePciCfgWord (PciBus, DevFunc, PciReg, + *(UINT16 *) Value); + break; + + case 32: + Status = AcpiOsWritePciCfgDword (PciBus, DevFunc, PciReg, + *Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ( + "AmlPciConfigSpaceHandler: Invalid PCIConfig width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + + } /* Switch bitWidth */ + + break; + + + default: + + Status = AE_BAD_PARAMETER; + break; + + } + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c new file mode 100644 index 0000000..a7785a9 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresnte.c @@ -0,0 +1,693 @@ + +/****************************************************************************** + * + * Module Name: amresnte - AML Interpreter object resolution + * $Revision: 23 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMRESNTE_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amresnte") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveNodeToValue + * + * PARAMETERS: StackPtr - Pointer to a location on a stack that contains + * a pointer to an Node + * + * RETURN: Status + * + * DESCRIPTION: Resolve a ACPI_NAMESPACE_NODE (Node, + * A.K.A. a "direct name pointer") + * + * 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_NUMBER + * ACPI_TYPE_STRING + * ACPI_TYPE_BUFFER + * ACPI_TYPE_MUTEX + * ACPI_TYPE_PACKAGE + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveNodeToValue ( + ACPI_NAMESPACE_NODE **StackPtr) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ValDesc = NULL; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + UINT8 *AmlPointer = NULL; + OBJECT_TYPE_INTERNAL EntryType; + BOOLEAN Locked; + BOOLEAN AttachedAmlPointer = FALSE; + UINT8 AmlOpcode = 0; + ACPI_INTEGER TempVal; + OBJECT_TYPE_INTERNAL ObjectType; + + + FUNCTION_TRACE ("AmlResolveEntryToValue"); + + Node = *StackPtr; + + + /* + * The stack pointer is a "Direct name ptr", and points to a + * a ACPI_NAMESPACE_NODE (Node). Get the pointer that is attached to + * the Node. + */ + + ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveEntryToValue: Entry=%p ValDesc=%p Type=%X\n", + Node, ValDesc, EntryType)); + + /* + * The ValDesc attached to the Node can be either: + * 1) An internal ACPI object + * 2) A pointer into the AML stream (into one of the ACPI system tables) + */ + + if (AcpiTbSystemTablePointer (ValDesc)) + { + AttachedAmlPointer = TRUE; + AmlOpcode = *((UINT8 *) ValDesc); + AmlPointer = ((UINT8 *) ValDesc) + 1; + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveEntryToValue: Unparsed AML: %p Len=%X\n", + AmlOpcode, AmlPointer)); + } + + + /* + * Several EntryTypes do not require further processing, so + * we will return immediately + */ + /* Devices rarely have an attached object, return the Node + * and Method locals and arguments have a pseudo-Node + */ + if (EntryType == ACPI_TYPE_DEVICE || + EntryType == INTERNAL_TYPE_METHOD_ARGUMENT || + EntryType == INTERNAL_TYPE_METHOD_LOCAL_VAR) + { + return_ACPI_STATUS (AE_OK); + } + + if (!ValDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: No object attached to node %p\n", + Node)); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Action is based on the type of the Node, which indicates the type + * of the attached object or pointer + */ + switch (EntryType) + { + + case ACPI_TYPE_PACKAGE: + + if (AttachedAmlPointer) + { + /* + * This means that the package initialization is not parsed + * -- should not happen + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Unparsed Packages not supported!\n")); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + /* ValDesc is an internal object in all cases by the time we get here */ + + if (ACPI_TYPE_PACKAGE != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Object not a package, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + case ACPI_TYPE_BUFFER: + + if (AttachedAmlPointer) + { + /* + * This means that the buffer initialization is not parsed + * -- should not happen + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Unparsed Buffers not supported!\n")); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + /* ValDesc is an internal object in all cases by the time we get here */ + + if (ACPI_TYPE_BUFFER != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Object not a buffer, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + case ACPI_TYPE_STRING: + + if (AttachedAmlPointer) + { + /* Allocate a new string object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init the internal object */ + + ObjDesc->String.Pointer = (NATIVE_CHAR *) AmlPointer; + ObjDesc->String.Length = STRLEN (ObjDesc->String.Pointer); + } + + else + { + if (ACPI_TYPE_STRING != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Object not a string, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + } + + break; + + + case ACPI_TYPE_NUMBER: + + DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: case Number \n")); + + /* + * The Node has an attached internal object, make sure that it's a + * number + */ + + if (ACPI_TYPE_NUMBER != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveToValue: Object not a Number, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + /* + * TBD: [Investigate] Is this the correct solution? + * + * This section was extended to convert to generic buffer if + * the return length is greater than 32 bits, but still allows + * for returning a type Number for smaller values because the + * caller can then apply arithmetic operators on those fields. + * + * XXX - Implementation limitation: Fields are implemented as type + * XXX - Number, but they really are supposed to be type Buffer. + * XXX - The two are interchangeable only for lengths <= 32 bits. + */ + if(ValDesc->Field.Length > 32) + { + ObjectType = ACPI_TYPE_BUFFER; + } + else + { + ObjectType = ACPI_TYPE_NUMBER; + } + + /* + * Create the destination buffer object and the buffer space. + */ + ObjDesc = AcpiCmCreateInternalObject (ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Fill in the object specific details + */ + if (ACPI_TYPE_BUFFER == ObjectType) + { + ObjDesc->Buffer.Pointer = AcpiCmCallocate (ValDesc->Field.Length); + if (!ObjDesc->Buffer.Pointer) + { + AcpiCmRemoveReference(ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Buffer.Length = ValDesc->Field.Length; + + Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node, + ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node, + &TempVal, sizeof (TempVal)); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc->Number.Value = TempVal; + } + + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveEntryToValue: DefField Entry=%p ValDesc=%p Type=%X\n", + Node, ValDesc, EntryType)); + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + if (AttachedAmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: BankField cannot be an Aml ptr\n")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (INTERNAL_TYPE_BANK_FIELD != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlResolveToValue: Object not a BankField, type %X\n", + ValDesc->Common.Type)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* Get the global lock if needed */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr; + Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule); + + /* Set Index value to select proper Data register */ + /* perform the update */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + ValDesc->BankField.BankSelect, &ValDesc->BankField.Value, + sizeof (ValDesc->BankField.Value)); + + AcpiAmlReleaseGlobalLock (Locked); + + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Read Data value */ + + Status = AcpiAmlAccessNamedField (ACPI_READ, + (ACPI_HANDLE) ValDesc->BankField.Container, + &TempVal, sizeof (TempVal)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create an object for the result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Number.Value = TempVal; + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + if (AttachedAmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal - IndexField cannot be an Aml ptr\n")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (INTERNAL_TYPE_INDEX_FIELD != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlResolveToValue: Object not an IndexField, type %X\n", + ValDesc->Common.Type)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* Set Index value to select proper Data register */ + /* Get the global lock if needed */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr; + Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule); + + /* Perform the update */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + ValDesc->IndexField.Index, &ValDesc->IndexField.Value, + sizeof (ValDesc->IndexField.Value)); + + AcpiAmlReleaseGlobalLock (Locked); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Read Data value */ + + Status = AcpiAmlAccessNamedField (ACPI_READ, ValDesc->IndexField.Data, + &TempVal, sizeof (TempVal)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create an object for the result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Number.Value = TempVal; + break; + + + case ACPI_TYPE_FIELD_UNIT: + + if (AttachedAmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: FieldUnit cannot be an Aml ptr\n")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ValDesc->Common.Type != (UINT8) EntryType) + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlResolveToValue: Object type %X not same as EntryType %X\n", + ValDesc->Common.Type, EntryType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + break; + } + + /* Create object for result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiAmlGetFieldUnitValue (ValDesc, ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); + } + + break; + + + /* + * For these objects, just return the object attached to the Node + */ + + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_METHOD: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + /* TYPE_Any is untyped, and thus there is no object associated with it */ + + case ACPI_TYPE_ANY: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Untyped entry %p, no attached object!\n", + Node)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ + break; + + + /* + * The only named references allowed are named constants + * + * e.g. Name (\OSFL, Ones) + */ + case INTERNAL_TYPE_REFERENCE: + + switch (ValDesc->Reference.OpCode) + { + + case AML_ZERO_OP: + + TempVal = 0; + break; + + + case AML_ONE_OP: + + TempVal = 1; + break; + + + case AML_ONES_OP: + + TempVal = ACPI_UINT32_MAX; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveToValue/Number: Unsupported reference opcode %X\n", + ValDesc->Reference.OpCode)); + + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + /* Create object for result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Number.Value = TempVal; + + break; + + + /* Default case is for unknown types */ + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Node %p - Unknown object type %X\n", + Node, EntryType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + + } /* switch (EntryType) */ + + + /* Put the object descriptor on the stack */ + + *StackPtr = (void *) ObjDesc; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c new file mode 100644 index 0000000..5f23c2d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresolv.c @@ -0,0 +1,629 @@ + +/****************************************************************************** + * + * Module Name: amresolv - AML Interpreter object resolution + * $Revision: 76 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMRESOLV_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amresolv") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlGetFieldUnitValue + * + * PARAMETERS: *FieldDesc - Pointer to a FieldUnit + * *ResultDesc - Pointer to an empty descriptor + * which will become a Number + * containing the field's value. + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value from a FieldUnit + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlGetFieldUnitValue ( + ACPI_OPERAND_OBJECT *FieldDesc, + ACPI_OPERAND_OBJECT *ResultDesc) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Mask; + UINT8 *Location = NULL; + BOOLEAN Locked = FALSE; + + + FUNCTION_TRACE ("AmlGetFieldUnitValue"); + + + if (!FieldDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - null field pointer\n")); + Status = AE_AML_NO_OPERAND; + } + + if (!(FieldDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetFieldUnitArguments (FieldDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (!FieldDesc->FieldUnit.Container) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - null container pointer\n")); + Status = AE_AML_INTERNAL; + } + + else if (ACPI_TYPE_BUFFER != FieldDesc->FieldUnit.Container->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - container is not a Buffer\n")); + Status = AE_AML_OPERAND_TYPE; + } + + else if (!ResultDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - null result pointer\n")); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Get the global lock if needed */ + + Locked = AcpiAmlAcquireGlobalLock (FieldDesc->FieldUnit.LockRule); + + /* Field location is (base of buffer) + (byte offset) */ + + Location = FieldDesc->FieldUnit.Container->Buffer.Pointer + + FieldDesc->FieldUnit.Offset; + + /* + * Construct Mask with as many 1 bits as the field width + * + * NOTE: Only the bottom 5 bits are valid for a shift operation, so + * special care must be taken for any shift greater than 31 bits. + * + * TBD: [Unhandled] Fields greater than 32-bits will not work. + */ + + if (FieldDesc->FieldUnit.Length < 32) + { + Mask = ((UINT32) 1 << FieldDesc->FieldUnit.Length) - (UINT32) 1; + } + else + { + Mask = ACPI_UINT32_MAX; + } + + ResultDesc->Number.Type = (UINT8) ACPI_TYPE_NUMBER; + + /* Get the 32 bit value at the location */ + + MOVE_UNALIGNED32_TO_32 (&ResultDesc->Number.Value, Location); + + /* + * Shift the 32-bit word containing the field, and mask off the + * resulting value + */ + + ResultDesc->Number.Value = + (ResultDesc->Number.Value >> FieldDesc->FieldUnit.BitOffset) & Mask; + + DEBUG_PRINT (ACPI_INFO, + ("** Read from buffer %p byte %ld bit %d width %d addr %p mask %08lx val %08lx\n", + FieldDesc->FieldUnit.Container->Buffer.Pointer, + FieldDesc->FieldUnit.Offset, + FieldDesc->FieldUnit.BitOffset, + FieldDesc->FieldUnit.Length, + Location, Mask, ResultDesc->Number.Value)); + + /* Release global lock if we acquired it earlier */ + + AcpiAmlReleaseGlobalLock (Locked); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveToValue + * + * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can + * be either an (ACPI_OPERAND_OBJECT *) + * or an ACPI_HANDLE. + * + * RETURN: Status + * + * DESCRIPTION: Convert Reference entries on ObjStack to Rvalues + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AmlResolveToValue", StackPtr); + + + if (!StackPtr || !*StackPtr) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveToValue: Internal error - null pointer\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + + /* + * The entity pointed to by the StackPtr can be either + * 1) A valid ACPI_OPERAND_OBJECT, or + * 2) A ACPI_NAMESPACE_NODE (NamedObj) + */ + + if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_INTERNAL)) + { + + Status = AcpiAmlResolveObjectToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Object on the stack may have changed if AcpiAmlResolveObjectToValue() + * was called (i.e., we can't use an _else_ here.) + */ + + if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_NAMED)) + { + Status = AcpiAmlResolveNodeToValue ((ACPI_NAMESPACE_NODE **) StackPtr); + } + + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveToValue: Returning resolved object %p\n", *StackPtr)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveObjectToValue + * + * PARAMETERS: StackPtr - Pointer to a stack location that contains a + * ptr to an internal object. + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value from an internal object. The Reference type + * uses the associated AML opcode to determine the value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *StackDesc; + ACPI_STATUS Status = AE_OK; + ACPI_HANDLE TempHandle = NULL; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + UINT32 Index = 0; + UINT16 Opcode; + + + FUNCTION_TRACE ("AmlResolveObjectToValue"); + + + StackDesc = *StackPtr; + + /* This is an ACPI_OPERAND_OBJECT */ + + switch (StackDesc->Common.Type) + { + + case INTERNAL_TYPE_REFERENCE: + + Opcode = StackDesc->Reference.OpCode; + + switch (Opcode) + { + + case AML_NAME_OP: + + /* + * Convert indirect name ptr to a direct name ptr. + * Then, AcpiAmlResolveNodeToValue can be used to get the value + */ + + TempHandle = StackDesc->Reference.Object; + + /* Delete the Reference Object */ + + AcpiCmRemoveReference (StackDesc); + + /* Put direct name pointer onto stack and exit */ + + (*StackPtr) = TempHandle; + Status = AE_OK; + break; + + + case AML_LOCAL_OP: + + Index = StackDesc->Reference.Offset; + + /* + * Get the local from the method's state info + * Note: this increments the local's object reference count + */ + + Status = AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL, Index, + WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now we can delete the original Reference Object and + * replace it with the resolve value + */ + + AcpiCmRemoveReference (StackDesc); + *StackPtr = ObjDesc; + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveObjectToValue: [Local%d] ValueObj is %p\n", + Index, ObjDesc)); + + if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) + { + /* Value is a Number */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveObjectToValue: [Local%d] value is [0x%X] \n", + Index, ObjDesc->Number.Value)); + } + + break; + + + case AML_ARG_OP: + + Index = StackDesc->Reference.Offset; + + + /* + * Get the argument from the method's state info + * Note: this increments the object reference count + */ + + Status = AcpiDsMethodDataGetValue (MTH_TYPE_ARG, Index, + WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now we can delete the original Reference Object and + * replace it with the resolve value + */ + + AcpiCmRemoveReference (StackDesc); + *StackPtr = ObjDesc; + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveObjectToValue: [Arg%d] ValueObj is %p\n", + Index, ObjDesc)); + + if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) + { + /* Value is a Number */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveObjectToValue: [Arg%d] value is [0x%X] \n", + Index, ObjDesc->Number.Value)); + } + + break; + + + /* + * TBD: [Restructure] These next three opcodes change the type of + * the object, which is actually a no-no. + */ + + case AML_ZERO_OP: + + StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; + StackDesc->Number.Value = 0; + break; + + + case AML_ONE_OP: + + StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; + StackDesc->Number.Value = 1; + break; + + + case AML_ONES_OP: + + StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; + StackDesc->Number.Value = ACPI_INTEGER_MAX; + break; + + + case AML_INDEX_OP: + + switch (StackDesc->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + /* Just return - leave the Reference on the stack */ + break; + + + case ACPI_TYPE_PACKAGE: + ObjDesc = *StackDesc->Reference.Where; + if (ObjDesc) + { + /* + * Valid obj descriptor, copy pointer to return value + * (i.e., dereference the package index) + * Delete the ref object, increment the returned object + */ + AcpiCmRemoveReference (StackDesc); + AcpiCmAddReference (ObjDesc); + *StackPtr = ObjDesc; + } + + else + { + /* + * A NULL object descriptor means an unitialized element of + * the package, can't deref it + */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveObjectToValue: Attempt to deref an Index to NULL pkg element Idx=%p\n", StackDesc)); + Status = AE_AML_UNINITIALIZED_ELEMENT; + } + break; + + default: + /* Invalid reference OBJ*/ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveObjectToValue: Unknown TargetType %d in Index/Reference obj %p\n", + StackDesc->Reference.TargetType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + + break; + + + case AML_DEBUG_OP: + + /* Just leave the object as-is */ + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveObjectToValue: Unknown Reference object subtype %02x in %p\n", + Opcode, StackDesc)); + Status = AE_AML_INTERNAL; + + } /* switch (Opcode) */ + + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + break; /* case INTERNAL_TYPE_REFERENCE */ + + + case ACPI_TYPE_FIELD_UNIT: + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); + if (!ObjDesc) + { + /* Descriptor allocation failure */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + + *StackPtr = (void *) ObjDesc; + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); + if (!ObjDesc) + { + /* Descriptor allocation failure */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + + *StackPtr = (void *) ObjDesc; + break; + + + /* TBD: [Future] - may need to handle IndexField, and DefField someday */ + + default: + + break; + + } /* switch (StackDesc->Common.Type) */ + + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c new file mode 100644 index 0000000..02a13d4 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amresop.c @@ -0,0 +1,629 @@ + +/****************************************************************************** + * + * Module Name: amresop - AML Interpreter operand/object resolution + * $Revision: 15 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMRESOP_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amresop") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveOperands + * + * PARAMETERS: Opcode Opcode being interpreted + * StackPtr Top of operand stack + * + * RETURN: Status + * + * DESCRIPTION: Convert stack entries to required types + * + * Each nibble in ArgTypes represents one required operand + * and indicates the required Type: + * + * The corresponding stack entry will be converted to the + * required type if possible, else return an exception + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + UINT8 ObjectType; + ACPI_HANDLE TempHandle; + UINT32 ArgTypes; + ACPI_OPCODE_INFO *OpInfo; + UINT32 ThisArgType; + + + FUNCTION_TRACE_U32 ("AmlResolveOperands", Opcode); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + + ArgTypes = OpInfo->RuntimeArgs; + if (ArgTypes == ARGI_INVALID_OPCODE) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Internal error - %X is not a runtime opcode\n", Opcode)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveOperands: Opcode %X OperandTypes=%X \n", + Opcode, ArgTypes)); + + + /* + * Normal exit is with *Types == '\0' at end of string. + * Function will return an exception from within the loop upon + * finding an entry which is not, and cannot be converted + * to, the required type; if stack underflows; or upon + * finding a NULL stack entry (which "should never happen"). + */ + + while (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + if (!StackPtr || !*StackPtr) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Internal error - null stack entry at %X\n", StackPtr)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + /* Extract useful items */ + + ObjDesc = *StackPtr; + + /* Decode the descriptor type */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Node */ + + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) + { + /* ACPI internal object */ + + ObjectType = ObjDesc->Common.Type; + + /* Check for bad ACPI_OBJECT_TYPE */ + + if (!AcpiAmlValidateObjectType (ObjectType)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Bad operand object type [0x%x]\n", + ObjectType)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (ObjectType == (UINT8) INTERNAL_TYPE_REFERENCE) + { + /* + * Decode the Reference + */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + + switch (ObjDesc->Reference.OpCode) + { + case AML_ZERO_OP: + case AML_ONE_OP: + case AML_ONES_OP: + case AML_DEBUG_OP: + case AML_NAME_OP: + case AML_INDEX_OP: + case AML_ARG_OP: + case AML_LOCAL_OP: + + DEBUG_ONLY_MEMBERS (DEBUG_PRINT (ACPI_INFO, + ("Reference Opcode: %s\n", OpInfo->Name))); + break; + + default: + DEBUG_PRINT (ACPI_INFO, + ("Reference Opcode: Unknown [%02x]\n", + ObjDesc->Reference.OpCode)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + break; + } + } + + } + + else + { + /* Invalid descriptor */ + + DEBUG_PRINT (ACPI_ERROR, + ("Bad descriptor type 0x%X in Obj %p\n", + ObjDesc->Common.DataType, ObjDesc)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Decode a character from the type string + */ + + ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); + INCREMENT_ARG_LIST (ArgTypes); + + + switch (ThisArgType) + { + + case ARGI_REFERENCE: /* Reference */ + case ARGI_TARGETREF: + + /* Need an operand of type INTERNAL_TYPE_REFERENCE */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) /* direct name ptr OK as-is */ + { + break; + } + + if (INTERNAL_TYPE_REFERENCE != ObjectType) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Reference, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (AML_NAME_OP == ObjDesc->Reference.OpCode) + { + /* + * Convert an indirect name ptr to direct name ptr and put + * it on the stack + */ + + TempHandle = ObjDesc->Reference.Object; + AcpiCmRemoveReference (ObjDesc); + (*StackPtr) = TempHandle; + } + break; + + + case ARGI_NUMBER: /* Number */ + + /* Need an operand of type ACPI_TYPE_NUMBER */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_NUMBER != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Number, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_STRING: + + /* Need an operand of type ACPI_TYPE_STRING or ACPI_TYPE_BUFFER */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if ((ACPI_TYPE_STRING != (*StackPtr)->Common.Type) && + (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed String or Buffer, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_BUFFER: + + /* Need an operand of type ACPI_TYPE_BUFFER */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Buffer, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_MUTEX: + + /* Need an operand of type ACPI_TYPE_MUTEX */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_MUTEX != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Mutex, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_EVENT: + + /* Need an operand of type ACPI_TYPE_EVENT */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_EVENT != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed AcpiEvent, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_REGION: + + /* Need an operand of type ACPI_TYPE_REGION */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_REGION != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Region, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_IF: /* If */ + + /* Need an operand of type INTERNAL_TYPE_IF */ + + if (INTERNAL_TYPE_IF != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed If, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_PACKAGE: /* Package */ + + /* Need an operand of type ACPI_TYPE_PACKAGE */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_PACKAGE != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Package, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_ANYTYPE: + + + /* + * We don't want to resolve IndexOp reference objects during + * a store because this would be an implicit DeRefOf operation. + * Instead, we just want to store the reference object. + */ + + if ((Opcode == AML_STORE_OP) && + ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) && + ((*StackPtr)->Reference.OpCode == AML_INDEX_OP)) + { + break; + } + + /* All others must be resolved */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* All types OK, so we don't perform any typechecks */ + + break; + + + case ARGI_DATAOBJECT: + /* + * ARGI_DATAOBJECT is only used by the SizeOf operator. + * + * The ACPI specification allows SizeOf to return the size of + * a Buffer, String or Package. However, the MS ACPI.SYS AML + * Interpreter also allows an Node reference to return without + * error with a size of 4. + */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Need a buffer, string, package or Node reference */ + + if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) && + ((*StackPtr)->Common.Type != ACPI_TYPE_STRING) && + ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE) && + ((*StackPtr)->Common.Type != INTERNAL_TYPE_REFERENCE)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Buf/Str/Pkg, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * If this is a reference, only allow a reference to an Node. + */ + if ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) + { + if (!(*StackPtr)->Reference.Node) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Node reference, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + + break; + + + case ARGI_COMPLEXOBJ: + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Need a buffer or package */ + + if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) && + ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Package, Buf/Pkg %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + /* Unknown abbreviation passed in */ + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Internal error - Unknown arg type %X\n", + ThisArgType)); + Status = AE_BAD_PARAMETER; + goto Cleanup; + + } /* switch (*Types++) */ + + + /* + * If more operands needed, decrement StackPtr to point + * to next operand on stack (after checking for underflow). + */ + if (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + StackPtr--; + } + + } /* while (*Types) */ + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c new file mode 100644 index 0000000..976ecc7 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstore.c @@ -0,0 +1,531 @@ + +/****************************************************************************** + * + * Module Name: amstore - AML Interpreter object store support + * $Revision: 116 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSTORE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amstore") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecStore + * + * PARAMETERS: *ValDesc - Value to be stored + * *DestDesc - Where to store it 0 Must be (ACPI_HANDLE) + * or an ACPI_OPERAND_OBJECT of type + * Reference; if the latter the descriptor + * will be either reused or deleted. + * + * RETURN: Status + * + * DESCRIPTION: Store the value described by ValDesc into the location + * described by DestDesc. Called by various interpreter + * functions to store the result of an operation into + * the destination operand. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecStore ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *DeleteDestDesc = NULL; + ACPI_OPERAND_OBJECT *TmpDesc; + ACPI_NAMESPACE_NODE *Node = NULL; + UINT8 Value = 0; + UINT32 Length; + UINT32 i; + + + FUNCTION_TRACE ("AmlExecStore"); + + DEBUG_PRINT (ACPI_INFO, ("entered AcpiAmlExecStore: Val=%p, Dest=%p\n", + ValDesc, DestDesc)); + + + /* Validate parameters */ + + if (!ValDesc || !DestDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore: Internal error - null pointer\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* Examine the datatype of the DestDesc */ + + if (VALID_DESCRIPTOR_TYPE (DestDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Dest is an ACPI_HANDLE, create a new object */ + + Node = (ACPI_NAMESPACE_NODE *) DestDesc; + DestDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!DestDesc) + { + /* Allocation failure */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Build a new Reference wrapper around the handle */ + + DestDesc->Reference.OpCode = AML_NAME_OP; + DestDesc->Reference.Object = Node; + } + + else + { + DEBUG_PRINT (ACPI_INFO, + ("AmlExecStore: Dest is object (not handle) - may be deleted!\n")); + } + + /* Destination object must be of type Reference */ + + if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE) + { + /* Destination is not an Reference */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore: Destination is not an Reference [%p]\n", DestDesc)); + + DUMP_STACK_ENTRY (ValDesc); + DUMP_STACK_ENTRY (DestDesc); + DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "AmlExecStore", + 2, "target not Reference"); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Examine the Reference opcode */ + + switch (DestDesc->Reference.OpCode) + { + + case AML_NAME_OP: + + /* + * Storing into a Name + */ + DeleteDestDesc = DestDesc; + Status = AcpiAmlStoreObjectToNode (ValDesc, DestDesc->Reference.Object, + WalkState); + + break; /* Case NameOp */ + + + case AML_INDEX_OP: + + DeleteDestDesc = DestDesc; + + /* + * Valid source value and destination reference pointer. + * + * ACPI Specification 1.0B section 15.2.3.4.2.13: + * Destination should point to either a buffer or a package + */ + + /* + * Actually, storing to a package is not so simple. The source must be + * evaluated and converted to the type of the destination and then the + * source is copied into the destination - we can't just point to the + * source object. + */ + if (DestDesc->Reference.TargetType == ACPI_TYPE_PACKAGE) + { + /* + * The object at *(DestDesc->Reference.Where) is the + * element within the package that is to be modified. + */ + TmpDesc = *(DestDesc->Reference.Where); + if (TmpDesc) + { + /* + * If the Destination element is a package, we will delete + * that object and construct a new one. + * + * TBD: [Investigate] Should both the src and dest be required + * to be packages? + * && (ValDesc->Common.Type == ACPI_TYPE_PACKAGE) + */ + if (TmpDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + /* + * Take away the reference for being part of a package and + * delete + */ + AcpiCmRemoveReference (TmpDesc); + AcpiCmRemoveReference (TmpDesc); + + TmpDesc = NULL; + } + } + + if (!TmpDesc) + { + /* + * If the TmpDesc is NULL, that means an uninitialized package + * has been used as a destination, therefore, we must create + * the destination element to match the type of the source + * element NOTE: ValDesc can be of any type. + */ + TmpDesc = AcpiCmCreateInternalObject (ValDesc->Common.Type); + if (!TmpDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * If the source is a package, copy the source to the new dest + */ + if (ACPI_TYPE_PACKAGE == TmpDesc->Common.Type) + { + Status = AcpiAmlBuildCopyInternalPackageObject ( + ValDesc, TmpDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (TmpDesc); + TmpDesc = NULL; + goto Cleanup; + } + } + + /* + * Install the new descriptor into the package and add a + * reference to the newly created descriptor for now being + * part of the parent package + */ + + *(DestDesc->Reference.Where) = TmpDesc; + AcpiCmAddReference (TmpDesc); + } + + if (ACPI_TYPE_PACKAGE != TmpDesc->Common.Type) + { + /* + * The destination element is not a package, so we need to + * convert the contents of the source (ValDesc) and copy into + * the destination (TmpDesc) + */ + Status = AcpiAmlStoreObjectToObject (ValDesc, TmpDesc, + WalkState); + if (ACPI_FAILURE (Status)) + { + /* + * An error occurrered when copying the internal object + * so delete the reference. + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore/Index: Unable to copy the internal object\n")); + Status = AE_AML_OPERAND_TYPE; + } + } + + break; + } + + /* + * Check that the destination is a Buffer Field type + */ + if (DestDesc->Reference.TargetType != ACPI_TYPE_BUFFER_FIELD) + { + Status = AE_AML_OPERAND_TYPE; + break; + } + + /* + * Storing into a buffer at a location defined by an Index. + * + * Each 8-bit element of the source object is written to the + * 8-bit Buffer Field of the Index destination object. + */ + + /* + * Set the TmpDesc to the destination object and type check. + */ + TmpDesc = DestDesc->Reference.Object; + + if (TmpDesc->Common.Type != ACPI_TYPE_BUFFER) + { + Status = AE_AML_OPERAND_TYPE; + break; + } + + /* + * The assignment of the individual elements will be slightly + * different for each source type. + */ + + switch (ValDesc->Common.Type) + { + /* + * If the type is Integer, the Length is 4. + * This loop to assign each of the elements is somewhat + * backward because of the Big Endian-ness of IA-64 + */ + case ACPI_TYPE_NUMBER: + Length = 4; + for (i = Length; i != 0; i--) + { + Value = (UINT8)(ValDesc->Number.Value >> (MUL_8 (i - 1))); + TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + } + break; + + /* + * If the type is Buffer, the Length is in the structure. + * Just loop through the elements and assign each one in turn. + */ + case ACPI_TYPE_BUFFER: + Length = ValDesc->Buffer.Length; + for (i = 0; i < Length; i++) + { + Value = *(ValDesc->Buffer.Pointer + i); + TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + } + break; + + /* + * If the type is String, the Length is in the structure. + * Just loop through the elements and assign each one in turn. + */ + case ACPI_TYPE_STRING: + Length = ValDesc->String.Length; + for (i = 0; i < Length; i++) + { + Value = *(ValDesc->String.Pointer + i); + TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + } + break; + + /* + * If source is not a valid type so return an error. + */ + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore/Index: Source must be Number/Buffer/String type, not 0x%x\n", + ValDesc->Common.Type)); + Status = AE_AML_OPERAND_TYPE; + break; + } + + /* + * If we had an error, break out of this case statement. + */ + if (ACPI_FAILURE (Status)) + { + break; + } + + /* + * Set the return pointer + */ + DestDesc = TmpDesc; + + break; + + case AML_ZERO_OP: + case AML_ONE_OP: + case AML_ONES_OP: + + /* + * Storing to a constant is a no-op -- see ACPI Specification + * Delete the result descriptor. + */ + + DeleteDestDesc = DestDesc; + break; + + + case AML_LOCAL_OP: + + Status = AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, + (DestDesc->Reference.Offset), ValDesc, WalkState); + DeleteDestDesc = DestDesc; + break; + + + case AML_ARG_OP: + + Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG, + (DestDesc->Reference.Offset), ValDesc, WalkState); + DeleteDestDesc = DestDesc; + break; + + + case AML_DEBUG_OP: + + /* + * Storing to the Debug object causes the value stored to be + * displayed and otherwise has no effect -- see ACPI Specification + */ + DEBUG_PRINT (ACPI_INFO, ("**** Write to Debug Object: ****: \n")); + if (ValDesc->Common.Type == ACPI_TYPE_STRING) + { + DEBUG_PRINT (ACPI_INFO, ("%s\n", ValDesc->String.Pointer)); + } + else + { + DUMP_STACK_ENTRY (ValDesc); + } + + DeleteDestDesc = DestDesc; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore: Internal error - Unknown Reference subtype %02x\n", + DestDesc->Reference.OpCode)); + + /* TBD: [Restructure] use object dump routine !! */ + + DUMP_BUFFER (DestDesc, sizeof (ACPI_OPERAND_OBJECT)); + + DeleteDestDesc = DestDesc; + Status = AE_AML_INTERNAL; + + } /* switch(DestDesc->Reference.OpCode) */ + + +Cleanup: + + /* Cleanup and exit*/ + + if (DeleteDestDesc) + { + AcpiCmRemoveReference (DeleteDestDesc); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c new file mode 100644 index 0000000..1b626bf --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstoren.c @@ -0,0 +1,713 @@ + +/****************************************************************************** + * + * Module Name: amstoren - AML Interpreter object store support, + * Store to Node (namespace object) + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSTOREN_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amstoren") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObjectToNode + * + * PARAMETERS: *ValDesc - Value to be stored + * *Node - Named object to recieve the value + * + * RETURN: Status + * + * DESCRIPTION: Store the object to the named object. + * + * The Assignment of an object to a named object is handled here + * The val 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. + * + * NOTE: the global lock is acquired early. This will result + * in the global lock being held a bit longer. Also, if the + * function fails during set up we may get the lock when we + * don't really need it. I don't think we care. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObjectToNode ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *Buffer = NULL; + UINT32 Length = 0; + UINT32 Mask; + UINT32 NewValue; + BOOLEAN Locked = FALSE; + UINT8 *Location=NULL; + ACPI_OPERAND_OBJECT *DestDesc; + OBJECT_TYPE_INTERNAL DestinationType = ACPI_TYPE_ANY; + + + FUNCTION_TRACE ("AmlStoreObjectToNte"); + + DEBUG_PRINT (ACPI_INFO, + ("entered AcpiAmlStoreObjectToNode: NamedObj=%p, Obj=%p\n", + Node, ValDesc)); + + /* + * Assuming the parameters are valid!!! + */ + ACPI_ASSERT((Node) && (ValDesc)); + + DestinationType = AcpiNsGetType (Node); + + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToNte: Storing %s into %s\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + + /* + * First ensure we have a value that can be stored in the target + */ + switch (DestinationType) + { + /* Type of Name's existing value */ + + case INTERNAL_TYPE_ALIAS: + + /* + * Aliases are resolved by AcpiAmlPrepOperands + */ + + DEBUG_PRINT (ACPI_WARN, + ("AmlStoreObjectToNte: Store into Alias - should never happen\n")); + Status = AE_AML_INTERNAL; + break; + + + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_FIELD_UNIT: + case ACPI_TYPE_NUMBER: + + /* + * These cases all require only number values or values that + * can be converted to numbers. + * + * If value is not a Number, try to resolve it to one. + */ + + if (ValDesc->Common.Type != ACPI_TYPE_NUMBER) + { + /* + * Initially not a number, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER)) + { + /* + * Conversion successful but still not a number + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Value assigned to %s must be Number, not %s\n", + AcpiCmGetTypeName (DestinationType), + AcpiCmGetTypeName (ValDesc->Common.Type))); + Status = AE_AML_OPERAND_TYPE; + } + } + + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case INTERNAL_TYPE_DEF_FIELD: + + /* + * Storing into a Field in a region or into a buffer or into + * a string all is essentially the same. + * + * If value is not a valid type, try to resolve it to one. + */ + + if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Initially not a valid type, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Conversion successful but still not a valid type + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Assign wrong type %s to %s (must be type Num/Str/Buf)\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + Status = AE_AML_OPERAND_TYPE; + } + } + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * TBD: [Unhandled] Not real sure what to do here + */ + Status = AE_NOT_IMPLEMENTED; + break; + + + default: + + /* + * All other types than Alias and the various Fields come here. + * Store ValDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * ValDesc reference count is incremented by AttachObject. + */ + + Status = AcpiNsAttachObject (Node, ValDesc, ValDesc->Common.Type); + + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: Store %s into %s via Attach\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + + goto CleanUpAndBailOut; + break; + } + + /* Exit now if failure above */ + + if (ACPI_FAILURE (Status)) + { + goto CleanUpAndBailOut; + } + + /* + * Get descriptor for object attached to Node + */ + DestDesc = AcpiNsGetAttachedObject (Node); + if (!DestDesc) + { + /* + * There is no existing object attached to this Node + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Internal error - no destination object for %4.4s type %d\n", + &Node->Name, DestinationType)); + Status = AE_AML_INTERNAL; + goto CleanUpAndBailOut; + } + + /* + * Make sure the destination Object is the same as the Node + */ + if (DestDesc->Common.Type != (UINT8) DestinationType) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Internal error - Name %4.4s type %d does not match value-type %d at %p\n", + &Node->Name, AcpiNsGetType (Node), + DestDesc->Common.Type, DestDesc)); + Status = AE_AML_INTERNAL; + goto CleanUpAndBailOut; + } + + /* + * AcpiEverything is ready to execute now, We have + * a value we can handle, just perform the update + */ + + switch (DestinationType) + { + /* Type of Name's existing value */ + + case INTERNAL_TYPE_BANK_FIELD: + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (DestDesc->BankField.LockRule); + + /* + * Set Bank value to select proper Bank + * Perform the update (Set Bank Select) + */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->BankField.BankSelect, + &DestDesc->BankField.Value, + sizeof (DestDesc->BankField.Value)); + if (ACPI_SUCCESS (Status)) + { + /* Set bank select successful, set data value */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->BankField.BankSelect, + &ValDesc->BankField.Value, + sizeof (ValDesc->BankField.Value)); + } + + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (ValDesc->Field.LockRule); + + /* + * Perform the update + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + Node, Buffer, Length); + + break; /* Global Lock released below */ + + + case ACPI_TYPE_STRING: + + /* + * Perform the update + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * Setting a string value replaces the old string + */ + + if (Length < DestDesc->String.Length) + { + /* + * Zero fill, not willing to do pointer arithmetic for + * archetecture independance. Just clear the whole thing + */ + MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length); + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + else + { + /* + * Free the current buffer, then allocate a buffer + * large enough to hold the value + */ + if ( DestDesc->String.Pointer && + !AcpiTbSystemTablePointer (DestDesc->String.Pointer)) + { + /* + * Only free if not a pointer into the DSDT + */ + + AcpiCmFree(DestDesc->String.Pointer); + } + + DestDesc->String.Pointer = AcpiCmAllocate (Length + 1); + DestDesc->String.Length = Length; + + if (!DestDesc->String.Pointer) + { + Status = AE_NO_MEMORY; + goto CleanUpAndBailOut; + } + + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + break; + + + case ACPI_TYPE_BUFFER: + + /* + * Perform the update to the buffer + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * Buffer is a static allocation, + * only place what will fit in the buffer. + */ + if (Length <= DestDesc->Buffer.Length) + { + /* + * Zero fill first, not willing to do pointer arithmetic for + * archetecture independence. Just clear the whole thing + */ + MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length); + MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length); + } + else + { + /* + * truncate, copy only what will fit + */ + MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length); + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: Truncating src buffer from %d to %d\n", + Length, DestDesc->Buffer.Length)); + } + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (DestDesc->IndexField.LockRule); + + /* + * Set Index value to select proper Data register + * perform the update (Set index) + */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->IndexField.Index, + &DestDesc->IndexField.Value, + sizeof (DestDesc->IndexField.Value)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: IndexField: set index returned %s\n", + AcpiCmFormatException (Status))); + + if (ACPI_SUCCESS (Status)) + { + /* set index successful, next set Data value */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->IndexField.Data, + &ValDesc->Number.Value, + sizeof (ValDesc->Number.Value)); + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: IndexField: set data returned %s\n", + AcpiCmFormatException (Status))); + } + break; + + + case ACPI_TYPE_FIELD_UNIT: + + + /* + * If the Field Buffer and Index have not been previously evaluated, + * evaluate them and save the results. + */ + if (!(DestDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetFieldUnitArguments (DestDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if ((!DestDesc->FieldUnit.Container || + ACPI_TYPE_BUFFER != DestDesc->FieldUnit.Container->Common.Type)) + { + DUMP_PATHNAME (Node, + "AmlStoreObjectToNte: FieldUnit: Bad container in ", + ACPI_ERROR, _COMPONENT); + DUMP_ENTRY (Node, ACPI_ERROR); + DEBUG_PRINT (ACPI_ERROR, + ("Container: %p", DestDesc->FieldUnit.Container)); + + if (DestDesc->FieldUnit.Container) + { + DEBUG_PRINT_RAW (ACPI_ERROR, (" Type %d", + DestDesc->FieldUnit.Container->Common.Type)); + } + DEBUG_PRINT_RAW (ACPI_ERROR, ("\n")); + + Status = AE_AML_INTERNAL; + goto CleanUpAndBailOut; + } + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (DestDesc->FieldUnit.LockRule); + + /* + * TBD: [Unhandled] REMOVE this limitation + * Make sure the operation is within the limits of our implementation + * this is not a Spec limitation!! + */ + if (DestDesc->FieldUnit.Length + DestDesc->FieldUnit.BitOffset > 32) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: FieldUnit: Implementation limitation - Field exceeds UINT32\n")); + Status = AE_NOT_IMPLEMENTED; + goto CleanUpAndBailOut; + } + + /* Field location is (base of buffer) + (byte offset) */ + + Location = DestDesc->FieldUnit.Container->Buffer.Pointer + + DestDesc->FieldUnit.Offset; + + /* + * Construct Mask with 1 bits where the field is, + * 0 bits elsewhere + */ + Mask = ((UINT32) 1 << DestDesc->FieldUnit.Length) - ((UINT32)1 + << DestDesc->FieldUnit.BitOffset); + + DEBUG_PRINT (TRACE_EXEC, + ("** Store %lx in buffer %p byte %ld bit %d width %d addr %p mask %08lx\n", + ValDesc->Number.Value, + DestDesc->FieldUnit.Container->Buffer.Pointer, + DestDesc->FieldUnit.Offset, DestDesc->FieldUnit.BitOffset, + DestDesc->FieldUnit.Length,Location, Mask)); + + /* Zero out the field in the buffer */ + + MOVE_UNALIGNED32_TO_32 (&NewValue, Location); + NewValue &= ~Mask; + + /* + * Shift and mask the new value into position, + * and or it into the buffer. + */ + NewValue |= (ValDesc->Number.Value << DestDesc->FieldUnit.BitOffset) & + Mask; + + /* Store back the value */ + + MOVE_UNALIGNED32_TO_32 (Location, &NewValue); + + DEBUG_PRINT (TRACE_EXEC, ("New Field value %08lx\n", NewValue)); + break; + + + case ACPI_TYPE_NUMBER: + + DestDesc->Number.Value = ValDesc->Number.Value; + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * TBD: [Unhandled] Not real sure what to do here + */ + Status = AE_NOT_IMPLEMENTED; + break; + + + default: + + /* + * All other types than Alias and the various Fields come here. + * Store ValDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * ValDesc reference count is incremented by AttachObject. + */ + + DEBUG_PRINT (ACPI_WARN, + ("AmlStoreObjectToNte: Store into %s not implemented\n", + AcpiCmGetTypeName (AcpiNsGetType (Node)))); + + Status = AE_NOT_IMPLEMENTED; + break; + } + + +CleanUpAndBailOut: + + /* + * Release global lock if we acquired it earlier + */ + AcpiAmlReleaseGlobalLock (Locked); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c new file mode 100644 index 0000000..205fdad --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amstorob.c @@ -0,0 +1,442 @@ + +/****************************************************************************** + * + * Module Name: amstorob - AML Interpreter object store support, store to object + * $Revision: 16 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSTOROB_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amstorob") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObjectToObject + * + * PARAMETERS: *ValDesc - Value to be stored + * *DestDesc - Object to receive the value + * + * RETURN: Status + * + * DESCRIPTION: Store an object to another object. + * + * The Assignment of an object to another (not named) object + * is handled here. + * The val 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, + * and Buffer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObjectToObject ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *Buffer = NULL; + UINT32 Length = 0; + OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type; + + + FUNCTION_TRACE ("AmlStoreObjectToObject"); + + DEBUG_PRINT (ACPI_INFO, + ("entered AcpiAmlStoreObjectToObject: Dest=%p, Val=%p\n", + DestDesc, ValDesc)); + + /* + * Assuming the parameters are valid!!! + */ + ACPI_ASSERT((DestDesc) && (ValDesc)); + + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %s into %s\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestDesc->Common.Type))); + + /* + * First ensure we have a value that can be stored in the target + */ + switch (DestinationType) + { + /* Type of Name's existing value */ + + case ACPI_TYPE_NUMBER: + + /* + * These cases all require only number values or values that + * can be converted to numbers. + * + * If value is not a Number, try to resolve it to one. + */ + + if (ValDesc->Common.Type != ACPI_TYPE_NUMBER) + { + /* + * Initially not a number, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER)) + { + /* + * Conversion successful but still not a number + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToObject: Value assigned to %s must be Number, not %s\n", + AcpiCmGetTypeName (DestinationType), + AcpiCmGetTypeName (ValDesc->Common.Type))); + Status = AE_AML_OPERAND_TYPE; + } + } + + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * Storing into a Field in a region or into a buffer or into + * a string all is essentially the same. + * + * If value is not a valid type, try to resolve it to one. + */ + + if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Initially not a valid type, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Conversion successful but still not a valid type + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToObject: Assign wrong type %s to %s (must be type Num/Str/Buf)\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + Status = AE_AML_OPERAND_TYPE; + } + } + break; + + + default: + + /* + * TBD: [Unhandled] What other combinations must be implemented? + */ + Status = AE_NOT_IMPLEMENTED; + break; + } + + /* Exit now if failure above */ + + if (ACPI_FAILURE (Status)) + { + goto CleanUpAndBailOut; + } + + /* + * AcpiEverything is ready to execute now, We have + * a value we can handle, just perform the update + */ + + switch (DestinationType) + { + + case ACPI_TYPE_STRING: + + /* + * Perform the update + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * Setting a string value replaces the old string + */ + + if (Length < DestDesc->String.Length) + { + /* + * Zero fill, not willing to do pointer arithmetic for + * architecture independence. Just clear the whole thing + */ + MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length); + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + else + { + /* + * Free the current buffer, then allocate a buffer + * large enough to hold the value + */ + if ( DestDesc->String.Pointer && + !AcpiTbSystemTablePointer (DestDesc->String.Pointer)) + { + /* + * Only free if not a pointer into the DSDT + */ + + AcpiCmFree(DestDesc->String.Pointer); + } + + DestDesc->String.Pointer = AcpiCmAllocate (Length + 1); + DestDesc->String.Length = Length; + + if (!DestDesc->String.Pointer) + { + Status = AE_NO_MEMORY; + goto CleanUpAndBailOut; + } + + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + break; + + + case ACPI_TYPE_BUFFER: + + /* + * Perform the update to the buffer + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * If the buffer is uninitialized, + * memory needs to be allocated for the copy. + */ + if(0 == DestDesc->Buffer.Length) + { + DestDesc->Buffer.Pointer = AcpiCmCallocate(Length); + DestDesc->Buffer.Length = Length; + + if (!DestDesc->Buffer.Pointer) + { + Status = AE_NO_MEMORY; + goto CleanUpAndBailOut; + } + } + + /* + * Buffer is a static allocation, + * only place what will fit in the buffer. + */ + if (Length <= DestDesc->Buffer.Length) + { + /* + * Zero fill first, not willing to do pointer arithmetic for + * architecture independence. Just clear the whole thing + */ + MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length); + MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length); + } + else + { + /* + * truncate, copy only what will fit + */ + MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length); + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToObject: Truncating src buffer from %d to %d\n", + Length, DestDesc->Buffer.Length)); + } + break; + + case ACPI_TYPE_NUMBER: + + DestDesc->Number.Value = ValDesc->Number.Value; + break; + + default: + + /* + * All other types than Alias and the various Fields come here. + * Store ValDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * ValDesc reference count is incremented by AttachObject. + */ + + DEBUG_PRINT (ACPI_WARN, + ("AmlStoreObjectToObject: Store into %s not implemented\n", + AcpiCmGetTypeName (DestDesc->Common.Type))); + + Status = AE_NOT_IMPLEMENTED; + break; + } + +CleanUpAndBailOut: + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c new file mode 100644 index 0000000..d4c1923 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amsystem.c @@ -0,0 +1,463 @@ + +/****************************************************************************** + * + * Module Name: amsystem - Interface to OS services + * $Revision: 52 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSYSTEM_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amsystem") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemThreadId + * + * PARAMETERS: None + * + * RETURN: Current Thread ID (for this implementation a 1 is returned) + * + * DESCRIPTION: An invocation is identified by its Thread ID. In a single + * threaded OS the Thread ID is undefined so a 1 will be + * returned. + * + ******************************************************************************/ + +UINT16 +AcpiAmlSystemThreadId (void) +{ + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemWaitSemaphore + * + * PARAMETERS: Semaphore - OSD semaphore to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a semaphore wait with a check to see if the + * semaphore is available immediately. If it is not, the + * interpreter is released. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemWaitSemaphore ( + ACPI_HANDLE Semaphore, + UINT32 Timeout) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiAmlSystemWaitSemaphore"); + + Status = AcpiOsWaitSemaphore (Semaphore, 1, 0); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiAmlExitInterpreter (); + + Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); + + /* Reacquire the interpreter */ + + AcpiAmlEnterInterpreter (); + + DEBUG_PRINT (TRACE_EXEC, + ("*** Thread awake and inside interpreter after blocking, %s\n", + AcpiCmFormatException (Status))); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemDoStall + * + * PARAMETERS: HowLong - The amount of time to stall + * + * RETURN: None + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * + ******************************************************************************/ + +void +AcpiAmlSystemDoStall ( + UINT32 HowLong) +{ + + if (HowLong > 1000) /* 1 millisecond */ + { + /* Since this thread will sleep, we must release the interpreter */ + + AcpiAmlExitInterpreter (); + + AcpiOsSleepUsec (HowLong); + + /* And now we must get the interpreter again */ + + AcpiAmlEnterInterpreter (); + } + + else + { + AcpiOsSleepUsec (HowLong); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemDoSuspend + * + * PARAMETERS: HowLong - The amount of time to suspend + * + * RETURN: None + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * + ******************************************************************************/ + +void +AcpiAmlSystemDoSuspend ( + UINT32 HowLong) +{ + /* Since this thread will sleep, we must release the interpreter */ + + AcpiAmlExitInterpreter (); + + AcpiOsSleep ((UINT16) (HowLong / (UINT32) 1000), + (UINT16) (HowLong % (UINT32) 1000)); + + /* And now we must get the interpreter again */ + + AcpiAmlEnterInterpreter (); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemAcquireMutex + * + * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor + * *ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. This function will cause a lock to be generated + * for the Mutex pointed to by ObjDesc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AcpiAmlSystemAcquireMutex", ObjDesc); + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Support for the _GL_ Mutex object -- go get the global lock + */ + + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) + { + Status = AcpiEvAcquireGlobalLock (); + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Mutex.Semaphore, + (UINT32) TimeDesc->Number.Value); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemReleaseMutex + * + * PARAMETERS: *ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. This operation is a request to release a + * previously acquired Mutex. If the Mutex variable is set then + * it will be decremented. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiAmlSystemReleaseMutex"); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Support for the _GL_ Mutex object -- release the global lock + */ + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) + { + AcpiEvReleaseGlobalLock (); + return_ACPI_STATUS (AE_OK); + } + + Status = AcpiOsSignalSemaphore (ObjDesc->Mutex.Semaphore, 1); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemSignalEvent + * + * PARAMETERS: *ObjDesc - The object descriptor for this op + * + * RETURN: AE_OK + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemSignalEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiAmlSystemSignalEvent"); + + + if (ObjDesc) + { + Status = AcpiOsSignalSemaphore (ObjDesc->Event.Semaphore, 1); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemWaitEvent + * + * 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 +AcpiAmlSystemWaitEvent ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiAmlSystemWaitEvent"); + + + if (ObjDesc) + { + Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Event.Semaphore, + (UINT32) TimeDesc->Number.Value); + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemResetEvent + * + * PARAMETERS: *ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemResetEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + void *TempSemaphore; + + + /* + * 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)) + { + AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore); + ObjDesc->Mutex.Semaphore = TempSemaphore; + } + + return (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c new file mode 100644 index 0000000..56dbc67 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amutils.c @@ -0,0 +1,652 @@ + +/****************************************************************************** + * + * Module Name: amutils - interpreter/scanner utilities + * $Revision: 56 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMUTILS_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acevents.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amutils") + + +typedef struct Internal_Search_st +{ + ACPI_OPERAND_OBJECT *DestObj; + UINT32 Index; + ACPI_OPERAND_OBJECT *SourceObj; + +} INTERNAL_PKG_SEARCH_INFO; + + +/* Used to traverse nested packages when copying*/ + +INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH]; + + +static NATIVE_CHAR hex[] = + {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlEnterInterpreter + * + * PARAMETERS: None + * + * DESCRIPTION: Enter the interpreter execution region + * + ******************************************************************************/ + +void +AcpiAmlEnterInterpreter (void) +{ + FUNCTION_TRACE ("AmlEnterInterpreter"); + + + AcpiCmAcquireMutex (ACPI_MTX_EXECUTE); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExitInterpreter + * + * PARAMETERS: None + * + * DESCRIPTION: Exit the interpreter execution region + * + * Cases where the interpreter is unlocked: + * 1) Completion of the execution of a control method + * 2) Method blocked on a Sleep() AML opcode + * 3) Method blocked on an Acquire() AML opcode + * 4) Method blocked on a Wait() AML opcode + * 5) Method blocked to acquire the global lock + * 6) Method blocked to execute a serialized control method that is + * already executing + * 7) About to invoke a user-installed opregion handler + * + ******************************************************************************/ + +void +AcpiAmlExitInterpreter (void) +{ + FUNCTION_TRACE ("AmlExitInterpreter"); + + + AcpiCmReleaseMutex (ACPI_MTX_EXECUTE); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlValidateObjectType + * + * PARAMETERS: Type Object type to validate + * + * DESCRIPTION: Determine if a type is a valid ACPI object type + * + ******************************************************************************/ + +BOOLEAN +AcpiAmlValidateObjectType ( + ACPI_OBJECT_TYPE Type) +{ + + if ((Type > ACPI_TYPE_MAX && Type < INTERNAL_TYPE_BEGIN) || + (Type > INTERNAL_TYPE_MAX)) + { + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlBufSeq + * + * RETURN: The next buffer descriptor sequence number + * + * DESCRIPTION: Provide a unique sequence number for each Buffer descriptor + * allocated during the interpreter's existence. These numbers + * are used to relate FieldUnit descriptors to the Buffers + * within which the fields are defined. + * + * Just increment the global counter and return it. + * + ******************************************************************************/ + +UINT32 +AcpiAmlBufSeq (void) +{ + + return (++AcpiGbl_BufSeq); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlAcquireGlobalLock + * + * PARAMETERS: Rule - Lock rule: AlwaysLock, NeverLock + * + * RETURN: TRUE/FALSE indicating whether the lock was actually acquired + * + * DESCRIPTION: Obtain the global lock and keep track of this fact via two + * methods. A global variable keeps the state of the lock, and + * the state is returned to the caller. + * + ******************************************************************************/ + +BOOLEAN +AcpiAmlAcquireGlobalLock ( + UINT32 Rule) +{ + BOOLEAN Locked = FALSE; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlAcquireGlobalLock"); + + + /* Only attempt lock if the Rule says so */ + + if (Rule == (UINT32) GLOCK_ALWAYS_LOCK) + { + /* OK to get the lock */ + + Status = AcpiEvAcquireGlobalLock (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("Get Global Lock Failed!!\n")); + } + + if (ACPI_SUCCESS (Status)) + { + AcpiGbl_GlobalLockSet = TRUE; + Locked = TRUE; + } + } + + return_VALUE (Locked); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlReleaseGlobalLock + * + * PARAMETERS: LockedByMe - Return value from corresponding call to + * AcquireGlobalLock. + * + * RETURN: Status + * + * DESCRIPTION: Release the global lock if it is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlReleaseGlobalLock ( + BOOLEAN LockedByMe) +{ + + FUNCTION_TRACE ("AmlReleaseGlobalLock"); + + + /* Only attempt unlock if the caller locked it */ + + if (LockedByMe) + { + /* Double check against the global flag */ + + if (AcpiGbl_GlobalLockSet) + { + /* OK, now release the lock */ + + AcpiEvReleaseGlobalLock (); + AcpiGbl_GlobalLockSet = FALSE; + } + + else + { + DEBUG_PRINT (ACPI_ERROR, ("Global lock was not set\n")); + } + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlDigitsNeeded + * + * PARAMETERS: val - Value to be represented + * base - Base of representation + * + * RETURN: the number of digits needed to represent val in base + * + ******************************************************************************/ + +UINT32 +AcpiAmlDigitsNeeded ( + ACPI_INTEGER val, + UINT32 base) +{ + UINT32 NumDigits = 0; + + + FUNCTION_TRACE ("AmlDigitsNeeded"); + + + if (base < 1) + { + REPORT_ERROR (("AmlDigitsNeeded: Internal error - Invalid base\n")); + } + + else + { + for (NumDigits = 1 + (val < 0) ; val /= base ; ++NumDigits) + { ; } + } + + return_VALUE (NumDigits); +} + + +/******************************************************************************* + * + * FUNCTION: ntohl + * + * PARAMETERS: Value - Value to be converted + * + * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) + * + ******************************************************************************/ + +UINT32 +_ntohl ( + UINT32 Value) +{ + union + { + UINT32 Value; + UINT8 Bytes[4]; + } Out; + + union + { + UINT32 Value; + UINT8 Bytes[4]; + } In; + + + 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: AcpiAmlEisaIdToString + * + * PARAMETERS: NumericId - EISA ID to be converted + * OutString - Where to put the converted string (8 bytes) + * + * DESCRIPTION: Convert a numeric EISA ID to string representation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlEisaIdToString ( + UINT32 NumericId, + NATIVE_CHAR *OutString) +{ + UINT32 id; + + /* swap to big-endian to get contiguous bits */ + + id = _ntohl (NumericId); + + OutString[0] = (char) ('@' + ((id >> 26) & 0x1f)); + OutString[1] = (char) ('@' + ((id >> 21) & 0x1f)); + OutString[2] = (char) ('@' + ((id >> 16) & 0x1f)); + OutString[3] = hex[(id >> 12) & 0xf]; + OutString[4] = hex[(id >> 8) & 0xf]; + OutString[5] = hex[(id >> 4) & 0xf]; + OutString[6] = hex[id & 0xf]; + OutString[7] = 0; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlUnsignedIntegerToString + * + * PARAMETERS: Value - Value to be converted + * OutString - Where to put the converted string (8 bytes) + * + * RETURN: Convert a number to string representation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlUnsignedIntegerToString ( + ACPI_INTEGER Value, + NATIVE_CHAR *OutString) +{ + UINT32 Count; + UINT32 DigitsNeeded; + + + DigitsNeeded = AcpiAmlDigitsNeeded (Value, 10); + + OutString[DigitsNeeded] = '\0'; + + for (Count = DigitsNeeded; Count > 0; Count--) + { + OutString[Count-1] = (NATIVE_CHAR) ('0' + (Value % 10)); + Value /= 10; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlBuildCopyInternalPackageObject + * + * PARAMETERS: *SourceObj - Pointer to the source package object + * *DestObj - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to copy an internal package object + * into another internal package object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlBuildCopyInternalPackageObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState) +{ + UINT32 CurrentDepth = 0; + ACPI_STATUS Status = AE_OK; + UINT32 Length = 0; + UINT32 ThisIndex; + UINT32 ObjectSpace = 0; + ACPI_OPERAND_OBJECT *ThisDestObj; + ACPI_OPERAND_OBJECT *ThisSourceObj; + INTERNAL_PKG_SEARCH_INFO *LevelPtr; + + + FUNCTION_TRACE ("AmlBuildCopyInternalPackageObject"); + + + /* + * Initialize the working variables + */ + + MEMSET ((void *) CopyLevel, 0, sizeof(CopyLevel)); + + CopyLevel[0].DestObj = DestObj; + CopyLevel[0].SourceObj = SourceObj; + LevelPtr = &CopyLevel[0]; + CurrentDepth = 0; + + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Package.Count = SourceObj->Package.Count; + + + /* + * Build an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + + DestObj->Package.Elements = AcpiCmCallocate ( + (DestObj->Package.Count + 1) * + sizeof (void *)); + if (!DestObj->Package.Elements) + { + /* Package vector allocation failure */ + + REPORT_ERROR (("AmlBuildCopyInternalPackageObject: Package vector allocation failure\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + DestObj->Package.NextElement = DestObj->Package.Elements; + + + while (1) + { + ThisIndex = LevelPtr->Index; + ThisDestObj = (ACPI_OPERAND_OBJECT *) LevelPtr->DestObj->Package.Elements[ThisIndex]; + ThisSourceObj = (ACPI_OPERAND_OBJECT *) LevelPtr->SourceObj->Package.Elements[ThisIndex]; + + if (IS_THIS_OBJECT_TYPE (ThisSourceObj, ACPI_TYPE_PACKAGE)) + { + /* + * If this object is a package then we go one deeper + */ + if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) + { + /* + * Too many nested levels of packages for us to handle + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlBuildCopyInternalPackageObject: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* + * Build the package object + */ + ThisDestObj = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); + LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; + + + ThisDestObj->Common.Type = ACPI_TYPE_PACKAGE; + ThisDestObj->Package.Count = ThisDestObj->Package.Count; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = ThisDestObj->Package.Count * + sizeof (ACPI_OPERAND_OBJECT); + Length += ObjectSpace; + CurrentDepth++; + LevelPtr = &CopyLevel[CurrentDepth]; + LevelPtr->DestObj = ThisDestObj; + LevelPtr->SourceObj = ThisSourceObj; + LevelPtr->Index = 0; + + } /* if object is a package */ + + else + { + + ThisDestObj = AcpiCmCreateInternalObject ( + ThisSourceObj->Common.Type); + LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; + + Status = AcpiAmlStoreObjectToObject(ThisSourceObj, ThisDestObj, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* + * Failure get out + */ + return_ACPI_STATUS (Status); + } + + Length +=ObjectSpace; + + LevelPtr->Index++; + while (LevelPtr->Index >= LevelPtr->DestObj->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 + */ + if (CurrentDepth == 0) + { + /* + * 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. + */ + CurrentDepth--; + LevelPtr = &CopyLevel[CurrentDepth]; + LevelPtr->Index++; + } + } /* else object is NOT a package */ + } /* while (1) */ +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c b/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c new file mode 100644 index 0000000..1c0380e --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Interpreter/amxface.c @@ -0,0 +1,190 @@ + +/****************************************************************************** + * + * Module Name: amxface - External interpreter interfaces + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMXFACE_C__ + +#include "acpi.h" +#include "acinterp.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amxface") + + +/* + * 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 "amlcode.h" +#include "acparser.h" +#include "acnamesp.h" + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecuteMethod + * + * PARAMETERS: Pcode - Pointer to the pcode stream + * PcodeLength - Length of pcode that comprises the method + * **Params - List of parameters to pass to method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecuteMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecuteMethod"); + + + /* + * The point here is to lock the interpreter and call the low + * level execute. + */ + + AcpiAmlEnterInterpreter (); + + Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc); + + AcpiAmlExitInterpreter (); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c new file mode 100644 index 0000000..78bd747 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsaccess.c @@ -0,0 +1,737 @@ +/******************************************************************************* + * + * Module Name: nsaccess - Top-level functions for accessing ACPI namespace + * $Revision: 111 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSACCESS_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT NAMESPACE + 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 = AE_OK; + PREDEFINED_NAMES *InitVal = NULL; + ACPI_NAMESPACE_NODE *NewNode; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("NsRootInitialize"); + + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* + * 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 */ + + DEBUG_PRINT (ACPI_INFO, + ("Entering predefined name table entries into namespace\n")); + + for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) + { + Status = AcpiNsLookup (NULL, InitVal->Name, + (OBJECT_TYPE_INTERNAL) InitVal->Type, + IMODE_LOAD_PASS2, NS_NO_UPSEARCH, + NULL, &NewNode); + + if (ACPI_FAILURE (Status) || + (!NewNode)) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not create predefined name %s, %s\n", + InitVal->Name, AcpiCmFormatException (Status))); + } + + /* + * Name entered successfully. + * If entry in PreDefinedNames[] specifies an + * initial value, create the initial value. + */ + + if (InitVal->Val) + { + /* + * Entry requests an initial value, allocate a + * descriptor for it. + */ + + ObjDesc = AcpiCmCreateInternalObject ( + (OBJECT_TYPE_INTERNAL) 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_NUMBER: + + ObjDesc->Number.Value = + (ACPI_INTEGER) STRTOUL (InitVal->Val, NULL, 10); + break; + + + case ACPI_TYPE_STRING: + + ObjDesc->String.Length = + (UINT16) STRLEN (InitVal->Val); + + /* + * Allocate a buffer for the string. All + * String.Pointers must be allocated buffers! + * (makes deletion simpler) + */ + ObjDesc->String.Pointer = AcpiCmAllocate ( + (ObjDesc->String.Length + 1)); + if (!ObjDesc->String.Pointer) + { + AcpiCmRemoveReference (ObjDesc); + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + STRCPY (ObjDesc->String.Pointer, InitVal->Val); + break; + + + case ACPI_TYPE_MUTEX: + + ObjDesc->Mutex.SyncLevel = + (UINT16) STRTOUL (InitVal->Val, NULL, 10); + + if (STRCMP (InitVal->Name, "_GL_") == 0) + { + /* + * Create a counting semaphore for the + * global lock + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, + 1, &ObjDesc->Mutex.Semaphore); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + /* + * We just created the mutex for the + * global lock, save it + */ + + AcpiGbl_GlobalLockSemaphore = ObjDesc->Mutex.Semaphore; + } + + else + { + /* Create a mutex */ + + Status = AcpiOsCreateSemaphore (1, 1, + &ObjDesc->Mutex.Semaphore); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + break; + + + default: + REPORT_ERROR (("Unsupported initial type value %X\n", + InitVal->Type)); + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + continue; + } + + /* Store pointer to value descriptor in the Node */ + + AcpiNsAttachObject (NewNode, ObjDesc, + ObjDesc->Common.Type); + } + } + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLookup + * + * PARAMETERS: PrefixNode - Search scope if name is not fully qualified + * Pathname - Search pathname, in internal format + * (as represented in the AML stream) + * Type - Type associated with name + * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found + * Flags - Flags describing the search restrictions + * WalkState - Current state of the walk + * ReturnNode - Where the Node is placed (if found + * or created successfully) + * + * RETURN: Status + * + * DESCRIPTION: Find or enter the passed name in the name space. + * Log an error if name not found in Exec mode. + * + * MUTEX: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + NATIVE_CHAR *Pathname, + OBJECT_TYPE_INTERNAL Type, + OPERATING_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *PrefixNode; + ACPI_NAMESPACE_NODE *CurrentNode = NULL; + ACPI_NAMESPACE_NODE *ScopeToPush = NULL; + ACPI_NAMESPACE_NODE *ThisNode = NULL; + UINT32 NumSegments; + ACPI_NAME SimpleName; + BOOLEAN NullNamePath = FALSE; + OBJECT_TYPE_INTERNAL TypeToCheckFor; + OBJECT_TYPE_INTERNAL ThisSearchType; + DEBUG_EXEC (UINT32 i) + + + FUNCTION_TRACE ("NsLookup"); + + + if (!ReturnNode) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + AcpiGbl_NsLookupCount++; + + *ReturnNode = ENTRY_NOT_FOUND; + + + if (!AcpiGbl_RootNode) + { + return (AE_NO_NAMESPACE); + } + + /* + * Get the prefix scope. + * A null scope means use the root scope + */ + + if ((!ScopeInfo) || + (!ScopeInfo->Scope.Node)) + { + PrefixNode = AcpiGbl_RootNode; + } + else + { + PrefixNode = ScopeInfo->Scope.Node; + } + + + /* + * This check is explicitly split provide relax the TypeToCheckFor + * conditions for BankFieldDefn. Originally, both BankFieldDefn and + * DefFieldDefn caused TypeToCheckFor to be set to ACPI_TYPE_REGION, + * but the BankFieldDefn may also check for a Field definition as well + * as an OperationRegion. + */ + + if (INTERNAL_TYPE_DEF_FIELD_DEFN == Type) + { + /* DefFieldDefn defines fields in a Region */ + + TypeToCheckFor = ACPI_TYPE_REGION; + } + + else if (INTERNAL_TYPE_BANK_FIELD_DEFN == Type) + { + /* BankFieldDefn defines data fields in a Field Object */ + + TypeToCheckFor = ACPI_TYPE_ANY; + } + + else + { + TypeToCheckFor = Type; + } + + + /* TBD: [Restructure] - Move the pathname stuff into a new procedure */ + + /* Examine the name pointer */ + + if (!Pathname) + { + /* 8-12-98 ASL Grammar Update supports null NamePath */ + + NullNamePath = TRUE; + NumSegments = 0; + ThisNode = AcpiGbl_RootNode; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Null Pathname (Zero segments), Flags=%x\n", Flags)); + } + + else + { + /* + * Valid name pointer (Internal name format) + * + * Check for prefixes. As represented in the AML stream, a + * Pathname consists of an optional scope prefix followed by + * a segment part. + * + * If present, the scope prefix is either a RootPrefix (in + * which case the name is fully qualified), or zero or more + * ParentPrefixes (in which case the name's scope is relative + * to the current scope). + * + * The segment part consists of either: + * - A single 4-byte name segment, or + * - A DualNamePrefix followed by two 4-byte name segments, or + * - A MultiNamePrefixOp, followed by a byte indicating the + * number of segments and the segments themselves. + */ + + if (*Pathname == AML_ROOT_PREFIX) + { + /* Pathname is fully qualified, look in root name table */ + + CurrentNode = AcpiGbl_RootNode; + + /* point to segment part */ + + Pathname++; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Searching from root [%p]\n", + CurrentNode)); + + /* Direct reference to root, "\" */ + + if (!(*Pathname)) + { + ThisNode = AcpiGbl_RootNode; + goto CheckForNewScopeAndExit; + } + } + + else + { + /* Pathname is relative to current scope, start there */ + + CurrentNode = PrefixNode; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Searching relative to pfx scope [%p]\n", + PrefixNode)); + + /* + * Handle up-prefix (carat). More than one prefix + * is supported + */ + + while (*Pathname == AML_PARENT_PREFIX) + { + /* Point to segment part or next ParentPrefix */ + + Pathname++; + + /* Backup to the parent's scope */ + + ThisNode = AcpiNsGetParentObject (CurrentNode); + if (!ThisNode) + { + /* Current scope has no parent scope */ + + REPORT_ERROR (("Too many parent prefixes (^) - reached root\n")); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + CurrentNode = ThisNode; + } + } + + + /* + * Examine the name prefix opcode, if any, + * to determine the number of segments + */ + + if (*Pathname == AML_DUAL_NAME_PREFIX) + { + NumSegments = 2; + + /* point to first segment */ + + Pathname++; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Dual Pathname (2 segments, Flags=%X)\n", Flags)); + } + + else if (*Pathname == AML_MULTI_NAME_PREFIX_OP) + { + NumSegments = (UINT32)* (UINT8 *) ++Pathname; + + /* point to first segment */ + + Pathname++; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Multi Pathname (%d Segments, Flags=%X) \n", + NumSegments, Flags)); + } + + else + { + /* + * No Dual or Multi prefix, hence there is only one + * segment and Pathname is already pointing to it. + */ + NumSegments = 1; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Simple Pathname (1 segment, Flags=%X)\n", Flags)); + } + +#ifdef ACPI_DEBUG + + /* TBD: [Restructure] Make this a procedure */ + + /* Debug only: print the entire name that we are about to lookup */ + + DEBUG_PRINT (TRACE_NAMES, ("NsLookup: [")); + + for (i = 0; i < NumSegments; i++) + { + DEBUG_PRINT_RAW (TRACE_NAMES, ("%4.4s/", &Pathname[i * 4])); + } + DEBUG_PRINT_RAW (TRACE_NAMES, ("]\n")); +#endif + } + + + /* + * Search namespace for each segment of the name. + * Loop through and verify/add each name segment. + */ + + + while (NumSegments-- && CurrentNode) + { + /* + * Search for the current name segment under the current + * named object. The Type is significant only at the last (topmost) + * level. (We don't care about the types along the path, only + * the type of the final target object.) + */ + ThisSearchType = ACPI_TYPE_ANY; + if (!NumSegments) + { + ThisSearchType = Type; + } + + /* Pluck and ACPI name from the front of the pathname */ + + MOVE_UNALIGNED32_TO_32 (&SimpleName, Pathname); + + /* Try to find the ACPI name */ + + Status = AcpiNsSearchAndEnter (SimpleName, WalkState, + CurrentNode, InterpreterMode, + ThisSearchType, Flags, + &ThisNode); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + /* Name not found in ACPI namespace */ + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Name [%4.4s] not found in scope %X\n", + &SimpleName, CurrentNode)); + } + + return_ACPI_STATUS (Status); + } + + + /* + * If 1) This is the last segment (NumSegments == 0) + * 2) and looking for a specific type + * (Not checking for TYPE_ANY) + * 3) Which is not an alias + * 4) which is not a local type (TYPE_DEF_ANY) + * 5) which is not a local type (TYPE_SCOPE) + * 6) which is not a local type (TYPE_INDEX_FIELD_DEFN) + * 7) and type of object is known (not TYPE_ANY) + * 8) and object does not match request + * + * Then we have a type mismatch. Just warn and ignore it. + */ + if ((NumSegments == 0) && + (TypeToCheckFor != ACPI_TYPE_ANY) && + (TypeToCheckFor != INTERNAL_TYPE_ALIAS) && + (TypeToCheckFor != INTERNAL_TYPE_DEF_ANY) && + (TypeToCheckFor != INTERNAL_TYPE_SCOPE) && + (TypeToCheckFor != INTERNAL_TYPE_INDEX_FIELD_DEFN) && + (ThisNode->Type != ACPI_TYPE_ANY) && + (ThisNode->Type != TypeToCheckFor)) + { + /* Complain about a type mismatch */ + + REPORT_WARNING ( + ("NsLookup: %4.4s, type 0x%X, checking for type 0x%X\n", + &SimpleName, ThisNode->Type, TypeToCheckFor)); + } + + /* + * If this is the last name segment and we are not looking for a + * specific type, but the type of found object is known, use that type + * to see if it opens a scope. + */ + + if ((0 == NumSegments) && (ACPI_TYPE_ANY == Type)) + { + Type = ThisNode->Type; + } + + if ((NumSegments || AcpiNsOpensScope (Type)) && + (ThisNode->Child == NULL)) + { + /* + * More segments or the type implies enclosed scope, + * and the next scope has not been allocated. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsLookup: Load mode=%d ThisNode=%x\n", + InterpreterMode, ThisNode)); + } + + CurrentNode = ThisNode; + + /* point to next name segment */ + + Pathname += ACPI_NAME_SIZE; + } + + + /* + * Always check if we need to open a new scope + */ + +CheckForNewScopeAndExit: + + if (!(Flags & NS_DONT_OPEN_SCOPE) && (WalkState)) + { + /* + * If entry is a type which opens a scope, + * push the new scope on the scope stack. + */ + + if (AcpiNsOpensScope (TypeToCheckFor)) + { + /* 8-12-98 ASL Grammar Update supports null NamePath */ + + if (NullNamePath) + { + /* TBD: [Investigate] - is this the correct thing to do? */ + + ScopeToPush = NULL; + } + else + { + ScopeToPush = ThisNode; + } + + Status = AcpiDsScopeStackPush (ScopeToPush, Type, + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (ACPI_INFO, + ("NsLookup: Set global scope to %p\n", ScopeToPush)); + } + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c new file mode 100644 index 0000000..881a083 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsalloc.c @@ -0,0 +1,728 @@ +/******************************************************************************* + * + * Module Name: nsalloc - Namespace allocation and deletion utilities + * $Revision: 41 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSALLOC_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCreateNode + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 AcpiName) +{ + ACPI_NAMESPACE_NODE *Node; + + FUNCTION_TRACE ("NsCreateNode"); + + + Node = AcpiCmCallocate (sizeof (ACPI_NAMESPACE_NODE)); + if (!Node) + { + return_PTR (NULL); + } + + INCREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + Node->DataType = ACPI_DESC_TYPE_NAMED; + Node->Name = AcpiName; + Node->ReferenceCount = 1; + + return_PTR (Node); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNode + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PrevNode; + ACPI_NAMESPACE_NODE *NextNode; + + + FUNCTION_TRACE_PTR ("NsDeleteNode", Node); + + ParentNode = AcpiNsGetParentObject (Node); + + PrevNode = NULL; + NextNode = ParentNode->Child; + + while (NextNode != Node) + { + PrevNode = NextNode; + NextNode = PrevNode->Peer; + } + + if (PrevNode) + { + PrevNode->Peer = NextNode->Peer; + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; + } + } + else + { + ParentNode->Child = NextNode->Peer; + } + + + DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + /* + * Detach an object if there is one + */ + + if (Node->Object) + { + AcpiNsDetachObject (Node); + } + + AcpiCmFree (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 entry within a namespace table. + * + ******************************************************************************/ + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ + ACPI_NAMESPACE_NODE *Node, /* New Child*/ + OBJECT_TYPE_INTERNAL Type) +{ + UINT16 OwnerId = TABLE_ID_DSDT; + ACPI_NAMESPACE_NODE *ChildNode; + + + FUNCTION_TRACE ("NsInstallNode"); + + + /* + * Get the owner ID from the Walk state + * The owner ID is used to track table deletion and + * deletion of objects created by methods + */ + if (WalkState) + { + OwnerId = WalkState->OwnerId; + } + + + /* link the new entry into the parent and existing children */ + + /* TBD: Could be first, last, or alphabetic */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + ParentNode->Child = Node; + } + + else + { + while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) + { + ChildNode = ChildNode->Peer; + } + + ChildNode->Peer = Node; + + /* Clear end-of-list flag */ + + ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; + } + + /* Init the new entry */ + + Node->OwnerId = OwnerId; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + + + /* + * If adding a name with unknown type, or having to + * add the region in order to define fields in it, we + * have a forward reference. + */ + + if ((ACPI_TYPE_ANY == Type) || + (INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) + { + /* + * We don't want to abort here, however! + * We will fill in the actual type when the + * real definition is found later. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsInstallNode: [%4.4s] is a forward reference\n", + &Node->Name)); + + } + + /* + * The DefFieldDefn and BankFieldDefn cases are actually + * looking up the Region in which the field will be defined + */ + + if ((INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) + { + Type = ACPI_TYPE_REGION; + } + + /* + * Scope, DefAny, and IndexFieldDefn are bogus "types" which do + * not actually have anything to do with the type of the name + * being looked up. Save any other value of Type as the type of + * the entry. + */ + + if ((Type != INTERNAL_TYPE_SCOPE) && + (Type != INTERNAL_TYPE_DEF_ANY) && + (Type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) + { + Node->Type = (UINT8) Type; + } + + DEBUG_PRINT (TRACE_NAMES, + ("NsInstallNode: %4.4s added to %p at %p\n", + &Node->Name, ParentNode, Node)); + + /* + * Increment the reference count(s) of all parents up to + * the root! + */ + + while ((Node = AcpiNsGetParentObject (Node)) != NULL) + { + Node->ReferenceCount++; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteChildren + * + * PARAMETERS: ParentNode - Delete this objects children + * + * RETURN: None. + * + * DESCRIPTION: Delete all children of the parent object. Deletes a + * "scope". + * + ******************************************************************************/ + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *NextNode; + UINT8 Flags; + + + FUNCTION_TRACE_PTR ("AcpiNsDeleteChildren", ParentNode); + + + if (!ParentNode) + { + return_VOID; + } + + /* If no children, all done! */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + return_VOID; + } + + /* + * Deallocate all children at this level + */ + do + { + /* Get the things we need */ + + NextNode = ChildNode->Peer; + Flags = ChildNode->Flags; + + /* Grandchildren should have all been deleted already */ + + if (ChildNode->Child) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsDeleteChildren: Found a grandchild! P=%X C=%X\n", + ParentNode, ChildNode)); + } + + /* Now we can free this child object */ + + DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + DEBUG_PRINT (ACPI_INFO, + ("AcpiNsDeleteChildren: Object %p, Remaining %d\n", + ChildNode, AcpiGbl_CurrentNodeCount)); + + /* + * Detach an object if there is one + */ + + if (ChildNode->Object) + { + AcpiNsDetachObject (ChildNode); + } + + AcpiCmFree (ChildNode); + + /* And move on to the next child in the list */ + + ChildNode = NextNode; + + } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); + + + /* Clear the parent's child pointer */ + + ParentNode->Child = NULL; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceSubtree + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete a subtree of the namespace. This includes all objects + * stored within the subtree. Scope tables are deleted also + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Level; + + + FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); + + + if (!ParentNode) + { + return_ACPI_STATUS (AE_OK); + } + + + ChildNode = 0; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + + while (Level > 0) + { + /* + * Get the next typed object in this scope. + * Null returned if not found + */ + + ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, ParentNode, + ChildNode); + if (ChildNode) + { + /* + * Found an object - delete the object within + * the Value field + */ + + ObjDesc = AcpiNsGetAttachedObject (ChildNode); + if (ObjDesc) + { + AcpiNsDetachObject (ChildNode); + AcpiCmRemoveReference (ObjDesc); + } + + + /* Check if this object has any children */ + + if (AcpiNsGetNextObject (ACPI_TYPE_ANY, ChildNode, 0)) + { + /* + * There is at least one child of this object, + * visit the object + */ + + Level++; + ParentNode = ChildNode; + ChildNode = 0; + } + } + + else + { + /* + * No more children in this object. + * We will 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 object */ + + ChildNode = ParentNode; + + /* Now we can move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentObject (ParentNode); + } + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRemoveReference + * + * PARAMETERS: Node - Named object whose reference count is to be + * decremented + * + * RETURN: None. + * + * DESCRIPTION: Remove a Node reference. Decrements the reference count + * of all parent Nodes up to the root. Any object along + * the way that reaches zero references is freed. + * + ******************************************************************************/ + +void +AcpiNsRemoveReference ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_NAMESPACE_NODE *NextNode; + + + /* + * Decrement the reference count(s) of this object and all + * objects up to the root, Delete anything with zero remaining references. + */ + NextNode = Node; + while (NextNode) + { + /* Decrement the reference count on this object*/ + + NextNode->ReferenceCount--; + + /* Delete the object if no more references */ + + if (!NextNode->ReferenceCount) + { + /* Delete all children and delete the object */ + + AcpiNsDeleteChildren (NextNode); + AcpiNsDeleteNode (NextNode); + } + + /* Move up to parent */ + + NextNode = AcpiNsGetParentObject (NextNode); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceByOwner + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete entries within the namespace that are owned by a + * specific ID. Used to delete entire ACPI tables. All + * reference counts are updated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDeleteNamespaceByOwner ( + UINT16 OwnerId) +{ + ACPI_NAMESPACE_NODE *ChildNode; + UINT32 Level; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); + + + ParentNode = AcpiGbl_RootNode; + ChildNode = 0; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + + while (Level > 0) + { + /* + * Get the next typed object in this scope. + * Null returned if not found + */ + + ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, ParentNode, + ChildNode); + + if (ChildNode) + { + if (ChildNode->OwnerId == OwnerId) + { + /* + * Found an object - delete the object within + * the Value field + */ + + ObjDesc = AcpiNsGetAttachedObject (ChildNode); + if (ObjDesc) + { + AcpiNsDetachObject (ChildNode); + AcpiCmRemoveReference (ObjDesc); + } + } + + /* Check if this object has any children */ + + if (AcpiNsGetNextObject (ACPI_TYPE_ANY, ChildNode, 0)) + { + /* + * There is at least one child of this object, + * visit the object + */ + + Level++; + ParentNode = ChildNode; + ChildNode = 0; + } + + else if (ChildNode->OwnerId == OwnerId) + { + AcpiNsRemoveReference (ChildNode); + } + } + + else + { + /* + * No more children in this object. Move up to grandparent. + */ + Level--; + + if (Level != 0) + { + if (ParentNode->OwnerId == OwnerId) + { + AcpiNsRemoveReference (ParentNode); + } + } + + /* New "last child" is this parent object */ + + ChildNode = ParentNode; + + /* Now we can move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentObject (ParentNode); + } + } + + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c new file mode 100644 index 0000000..365638d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsdump.c @@ -0,0 +1,677 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * $Revision: 80 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSDUMP_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsdump") + + +#ifdef ACPI_DEBUG + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpPathname + * + * PARAMETERS: Handle - Object + * Msg - Prefix message + * Level - Desired debug level + * Component - Caller's component ID + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ***************************************************************************/ + +ACPI_STATUS +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + NATIVE_CHAR *Msg, + UINT32 Level, + UINT32 Component) +{ + NATIVE_CHAR *Buffer; + UINT32 Length; + + + FUNCTION_TRACE ("NsDumpPathname"); + + /* Do this only if the requested debug level and component are enabled */ + + if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) + { + return_ACPI_STATUS (AE_OK); + } + + Buffer = AcpiCmAllocate (PATHNAME_MAX); + if (!Buffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Convert handle to a full pathname and print it (with supplied message) */ + + Length = PATHNAME_MAX; + if (ACPI_SUCCESS (AcpiNsHandleToPathname (Handle, &Length, Buffer))) + { + AcpiOsPrintf ("%s %s (%p)\n", Msg, Buffer, Handle); + } + + AcpiCmFree (Buffer); + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpOneObject + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * + * DESCRIPTION: Dump a single Node + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *ThisNode; + UINT8 *Value; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + OBJECT_TYPE_INTERNAL ObjType; + OBJECT_TYPE_INTERNAL Type; + UINT32 BytesToDump; + UINT32 DownstreamSiblingMask = 0; + UINT32 LevelTmp; + UINT32 WhichBit; + + + ThisNode = AcpiNsConvertHandleToEntry (ObjHandle); + + LevelTmp = Level; + Type = ThisNode->Type; + WhichBit = 1; + + + if (!(AcpiDbgLevel & Info->DebugLevel)) + { + return (AE_OK); + } + + if (!ObjHandle) + { + DEBUG_PRINT (ACPI_INFO, ("Null object handle\n")); + return (AE_OK); + } + + /* Check if the owner matches */ + + if ((Info->OwnerId != ACPI_UINT32_MAX) && + (Info->OwnerId != ThisNode->OwnerId)) + { + return (AE_OK); + } + + + /* Indent the object according to the level */ + + while (LevelTmp--) + { + + /* Print appropriate characters to form tree structure */ + + if (LevelTmp) + { + if (DownstreamSiblingMask & WhichBit) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("|")); + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); + } + + WhichBit <<= 1; + } + + else + { + if (AcpiNsExistDownstreamSibling (ThisNode + 1)) + { + DownstreamSiblingMask |= (1 << (Level - 1)); + DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); + } + + else + { + DownstreamSiblingMask &= ACPI_UINT32_MAX ^ (1 << (Level - 1)); + DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); + } + + if (ThisNode->Child == NULL) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); + } + + else if (AcpiNsExistDownstreamSibling (ThisNode->Child)) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); + } + } + } + + + /* Check the integrity of our data */ + + if (Type > INTERNAL_TYPE_MAX) + { + Type = INTERNAL_TYPE_DEF_ANY; /* prints as *ERROR* */ + } + + if (!AcpiCmValidAcpiName (ThisNode->Name)) + { + REPORT_WARNING (("Invalid ACPI Name 0x%X\n", ThisNode->Name)); + } + + /* + * Now we can print out the pertinent information + */ + + DEBUG_PRINT_RAW (TRACE_TABLES, (" %4.4s %-9s ", &ThisNode->Name, AcpiCmGetTypeName (Type))); + DEBUG_PRINT_RAW (TRACE_TABLES, ("%p S:%p O:%p", ThisNode, ThisNode->Child, ThisNode->Object)); + + + if (!ThisNode->Object) + { + /* No attached object, we are done */ + + DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); + return (AE_OK); + } + + switch (Type) + { + + case ACPI_TYPE_METHOD: + + /* Name is a Method and its AML offset/length are set */ + + DEBUG_PRINT_RAW (TRACE_TABLES, (" M:%p-%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.Pcode, + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.PcodeLength)); + + break; + + + case ACPI_TYPE_NUMBER: + + DEBUG_PRINT_RAW (TRACE_TABLES, (" N:%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Number.Value)); + break; + + + case ACPI_TYPE_STRING: + + DEBUG_PRINT_RAW (TRACE_TABLES, (" S:%p-%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Pointer, + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Length)); + break; + + + case ACPI_TYPE_BUFFER: + + DEBUG_PRINT_RAW (TRACE_TABLES, (" B:%p-%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Pointer, + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Length)); + break; + + + default: + + DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); + break; + } + + /* If debug turned off, done */ + + if (!(AcpiDbgLevel & TRACE_VALUES)) + { + return (AE_OK); + } + + + /* If there is an attached object, display it */ + + Value = ThisNode->Object; + + /* Dump attached objects */ + + while (Value) + { + ObjType = INTERNAL_TYPE_INVALID; + + /* Decode the type of attached object and dump the contents */ + + DEBUG_PRINT_RAW (TRACE_TABLES, (" Attached Object %p: ", Value)); + + if (AcpiTbSystemTablePointer (Value)) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to AML Code)\n")); + BytesToDump = 16; + } + + else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to Node)\n")); + BytesToDump = sizeof (ACPI_NAMESPACE_NODE); + } + + + else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_INTERNAL)) + { + ObjDesc = (ACPI_OPERAND_OBJECT *) Value; + ObjType = ObjDesc->Common.Type; + + if (ObjType > INTERNAL_TYPE_MAX) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type 0x%X [UNKNOWN])\n", ObjType)); + BytesToDump = 32; + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type 0x%X [%s])\n", + ObjType, AcpiCmGetTypeName (ObjType))); + BytesToDump = sizeof (ACPI_OPERAND_OBJECT); + } + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(String or Buffer - not descriptor)\n", Value)); + BytesToDump = 16; + } + + DUMP_BUFFER (Value, BytesToDump); + + /* If value is NOT an internal object, we are done */ + + if ((AcpiTbSystemTablePointer (Value)) || + (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED))) + { + goto Cleanup; + } + + /* + * Valid object, get the pointer to next level, if any + */ + switch (ObjType) + { + case ACPI_TYPE_STRING: + Value = (UINT8 *) ObjDesc->String.Pointer; + break; + + case ACPI_TYPE_BUFFER: + Value = (UINT8 *) ObjDesc->Buffer.Pointer; + break; + + case ACPI_TYPE_PACKAGE: + Value = (UINT8 *) ObjDesc->Package.Elements; + break; + + case ACPI_TYPE_METHOD: + Value = (UINT8 *) ObjDesc->Method.Pcode; + break; + + case ACPI_TYPE_FIELD_UNIT: + Value = (UINT8 *) ObjDesc->FieldUnit.Container; + break; + + case INTERNAL_TYPE_DEF_FIELD: + Value = (UINT8 *) ObjDesc->Field.Container; + break; + + case INTERNAL_TYPE_BANK_FIELD: + Value = (UINT8 *) ObjDesc->BankField.Container; + break; + + case INTERNAL_TYPE_INDEX_FIELD: + Value = (UINT8 *) ObjDesc->IndexField.Index; + break; + + default: + goto Cleanup; + } + + ObjType = INTERNAL_TYPE_INVALID; /* Terminate loop after next pass */ + } + +Cleanup: + DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); + return (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpObjects + * + * PARAMETERS: Type - Object type to be dumped + * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX + * for an effectively unlimited depth. + * OwnerId - Dump only objects owned by this ID. Use + * ACPI_UINT32_MAX to match all owners. + * StartHandle - Where in namespace to start/end search + * + * DESCRIPTION: Dump typed objects within the loaded namespace. + * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. + * + ***************************************************************************/ + +void +AcpiNsDumpObjects ( + OBJECT_TYPE_INTERNAL Type, + UINT32 MaxDepth, + UINT32 OwnerId, + ACPI_HANDLE StartHandle) +{ + ACPI_WALK_INFO Info; + + + Info.DebugLevel = TRACE_TABLES; + Info.OwnerId = OwnerId; + + AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject, + (void *) &Info, NULL); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpOneDevice + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * + * DESCRIPTION: Dump a single Node that represents a device + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_INFO Info; + ACPI_STATUS Status; + UINT32 i; + + + Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); + + Status = AcpiGetObjectInfo (ObjHandle, &Info); + if (ACPI_SUCCESS (Status)) + { + for (i = 0; i < Level; i++) + { + DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); + } + + DEBUG_PRINT_RAW (TRACE_TABLES, (" HID: %.8X, ADR: %.8X, Status: %x\n", + Info.HardwareId, Info.Address, Info.CurrentStatus)); + } + + return (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpRootDevices + * + * PARAMETERS: None + * + * DESCRIPTION: Dump all objects of type "device" + * + ***************************************************************************/ + +void +AcpiNsDumpRootDevices (void) +{ + ACPI_HANDLE SysBusHandle; + + + /* Only dump the table if tracing is enabled */ + + if (!(TRACE_TABLES & AcpiDbgLevel)) + { + return; + } + + AcpiGetHandle (0, NS_SYSTEM_BUS, &SysBusHandle); + + DEBUG_PRINT (TRACE_TABLES, ("Display of all devices in the namespace:\n")); + AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, NS_WALK_NO_UNLOCK, + AcpiNsDumpOneDevice, NULL, NULL); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpTables + * + * PARAMETERS: SearchBase - Root of subtree to be dumped, or + * NS_ALL to dump the entire namespace + * MaxDepth - Maximum depth of dump. Use INT_MAX + * for an effectively unlimited depth. + * + * DESCRIPTION: Dump the name space, or a portion of it. + * + ***************************************************************************/ + +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth) +{ + ACPI_HANDLE SearchHandle = SearchBase; + + + FUNCTION_TRACE ("NsDumpTables"); + + + if (!AcpiGbl_RootNode) + { + /* + * If the name space has not been initialized, + * there is nothing to dump. + */ + DEBUG_PRINT (TRACE_TABLES, ("NsDumpTables: name space not initialized!\n")); + return_VOID; + } + + if (NS_ALL == SearchBase) + { + /* entire namespace */ + + SearchHandle = AcpiGbl_RootNode; + DEBUG_PRINT (TRACE_TABLES, ("\\\n")); + } + + + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SearchHandle); + return_VOID; +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpEntry + * + * PARAMETERS: Handle - Node to be dumped + * DebugLevel - Output level + * + * DESCRIPTION: Dump a single Node + * + ***************************************************************************/ + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel) +{ + ACPI_WALK_INFO Info; + + + FUNCTION_TRACE_PTR ("NsDumpEntry", Handle); + + Info.DebugLevel = DebugLevel; + Info.OwnerId = ACPI_UINT32_MAX; + + AcpiNsDumpOneObject (Handle, 1, &Info, NULL); + + DEBUG_PRINT (TRACE_EXEC, ("leave AcpiNsDumpEntry %p\n", Handle)); + return_VOID; +} + +#endif + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c new file mode 100644 index 0000000..e7a587f --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nseval.c @@ -0,0 +1,670 @@ +/******************************************************************************* + * + * Module Name: nseval - Object evaluation interfaces -- includes control + * method lookup and execution. + * $Revision: 79 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSEVAL_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nseval") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluateRelative + * + * PARAMETERS: Handle - The relative containing object + * *Pathname - Name of method to execute, If NULL, the + * handle is the object to execute + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Find and execute the requested method using the handle as a + * scope + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluateRelative ( + ACPI_NAMESPACE_NODE *Handle, + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_NAMESPACE_NODE *PrefixNode; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + NATIVE_CHAR *InternalPath = NULL; + ACPI_GENERIC_STATE ScopeInfo; + + + FUNCTION_TRACE ("NsEvaluateRelative"); + + + /* + * Must have a valid object handle + */ + if (!Handle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Build an internal name string for the method */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the prefix handle and Node */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + PrefixNode = AcpiNsConvertHandleToEntry (Handle); + if (!PrefixNode) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* Lookup the name in the namespace */ + + ScopeInfo.Scope.Node = PrefixNode; + Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, + IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + &Node); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateRelative: Object [%s] not found [%.4X]\n", + Pathname, AcpiCmFormatException (Status))); + goto Cleanup; + } + + /* + * Now that we have a handle to the object, we can attempt + * to evaluate it. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateRelative: %s [%p] Value %p\n", + Pathname, Node, Node->Object)); + + Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateRelative: *** Completed eval of object %s ***\n", + Pathname)); + +Cleanup: + + /* Cleanup */ + + AcpiCmFree (InternalPath); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluateByName + * + * PARAMETERS: Pathname - Fully qualified pathname to the object + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * + * RETURN: Status + * + * DESCRIPTION: Find and execute the requested method passing the given + * parameters + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluateByName ( + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + NATIVE_CHAR *InternalPath = NULL; + + + FUNCTION_TRACE ("NsEvaluateByName"); + + + /* Build an internal name string for the method */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Lookup the name in the namespace */ + + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, + IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + &Node); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateByName: Object at [%s] was not found, status=%.4X\n", + Pathname, Status)); + goto Cleanup; + } + + /* + * Now that we have a handle to the object, we can attempt + * to evaluate it. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateByName: %s [%p] Value %p\n", + Pathname, Node, Node->Object)); + + Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateByName: *** Completed eval of object %s ***\n", + Pathname)); + + +Cleanup: + + /* Cleanup */ + + if (InternalPath) + { + AcpiCmFree (InternalPath); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluateByHandle + * + * PARAMETERS: Handle - Method Node to execute + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Execute the requested method passing the given parameters + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluateByHandle ( + ACPI_NAMESPACE_NODE *Handle, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *LocalReturnObject; + + + FUNCTION_TRACE ("NsEvaluateByHandle"); + + + /* Check if namespace has been initialized */ + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + /* Parameter Validation */ + + if (!Handle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ReturnObject) + { + /* Initialize the return value to an invalid object */ + + *ReturnObject = NULL; + } + + /* Get the prefix handle and Node */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* + * Two major cases here: + * 1) The object is an actual control method -- execute it. + * 2) The object is not a method -- just return it's current + * value + * + * In both cases, the namespace is unlocked by the + * AcpiNs* procedure + */ + if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD) + { + /* + * Case 1) We have an actual control method to execute + */ + Status = AcpiNsExecuteControlMethod (Node, Params, + &LocalReturnObject); + } + + else + { + /* + * Case 2) Object is NOT a method, just return its + * current value + */ + Status = AcpiNsGetObjectValue (Node, &LocalReturnObject); + } + + + /* + * Check if there is a return value on the stack that must + * be dealt with + */ + if (Status == AE_CTRL_RETURN_VALUE) + { + /* + * If the Method returned a value and the caller + * provided a place to store a returned value, Copy + * the returned value to the object descriptor provided + * by the caller. + */ + if (ReturnObject) + { + /* + * Valid return object, copy the pointer to + * the returned object + */ + *ReturnObject = LocalReturnObject; + } + + + /* Map AE_RETURN_VALUE to AE_OK, we are done with it */ + + if (Status == AE_CTRL_RETURN_VALUE) + { + Status = AE_OK; + } + } + + /* + * Namespace was unlocked by the handling AcpiNs* function, + * so we just return + */ + return_ACPI_STATUS (Status); + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecuteControlMethod + * + * PARAMETERS: MethodNode - The object/method + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * **ReturnObjDesc - List of result objects to be returned + * from the method. + * + * RETURN: Status + * + * DESCRIPTION: Execute the requested method passing the given parameters + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsExecuteControlMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("NsExecuteControlMethod"); + + + /* Verify that there is a method associated with this object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) MethodNode); + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("Control method is undefined (nil value)\n")); + return_ACPI_STATUS (AE_ERROR); + } + + + DEBUG_PRINT (ACPI_INFO, ("Control method at Offset %x Length %lx]\n", + ObjDesc->Method.Pcode + 1, + ObjDesc->Method.PcodeLength - 1)); + + DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing", + TRACE_NAMES, _COMPONENT); + + DEBUG_PRINT (TRACE_NAMES, + ("At offset %8XH\n", ObjDesc->Method.Pcode + 1)); + + + /* + * Unlock the namespace before execution. This allows namespace access + * via the external Acpi* interfaces while a method is being executed. + * However, any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of the + * namespace that is being deleted. + */ + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * Excecute the method via the interpreter + */ + Status = AcpiAmlExecuteMethod (MethodNode, Params, ReturnObjDesc); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetObjectValue + * + * PARAMETERS: Node - The object + * + * RETURN: Status + * + * DESCRIPTION: Return the current value of the object + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetObjectValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *ValDesc; + + + FUNCTION_TRACE ("NsGetObjectValue"); + + + /* + * We take the value from certain objects directly + */ + + if ((Node->Type == ACPI_TYPE_PROCESSOR) || + (Node->Type == ACPI_TYPE_POWER)) + { + /* + * Create a Reference object to contain the object + */ + ObjDesc = AcpiCmCreateInternalObject (Node->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* + * Get the attached object + */ + + ValDesc = AcpiNsGetAttachedObject (Node); + if (!ValDesc) + { + Status = AE_NULL_OBJECT; + goto UnlockAndExit; + } + + /* + * Just copy from the original to the return object + * + * TBD: [Future] - need a low-level object copy that handles + * the reference count automatically. (Don't want to copy it) + */ + + MEMCPY (ObjDesc, ValDesc, sizeof (ACPI_OPERAND_OBJECT)); + ObjDesc->Common.ReferenceCount = 1; + } + + + /* + * Other objects require a reference object wrapper which we + * then attempt to resolve. + */ + else + { + /* Create an Reference object to contain the object */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Construct a descriptor pointing to the name */ + + ObjDesc->Reference.OpCode = (UINT8) AML_NAME_OP; + ObjDesc->Reference.Object = (void *) Node; + + /* + * Use AcpiAmlResolveToValue() to get the associated value. + * The call to AcpiAmlResolveToValue causes + * ObjDesc (allocated above) to always be deleted. + * + * NOTE: we can get away with passing in NULL for a walk state + * because ObjDesc is guaranteed to not be a reference to either + * a method local or a method argument + * + * Even though we do not technically need to use the interpreter + * for this, we must enter it because we could hit an opregion. + * The opregion access code assumes it is in the interpreter. + */ + + AcpiAmlEnterInterpreter(); + + Status = AcpiAmlResolveToValue (&ObjDesc, NULL); + + AcpiAmlExitInterpreter(); + } + + /* + * If AcpiAmlResolveToValue() succeeded, the return value was + * placed in ObjDesc. + */ + + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_RETURN_VALUE; + + *ReturnObjDesc = ObjDesc; + DEBUG_PRINT (ACPI_INFO, + ("NsGetObjectValue: Returning obj %p\n", *ReturnObjDesc)); + } + + +UnlockAndExit: + + /* Unlock the namespace */ + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c new file mode 100644 index 0000000..6be2d04 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsinit.c @@ -0,0 +1,514 @@ +/****************************************************************************** + * + * Module Name: nsinit - namespace initialization + * $Revision: 4 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFINIT_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acdispat.h" + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsinit") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + + + FUNCTION_TRACE ("NsInitializeObjects"); + + + DEBUG_PRINT (TRACE_DISPATCH, + ("NsInitializeObjects: **** Starting initialization of namespace objects ****\n")); + DEBUG_PRINT_RAW (ACPI_OK, ("Completing Region and Field initialization:")); + + + Info.FieldCount = 0; + Info.FieldInit = 0; + Info.OpRegionCount = 0; + Info.OpRegionInit = 0; + Info.ObjectCount = 0; + + + /* Walk entire namespace from the supplied root */ + + Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiNsInitOneObject, + &Info, NULL); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsInitializeObjects: WalkNamespace failed! %x\n", Status)); + } + + DEBUG_PRINT_RAW (ACPI_OK, + ("\n%d/%d Regions, %d/%d Fields initialized (%d nodes total)\n", + Info.OpRegionInit, Info.OpRegionCount, Info.FieldInit, Info.FieldCount, Info.ObjectCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("NsInitializeObjects: %d Control Methods found\n", Info.MethodCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("NsInitializeObjects: %d 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. + * + * Also: Install PCI config space handler for all PCI root bridges. + * A PCI root bridge is found by searching for devices containing + * a HID with the value EISAID("PNP0A03") + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeDevices ( + UINT32 Flags) +{ + ACPI_STATUS Status; + ACPI_DEVICE_WALK_INFO Info; + + + FUNCTION_TRACE ("NsInitializeDevices"); + + + Info.Flags = Flags; + Info.DeviceCount = 0; + Info.Num_STA = 0; + Info.Num_INI = 0; + Info.Num_HID = 0; + Info.Num_PCI = 0; + + + DEBUG_PRINT_RAW (ACPI_OK, ("Executing device _INI methods:")); + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + FALSE, AcpiNsInitOneDevice, &Info, NULL); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsInitializeDevices: WalkNamespace failed! %x\n", Status)); + } + + + DEBUG_PRINT_RAW (ACPI_OK, + ("\n%d Devices found: %d _STA, %d _INI, %d _HID, %d PCIRoot\n", + Info.DeviceCount, Info.Num_STA, Info.Num_INI, + Info.Num_HID, Info.Num_PCI)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneObject + * + * PARAMETERS: ObjHandle - Node + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Op Regions + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + OBJECT_TYPE_INTERNAL Type; + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OPERAND_OBJECT *ObjDesc; + + + Info->ObjectCount++; + + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + ObjDesc = Node->Object; + if (!ObjDesc) + { + return (AE_OK); + } + + switch (Type) + { + + case ACPI_TYPE_REGION: + + Info->OpRegionCount++; + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + break; + } + + Info->OpRegionInit++; + Status = AcpiDsGetRegionArguments (ObjDesc); + DEBUG_PRINT_RAW (ACPI_OK, (".")); + break; + + + case ACPI_TYPE_FIELD_UNIT: + + Info->FieldCount++; + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + break; + } + + Info->FieldInit++; + Status = AcpiDsGetFieldUnitArguments (ObjDesc); + DEBUG_PRINT_RAW (ACPI_OK, (".")); + + 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: AcpiNsInitOneDevice + * + * PARAMETERS: The usual "I'm a namespace callback" stuff + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: This is called once per device soon after ACPI is enabled + * to initialize each device. It determines if the device is + * present, and if so, calls _INI. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RetObj = NULL; + ACPI_NAMESPACE_NODE *Node; + UINT32 Flags; + ACPI_DEVICE_WALK_INFO *Info = (ACPI_DEVICE_WALK_INFO *) Context; + + + FUNCTION_TRACE ("AcpiNsInitOneDevice"); + + + DEBUG_PRINT_RAW (ACPI_OK, (".")); + Info->DeviceCount++; + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (ObjHandle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * Run _STA to determine if we can run _INI on the device. + */ + + Status = AcpiCmExecute_STA (Node, &Flags); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Info->Num_STA++; + + if (!(Flags & 0x01)) + { + /* don't look at children of a not present device */ + return_ACPI_STATUS(AE_CTRL_DEPTH); + } + + /* + * The device is present. Run _INI. + */ + + Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); + if (AE_NOT_FOUND == Status) + { + /* No _INI means device requires no initialization */ + } + + else if (ACPI_FAILURE (Status)) + { +#ifdef ACPI_DEBUG + NATIVE_CHAR *ScopeName = AcpiNsGetTablePathname (ObjHandle); + + DEBUG_PRINT (ACPI_ERROR, ("%s._INI failed: %s\n", + ScopeName, AcpiCmFormatException (Status))); + + AcpiCmFree (ScopeName); +#endif + return_ACPI_STATUS (Status); + } + + else + { + Info->Num_INI++; + } + + + /* + * Examine the HID of the device. _HID can be an executable + * control method -- it simply has to return a string or number + * containing the HID. + */ + + if (RetObj) + { + AcpiCmRemoveReference (RetObj); + } + + RetObj = NULL; + Status = AcpiNsEvaluateRelative (ObjHandle, "_HID", NULL, &RetObj); + if (AE_NOT_FOUND == Status) + { + /* No _HID --> Can't be a PCI root bridge */ + + return_ACPI_STATUS (AE_OK); + } + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Info->Num_HID++; + + + /* + * Found an _HID object. + * Check for a PCI Root Bridge. We need to install the PCI_CONFIG space + * handler on all PCI Root Bridges found within the namespace + * + * A PCI Root Bridge has an HID with the value EISAID("PNP0A03") + * The HID can be either a number or a string. + */ + + switch (RetObj->Common.Type) + { + case ACPI_TYPE_NUMBER: + + if (RetObj->Number.Value != PCI_ROOT_HID_VALUE) + { + goto Cleanup; + } + + break; + + case ACPI_TYPE_STRING: + + if (STRNCMP (RetObj->String.Pointer, PCI_ROOT_HID_STRING, + sizeof (PCI_ROOT_HID_STRING))) + { + goto Cleanup; + } + + break; + + default: + + goto Cleanup; + } + + + /* + * We found a valid PCI_ROOT_HID. + * The parent of the HID entry is the PCI device; Install the default PCI + * handler for this PCI device. + */ + + Info->Num_PCI++; + + if (!(Info->Flags & ACPI_NO_PCI_INIT)) + { + Status = AcpiInstallAddressSpaceHandler (ObjHandle, + ADDRESS_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + } + +Cleanup: + + if (RetObj) + { + AcpiCmRemoveReference (RetObj); + } + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c new file mode 100644 index 0000000..e006ccf --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsload.c @@ -0,0 +1,712 @@ +/****************************************************************************** + * + * Module Name: nsload - namespace loading/expanding/contracting procedures + * $Revision: 31 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSLOAD_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acdebug.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsload") + + +/****************************************************************************** + * + * FUNCTION: AcpiLoadNamespace + * + * PARAMETERS: DisplayAmlDuringLoad + * + * 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; + + + FUNCTION_TRACE ("AcpiLoadNameSpace"); + + + /* There must be at least a DSDT installed */ + + if (AcpiGbl_DSDT == NULL) + { + DEBUG_PRINT (ACPI_ERROR, ("DSDT is not in memory\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + + /* + * Load the namespace. The DSDT is required, + * but the SSDT and PSDT tables are optional. + */ + + Status = AcpiNsLoadTableByType (ACPI_TABLE_DSDT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ignore exceptions from these */ + + AcpiNsLoadTableByType (ACPI_TABLE_SSDT); + AcpiNsLoadTableByType (ACPI_TABLE_PSDT); + + + DEBUG_PRINT_RAW (ACPI_OK, + ("ACPI Namespace successfully loaded at root 0x%p\n", + AcpiGbl_RootNode)); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsOneParsePass + * + * PARAMETERS: + * + * RETURN: Status + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; + ACPI_PARSE_OBJECT *ParseRoot; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("NsOneCompleteParse"); + + + switch (PassNumber) + { + case 1: + DescendingCallback = AcpiDsLoad1BeginOp; + AscendingCallback = AcpiDsLoad1EndOp; + break; + + case 2: + DescendingCallback = AcpiDsLoad2BeginOp; + AscendingCallback = AcpiDsLoad2EndOp; + break; + + case 3: + DescendingCallback = AcpiDsExecBeginOp; + AscendingCallback = AcpiDsExecEndOp; + break; + + default: + return (AE_BAD_PARAMETER); + } + + /* Create and init a Root Node */ + + ParseRoot = AcpiPsAllocOp (AML_SCOPE_OP); + if (!ParseRoot) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ((ACPI_PARSE2_OBJECT *) ParseRoot)->Name = ACPI_ROOT_NAME; + + + /* Pass 1: Parse everything except control method bodies */ + + DEBUG_PRINT (TRACE_PARSE, + ("NsParseTable: *PARSE* pass %d parse\n", PassNumber)); + + Status = AcpiPsParseAml (ParseRoot, + TableDesc->AmlPointer, + TableDesc->AmlLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + NULL, NULL, NULL, + DescendingCallback, + AscendingCallback); + + AcpiPsDeleteParseTree (ParseRoot); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsParseTable + * + * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse + * StartNode - Where to enter the table into the namespace + * + * RETURN: Status + * + * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsParseTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("NsParseTable"); + + + /* + * AML Parse, pass 1 + * + * In this pass, we load most of the namespace. Control methods + * are not parsed until later. A parse tree is not created. Instead, + * each Parser Op subtree is deleted when it is finished. This saves + * a great deal of memory, and allows a small cache of parse objects + * to service the entire parse. The second pass of the parse then + * performs another complete parse of the AML.. + */ + + Status = AcpiNsOneCompleteParse (1, TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* + * AML Parse, pass 2 + * + * In this pass, we resolve forward references and other things + * that could not be completed during the first pass. + * Another complete parse of the AML is performed, but the + * overhead of this is compensated for by the fact that the + * parse objects are all cached. + */ + + Status = AcpiNsOneCompleteParse (2, TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* TBD: no longer needed, remove */ + + AcpiGbl_ParsedNamespaceRoot = NULL; + + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiNsLoadTable + * + * PARAMETERS: *PcodeAddr - Address of pcode block + * PcodeLength - Length of pcode block + * + * RETURN: Status + * + * DESCRIPTION: Load one ACPI table into the namespace + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsLoadTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("NsLoadTable"); + + + if (!TableDesc->AmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, ("NsLoadTable: Null AML pointer\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: AML block at %p\n", TableDesc->AmlPointer)); + + + if (!TableDesc->AmlLength) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsLoadTable: Zero-length AML block\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* + * 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! + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: **** Loading table into namespace ****\n")); + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiNsParseTable (TableDesc, Node->Child); + AcpiCmReleaseMutex (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. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: **** Begin Table Method Parsing and Object Initialization ****\n")); + + Status = AcpiDsInitializeObjects (TableDesc, Node); + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: **** Completed Table Method Parsing and Object Initialization ****\n")); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsLoadTableByType + * + * PARAMETERS: TableType - Id of the table type to load + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables + * of the given type are loaded. The mechanism allows this + * routine to be called repeatedly. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsLoadTableByType ( + ACPI_TABLE_TYPE TableType) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *TablePtr; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE ("NsLoadTableByType"); + + + AcpiCmAcquireMutex (ACPI_MTX_TABLES); + + + /* + * Table types supported are: + * DSDT (one), SSDT/PSDT (multiple) + */ + + switch (TableType) + { + + case ACPI_TABLE_DSDT: + + DEBUG_PRINT (ACPI_INFO, ("NsLoadTableByType: Loading DSDT\n")); + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_DSDT]; + + /* If table already loaded into namespace, just return */ + + if (TableDesc->LoadedIntoNamespace) + { + goto UnlockAndExit; + } + + TableDesc->TableId = TABLE_ID_DSDT; + + /* Now load the single DSDT */ + + Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode); + if (ACPI_SUCCESS (Status)) + { + TableDesc->LoadedIntoNamespace = TRUE; + } + + break; + + + case ACPI_TABLE_SSDT: + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTableByType: Loading %d SSDTs\n", + AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count)); + + /* + * Traverse list of SSDT tables + */ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_SSDT]; + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count; i++) + { + TablePtr = TableDesc->Pointer; + + /* + * Only attempt to load table if it is not + * already loaded! + */ + + if (!TableDesc->LoadedIntoNamespace) + { + Status = AcpiNsLoadTable (TableDesc, + AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + break; + } + + TableDesc->LoadedIntoNamespace = TRUE; + } + + TableDesc = TableDesc->Next; + } + + break; + + + case ACPI_TABLE_PSDT: + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTableByType: Loading %d PSDTs\n", + AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count)); + + /* + * Traverse list of PSDT tables + */ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_PSDT]; + + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count; i++) + { + TablePtr = TableDesc->Pointer; + + /* Only attempt to load table if it is not already loaded! */ + + if (!TableDesc->LoadedIntoNamespace) + { + Status = AcpiNsLoadTable (TableDesc, + AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + break; + } + + TableDesc->LoadedIntoNamespace = TRUE; + } + + TableDesc = TableDesc->Next; + } + + break; + + + default: + Status = AE_SUPPORT; + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_TABLES); + + return_ACPI_STATUS (Status); + +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsDeleteSubtree + * + * PARAMETERS: StartHandle - Handle in namespace where search begins + * + * RETURNS Status + * + * DESCRIPTION: Walks the namespace starting at the given handle and deletes + * all objects, entries, and scopes in the entire subtree. + * + * TBD: [Investigate] What if any part of this subtree is in use? + * (i.e. on one of the object stacks?) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle) +{ + ACPI_STATUS Status; + ACPI_HANDLE ChildHandle; + ACPI_HANDLE ParentHandle; + ACPI_HANDLE NextChildHandle; + ACPI_HANDLE Dummy; + UINT32 Level; + + + FUNCTION_TRACE ("NsDeleteSubtree"); + + + ParentHandle = StartHandle; + ChildHandle = 0; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + + while (Level > 0) + { + /* Attempt to get the next object in this scope */ + + Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, + ChildHandle, + &NextChildHandle); + + ChildHandle = NextChildHandle; + + + /* Did we get a new object? */ + + if (ACPI_SUCCESS (Status)) + { + /* Check if this object has any children */ + + if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, + ChildHandle, 0, + &Dummy))) + { + /* + * There is at least one child of this object, + * visit the object + */ + + Level++; + ParentHandle = ChildHandle; + ChildHandle = 0; + } + } + + else + { + /* + * No more children in this object, go back up to + * the object's parent + */ + Level--; + + /* Delete all children now */ + + AcpiNsDeleteChildren (ChildHandle); + + ChildHandle = ParentHandle; + AcpiGetParent (ParentHandle, &ParentHandle); + } + } + + /* Now delete the starting object, and we are done */ + + AcpiNsDeleteNode (ChildHandle); + + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsUnloadNameSpace + * + * PARAMETERS: Handle - Root of namespace subtree to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Shrinks the namespace, typically in response to an undocking + * event. Deletes an entire subtree starting from (and + * including) the given handle. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle) +{ + ACPI_STATUS Status; + + + 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); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c new file mode 100644 index 0000000..795c811 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsnames.c @@ -0,0 +1,334 @@ +/******************************************************************************* + * + * Module Name: nsnames - Name manipulation and search + * $Revision: 49 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSNAMES_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsnames") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetTablePathname + * + * PARAMETERS: Node - Scope whose name is needed + * + * RETURN: Pointer to storage containing the fully qualified name of + * the scope, in Label format (all segments strung together + * with no separators) + * + * DESCRIPTION: Used for debug printing in AcpiNsSearchTable(). + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiNsGetTablePathname ( + ACPI_NAMESPACE_NODE *Node) +{ + NATIVE_CHAR *NameBuffer; + UINT32 Size; + ACPI_NAME Name; + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE_PTR ("AcpiNsGetTablePathname", Node); + + + if (!AcpiGbl_RootNode || !Node) + { + /* + * If the name space has not been initialized, + * this function should not have been called. + */ + return_PTR (NULL); + } + + ChildNode = Node->Child; + + + /* Calculate required buffer size based on depth below root */ + + Size = 1; + ParentNode = ChildNode; + while (ParentNode) + { + ParentNode = AcpiNsGetParentObject (ParentNode); + if (ParentNode) + { + Size += ACPI_NAME_SIZE; + } + } + + + /* Allocate a buffer to be returned to caller */ + + NameBuffer = AcpiCmCallocate (Size + 1); + if (!NameBuffer) + { + REPORT_ERROR (("NsGetTablePathname: allocation failure\n")); + return_PTR (NULL); + } + + + /* Store terminator byte, then build name backwards */ + + NameBuffer[Size] = '\0'; + while ((Size > ACPI_NAME_SIZE) && + AcpiNsGetParentObject (ChildNode)) + { + Size -= ACPI_NAME_SIZE; + Name = AcpiNsFindParentName (ChildNode); + + /* Put the name into the buffer */ + + MOVE_UNALIGNED32_TO_32 ((NameBuffer + Size), &Name); + ChildNode = AcpiNsGetParentObject (ChildNode); + } + + NameBuffer[--Size] = AML_ROOT_PREFIX; + + if (Size != 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsGetTablePathname: Bad pointer returned; size = %d\n", Size)); + } + + return_PTR (NameBuffer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsHandleToPathname + * + * PARAMETERS: TargetHandle - Handle of named object whose name is + * to be found + * BufSize - Size of the buffer provided + * UserBuffer - 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 + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + UINT32 *BufSize, + NATIVE_CHAR *UserBuffer) +{ + ACPI_STATUS Status = AE_OK; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *NextNode; + UINT32 PathLength; + UINT32 Size; + UINT32 UserBufSize; + ACPI_NAME Name; + + FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle); + + + if (!AcpiGbl_RootNode || !TargetHandle) + { + /* + * If the name space has not been initialized, + * this function should not have been called. + */ + + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + Node = AcpiNsConvertHandleToEntry (TargetHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Compute length of pathname as 5 * number of name segments. + * Go back up the parent tree to the root + */ + for (Size = 0, NextNode = Node; + AcpiNsGetParentObject (NextNode); + NextNode = AcpiNsGetParentObject (NextNode)) + { + Size += PATH_SEGMENT_LENGTH; + } + + /* Set return length to the required path length */ + + PathLength = Size + 1; + UserBufSize = *BufSize; + *BufSize = PathLength; + + /* Check if the user buffer is sufficiently large */ + + if (PathLength > UserBufSize) + { + Status = AE_BUFFER_OVERFLOW; + goto Exit; + } + + /* Store null terminator */ + + UserBuffer[Size] = 0; + Size -= ACPI_NAME_SIZE; + + /* Put the original ACPI name at the end of the path */ + + MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size), + &Node->Name); + + UserBuffer[--Size] = PATH_SEPARATOR; + + /* Build name backwards, putting "." between segments */ + + while ((Size > ACPI_NAME_SIZE) && Node) + { + Size -= ACPI_NAME_SIZE; + Name = AcpiNsFindParentName (Node); + MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size), &Name); + + UserBuffer[--Size] = PATH_SEPARATOR; + Node = AcpiNsGetParentObject (Node); + } + + /* + * Overlay the "." preceding the first segment with + * the root name "\" + */ + + UserBuffer[Size] = '\\'; + + DEBUG_PRINT (TRACE_EXEC, + ("NsHandleToPathname: Len=%d, %s \n", + PathLength, UserBuffer)); + +Exit: + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c new file mode 100644 index 0000000..6dd5fe3 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsobject.c @@ -0,0 +1,523 @@ +/******************************************************************************* + * + * Module Name: nsobject - Utilities for objects attached to namespace + * table entries + * $Revision: 46 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSOBJECT_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "actables.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsobject") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachObject + * + * PARAMETERS: Node - Parent Node + * Object - Object to be attached + * Type - Type of object, or ACPI_TYPE_ANY if not + * known + * + * DESCRIPTION: Record the given object as the value associated with the + * name whose ACPI_HANDLE is passed. If Object is NULL + * and Type is ACPI_TYPE_ANY, set the name as having no value. + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + OBJECT_TYPE_INTERNAL Type) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *PreviousObjDesc; + OBJECT_TYPE_INTERNAL ObjType = ACPI_TYPE_ANY; + UINT8 Flags; + UINT16 Opcode; + + + FUNCTION_TRACE ("NsAttachObject"); + + + /* + * Parameter validation + */ + + if (!AcpiGbl_RootNode) + { + /* Name space not initialized */ + + REPORT_ERROR (("NsAttachObject: Namespace not initialized\n")); + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + if (!Node) + { + /* Invalid handle */ + + REPORT_ERROR (("NsAttachObject: Null NamedObj handle\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!Object && (ACPI_TYPE_ANY != Type)) + { + /* Null object */ + + REPORT_ERROR (("NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!VALID_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED)) + { + /* Not a name handle */ + + REPORT_ERROR (("NsAttachObject: Invalid handle\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check if this object is already attached */ + + if (Node->Object == Object) + { + DEBUG_PRINT (TRACE_EXEC, + ("NsAttachObject: Obj %p already installed in NameObj %p\n", + Object, Node)); + + return_ACPI_STATUS (AE_OK); + } + + + /* Get the current flags field of the Node */ + + Flags = Node->Flags; + Flags &= ~ANOBJ_AML_ATTACHMENT; + + + /* If null object, we will just install it */ + + if (!Object) + { + ObjDesc = NULL; + ObjType = ACPI_TYPE_ANY; + } + + /* + * If the object is an Node with an attached object, + * we will use that (attached) object + */ + + else if (VALID_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; + ObjType = ((ACPI_NAMESPACE_NODE *) Object)->Type; + + /* + * Copy appropriate flags + */ + + if (((ACPI_NAMESPACE_NODE *) Object)->Flags & ANOBJ_AML_ATTACHMENT) + { + Flags |= ANOBJ_AML_ATTACHMENT; + } + } + + + /* + * Otherwise, we will use the parameter object, but we must type + * it first + */ + + else + { + ObjDesc = (ACPI_OPERAND_OBJECT *) Object; + + + /* If a valid type (non-ANY) was given, just use it */ + + if (ACPI_TYPE_ANY != Type) + { + ObjType = Type; + } + + + /* + * Type is TYPE_Any, we must try to determinte the + * actual type of the object + */ + + /* + * Check if value points into the AML code + */ + else if (AcpiTbSystemTablePointer (Object)) + { + /* + * Object points into the AML stream. + * Set a flag bit in the Node to indicate this + */ + + Flags |= ANOBJ_AML_ATTACHMENT; + + /* + * The next byte (perhaps the next two bytes) + * will be the AML opcode + */ + + MOVE_UNALIGNED16_TO_16 (&Opcode, Object); + + /* Check for a recognized OpCode */ + + switch ((UINT8) Opcode) + { + + case AML_OP_PREFIX: + + if (Opcode != AML_REVISION_OP) + { + /* + * OpPrefix is unrecognized unless part + * of RevisionOp + */ + + break; + } + + /* Else fall through to set type as Number */ + + + case AML_ZERO_OP: case AML_ONES_OP: case AML_ONE_OP: + case AML_BYTE_OP: case AML_WORD_OP: case AML_DWORD_OP: + + ObjType = ACPI_TYPE_NUMBER; + break; + + + case AML_STRING_OP: + + ObjType = ACPI_TYPE_STRING; + break; + + + case AML_BUFFER_OP: + + ObjType = ACPI_TYPE_BUFFER; + break; + + + case AML_MUTEX_OP: + + ObjType = ACPI_TYPE_MUTEX; + break; + + + case AML_PACKAGE_OP: + + ObjType = ACPI_TYPE_PACKAGE; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AML Opcode/Type [%x] not supported in attach\n", + (UINT8) Opcode)); + + return_ACPI_STATUS (AE_TYPE); + break; + } + } + + else + { + /* + * Cannot figure out the type -- set to DefAny which + * will print as an error in the name table dump + */ + + if (GetDebugLevel () > 0) + { + DUMP_PATHNAME (Node, + "NsAttachObject confused: setting bogus type for ", + ACPI_INFO, _COMPONENT); + + if (AcpiTbSystemTablePointer (Object)) + { + DEBUG_PRINT (ACPI_INFO, + ("AML-stream code %02x\n", *(UINT8 *) Object)); + } + + else if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_NAMED)) + { + DUMP_PATHNAME (Object, + "name ", ACPI_INFO, + _COMPONENT); + } + + else + { + DUMP_PATHNAME (Object, "object ", + ACPI_INFO, _COMPONENT); + DUMP_STACK_ENTRY (Object); + } + } + + ObjType = INTERNAL_TYPE_DEF_ANY; + } + } + + + DEBUG_PRINT (TRACE_EXEC, + ("NsAttachObject: Installing obj %p into NameObj %p [%4.4s]\n", + ObjDesc, Node, &Node->Name)); + + + /* + * Must increment the new value's reference count + * (if it is an internal object) + */ + + AcpiCmAddReference (ObjDesc); + + /* Save the existing object (if any) for deletion later */ + + PreviousObjDesc = Node->Object; + + /* Install the object and set the type, flags */ + + Node->Object = ObjDesc; + Node->Type = (UINT8) ObjType; + Node->Flags |= Flags; + + + /* + * Delete an existing attached object. + */ + + if (PreviousObjDesc) + { + /* One for the attach to the Node */ + + AcpiCmRemoveReference (PreviousObjDesc); + + /* Now delete */ + + AcpiCmRemoveReference (PreviousObjDesc); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachObject + * + * PARAMETERS: Node - An object whose Value will be deleted + * + * RETURN: None. + * + * DESCRIPTION: Delete the Value associated with a namespace object. If the + * Value is an allocated object, it is freed. Otherwise, the + * field is simply cleared. + * + ******************************************************************************/ + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("NsDetachObject"); + + ObjDesc = Node->Object; + if (!ObjDesc) + { + return_VOID; + } + + /* Clear the entry in all cases */ + + Node->Object = NULL; + + /* Found a valid value */ + + DEBUG_PRINT (ACPI_INFO, + ("NsDetachObject: Object=%p Value=%p Name %4.4s\n", + Node, ObjDesc, &Node->Name)); + + /* + * Not every value is an object allocated via AcpiCmCallocate, + * - must check + */ + + if (!AcpiTbSystemTablePointer (ObjDesc)) + { + /* Attempt to delete the object (and all subobjects) */ + + AcpiCmRemoveReference (ObjDesc); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedObject + * + * PARAMETERS: Handle - Parent Node to be examined + * + * RETURN: Current value of the object field from the Node whose + * handle is passed + * + ******************************************************************************/ + +void * +AcpiNsGetAttachedObject ( + ACPI_HANDLE Handle) +{ + FUNCTION_TRACE_PTR ("NsGetAttachedObject", Handle); + + + if (!Handle) + { + /* handle invalid */ + + REPORT_WARNING (("NsGetAttachedObject: Null handle\n")); + return_PTR (NULL); + } + + return_PTR (((ACPI_NAMESPACE_NODE *) Handle)->Object); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c new file mode 100644 index 0000000..e8e26af --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nssearch.c @@ -0,0 +1,505 @@ +/******************************************************************************* + * + * Module Name: nssearch - Namespace search + * $Revision: 58 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSSEARCH_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nssearch") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchNode + * + * PARAMETERS: *TargetName - Ascii ACPI name to search for + * *Node - Starting table where search will begin + * Type - Object type to match + * **ReturnNode - Where the matched Named obj is returned + * + * RETURN: Status + * + * DESCRIPTION: Search a single namespace table. Performs a simple search, + * does not add entries or search parents. + * + * + * Named object lists are built (and subsequently dumped) in the + * order in which the names are encountered during the namespace load; + * + * All namespace searching is linear in this implementation, but + * could be easily modified to support any improved search + * algorithm. However, the linear search was chosen for simplicity + * and because the trees are small and the other interpreter + * execution overhead is relatively high. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchNode ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_NAMESPACE_NODE *NextNode; + + + FUNCTION_TRACE ("NsSearchNode"); + + { + DEBUG_EXEC (NATIVE_CHAR *ScopeName = AcpiNsGetTablePathname (Node)); + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: Searching %s [%p]\n", + ScopeName, Node)); + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: For %4.4s (type 0x%X)\n", + &TargetName, Type)); + DEBUG_EXEC (AcpiCmFree (ScopeName)); + } + + + /* + * Search for name in this table, which is to say that we must search + * for the name among the children of this object + */ + + NextNode = Node->Child; + while (NextNode) + { + /* Check for match against the name */ + + if (NextNode->Name == TargetName) + { + /* + * Found matching entry. Capture type if + * appropriate before returning the entry. + */ + + /* + * The DefFieldDefn and BankFieldDefn cases + * are actually looking up the Region in which + * the field will be defined + */ + + if ((INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) + { + Type = ACPI_TYPE_REGION; + } + + /* + * Scope, DefAny, and IndexFieldDefn are bogus + * "types" which do not actually have anything + * to do with the type of the name being looked + * up. For any other value of Type, if the type + * stored in the entry is Any (i.e. unknown), + * save the actual type. + */ + + if (Type != INTERNAL_TYPE_SCOPE && + Type != INTERNAL_TYPE_DEF_ANY && + Type != INTERNAL_TYPE_INDEX_FIELD_DEFN && + NextNode->Type == ACPI_TYPE_ANY) + { + NextNode->Type = (UINT8) Type; + } + + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: Name %4.4s (actual type 0x%X) found at %p\n", + &TargetName, NextNode->Type, NextNode)); + + *ReturnNode = NextNode; + return_ACPI_STATUS (AE_OK); + } + + + /* + * The last entry in the list points back to the parent, + * so a flag is used to indicate the end-of-list + */ + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + /* Searched entire list, we are done */ + + break; + } + + /* Didn't match name, move on to the next peer object */ + + NextNode = NextNode->Peer; + } + + + /* Searched entire table, not found */ + + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: Name %4.4s (type 0x%X) not found at %p\n", + &TargetName, Type, NextNode)); + + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchParentTree + * + * PARAMETERS: *TargetName - Ascii ACPI name to search for + * *Node - Starting table where search will begin + * Type - Object type to match + * **ReturnNode - Where the matched Named Obj is returned + * + * RETURN: Status + * + * DESCRIPTION: Called when a name has not been found in the current namespace + * table. Before adding it or giving up, ACPI scope rules require + * 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) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE ("NsSearchParentTree"); + + + ParentNode = AcpiNsGetParentObject (Node); + + /* + * If there is no parent (at the root) or type is "local", we won't be + * searching the parent tree. + */ + if ((AcpiNsLocal (Type)) || + (!ParentNode)) + { + if (!ParentNode) + { + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchParentTree: [%4.4s] has no parent\n", + &TargetName)); + } + + if (AcpiNsLocal (Type)) + { + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchParentTree: [%4.4s] (type 0x%X) is local (no search)\n", + &TargetName, Type)); + } + + return_ACPI_STATUS (AE_NOT_FOUND); + } + + + /* Search the parent tree */ + + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchParentTree: Searching parent for %4.4s\n", + &TargetName)); + + /* + * Search parents until found the target or we have backed up to + * the root + */ + + while (ParentNode) + { + /* Search parent scope */ + /* TBD: [Investigate] Why ACPI_TYPE_ANY? */ + + Status = AcpiNsSearchNode (TargetName, ParentNode, + ACPI_TYPE_ANY, ReturnNode); + + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Not found here, go up another level + * (until we reach the root) + */ + + ParentNode = AcpiNsGetParentObject (ParentNode); + } + + + /* Not found in parent tree */ + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchAndEnter + * + * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) + * WalkState - Current state of the walk + * *Node - Starting table where search will begin + * InterpreterMode - Add names only in MODE_LoadPassX. + * Otherwise,search only. + * Type - Object type to match + * Flags - Flags describing the search restrictions + * **ReturnNode - Where the Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Search for a name segment in a single name table, + * optionally adding it if it is not found. If the passed + * Type is not Any and the type previously stored in the + * entry was Any (i.e. unknown), update the stored type. + * + * In IMODE_EXECUTE, search only. + * In other modes, search and add if not found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 TargetName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + OPERATING_MODE InterpreterMode, + OBJECT_TYPE_INTERNAL Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *NewNode; + + + FUNCTION_TRACE ("NsSearchAndEnter"); + + + /* Parameter validation */ + + if (!Node || !TargetName || !ReturnNode) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsSearchAndEnter: Null param: Table %p Name %p Return %p\n", + Node, TargetName, ReturnNode)); + + REPORT_ERROR (("NsSearchAndEnter: bad (null) parameter\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Name must consist of printable characters */ + + if (!AcpiCmValidAcpiName (TargetName)) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsSearchAndEnter: *** Bad character in name: %08lx *** \n", + TargetName)); + + REPORT_ERROR (("NsSearchAndEnter: Bad character in ACPI Name\n")); + return_ACPI_STATUS (AE_BAD_CHARACTER); + } + + + /* Try to find the name in the table specified by the caller */ + + *ReturnNode = ENTRY_NOT_FOUND; + Status = AcpiNsSearchNode (TargetName, Node, + Type, ReturnNode); + if (Status != AE_NOT_FOUND) + { + /* + * Either found it or there was an error + * -- finished either way + */ + return_ACPI_STATUS (Status); + } + + + /* + * Not found in the table. 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 != IMODE_LOAD_PASS1) && + (Flags & NS_SEARCH_PARENT)) + { + /* + * Not found in table - search parent tree according + * to ACPI specification + */ + + Status = AcpiNsSearchParentTree (TargetName, Node, + Type, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + /* + * In execute mode, just search, never add names. Exit now. + */ + if (InterpreterMode == IMODE_EXECUTE) + { + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchAndEnter: %4.4s Not found in %p [Not adding]\n", + &TargetName, Node)); + + return_ACPI_STATUS (AE_NOT_FOUND); + } + + + /* Create the new named object */ + + NewNode = AcpiNsCreateNode (TargetName); + if (!NewNode) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Install the new object into the parent's list of children */ + + AcpiNsInstallNode (WalkState, Node, NewNode, Type); + *ReturnNode = NewNode; + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c new file mode 100644 index 0000000..1a259b1 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsutils.c @@ -0,0 +1,1001 @@ +/****************************************************************************** + * + * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing + * parents and siblings and Scope manipulation + * $Revision: 71 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSUTILS_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" +#include "actables.h" + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsutils") + + +/**************************************************************************** + * + * FUNCTION: AcpiNsValidRootPrefix + * + * PARAMETERS: Prefix - Character to be checked + * + * RETURN: TRUE if a valid prefix + * + * DESCRIPTION: Check if a character is a valid ACPI Root prefix + * + ***************************************************************************/ + +BOOLEAN +AcpiNsValidRootPrefix ( + NATIVE_CHAR Prefix) +{ + + return ((BOOLEAN) (Prefix == '\\')); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsValidPathSeparator + * + * PARAMETERS: Sep - Character to be checked + * + * RETURN: TRUE if a valid path separator + * + * DESCRIPTION: Check if a character is a valid ACPI path separator + * + ***************************************************************************/ + +BOOLEAN +AcpiNsValidPathSeparator ( + NATIVE_CHAR Sep) +{ + + return ((BOOLEAN) (Sep == '.')); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsGetType + * + * PARAMETERS: Handle - Parent Node to be examined + * + * RETURN: Type field from Node whose handle is passed + * + ***************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiNsGetType ( + ACPI_HANDLE handle) +{ + FUNCTION_TRACE ("NsGetType"); + + + if (!handle) + { + REPORT_WARNING (("NsGetType: Null handle\n")); + return_VALUE (ACPI_TYPE_ANY); + } + + return_VALUE (((ACPI_NAMESPACE_NODE *) handle)->Type); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsLocal + * + * PARAMETERS: Type - A namespace object type + * + * RETURN: LOCAL if names must be found locally in objects of the + * passed type, 0 if enclosing scopes should be searched + * + ***************************************************************************/ + +UINT32 +AcpiNsLocal ( + OBJECT_TYPE_INTERNAL Type) +{ + FUNCTION_TRACE ("NsLocal"); + + + if (!AcpiCmValidObjectType (Type)) + { + /* Type code out of range */ + + REPORT_WARNING (("NsLocal: Invalid Object Type\n")); + return_VALUE (NSP_NORMAL); + } + + return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & NSP_LOCAL); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsInternalizeName + * + * PARAMETERS: *ExternalName - External representation of name + * **Converted Name - Where to return the resulting + * internal represention of the name + * + * RETURN: Status + * + * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") + * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsInternalizeName ( + NATIVE_CHAR *ExternalName, + NATIVE_CHAR **ConvertedName) +{ + NATIVE_CHAR *Result = NULL; + NATIVE_CHAR *InternalName; + UINT32 NumSegments; + BOOLEAN FullyQualified = FALSE; + UINT32 i; + + + FUNCTION_TRACE ("NsInternalizeName"); + + + if ((!ExternalName) || + (*ExternalName == 0) || + (!ConvertedName)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* + * 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 (ExternalName[0])) + { + FullyQualified = TRUE; + ExternalName++; + } + + + /* + * 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. + */ + + NumSegments = 1; + for (i = 0; ExternalName[i]; i++) + { + if (AcpiNsValidPathSeparator (ExternalName[i])) + { + NumSegments++; + } + } + + + /* We need a segment to store the internal version of the name */ + + InternalName = AcpiCmCallocate ((ACPI_NAME_SIZE * NumSegments) + 4); + if (!InternalName) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + /* Setup the correct prefixes, counts, and pointers */ + + if (FullyQualified) + { + InternalName[0] = '\\'; + InternalName[1] = AML_MULTI_NAME_PREFIX_OP; + InternalName[2] = (char) NumSegments; + Result = &InternalName[3]; + } + else + { + InternalName[0] = AML_MULTI_NAME_PREFIX_OP; + InternalName[1] = (char) NumSegments; + Result = &InternalName[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 INT8 to uppercase and save it */ + + Result[i] = (char) TOUPPER (*ExternalName); + ExternalName++; + } + + } + + /* Now we must have a path separator, or the pathname is bad */ + + if (!AcpiNsValidPathSeparator (*ExternalName) && + (*ExternalName != 0)) + { + AcpiCmFree (InternalName); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Move on the next segment */ + + ExternalName++; + Result += ACPI_NAME_SIZE; + } + + + /* Return the completed name */ + + /* Terminate the string! */ + *Result = 0; + *ConvertedName = InternalName; + + + if (FullyQualified) + { + DEBUG_PRINT (TRACE_EXEC, + ("NsInternalizeName: returning [%p] (abs) \"\\%s\"\n", + InternalName, &InternalName[3])); + } + else + { + DEBUG_PRINT (TRACE_EXEC, + ("NsInternalizeName: returning [%p] (rel) \"%s\"\n", + InternalName, &InternalName[2])); + } + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsExternalizeName + * + * PARAMETERS: *InternalName - Internal representation of name + * **ConvertedName - Where to return the resulting + * external representation of name + * + * RETURN: Status + * + * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * to its external form (e.g. "\_PR_.CPU0") + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName) +{ + UINT32 PrefixLength = 0; + UINT32 NamesIndex = 0; + UINT32 NamesCount = 0; + UINT32 i = 0; + UINT32 j = 0; + + + FUNCTION_TRACE ("NsExternalizeName"); + + + if (!InternalNameLength || + !InternalName || + !ConvertedNameLength || + !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; + } + } + + if (i == InternalNameLength) + { + PrefixLength = i; + } + + break; + } + + /* + * Check for object names. Note that there could be 0-255 of these + * 4-byte elements. + */ + if (PrefixLength < InternalNameLength) + { + switch (InternalName[PrefixLength]) + { + + /* 4-byte names */ + + case AML_MULTI_NAME_PREFIX_OP: + NamesIndex = PrefixLength + 2; + NamesCount = (UINT32) InternalName[PrefixLength + 1]; + break; + + + /* two 4-byte names */ + + case AML_DUAL_NAME_PREFIX: + NamesIndex = PrefixLength + 1; + NamesCount = 2; + break; + + + /* NullName */ + + case 0: + NamesIndex = 0; + NamesCount = 0; + break; + + + /* one 4-byte name */ + + default: + NamesIndex = PrefixLength; + NamesCount = 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. + */ + *ConvertedNameLength = PrefixLength + (4 * NamesCount) + + ((NamesCount > 0) ? (NamesCount - 1) : 0) + 1; + + /* + * Check to see if we're still in bounds. If not, there's a problem + * with InternalName (invalid format). + */ + if (*ConvertedNameLength > InternalNameLength) + { + REPORT_ERROR (("NsExternalizeName: Invalid internal name\n")); + return_ACPI_STATUS (AE_BAD_PATHNAME); + } + + /* + * Build ConvertedName... + */ + + (*ConvertedName) = AcpiCmCallocate (*ConvertedNameLength); + if (!(*ConvertedName)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + j = 0; + + for (i = 0; i < PrefixLength; i++) + { + (*ConvertedName)[j++] = InternalName[i]; + } + + if (NamesCount > 0) + { + for (i = 0; i < NamesCount; i++) + { + if (i > 0) + { + (*ConvertedName)[j++] = '.'; + } + + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsConvertHandleToEntry + * + * PARAMETERS: Handle - Handle to be converted to an Node + * + * RETURN: A Name table entry pointer + * + * DESCRIPTION: Convert a namespace handle to a real Node + * + ****************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsConvertHandleToEntry ( + ACPI_HANDLE Handle) +{ + + /* + * Simple implementation for now; + * TBD: [Future] Real integer handles allow for more verification + * and keep all pointers within this subsystem! + */ + + if (!Handle) + { + return (NULL); + } + + if (Handle == ACPI_ROOT_OBJECT) + { + return (AcpiGbl_RootNode); + } + + + /* We can at least attempt to verify the handle */ + + if (!VALID_DESCRIPTOR_TYPE (Handle, ACPI_DESC_TYPE_NAMED)) + { + return (NULL); + } + + return ((ACPI_NAMESPACE_NODE *) Handle); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsConvertEntryToHandle + * + * PARAMETERS: Node - Node to be converted to a Handle + * + * RETURN: An USER ACPI_HANDLE + * + * DESCRIPTION: Convert a real Node to a namespace handle + * + ****************************************************************************/ + +ACPI_HANDLE +AcpiNsConvertEntryToHandle ( + ACPI_NAMESPACE_NODE *Node) +{ + + + /* + * Simple implementation for now; + * TBD: [Future] Real integer handles allow for more verification + * and keep all pointers within this subsystem! + */ + + return ((ACPI_HANDLE) Node); + + +/* --------------------------------------------------- + + if (!Node) + { + return (NULL); + } + + if (Node == AcpiGbl_RootNode) + { + return (ACPI_ROOT_OBJECT); + } + + + return ((ACPI_HANDLE) Node); +------------------------------------------------------*/ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiNsTerminate (void) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *ThisNode; + + + FUNCTION_TRACE ("NsTerminate"); + + + ThisNode = AcpiGbl_RootNode; + + /* + * 1) Free the entire namespace -- all objects, tables, and stacks + */ + /* + * Delete all objects linked to the root + * (additional table descriptors) + */ + + AcpiNsDeleteNamespaceSubtree (ThisNode); + + /* Detach any object(s) attached to the root */ + + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + if (ObjDesc) + { + AcpiNsDetachObject (ThisNode); + AcpiCmRemoveReference (ObjDesc); + } + + AcpiNsDeleteChildren (ThisNode); + + DEBUG_PRINT (ACPI_INFO, ("NsTerminate: Namespace freed\n")); + + + /* + * 2) Now we can delete the ACPI tables + */ + + AcpiTbDeleteAcpiTables (); + + DEBUG_PRINT (ACPI_INFO, ("NsTerminate: ACPI Tables freed\n")); + + return_VOID; +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsOpensScope + * + * PARAMETERS: Type - A valid namespace type + * + * RETURN: NEWSCOPE if the passed type "opens a name scope" according + * to the ACPI specification, else 0 + * + ***************************************************************************/ + +UINT32 +AcpiNsOpensScope ( + OBJECT_TYPE_INTERNAL Type) +{ + FUNCTION_TRACE_U32 ("NsOpensScope", Type); + + + if (!AcpiCmValidObjectType (Type)) + { + /* type code out of range */ + + REPORT_WARNING (("NsOpensScope: Invalid Object Type\n")); + return_VALUE (NSP_NORMAL); + } + + return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & NSP_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. + * StartNode - Root of subtree to be searched, or NS_ALL for the + * root of the name space. If Name is fully + * qualified (first INT8 is '\'), the passed value + * of Scope will not be accessed. + * 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 ( + NATIVE_CHAR *Pathname, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_GENERIC_STATE ScopeInfo; + ACPI_STATUS Status; + NATIVE_CHAR *InternalPath = NULL; + + + FUNCTION_TRACE_PTR ("NsGetNte", Pathname); + + + ScopeInfo.Scope.Node = StartNode; + + /* Ensure that the namespace has been initialized */ + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + if (!Pathname) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Convert path to internal representation */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* NS_ALL means start from the root */ + + if (NS_ALL == ScopeInfo.Scope.Node) + { + ScopeInfo.Scope.Node = AcpiGbl_RootNode; + } + + else + { + ScopeInfo.Scope.Node = StartNode; + if (!ScopeInfo.Scope.Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* Lookup the name in the namespace */ + + Status = AcpiNsLookup (&ScopeInfo, InternalPath, + ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, ReturnNode); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_INFO, ("NsGetNte: %s, %s\n", + InternalPath, AcpiCmFormatException (Status))); + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Cleanup */ + + AcpiCmFree (InternalPath); + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsFindParentName + * + * PARAMETERS: *ChildNode - Named Obj whose name is to be found + * + * RETURN: The ACPI name + * + * DESCRIPTION: Search for the given obj in its parent scope and return the + * name segment, or "????" if the parent name can't be found + * (which "should not happen"). + * + ***************************************************************************/ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE ("FindParentName"); + + + if (ChildNode) + { + /* Valid entry. Get the parent Node */ + + ParentNode = AcpiNsGetParentObject (ChildNode); + if (ParentNode) + { + DEBUG_PRINT (TRACE_EXEC, + ("Parent of %p [%4.4s] is %p [%4.4s]\n", + ChildNode, &ChildNode->Name, ParentNode, + &ParentNode->Name)); + + if (ParentNode->Name) + { + return_VALUE (ParentNode->Name); + } + } + + DEBUG_PRINT (TRACE_EXEC, + ("FindParentName: unable to find parent of %p (%4.4s)\n", + ChildNode, &ChildNode->Name)); + } + + + return_VALUE (ACPI_UNKNOWN_NAME); +} + + +#ifdef ACPI_DEBUG + +/**************************************************************************** + * + * FUNCTION: AcpiNsExistDownstreamSibling + * + * PARAMETERS: *Node - pointer to first Node to examine + * + * RETURN: TRUE if sibling is found, FALSE otherwise + * + * DESCRIPTION: Searches remainder of scope being processed to determine + * whether there is a downstream sibling to the current + * object. This function is used to determine what type of + * line drawing character to use when displaying namespace + * trees. + * + ***************************************************************************/ + +BOOLEAN +AcpiNsExistDownstreamSibling ( + ACPI_NAMESPACE_NODE *Node) +{ + + if (!Node) + { + return (FALSE); + } + + if (Node->Name) + { + return (TRUE); + } + + return (FALSE); +} + +#endif /* ACPI_DEBUG */ + + +/**************************************************************************** + * + * FUNCTION: AcpiNsGetParentObject + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Parent entry of the given entry + * + * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. + * + ***************************************************************************/ + + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentObject ( + ACPI_NAMESPACE_NODE *Node) +{ + + + /* + * Walk to the end of this peer list. + * The last entry is marked with a flag and the peer + * pointer is really a pointer back to the parent. + * This saves putting a parent back pointer in each and + * every named object! + */ + + while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) + { + Node = Node->Peer; + } + + + return (Node->Peer); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsGetNextValidObject + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Next valid object in the table. NULL if no more valid + * objects + * + * DESCRIPTION: Find the next valid object within a name table. + * Useful for implementing NULL-end-of-list loops. + * + ***************************************************************************/ + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidObject ( + ACPI_NAMESPACE_NODE *Node) +{ + + /* If we are at the end of this peer list, return NULL */ + + if (Node->Flags & ANOBJ_END_OF_PEER_LIST) + { + return NULL; + } + + /* Otherwise just return the next peer */ + + return (Node->Peer); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c new file mode 100644 index 0000000..9b37c32 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nswalk.c @@ -0,0 +1,384 @@ +/****************************************************************************** + * + * Module Name: nswalk - Functions for walking the APCI namespace + * $Revision: 17 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSWALK_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nswalk") + + +/**************************************************************************** + * + * 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 + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * 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_NAMESPACE_NODE * +AcpiNsGetNextObject ( + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *NextNode = NULL; + + + if (!ChildNode) + { + + /* It's really the parent's _scope_ that we want */ + + if (ParentNode->Child) + { + NextNode = ParentNode->Child; + } + } + + else + { + /* Start search at the NEXT object */ + + NextNode = AcpiNsGetNextValidObject (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 object -- 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 object */ + + NextNode = AcpiNsGetNextValidObject (NextNode); + } + + + /* Not found */ + + return (NULL); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartNode - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * UnlockBeforeCallback- Whether to unlock the NS before invoking + * the callback routine + * UserFunction - Called when an object of "Type" is found + * Context - Passed to user function + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object that matches + * the type parameter is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the User Function can be tailored + * to each task, whether it is a print function, a compare + * function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsWalkNamespace ( + OBJECT_TYPE_INTERNAL Type, + ACPI_HANDLE StartNode, + UINT32 MaxDepth, + BOOLEAN UnlockBeforeCallback, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *ParentNode; + OBJECT_TYPE_INTERNAL ChildType; + UINT32 Level; + + + FUNCTION_TRACE ("NsWalkNamespace"); + + /* Special case for the namespace Root Node */ + + if (StartNode == ACPI_ROOT_OBJECT) + { + StartNode = AcpiGbl_RootNode; + } + + + /* Null child means "get first object" */ + + ParentNode = StartNode; + ChildNode = 0; + ChildType = ACPI_TYPE_ANY; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up to where we + * started. When Level is zero, the loop is done because we have + * bubbled up to (and passed) the original parent handle (StartEntry) + */ + + while (Level > 0) + { + /* + * Get the next typed object in this scope. Null returned + * if not found + */ + + Status = AE_OK; + ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, + ParentNode, + ChildNode); + + if (ChildNode) + { + /* + * Found an object, Get the type if we are not + * searching for ANY + */ + + if (Type != ACPI_TYPE_ANY) + { + ChildType = ChildNode->Type; + } + + if (ChildType == Type) + { + /* + * Found a matching object, invoke the user + * callback function + */ + + if (UnlockBeforeCallback) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + Status = UserFunction (ChildNode, Level, + Context, ReturnValue); + + if (UnlockBeforeCallback) + { + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + } + + 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); + break; + + default: + /* All others are valid exceptions */ + return_ACPI_STATUS (Status); + break; + } + } + + /* + * Depth first search: + * Attempt to go down another level in the namespace + * if we are allowed to. Don't go any further if we + * have reached the caller specified maximum depth + * or if the user function has specified that the + * maximum depth has been reached. + */ + + if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) + { + if (AcpiNsGetNextObject (ACPI_TYPE_ANY, + ChildNode, 0)) + { + /* + * There is at least one child of this + * object, visit the object + */ + Level++; + ParentNode = ChildNode; + ChildNode = 0; + } + } + } + + else + { + /* + * No more children in this object (AcpiNsGetNextObject + * failed), go back upwards in the namespace tree to + * the object's parent. + */ + Level--; + ChildNode = ParentNode; + ParentNode = AcpiNsGetParentObject (ParentNode); + } + } + + /* Complete walk, not terminated by user function */ + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c new file mode 100644 index 0000000..7133b9f --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfname.c @@ -0,0 +1,410 @@ +/****************************************************************************** + * + * Module Name: nsxfname - Public interfaces to the ACPI subsystem + * ACPI Namespace oriented interfaces + * $Revision: 71 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSXFNAME_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acevents.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsxfname") + + +/**************************************************************************** + * + * FUNCTION: AcpiGetHandle + * + * PARAMETERS: Parent - Object to search under (search scope). + * PathName - Pointer to an asciiz string containing the + * name + * RetHandle - Where the return handle is placed + * + * RETURN: Status + * + * DESCRIPTION: This routine will search for a caller specified name in the + * name space. The caller can restrict the search region by + * specifying a non NULL parent. The parent value is itself a + * namespace handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *PrefixNode = NULL; + + + if (!RetHandle || !Pathname) + { + return (AE_BAD_PARAMETER); + } + + if (Parent) + { + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (Parent); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + PrefixNode = Node->Child; + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + /* Special case for root, since we can't search for it */ + /* TBD: [Investigate] Check for both forward and backslash?? */ + + if (STRCMP (Pathname, NS_ROOT_PATH) == 0) + { + *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode); + return (AE_OK); + } + + /* + * Find the Node and convert to the user format + */ + Node = NULL; + Status = AcpiNsGetNode (Pathname, PrefixNode, &Node); + + *RetHandle = NULL; + if(ACPI_SUCCESS(Status)) + { + *RetHandle = AcpiNsConvertEntryToHandle (Node); + } + + return (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiGetPathname + * + * PARAMETERS: Handle - Handle to be converted to a pathname + * NameType - Full pathname or single segment + * RetPathPtr - 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 *RetPathPtr) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + /* Buffer pointer must be valid always */ + + if (!RetPathPtr || (NameType > ACPI_NAME_TYPE_MAX)) + { + return (AE_BAD_PARAMETER); + } + + /* Allow length to be zero and ignore the pointer */ + + if ((RetPathPtr->Length) && + (!RetPathPtr->Pointer)) + { + return (AE_BAD_PARAMETER); + } + + if (NameType == ACPI_FULL_PATHNAME) + { + /* Get the full pathname (From the namespace root) */ + + Status = AcpiNsHandleToPathname (Handle, &RetPathPtr->Length, + RetPathPtr->Pointer); + return (Status); + } + + /* + * Wants the single segment ACPI name. + * Validate handle and convert to an Node + */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Check if name will fit in buffer */ + + if (RetPathPtr->Length < PATH_SEGMENT_LENGTH) + { + RetPathPtr->Length = PATH_SEGMENT_LENGTH; + Status = AE_BUFFER_OVERFLOW; + goto UnlockAndExit; + } + + /* Just copy the ACPI name from the Node and zero terminate it */ + + STRNCPY (RetPathPtr->Pointer, (NATIVE_CHAR *) &Node->Name, + ACPI_NAME_SIZE); + ((NATIVE_CHAR *) RetPathPtr->Pointer) [ACPI_NAME_SIZE] = 0; + Status = AE_OK; + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiGetObjectInfo + * + * PARAMETERS: Handle - Object Handle + * Info - Where the info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns information about an object as gleaned from the + * namespace node and possibly by running several standard + * control methods (Such as in the case of a device.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO *Info) +{ + DEVICE_ID Hid; + DEVICE_ID Uid; + ACPI_STATUS Status; + UINT32 DeviceStatus = 0; + ACPI_INTEGER Address = 0; + ACPI_NAMESPACE_NODE *Node; + + + /* Parameter validation */ + + if (!Handle || !Info) + { + return (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + Info->Type = Node->Type; + Info->Name = Node->Name; + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * If not a device, we are all done. + */ + if (Info->Type != ACPI_TYPE_DEVICE) + { + return (AE_OK); + } + + + /* + * Get extra info for ACPI devices only. Run the + * _HID, _UID, _STA, and _ADR methods. Note: none + * of these methods are required, so they may or may + * not be present. The Info->Valid bits are used + * to indicate which methods ran successfully. + */ + + Info->Valid = 0; + + /* Execute the _HID method and save the result */ + + Status = AcpiCmExecute_HID (Node, &Hid); + if (ACPI_SUCCESS (Status)) + { + STRNCPY (Info->HardwareId, Hid.Buffer, sizeof(Info->HardwareId)); + + Info->Valid |= ACPI_VALID_HID; + } + + /* Execute the _UID method and save the result */ + + Status = AcpiCmExecute_UID (Node, &Uid); + if (ACPI_SUCCESS (Status)) + { + STRCPY (Info->UniqueId, Uid.Buffer); + + Info->Valid |= ACPI_VALID_UID; + } + + /* + * Execute the _STA method and save the result + * _STA is not always present + */ + + Status = AcpiCmExecute_STA (Node, &DeviceStatus); + if (ACPI_SUCCESS (Status)) + { + Info->CurrentStatus = DeviceStatus; + Info->Valid |= ACPI_VALID_STA; + } + + /* + * Execute the _ADR method and save result if successful + * _ADR is not always present + */ + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__ADR, + Node, &Address); + + if (ACPI_SUCCESS (Status)) + { + Info->Address = Address; + Info->Valid |= ACPI_VALID_ADR; + } + + return (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c new file mode 100644 index 0000000..8092758 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Namespace/nsxfobj.c @@ -0,0 +1,853 @@ +/******************************************************************************* + * + * Module Name: nsxfobj - Public interfaces to the ACPI subsystem + * ACPI Object oriented interfaces + * $Revision: 74 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFOBJ_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsxfobj") + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObject + * + * PARAMETERS: Handle - Object handle (optional) + * *Pathname - Object pathname (optional) + * **Params - List of parameters to pass to + * method, terminated by NULL. + * Params itself may be NULL + * if no parameters are being + * passed. + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Find and 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 *ParamObjects, + ACPI_BUFFER *ReturnBuffer) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **ParamPtr = NULL; + ACPI_OPERAND_OBJECT *ReturnObj = NULL; + ACPI_OPERAND_OBJECT *ObjectPtr = NULL; + UINT32 BufferSpaceNeeded; + UINT32 UserBufferLength; + UINT32 Count; + UINT32 i; + UINT32 ParamLength; + UINT32 ObjectLength; + + + FUNCTION_TRACE ("AcpiEvaluateObject"); + + + /* + * If there are parameters to be passed to the object + * (which must be a control method), the external objects + * must be converted to internal objects + */ + + if (ParamObjects && ParamObjects->Count) + { + /* + * Allocate a new parameter block for the internal objects + * Add 1 to count to allow for null terminated internal list + */ + + Count = ParamObjects->Count; + ParamLength = (Count + 1) * sizeof (void *); + ObjectLength = Count * sizeof (ACPI_OPERAND_OBJECT); + + ParamPtr = AcpiCmCallocate (ParamLength + /* Parameter List part */ + ObjectLength); /* Actual objects */ + if (!ParamPtr) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjectPtr = (ACPI_OPERAND_OBJECT *) ((UINT8 *) ParamPtr + + ParamLength); + + /* + * Init the param array of pointers and NULL terminate + * the list + */ + + for (i = 0; i < Count; i++) + { + ParamPtr[i] = &ObjectPtr[i]; + AcpiCmInitStaticObject (&ObjectPtr[i]); + } + ParamPtr[Count] = NULL; + + /* + * Convert each external object in the list to an + * internal object + */ + for (i = 0; i < Count; i++) + { + Status = + AcpiCmBuildInternalObject (&ParamObjects->Pointer[i], + ParamPtr[i]); + + if (ACPI_FAILURE (Status)) + { + AcpiCmDeleteInternalObjectList (ParamPtr); + return_ACPI_STATUS (Status); + } + } + } + + + /* + * Three major cases: + * 1) Fully qualified pathname + * 2) No handle, not fully qualified pathname (error) + * 3) Valid handle + */ + + if ((Pathname) && + (AcpiNsValidRootPrefix (Pathname[0]))) + { + /* + * The path is fully qualified, just evaluate by name + */ + Status = AcpiNsEvaluateByName (Pathname, ParamPtr, &ReturnObj); + } + + 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) + { + DEBUG_PRINT (ACPI_ERROR, + ("AcpiEvaluateObject: Both Handle and Pathname are NULL\n")); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AcpiEvaluateObject: Handle is NULL and Pathname is relative\n")); + } + + Status = AE_BAD_PARAMETER; + } + + else + { + /* + * We get here if we have a handle -- and if we have a + * pathname it is relative. The handle will be validated + * in the lower procedures + */ + + if (!Pathname) + { + /* + * The null pathname case means the handle is for + * the actual object to be evaluated + */ + Status = AcpiNsEvaluateByHandle (Handle, ParamPtr, &ReturnObj); + } + + else + { + /* + * Both a Handle and a relative Pathname + */ + Status = AcpiNsEvaluateRelative (Handle, Pathname, ParamPtr, + &ReturnObj); + } + } + + + /* + * If we are expecting a return value, and all went well above, + * copy the return value to an external object. + */ + + if (ReturnBuffer) + { + UserBufferLength = ReturnBuffer->Length; + ReturnBuffer->Length = 0; + + if (ReturnObj) + { + if (VALID_DESCRIPTOR_TYPE (ReturnObj, ACPI_DESC_TYPE_NAMED)) + { + /* + * If we got an Node as a return object, + * this means 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; + ReturnObj = NULL; /* No need to delete an Node */ + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Find out how large a buffer is needed + * to contain the returned object + */ + Status = AcpiCmGetObjectSize (ReturnObj, + &BufferSpaceNeeded); + if (ACPI_SUCCESS (Status)) + { + /* + * Check if there is enough room in the + * caller's buffer + */ + + if (UserBufferLength < BufferSpaceNeeded) + { + /* + * Caller's buffer is too small, can't + * give him partial results fail the call + * but return the buffer size needed + */ + + DEBUG_PRINT (ACPI_INFO, + ("AcpiEvaluateObject: Needed buffer size %d, received %d\n", + BufferSpaceNeeded, UserBufferLength)); + + ReturnBuffer->Length = BufferSpaceNeeded; + Status = AE_BUFFER_OVERFLOW; + } + + else + { + /* + * We have enough space for the object, build it + */ + Status = AcpiCmBuildExternalObject (ReturnObj, + ReturnBuffer); + ReturnBuffer->Length = BufferSpaceNeeded; + } + } + } + } + } + + + /* Delete the return and parameter objects */ + + if (ReturnObj) + { + /* + * Delete the internal return object. (Or at least + * decrement the reference count by one) + */ + AcpiCmRemoveReference (ReturnObj); + } + + /* + * Free the input parameter list (if we created one), + */ + + if (ParamPtr) + { + /* Free the allocated parameter block */ + + AcpiCmDeleteInternalObjectList (ParamPtr); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetNextObject + * + * PARAMETERS: Type - Type of object to be searched for + * Parent - Parent object whose children we are getting + * LastChild - Previous child that was found. + * The NEXT child will be returned + * RetHandle - Where handle to the next object is placed + * + * RETURN: Status + * + * DESCRIPTION: Return the next peer object within the namespace. If Handle is + * valid, Scope is ignored. Otherwise, the first object within + * Scope is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status = AE_OK; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode = NULL; + ACPI_NAMESPACE_NODE *ChildNode = NULL; + + + /* Parameter validation */ + + if (Type > ACPI_TYPE_MAX) + { + return (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* If null handle, use the parent */ + + if (!Child) + { + /* Start search at the beginning of the specified scope */ + + ParentNode = AcpiNsConvertHandleToEntry (Parent); + if (!ParentNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* Non-null handle, ignore the parent */ + + else + { + /* Convert and validate the handle */ + + ChildNode = AcpiNsConvertHandleToEntry (Child); + if (!ChildNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + + /* Internal function does the real work */ + + Node = AcpiNsGetNextObject ((OBJECT_TYPE_INTERNAL) Type, + ParentNode, ChildNode); + if (!Node) + { + Status = AE_NOT_FOUND; + goto UnlockAndExit; + } + + if (RetHandle) + { + *RetHandle = AcpiNsConvertEntryToHandle (Node); + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + + +/******************************************************************************* + * + * 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; + + + /* 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); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the handle */ + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + *RetType = Node->Type; + + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetParent + * + * PARAMETERS: Handle - Handle of object whose parent is desired + * RetHandle - Where the parent handle will be placed + * + * RETURN: Status + * + * DESCRIPTION: Returns a handle to the parent of the object represented by + * Handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Handle, + ACPI_HANDLE *RetHandle) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status = AE_OK; + + + /* No trace macro, too verbose */ + + + if (!RetHandle) + { + return (AE_BAD_PARAMETER); + } + + /* Special case for the predefined Root Node (no parent) */ + + if (Handle == ACPI_ROOT_OBJECT) + { + return (AE_NULL_ENTRY); + } + + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the handle */ + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* Get the parent entry */ + + *RetHandle = + AcpiNsConvertEntryToHandle (AcpiNsGetParentObject (Node)); + + /* Return exeption if parent is null */ + + if (!AcpiNsGetParentObject (Node)) + { + Status = AE_NULL_ENTRY; + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartObject - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * UserFunction - Called when an object of "Type" is found + * Context - Passed to user function + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object that matches + * the type parameter is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the User Function can be tailored + * to each task, whether it is a print function, a compare + * function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiWalkNamespace"); + + + /* Parameter validation */ + + if ((Type > ACPI_TYPE_MAX) || + (!MaxDepth) || + (!UserFunction)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Lock the namespace around the walk. + * The namespace will be unlocked/locked around each call + * to the user function - since this function + * must be allowed to make Acpi calls itself. + */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiNsWalkNamespace ((OBJECT_TYPE_INTERNAL) Type, + StartObject, MaxDepth, + NS_WALK_UNLOCK, + UserFunction, Context, + ReturnValue); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetDeviceCallback + * + * PARAMETERS: Callback from AcpiGetDevice + * + * RETURN: Status + * + * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- + * present devices, or if they specified a HID, it filters based + * on that. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsGetDeviceCallback ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + UINT32 Flags; + DEVICE_ID DeviceId; + ACPI_GET_DEVICES_INFO *Info; + + + Info = Context; + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (ObjHandle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * Run _STA to determine if device is present + */ + + Status = AcpiCmExecute_STA (Node, &Flags); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!(Flags & 0x01)) + { + /* don't return at the device or children of the device if not there */ + + return (AE_CTRL_DEPTH); + } + + /* + * Filter based on device HID + */ + if (Info->Hid != NULL) + { + Status = AcpiCmExecute_HID (Node, &DeviceId); + + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + + else if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (STRNCMP (DeviceId.Buffer, Info->Hid, sizeof (DeviceId.Buffer)) != 0) + { + return (AE_OK); + } + } + + Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetDevices + * + * PARAMETERS: HID - HID to search for. Can be NULL. + * UserFunction - Called when a matching object is found + * Context - Passed to user function + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object that matches + * the type parameter is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * This is a wrapper for WalkNamespace, but the callback performs + * additional filtering. Please see AcpiGetDeviceCallback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetDevices ( + NATIVE_CHAR *HID, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_GET_DEVICES_INFO Info; + + + FUNCTION_TRACE ("AcpiGetDevices"); + + + /* Parameter validation */ + + if (!UserFunction) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * We're going to call their callback from OUR callback, so we need + * to know what it is, and their context parameter. + */ + Info.Context = Context; + Info.UserFunction = UserFunction; + Info.Hid = HID; + + /* + * Lock the namespace around the walk. + * The namespace will be unlocked/locked around each call + * to the user function - since this function + * must be allowed to make Acpi calls itself. + */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, + ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + NS_WALK_UNLOCK, + AcpiNsGetDeviceCallback, &Info, + ReturnValue); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + return_ACPI_STATUS (Status); +} \ No newline at end of file diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psargs.c b/sys/contrib/dev/acpica/Subsystem/Parser/psargs.c new file mode 100644 index 0000000..6b203ff --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psargs.c @@ -0,0 +1,950 @@ +/****************************************************************************** + * + * Module Name: psargs - Parse AML opcode arguments + * $Revision: 35 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSARGS_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psargs") + + +UINT32 +AcpiPsPkgLengthEncodingSize ( + UINT32 FirstByte) +{ + + /* + * Bits 6-7 contain the number of bytes + * in the encoded package length (-1) + */ + + return ((FirstByte >> 6) + 1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageLength + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Decoded package length. On completion, the AML pointer points + * past the length byte or bytes. + * + * DESCRIPTION: Decode and return a package length field + * + ******************************************************************************/ + +UINT32 +xxxAcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 EncodingLength; + UINT32 PackageLength = 0; + UINT8 *AmlPtr = ParserState->Aml; + + + FUNCTION_TRACE ("PsGetNextPackageLength"); + + + EncodingLength = AcpiPsPkgLengthEncodingSize ((UINT32) GET8 (AmlPtr)); + + + switch (EncodingLength) + { + case 1: /* 1-byte encoding (bits 0-5) */ + + PackageLength = ((UINT32) GET8 (AmlPtr) & 0x3f); + break; + + + case 2: /* 2-byte encoding (next byte + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + + + case 3: /* 3-byte encoding (next 2 bytes + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 2)) << 12) | + (((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + + + case 4: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 3)) << 20) | + (((UINT32) GET8 (AmlPtr + 2)) << 12) | + (((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + } + + ParserState->Aml += EncodingLength; + + return_VALUE (PackageLength); +} + +UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 EncodedLength; + UINT32 Length = 0; + + + FUNCTION_TRACE ("PsGetNextPackageLength"); + + + EncodedLength = (UINT32) GET8 (ParserState->Aml); + ParserState->Aml++; + + + switch (EncodedLength >> 6) /* bits 6-7 contain encoding scheme */ + { + case 0: /* 1-byte encoding (bits 0-5) */ + + Length = (EncodedLength & 0x3f); + break; + + + case 1: /* 2-byte encoding (next byte + bits 0-3) */ + + Length = (GET8 (ParserState->Aml) << 4) | (EncodedLength & 0xf); + ParserState->Aml++; + break; + + + case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ + + Length = ( (GET8 (ParserState->Aml + 1) << 12) + | (GET8 (ParserState->Aml) << 4) + | (EncodedLength & 0xf)); + ParserState->Aml += 2; + break; + + + case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + + Length = ( (GET8 (ParserState->Aml + 2) << 20) + | (GET8 (ParserState->Aml + 1) << 12) + | (GET8 (ParserState->Aml) << 4) + | (EncodedLength & 0xf)); + ParserState->Aml += 3; + break; + } + + return_VALUE (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageEnd + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to end-of-package +1 + * + * DESCRIPTION: Get next package length and return a pointer past the end of + * the package. Consumes the package length field + * + ******************************************************************************/ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + NATIVE_UINT Length; + + + FUNCTION_TRACE ("PsGetNextPackageEnd"); + + + Length = (NATIVE_UINT) AcpiPsGetNextPackageLength (ParserState); + + return_PTR (Start + Length); /* end of package */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamestring + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to the start of the name string (pointer points into + * the AML. + * + * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name + * prefix characters. Set parser state to point past the string. + * (Name is consumed from the AML.) + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT8 *End = ParserState->Aml; + UINT32 Length; + + + FUNCTION_TRACE ("PsGetNextNamestring"); + + + /* Handle multiple prefix characters */ + + while (AcpiPsIsPrefixChar (GET8 (End))) + { + /* include prefix '\\' or '^' */ + + End++; + } + + /* Decode the path */ + + switch (GET8 (End)) + { + case 0: + + /* NullName */ + + if (End == Start) + { + Start = NULL; + } + End++; + break; + + + case AML_DUAL_NAME_PREFIX: + + /* two name segments */ + + End += 9; + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + /* multiple name segments */ + + Length = (UINT32) GET8 (End + 1) * 4; + End += 2 + Length; + break; + + + default: + + /* single name segment */ + /* assert (AcpiPsIsLead (GET8 (End))); */ + + End += 4; + break; + } + + ParserState->Aml = (UINT8*) End; + + return_PTR ((NATIVE_CHAR *) Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamepath + * + * PARAMETERS: ParserState - Current parser state object + * Arg - Where the namepath will be stored + * ArgCount - If the namepath points to a control method + * the method's argument is returned here. + * MethodCall - Whether the namepath can be the start + * of a method call + * + * RETURN: None + * + * DESCRIPTION: Get next name (if method call, push appropriate # args). Names + * are looked up in either the parsed or 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. + * + ******************************************************************************/ + + +#ifdef PARSER_ONLY + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall) +{ + NATIVE_CHAR *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Count; + + + FUNCTION_TRACE ("PsGetNextNamepath"); + + + Path = AcpiPsGetNextNamestring (ParserState); + if (!Path || !MethodCall) + { + /* Null name case, create a null namepath object */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + return_VOID; + } + + + if (AcpiGbl_ParsedNamespaceRoot) + { + /* + * Lookup the name in the parsed namespace + */ + + Op = NULL; + if (MethodCall) + { + Op = AcpiPsFind (AcpiPsGetParentScope (ParserState), + Path, AML_METHOD_OP, 0); + } + + if (Op) + { + if (Op->Opcode == AML_METHOD_OP) + { + /* + * The name refers to a control method, so this namepath is a + * method invocation. We need to 1) Get the number of arguments + * associated with this method, and 2) Change the NAMEPATH + * object into a METHODCALL object. + */ + + Count = AcpiPsGetArg (Op, 0); + if (Count && Count->Opcode == AML_BYTE_OP) + { + NameOp = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (NameOp) + { + /* Change arg into a METHOD CALL and attach the name */ + + AcpiPsInitOp (Arg, AML_METHODCALL_OP); + + NameOp->Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Node = (ACPI_NAMESPACE_NODE *) Op; + AcpiPsAppendArg (Arg, NameOp); + + *ArgCount = Count->Value.Integer & + METHOD_FLAGS_ARG_COUNT; + } + } + + return_VOID; + } + + /* + * Else this is normal named object reference. + * Just init the NAMEPATH object with the pathname. + * (See code below) + */ + } + } + + + /* + * Either we didn't find the object in the namespace, or the object is + * something other than a control method. Just initialize the Op with the + * pathname + */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + + + return_VOID; +} + + +#else + + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall) +{ + NATIVE_CHAR *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE ScopeInfo; + + + FUNCTION_TRACE ("PsGetNextNamepath"); + + + Path = AcpiPsGetNextNamestring (ParserState); + if (!Path || !MethodCall) + { + /* Null name case, create a null namepath object */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + return_VOID; + } + + + if (MethodCall) + { + /* + * Lookup the name in the internal namespace + */ + ScopeInfo.Scope.Node = NULL; + Node = ParserState->StartNode; + if (Node) + { + ScopeInfo.Scope.Node = Node; + } + + /* + * Lookup object. We don't want to add anything new to the namespace + * here, however. So we use MODE_EXECUTE. Allow searching of the + * parent tree, but don't open a new scope -- we just want to lookup the + * object (MUST BE mode EXECUTE to perform upsearch) + */ + + Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, + &Node); + if (ACPI_SUCCESS (Status)) + { + if (Node->Type == ACPI_TYPE_METHOD) + { + MethodNode = Node; + DEBUG_PRINT (TRACE_PARSE, + ("PsGetNextNamepath: method - %p Path=%p\n", + MethodNode, Path)); + + NameOp = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (NameOp) + { + /* Change arg into a METHOD CALL and attach name to it */ + + AcpiPsInitOp (Arg, AML_METHODCALL_OP); + + NameOp->Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Node = MethodNode; + AcpiPsAppendArg (Arg, NameOp); + + *ArgCount = ((ACPI_OPERAND_OBJECT *) MethodNode->Object)->Method.ParamCount; + } + + return_VOID; + } + + /* + * Else this is normal named object reference. + * Just init the NAMEPATH object with the pathname. + * (See code below) + */ + } + } + + /* + * Either we didn't find the object in the namespace, or the object is + * something other than a control method. Just initialize the Op with the + * pathname + */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + + + return_VOID; +} + +#endif + +/******************************************************************************* + * + * 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) +{ + + + FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); + + + switch (ArgType) + { + + case ARGP_BYTEDATA: + + AcpiPsInitOp (Arg, AML_BYTE_OP); + Arg->Value.Integer = (UINT32) GET8 (ParserState->Aml); + ParserState->Aml++; + break; + + + case ARGP_WORDDATA: + + AcpiPsInitOp (Arg, AML_WORD_OP); + + /* Get 2 bytes from the AML stream */ + + MOVE_UNALIGNED16_TO_32 (&Arg->Value.Integer, ParserState->Aml); + ParserState->Aml += 2; + break; + + + case ARGP_DWORDDATA: + + AcpiPsInitOp (Arg, AML_DWORD_OP); + + /* Get 4 bytes from the AML stream */ + + MOVE_UNALIGNED32_TO_32 (&Arg->Value.Integer, ParserState->Aml); + ParserState->Aml += 4; + break; + + + case ARGP_CHARLIST: + + AcpiPsInitOp (Arg, AML_STRING_OP); + Arg->Value.String = (char*) ParserState->Aml; + + while (GET8 (ParserState->Aml) != '\0') + { + ParserState->Aml++; + } + ParserState->Aml++; + break; + + + case ARGP_NAME: + case ARGP_NAMESTRING: + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = AcpiPsGetNextNamestring (ParserState); + break; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextField + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: A newly allocated FIELD op + * + * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_PTRDIFF AmlOffset = ParserState->Aml - + ParserState->AmlStart; + ACPI_PARSE_OBJECT *Field; + UINT16 Opcode; + UINT32 Name; + + + FUNCTION_TRACE ("PsGetNextField"); + + + /* determine field type */ + + switch (GET8 (ParserState->Aml)) + { + + default: + + Opcode = AML_NAMEDFIELD_OP; + break; + + + case 0x00: + + Opcode = AML_RESERVEDFIELD_OP; + ParserState->Aml++; + break; + + + case 0x01: + + Opcode = AML_ACCESSFIELD_OP; + ParserState->Aml++; + break; + } + + + /* Allocate a new field op */ + + Field = AcpiPsAllocOp (Opcode); + if (Field) + { + Field->AmlOffset = AmlOffset; + + /* Decode the field type */ + + switch (Opcode) + { + case AML_NAMEDFIELD_OP: + + /* Get the 4-character name */ + + MOVE_UNALIGNED32_TO_32 (&Name, ParserState->Aml); + AcpiPsSetName (Field, Name); + ParserState->Aml += 4; + + /* Get the length which is encoded as a package length */ + + Field->Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_RESERVEDFIELD_OP: + + /* Get the length which is encoded as a package length */ + + Field->Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_ACCESSFIELD_OP: + + /* Get AccessType and AccessAtrib and merge into the field Op */ + + Field->Value.Integer = ((GET8 (ParserState->Aml) << 8) | + GET8 (ParserState->Aml)); + ParserState->Aml += 2; + break; + } + } + + return_PTR (Field); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextArg + * + * PARAMETERS: ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * ArgCount - If the argument points to a control method + * the method's argument is returned here. + * + * RETURN: An op object containing the next argument. + * + * DESCRIPTION: Get next argument (including complex list arguments that require + * pushing the parser stack) + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetNextArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + UINT32 *ArgCount) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE_OBJECT *Prev = NULL; + ACPI_PARSE_OBJECT *Field; + UINT32 Subop; + + + 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) + { + 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) + { + break; + } + + if (Prev) + { + Prev->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_BYTELIST_OP); + if (Arg) + { + /* fill in bytelist data */ + + Arg->Value.Size = (ParserState->PkgEnd - ParserState->Aml); + ((ACPI_PARSE2_OBJECT *) Arg)->Data = ParserState->Aml; + } + + /* skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_TARGET: + case ARGP_SUPERNAME: + { + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + AcpiPsIsPrefixChar (Subop)) + { + /* NullName or NameString */ + + Arg = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (Arg) + { + AcpiPsGetNextNamepath (ParserState, Arg, ArgCount, 0); + } + } + + else + { + /* single complex argument, nothing returned */ + + *ArgCount = 1; + } + } + break; + + + case ARGP_DATAOBJ: + case ARGP_TERMARG: + + /* single complex argument, nothing returned */ + + *ArgCount = 1; + break; + + + case ARGP_DATAOBJLIST: + case ARGP_TERMLIST: + case ARGP_OBJLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* non-empty list of variable arguments, nothing returned */ + + *ArgCount = ACPI_VAR_ARGS; + } + break; + } + + return_PTR (Arg); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psfind.c b/sys/contrib/dev/acpica/Subsystem/Parser/psfind.c new file mode 100644 index 0000000..a0a9236 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psfind.c @@ -0,0 +1,459 @@ + +/****************************************************************************** + * + * Module Name: psfind - Parse tree search routine + * $Revision: 17 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __PSFIND_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psfind") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetParent + * + * PARAMETERS: Op - Get the parent of this Op + * + * RETURN: The Parent op. + * + * DESCRIPTION: Get op's parent + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsGetParent ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Parent = Op; + + + /* Traverse the tree upward (to root if necessary) */ + + while (Parent) + { + switch (Parent->Opcode) + { + case AML_SCOPE_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_DEVICE_OP: + case AML_POWER_RES_OP: + case AML_THERMAL_ZONE_OP: + + return (Parent->Parent); + } + + Parent = Parent->Parent; + } + + return (Parent); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFindName + * + * PARAMETERS: Scope - Scope to search + * Name - ACPI name to search for + * Opcode - Opcode to search for + * + * RETURN: Op containing the name + * + * DESCRIPTION: Find name segment from a list of acpi_ops. Searches a single + * scope, no more. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsFindName ( + ACPI_PARSE_OBJECT *Scope, + UINT32 Name, + UINT32 Opcode) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Field; + + + /* search scope level for matching name segment */ + + Op = AcpiPsGetChild (Scope); + + while (Op) + { + + if (AcpiPsIsFieldOp (Op->Opcode)) + { + /* Field, search named fields */ + + Field = AcpiPsGetChild (Op); + while (Field) + { + if (AcpiPsIsNamedOp (Field->Opcode) && + AcpiPsGetName (Field) == Name && + (!Opcode || Field->Opcode == Opcode)) + { + return (Field); + } + + Field = Field->Next; + } + } + + else if (AcpiPsIsCreateFieldOp (Op->Opcode)) + { + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + Field = AcpiPsGetArg (Op, 3); + } + + else + { + /* CreateXXXField, check name */ + + Field = AcpiPsGetArg (Op, 2); + } + + if ((Field) && + (Field->Value.String) && + (!STRNCMP (Field->Value.String, (char *) &Name, ACPI_NAME_SIZE))) + { + return (Op); + } + } + + else if ((AcpiPsIsNamedOp (Op->Opcode)) && + (AcpiPsGetName (Op) == Name) && + (!Opcode || Op->Opcode == Opcode || Opcode == AML_SCOPE_OP)) + { + break; + } + + Op = Op->Next; + } + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFind + * + * PARAMETERS: Scope - Where to begin the search + * Path - ACPI Path to the named object + * Opcode - Opcode associated with the object + * Create - if TRUE, create the object if not found. + * + * RETURN: Op if found, NULL otherwise. + * + * DESCRIPTION: Find object within scope + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR *Path, + UINT16 Opcode, + UINT32 Create) +{ + UINT32 SegCount; + UINT32 Name; + UINT32 NameOp; + ACPI_PARSE_OBJECT *Op = NULL; + BOOLEAN Unprefixed = TRUE; + + + FUNCTION_TRACE_PTR ("PsFind", Scope); + + + if (!Scope || !Path) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Null path (%p) or scope (%p)!\n", Path, Scope)); + return_VALUE (NULL); + } + + + AcpiGbl_PsFindCount++; + + + /* Handle all prefixes in the name path */ + + while (AcpiPsIsPrefixChar (GET8 (Path))) + { + switch (GET8 (Path)) + { + + case '\\': + + /* Could just use a global for "root scope" here */ + + while (Scope->Parent) + { + Scope = Scope->Parent; + } + + /* get first object within the scope */ + /* TBD: [Investigate] OR - set next in root scope to point to the same value as arg */ + + /* Scope = Scope->Value.Arg; */ + + break; + + + case '^': + + /* Go up to the next valid scoping Op (method, scope, etc.) */ + + if (AcpiPsGetParent (Scope)) + { + Scope = AcpiPsGetParent (Scope); + } + + break; + } + + Unprefixed = FALSE; + Path++; + } + + /* get name segment count */ + + switch (GET8 (Path)) + { + case '\0': + SegCount = 0; + + /* Null name case */ + + if (Unprefixed) + { + Op = NULL; + } + else + { + Op = Scope; + } + + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Null path, returning current root scope Op=%p\n", Op)); + return_PTR (Op); + break; + + case AML_DUAL_NAME_PREFIX: + SegCount = 2; + Path++; + break; + + case AML_MULTI_NAME_PREFIX_OP: + SegCount = GET8 (Path + 1); + Path += 2; + break; + + default: + SegCount = 1; + break; + } + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Search scope %p Segs=%d Opcode=%4.4X Create=%d\n", Scope, SegCount, Opcode, Create)); + + /* match each name segment */ + + while (Scope && SegCount) + { + MOVE_UNALIGNED32_TO_32 (&Name, Path); + Path += 4; + SegCount --; + + if (SegCount) + { + NameOp = 0; + } + else + { + NameOp = Opcode; + } + + Op = AcpiPsFindName (Scope, Name, NameOp); + if (Op) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Found! Op=%p Opcode=%4.4X\n", &Name, Op, Op->Opcode)); + } + + if (!Op) + { + if (Create) + { + /* Create a new Scope level */ + + if (SegCount) + { + Op = AcpiPsAllocOp (AML_SCOPE_OP); + } + else + { + Op = AcpiPsAllocOp (Opcode); + } + + if (Op) + { + AcpiPsSetName (Op, Name); + AcpiPsAppendArg (Scope, Op); + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Not found, created Op=%p Opcode=%4.4X\n", &Name, Op, Opcode)); + } + } + + else if (Unprefixed) + { + /* Search higher scopes for unprefixed name */ + + while (!Op && Scope->Parent) + { + Scope = Scope->Parent; + Op = AcpiPsFindName (Scope, Name, Opcode); + if (Op) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Found in parent tree! Op=%p Opcode=%4.4X\n", &Name, Op, Op->Opcode)); + } + + else + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Not found in parent=%p\n", &Name, Scope)); + } + } + } + + else + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Segment [%4.4s] Not Found in scope %p!\n", &Name, Scope)); + } + } + + Unprefixed = FALSE; + Scope = Op; + } + + return_PTR (Op); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c b/sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c new file mode 100644 index 0000000..8035f6a --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psopcode.c @@ -0,0 +1,704 @@ +/****************************************************************************** + * + * Module Name: psopcode - Parser opcode information table + * $Revision: 20 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT PARSER + MODULE_NAME ("psopcode") + + +UINT8 AcpiGbl_AmlShortOpInfoIndex[]; +UINT8 AcpiGbl_AmlLongOpInfoIndex[]; + +#define _UNK 0x6B +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D +#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ + +#define MAX_EXTENDED_OPCODE 0x87 +#define NUM_EXTENDED_OPCODE MAX_EXTENDED_OPCODE + 1 +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE MAX_INTERNAL_OPCODE + 1 + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeInfo + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the info about the opcode. NULL if the opcode was + * not found in the table. + * + * DESCRIPTION: Find AML opcode description based on the opcode. + * NOTE: This procedure must ALWAYS return a valid pointer! + * + ******************************************************************************/ + +ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *OpInfo; + UINT8 UpperOpcode; + UINT8 LowerOpcode; + + + /* Split the 16-bit opcode into separate bytes */ + + UpperOpcode = (UINT8) (Opcode >> 8); + LowerOpcode = (UINT8) Opcode; + + /* Default is "unknown opcode" */ + + OpInfo = &AcpiGbl_AmlOpInfo [_UNK]; + + + /* + * Detect normal 8-bit opcode or extended 16-bit opcode + */ + + switch (UpperOpcode) + { + case 0: + + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ + + OpInfo = &AcpiGbl_AmlOpInfo [AcpiGbl_AmlShortOpInfoIndex [LowerOpcode]]; + break; + + + case AML_EXTOP: + + /* Extended (16-bit, prefix+opcode) opcode */ + + if (LowerOpcode <= MAX_EXTENDED_OPCODE) + { + OpInfo = &AcpiGbl_AmlOpInfo [AcpiGbl_AmlLongOpInfoIndex [LowerOpcode]]; + } + break; + + + case AML_LNOT_OP: + + /* This case is for the bogus opcodes LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL */ + /* TBD: [Investigate] remove this case? */ + + DEBUG_PRINT (ACPI_ERROR, ("PsGetOpcodeInfo: Bad multi-byte opcode=%X\n", + Opcode)); + + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, ("PsGetOpcodeInfo: Unknown extended opcode=%X\n", + Opcode)); + + break; + } + + + /* Get the Op info pointer for this opcode */ + + return (OpInfo); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeName + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the name of the opcode (ASCII String) + * Note: Never returns NULL. + * + * DESCRIPTION: Translate an opcode into a human-readable string + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiPsGetOpcodeName ( + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *Op; + + + Op = AcpiPsGetOpcodeInfo (Opcode); + + /* Always guaranteed to return a valid pointer */ + + DEBUG_ONLY_MEMBERS (return Op->Name); + return ("AE_NOT_CONFIGURED"); +} + + +/******************************************************************************* + * + * NAME: AcpiGbl_AmlOpInfo + * + * DESCRIPTION: Opcode table. Each entry contains + * The name is a simple ascii string, the operand specifier is an + * ascii string with one letter per operand. The letter specifies + * the operand type. + * + ******************************************************************************/ + + +/* + * Flags byte: 0-4 (5 bits) = Opcode Type + * 5 (1 bit) = Has arguments flag + * 6-7 (2 bits) = Reserved + */ +#define AML_NO_ARGS 0 +#define AML_HAS_ARGS ACPI_OP_ARGS_MASK + +/* + * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed + * into a 32-bit number and stored in the master opcode table at the end of this file. + */ + +#define ARGP_ZERO_OP ARG_NONE +#define ARGP_ONE_OP ARG_NONE +#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) +#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) +#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) +#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) +#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) +#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) +#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) +#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) +#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) +#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) +#define ARGP_LOCAL0 ARG_NONE +#define ARGP_LOCAL1 ARG_NONE +#define ARGP_LOCAL2 ARG_NONE +#define ARGP_LOCAL3 ARG_NONE +#define ARGP_LOCAL4 ARG_NONE +#define ARGP_LOCAL5 ARG_NONE +#define ARGP_LOCAL6 ARG_NONE +#define ARGP_LOCAL7 ARG_NONE +#define ARGP_ARG0 ARG_NONE +#define ARGP_ARG1 ARG_NONE +#define ARGP_ARG2 ARG_NONE +#define ARGP_ARG3 ARG_NONE +#define ARGP_ARG4 ARG_NONE +#define ARGP_ARG5 ARG_NONE +#define ARGP_ARG6 ARG_NONE +#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) +#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) +#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_NOOP_OP ARG_NONE +#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_BREAK_OP ARG_NONE +#define ARGP_BREAK_POINT_OP ARG_NONE +#define ARGP_ONES_OP ARG_NONE +#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) +#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) +#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) +#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REVISION_OP ARG_NONE +#define ARGP_DEBUG_OP ARG_NONE +#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) +#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DEF_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) +#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) +#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) + + +/* + * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed + * into a 32-bit number and stored in the master opcode table at the end of this file. + * + * (Used by AcpiAmlPrepOperands procedure) + */ + +#define ARGI_ZERO_OP ARG_NONE +#define ARGI_ONE_OP ARG_NONE +#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE +#define ARGI_NAME_OP ARGI_INVALID_OPCODE +#define ARGI_BYTE_OP ARGI_INVALID_OPCODE +#define ARGI_WORD_OP ARGI_INVALID_OPCODE +#define ARGI_DWORD_OP ARGI_INVALID_OPCODE +#define ARGI_STRING_OP ARGI_INVALID_OPCODE +#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE +#define ARGI_BUFFER_OP ARGI_INVALID_OPCODE +#define ARGI_PACKAGE_OP ARGI_INVALID_OPCODE +#define ARGI_METHOD_OP ARGI_INVALID_OPCODE +#define ARGI_LOCAL0 ARG_NONE +#define ARGI_LOCAL1 ARG_NONE +#define ARGI_LOCAL2 ARG_NONE +#define ARGI_LOCAL3 ARG_NONE +#define ARGI_LOCAL4 ARG_NONE +#define ARGI_LOCAL5 ARG_NONE +#define ARGI_LOCAL6 ARG_NONE +#define ARGI_LOCAL7 ARG_NONE +#define ARGI_ARG0 ARG_NONE +#define ARGI_ARG1 ARG_NONE +#define ARGI_ARG2 ARG_NONE +#define ARGI_ARG3 ARG_NONE +#define ARGI_ARG4 ARG_NONE +#define ARGI_ARG5 ARG_NONE +#define ARGI_ARG6 ARG_NONE +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_TARGETREF) +#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_ADD_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_TARGETREF) +#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF, ARGI_TARGETREF) +#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_REFERENCE, ARGI_NUMBER) +#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) +#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) +#define ARGI_LAND_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LOR_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_IF_OP ARGI_INVALID_OPCODE +#define ARGI_ELSE_OP ARGI_INVALID_OPCODE +#define ARGI_WHILE_OP ARGI_INVALID_OPCODE +#define ARGI_NOOP_OP ARG_NONE +#define ARGI_RETURN_OP ARGI_INVALID_OPCODE +#define ARGI_BREAK_OP ARG_NONE +#define ARGI_BREAK_POINT_OP ARG_NONE +#define ARGI_ONES_OP ARG_NONE +#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE +#define ARGI_EVENT_OP ARGI_INVALID_OPCODE +#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_REFERENCE, ARGI_TARGETREF) +#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_NUMBER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION, ARGI_TARGETREF) +#define ARGI_STALL_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_NUMBER) +#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_NUMBER) +#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) +#define ARGI_REVISION_OP ARG_NONE +#define ARGI_DEBUG_OP ARG_NONE +#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_REGION_OP ARGI_INVALID_OPCODE +#define ARGI_DEF_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE +#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE +#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE +#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE +#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE +#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE +#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE +#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE + + +/* + * Master Opcode information table. A summary of everything we know about each opcode, all in one place. + */ + + +ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[] = +{ +/* Index Opcode Type Class Has Arguments? Name Parser Args Interpreter Args */ + +/* 00 */ /* AML_ZERO_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "ZeroOp", ARGP_ZERO_OP, ARGI_ZERO_OP), +/* 01 */ /* AML_ONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "OneOp", ARGP_ONE_OP, ARGI_ONE_OP), +/* 02 */ /* AML_ALIAS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP), +/* 03 */ /* AML_NAME_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Name", ARGP_NAME_OP, ARGI_NAME_OP), +/* 04 */ /* AML_BYTE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP), +/* 05 */ /* AML_WORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "WordConst", ARGP_WORD_OP, ARGI_WORD_OP), +/* 06 */ /* AML_DWORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP), +/* 07 */ /* AML_STRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "String", ARGP_STRING_OP, ARGI_STRING_OP), +/* 08 */ /* AML_SCOPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP), +/* 09 */ /* AML_BUFFER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP), +/* 0A */ /* AML_PACKAGE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP), +/* 0B */ /* AML_METHOD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Method", ARGP_METHOD_OP, ARGI_METHOD_OP), +/* 0C */ /* AML_LOCAL0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local0", ARGP_LOCAL0, ARGI_LOCAL0), +/* 0D */ /* AML_LOCAL1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local1", ARGP_LOCAL1, ARGI_LOCAL1), +/* 0E */ /* AML_LOCAL2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local2", ARGP_LOCAL2, ARGI_LOCAL2), +/* 0F */ /* AML_LOCAL3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local3", ARGP_LOCAL3, ARGI_LOCAL3), +/* 10 */ /* AML_LOCAL4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local4", ARGP_LOCAL4, ARGI_LOCAL4), +/* 11 */ /* AML_LOCAL5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local5", ARGP_LOCAL5, ARGI_LOCAL5), +/* 12 */ /* AML_LOCAL6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local6", ARGP_LOCAL6, ARGI_LOCAL6), +/* 13 */ /* AML_LOCAL7 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local7", ARGP_LOCAL7, ARGI_LOCAL7), +/* 14 */ /* AML_ARG0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg0", ARGP_ARG0, ARGI_ARG0), +/* 15 */ /* AML_ARG1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg1", ARGP_ARG1, ARGI_ARG1), +/* 16 */ /* AML_ARG2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg2", ARGP_ARG2, ARGI_ARG2), +/* 17 */ /* AML_ARG3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg3", ARGP_ARG3, ARGI_ARG3), +/* 18 */ /* AML_ARG4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg4", ARGP_ARG4, ARGI_ARG4), +/* 19 */ /* AML_ARG5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg5", ARGP_ARG5, ARGI_ARG5), +/* 1A */ /* AML_ARG6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg6", ARGP_ARG6, ARGI_ARG6), +/* 1B */ /* AML_STORE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "Store", ARGP_STORE_OP, ARGI_STORE_OP), +/* 1C */ /* AML_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP), +/* 1D */ /* AML_ADD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Add", ARGP_ADD_OP, ARGI_ADD_OP), +/* 1E */ /* AML_CONCAT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Concat", ARGP_CONCAT_OP, ARGI_CONCAT_OP), +/* 1F */ /* AML_SUBTRACT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP), +/* 20 */ /* AML_INCREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP), +/* 21 */ /* AML_DECREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP), +/* 22 */ /* AML_MULTIPLY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP), +/* 23 */ /* AML_DIVIDE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP), +/* 24 */ /* AML_SHIFT_LEFT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP), +/* 25 */ /* AML_SHIFT_RIGHT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP), +/* 26 */ /* AML_BIT_AND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP), +/* 27 */ /* AML_BIT_NAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP), +/* 28 */ /* AML_BIT_OR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP), +/* 29 */ /* AML_BIT_NOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP), +/* 2A */ /* AML_BIT_XOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP), +/* 2B */ /* AML_BIT_NOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP), +/* 2C */ /* AML_FIND_SET_LEFT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP), +/* 2D */ /* AML_FIND_SET_RIGHT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP, ARGI_FIND_SET_RIGHT_BIT_OP), +/* 2E */ /* AML_DEREF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP), +/* 2F */ /* AML_NOTIFY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC1| AML_HAS_ARGS, "Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP), +/* 30 */ /* AML_SIZE_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP), +/* 31 */ /* AML_INDEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_INDEX| AML_HAS_ARGS, "Index", ARGP_INDEX_OP, ARGI_INDEX_OP), +/* 32 */ /* AML_MATCH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MATCH| AML_HAS_ARGS, "Match", ARGP_MATCH_OP, ARGI_MATCH_OP), +/* 33 */ /* AML_DWORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateDWordField", ARGP_DWORD_FIELD_OP, ARGI_DWORD_FIELD_OP), +/* 34 */ /* AML_WORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateWordField", ARGP_WORD_FIELD_OP, ARGI_WORD_FIELD_OP), +/* 35 */ /* AML_BYTE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateByteField", ARGP_BYTE_FIELD_OP, ARGI_BYTE_FIELD_OP), +/* 36 */ /* AML_BIT_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateBitField", ARGP_BIT_FIELD_OP, ARGI_BIT_FIELD_OP), +/* 37 */ /* AML_TYPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP), +/* 38 */ /* AML_LAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LAnd", ARGP_LAND_OP, ARGI_LAND_OP), +/* 39 */ /* AML_LOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LOr", ARGP_LOR_OP, ARGI_LOR_OP), +/* 3A */ /* AML_LNOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "LNot", ARGP_LNOT_OP, ARGI_LNOT_OP), +/* 3B */ /* AML_LEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP), +/* 3C */ /* AML_LGREATER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP), +/* 3D */ /* AML_LLESS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LLess", ARGP_LLESS_OP, ARGI_LLESS_OP), +/* 3E */ /* AML_IF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "If", ARGP_IF_OP, ARGI_IF_OP), +/* 3F */ /* AML_ELSE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Else", ARGP_ELSE_OP, ARGI_ELSE_OP), +/* 40 */ /* AML_WHILE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "While", ARGP_WHILE_OP, ARGI_WHILE_OP), +/* 41 */ /* AML_NOOP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Noop", ARGP_NOOP_OP, ARGI_NOOP_OP), +/* 42 */ /* AML_RETURN_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Return", ARGP_RETURN_OP, ARGI_RETURN_OP), +/* 43 */ /* AML_BREAK_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Break", ARGP_BREAK_OP, ARGI_BREAK_OP), +/* 44 */ /* AML_BREAK_POINT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP), +/* 45 */ /* AML_ONES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "OnesOp", ARGP_ONES_OP, ARGI_ONES_OP), + +/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ + +/* 46 */ /* AML_MUTEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP), +/* 47 */ /* AML_EVENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_NO_ARGS, "Event", ARGP_EVENT_OP, ARGI_EVENT_OP), +/* 48 */ /* AML_COND_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP), +/* 49 */ /* AML_CREATE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP), +/* 4A */ /* AML_LOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Load", ARGP_LOAD_OP, ARGI_LOAD_OP), +/* 4B */ /* AML_STALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Stall", ARGP_STALL_OP, ARGI_STALL_OP), +/* 4C */ /* AML_SLEEP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP), +/* 4D */ /* AML_ACQUIRE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2S| AML_HAS_ARGS, "Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP), +/* 4E */ /* AML_SIGNAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP), +/* 4F */ /* AML_WAIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2S| AML_HAS_ARGS, "Wait", ARGP_WAIT_OP, ARGI_WAIT_OP), +/* 50 */ /* AML_RESET_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Reset", ARGP_RESET_OP, ARGI_RESET_OP), +/* 51 */ /* AML_RELEASE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP), +/* 52 */ /* AML_FROM_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP), +/* 53 */ /* AML_TO_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP), +/* 54 */ /* AML_UNLOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP), +/* 55 */ /* AML_REVISION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Revision", ARGP_REVISION_OP, ARGI_REVISION_OP), +/* 56 */ /* AML_DEBUG_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP), +/* 57 */ /* AML_FATAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_FATAL| AML_HAS_ARGS, "Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP), +/* 58 */ /* AML_REGION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "OpRegion", ARGP_REGION_OP, ARGI_REGION_OP), +/* 59 */ /* AML_DEF_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Field", ARGP_DEF_FIELD_OP, ARGI_DEF_FIELD_OP), +/* 5A */ /* AML_DEVICE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP), +/* 5B */ /* AML_PROCESSOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP), +/* 5C */ /* AML_POWER_RES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "PowerRes", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP), +/* 5D */ /* AML_THERMAL_ZONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP), +/* 5E */ /* AML_INDEX_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP), +/* 5F */ /* AML_BANK_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP), + +/* Internal opcodes that map to invalid AML opcodes */ + +/* 60 */ /* AML_LNOTEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP), +/* 61 */ /* AML_LLESSEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP), +/* 62 */ /* AML_LGREATEREQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP), +/* 63 */ /* AML_NAMEPATH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "NamePath", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP), +/* 64 */ /* AML_METHODCALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_CALL| AML_HAS_ARGS, "MethodCall", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP), +/* 65 */ /* AML_BYTELIST_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "ByteList", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP), +/* 66 */ /* AML_RESERVEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "ReservedField", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP), +/* 67 */ /* AML_NAMEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "NamedField", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP), +/* 68 */ /* AML_ACCESSFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "AccessField", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP), +/* 69 */ /* AML_STATICSTRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP), +/* 6A */ /* AML_RETURN_VALUE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RETURN| AML_HAS_ARGS, "[Return Value]", ARG_NONE, ARG_NONE), +/* 6B */ /* UNKNOWN OPCODES */ OP_INFO_ENTRY (ACPI_OP_TYPE_UNKNOWN | OPTYPE_BOGUS| AML_HAS_ARGS, "UNKNOWN_OP!", ARG_NONE, ARG_NONE), +/* 6C */ /* ASCII CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_ASCII | OPTYPE_BOGUS| AML_HAS_ARGS, "ASCII_ONLY!", ARG_NONE, ARG_NONE), +/* 6D */ /* PREFIX CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_PREFIX | OPTYPE_BOGUS| AML_HAS_ARGS, "PREFIX_ONLY!", ARG_NONE, ARG_NONE), +}; + +/* + * This table is directly indexed by the opcodes, and returns an + * index into the table above + */ + +UINT8 AcpiGbl_AmlShortOpInfoIndex[256] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, +/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, _UNK, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, _UNK, 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, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, +/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, +/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, +/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, +/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, +/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, _UNK, _UNK, 0x2f, 0x30, +/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, _UNK, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, _UNK, _UNK, +/* 0x98 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 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, +}; + + +UINT8 AcpiGbl_AmlLongOpInfoIndex[NUM_EXTENDED_OPCODE] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 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, _UNK, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +}; + + +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psparse.c b/sys/contrib/dev/acpica/Subsystem/Parser/psparse.c new file mode 100644 index 0000000..4951b7a --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psparse.c @@ -0,0 +1,1506 @@ +/****************************************************************************** + * + * Module Name: psparse - Parser top level AML parse routines + * $Revision: 60 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in AcpiGbl_AmlOpInfo[] + */ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psparse") + + +UINT32 AcpiGbl_Depth = 0; +extern UINT32 AcpiGbl_ScopeDepth; + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteCompletedOp + * + * PARAMETERS: State - Walk state + * Op - Completed op + * + * RETURN: AE_OK + * + * DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during + * AcpiPsDeleteParse tree to delete Op objects when all sub-objects + * have been visited (and deleted.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsDeleteCompletedOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op) +{ + + AcpiPsFreeOp (Op); + return (AE_OK); +} + + +#ifndef PARSER_ONLY +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseTree + * + * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete + * + * RETURN: None + * + * DESCRIPTION: Delete a portion of or an entire parse tree. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *SubtreeRoot) +{ + ACPI_WALK_STATE *WalkState; + ACPI_WALK_LIST WalkList; + + + FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot); + + + if (!SubtreeRoot) + { + return_VOID; + } + + /* Create and initialize a new walk list */ + + WalkList.WalkState = NULL; + WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, &WalkList); + if (!WalkState) + { + return_VOID; + } + + WalkState->ParserState = NULL; + WalkState->ParseFlags = 0; + WalkState->DescendingCallback = NULL; + WalkState->AscendingCallback = NULL; + + + WalkState->Origin = SubtreeRoot; + WalkState->NextOp = SubtreeRoot; + + + /* Head downward in the tree */ + + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Visit all nodes in the subtree */ + + while (WalkState->NextOp) + { + AcpiPsGetNextWalkOp (WalkState, WalkState->NextOp, + AcpiPsDeleteCompletedOp); + } + + /* We are done with this walk */ + + AcpiDsDeleteWalkState (WalkState); + + return_VOID; +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode) +{ + + /* Extended (2-byte) opcode if > 255 */ + + if (Opcode > 0x00FF) + { + return (2); + } + + /* Otherwise, just a single byte opcode */ + + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: ParserState - A parser state object + * + * RETURN: Status + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml; + UINT16 Opcode; + + + Aml = ParserState->Aml; + Opcode = (UINT16) GET8 (Aml); + + Aml++; + + + /* + * Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL. + * These opcodes are no longer recognized. Instead, they are broken into + * two opcodes. + * + * + * if (Opcode == AML_EXTOP + * || (Opcode == AML_LNOT + * && (GET8 (AcpiAml) == AML_LEQUAL + * || GET8 (AcpiAml) == AML_LGREATER + * || GET8 (AcpiAml) == AML_LLESS))) + * + * extended Opcode, !=, <=, or >= + */ + + if (Opcode == AML_EXTOP) + { + /* Extended opcode */ + + Opcode = (UINT16) ((Opcode << 8) | GET8 (Aml)); + Aml++; + } + + /* don't convert bare name to a namepath */ + + return (Opcode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateState + * + * PARAMETERS: AcpiAml - AcpiAml code pointer + * AcpiAmlSize - Length of AML code + * + * RETURN: A new parser state object + * + * DESCRIPTION: Create and initialize a new parser state object + * + ******************************************************************************/ + +ACPI_PARSE_STATE * +AcpiPsCreateState ( + UINT8 *Aml, + UINT32 AmlSize) +{ + ACPI_PARSE_STATE *ParserState; + + + FUNCTION_TRACE ("PsCreateState"); + + + ParserState = AcpiCmCallocate (sizeof (ACPI_PARSE_STATE)); + if (!ParserState) + { + return_VALUE (NULL); + } + + ParserState->Aml = Aml; + ParserState->AmlEnd = Aml + AmlSize; + ParserState->PkgEnd = ParserState->AmlEnd; + ParserState->AmlStart = Aml; + + + return_PTR (ParserState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFindObject + * + * PARAMETERS: Opcode - Current opcode + * ParserState - Current state + * WalkState - Current state + * *Op - Where found/new op is returned + * + * RETURN: Status + * + * DESCRIPTION: Find a named object. Two versions - one to search the parse + * tree (for parser-only applications such as acpidump), another + * to search the ACPI internal namespace (the parse tree may no + * longer exist) + * + ******************************************************************************/ + +#ifdef PARSER_ONLY + +ACPI_STATUS +AcpiPsFindObject ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + NATIVE_CHAR *Path; + + + /* We are only interested in opcodes that have an associated name */ + + if (!AcpiPsIsNamedOp (Opcode)) + { + *OutOp = Op; + return (AE_OK); + } + + /* Find the name in the parse tree */ + + Path = AcpiPsGetNextNamestring (WalkState->ParserState); + + *OutOp = AcpiPsFind (AcpiPsGetParentScope (WalkState->ParserState), + Path, Opcode, 1); + + if (!(*OutOp)) + { + return (AE_NOT_FOUND); + } + + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteThisOp + * + * PARAMETERS: WalkState - Current State + * Op - Op to complete + * + * RETURN: TRUE if Op and subtree was deleted + * + * DESCRIPTION: Perform any cleanup at the completion of an Op. + * + ******************************************************************************/ + +BOOLEAN +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ +#ifndef PARSER_ONLY + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + ACPI_OPCODE_INFO *OpInfo; + ACPI_OPCODE_INFO *ParentInfo; + UINT32 OpcodeClass; + ACPI_PARSE_OBJECT *ReplacementOp = NULL; + + + FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op); + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + OpcodeClass = ACPI_GET_OP_CLASS (OpInfo); + + + /* Delete this op and the subtree below it if asked to */ + + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && + (OpcodeClass != OPTYPE_CONSTANT) && + (OpcodeClass != OPTYPE_LITERAL) && + (OpcodeClass != OPTYPE_LOCAL_VARIABLE) && + (OpcodeClass != OPTYPE_METHOD_ARGUMENT) && + (OpcodeClass != OPTYPE_DATA_TERM) && + (Op->Opcode != AML_NAMEPATH_OP)) + { + /* Make sure that we only delete this subtree */ + + if (Op->Parent) + { + /* + * Check if we need to replace the operator and its subtree + * with a return value op + */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode); + + switch (ACPI_GET_OP_CLASS (ParentInfo)) + { + case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ + case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ + break; + + default: + ReplacementOp = AcpiPsAllocOp (AML_RETURN_VALUE_OP); + if (!ReplacementOp) + { + return_VALUE (FALSE); + } + } + + /* We must unlink this op from the parent tree */ + + Prev = Op->Parent->Value.Arg; + if (Prev == Op) + { + /* This op is the first in the list */ + + if (ReplacementOp) + { + ReplacementOp->Parent = Op->Parent; + ReplacementOp->Value.Arg = NULL; + Op->Parent->Value.Arg = ReplacementOp; + ReplacementOp->Next = Op->Next; + } + else + { + Op->Parent->Value.Arg = Op->Next; + } + } + + /* Search the parent list */ + + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + + Next = Prev->Next; + if (Next == Op) + { + if (ReplacementOp) + { + ReplacementOp->Parent = Op->Parent; + ReplacementOp->Value.Arg = NULL; + Prev->Next = ReplacementOp; + ReplacementOp->Next = Op->Next; + Next = NULL; + } + else + { + Prev->Next = Op->Next; + Next = NULL; + } + } + + Prev = Next; + } + + } + + /* Now we can actually delete the subtree rooted at op */ + + AcpiPsDeleteParseTree (Op); + + return_VALUE (TRUE); + } + + return_VALUE (FALSE); + +#else + return (FALSE); +#endif +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsNextParseState + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + + +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; + UINT8 *Start; + UINT32 PackageLength; + + + 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_PENDING: + + /* + * Predicate of a WHILE was true and the loop just completed an + * execution. Go back to the start of the loop and reevaluate the + * predicate. + */ +/* WalkState->ControlState->Common.State = + CONTROL_PREDICATE_EXECUTING;*/ + + /* TBD: How to handle a break within a while. */ + /* This code attempts it */ + + ParserState->Aml = WalkState->AmlLastWhile; + break; + + + case AE_CTRL_TRUE: + /* + * Predicate of an IF was true, and we are at the matching ELSE. + * Just close out this package + * + * Note: ParserState->Aml is modified by the package length procedure + * TBD: [Investigate] perhaps it shouldn't, too much trouble + */ + Start = ParserState->Aml; + PackageLength = AcpiPsGetNextPackageLength (ParserState); + ParserState->Aml = Start + PackageLength; + 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->Value.Arg)->Node; + + /* Will return value (if any) be used by the caller? */ + + WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState); + break; + + + default: + Status = CallbackStatus; + if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) + { + Status = AE_OK; + } + break; + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_OPCODE_INFO *OpInfo; + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE2_OBJECT *DeferredOp; + UINT32 ArgCount; /* push for fixed or var args */ + UINT32 ArgTypes = 0; + ACPI_PTRDIFF AmlOffset; + UINT16 Opcode; + ACPI_PARSE_OBJECT PreOp; + ACPI_PARSE_STATE *ParserState; + + + + FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); + + + ParserState = WalkState->ParserState; + + if (WalkState->WalkType & 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->Opcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Opcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + CONTROL_PREDICATE_EXECUTING)) + { + + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + + Status = AcpiDsGetPredicateValue (WalkState, NULL, TRUE); + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op)); + } + + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + ArgTypes = WalkState->PrevArgTypes; + } + } + + /* + * Iterative parsing loop, while there is more aml to process: + */ + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + if (!Op) + { + /* Get the next opcode from the AML stream */ + + AmlOffset = ParserState->Aml - ParserState->AmlStart; + Opcode = AcpiPsPeekOpcode (ParserState); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + switch (ACPI_GET_OP_TYPE (OpInfo)) + { + case ACPI_OP_TYPE_OPCODE: + + /* Found opcode info, this is a normal opcode */ + + ParserState->Aml += AcpiPsGetOpcodeSize (Opcode); + ArgTypes = OpInfo->ParseArgs; + break; + + case ACPI_OP_TYPE_ASCII: + case ACPI_OP_TYPE_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + + Opcode = AML_NAMEPATH_OP; + ArgTypes = ARGP_NAMESTRING; + break; + + case ACPI_OP_TYPE_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + DEBUG_PRINT (ACPI_ERROR, + ("ParseLoop: Found unknown opcode 0x%lX at AML offset 0x%X, ignoring\n", + Opcode, AmlOffset)); + + DUMP_BUFFER (ParserState->Aml, 128); + + /* Assume one-byte bad opcode */ + + ParserState->Aml++; + continue; + } + + + /* Create Op structure and append to parent's argument list */ + + if (AcpiPsIsNamedOp (Opcode)) + { + PreOp.Value.Arg = NULL; + PreOp.Opcode = Opcode; + + while (GET_CURRENT_ARG_TYPE (ArgTypes) != ARGP_NAME) + { + Arg = AcpiPsGetNextArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), + &ArgCount); + AcpiPsAppendArg (&PreOp, Arg); + INCREMENT_ARG_LIST (ArgTypes); + } + + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (ArgTypes); + + if (WalkState->DescendingCallback != NULL) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + Status = WalkState->DescendingCallback (Opcode, NULL, WalkState, &Op); + if (Op == NULL) + { + continue; + } + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + } + + AcpiPsAppendArg (Op, PreOp.Value.Arg); + AcpiGbl_Depth++; + + + if (Op->Opcode == AML_REGION_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Backup to beginning of OpRegion declaration (2 for + * Opcode, 4 for name) + * + * BodyLength is unknown until we parse the body + */ + + DeferredOp->Data = ParserState->Aml - 6; + DeferredOp->Length = 0; + } + } + } + + + else + { + /* Not a named opcode, just allocate Op and append to parent */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + if ((Op->Opcode == AML_CREATE_FIELD_OP) || + (Op->Opcode == AML_BIT_FIELD_OP) || + (Op->Opcode == AML_BYTE_FIELD_OP) || + (Op->Opcode == AML_WORD_FIELD_OP) || + (Op->Opcode == AML_DWORD_FIELD_OP)) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + DeferredOp = (ACPI_PARSE2_OBJECT *) Op; + + DeferredOp->Data = ParserState->Aml -1; + DeferredOp->Length = 0; + } + + AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op); + + if ((WalkState->DescendingCallback != NULL)) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + Status = WalkState->DescendingCallback (Opcode, Op, WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + } + } + + Op->AmlOffset = AmlOffset; + + if (OpInfo) + { + DEBUG_PRINT (TRACE_PARSE, + ("ParseLoop: Op=%p Opcode=%4.4lX Aml %p Oft=%5.5lX\n", + Op, Op->Opcode, ParserState->Aml, Op->AmlOffset)); + } + } + + + /* Start ArgCount at zero because we don't know if there are any args yet */ + + ArgCount = 0; + + + if (ArgTypes) /* Are there any arguments that must be processed? */ + { + /* get arguments */ + + switch (Op->Opcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* fill in constant or string argument directly */ + + AcpiPsGetNextSimpleArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), Op); + break; + + case AML_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + AcpiPsGetNextNamepath (ParserState, Op, &ArgCount, 1); + ArgTypes = 0; + break; + + + default: + + /* Op is not a constant or string, append each argument */ + + while (GET_CURRENT_ARG_TYPE (ArgTypes) && !ArgCount) + { + AmlOffset = ParserState->Aml - ParserState->AmlStart; + Arg = AcpiPsGetNextArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), + &ArgCount); + if (Arg) + { + Arg->AmlOffset = AmlOffset; + AcpiPsAppendArg (Op, Arg); + } + + INCREMENT_ARG_LIST (ArgTypes); + } + + + /* For a method, save the length and address of the body */ + + if (Op->Opcode == AML_METHOD_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + */ + + DeferredOp->Data = ParserState->Aml; + DeferredOp->Length = ParserState->PkgEnd - + ParserState->Aml; + + /* + * Skip body of method. For OpRegions, we must continue + * parsing because the opregion is not a standalone + * package (We don't know where the end is). + */ + ParserState->Aml = ParserState->PkgEnd; + ArgCount = 0; + } + } + + break; + } + } + + + /* + * Zero ArgCount means that all arguments for this op have been processed + */ + if (!ArgCount) + { + /* completed Op, prepare for next */ + + if (AcpiPsIsNamedOp (Op->Opcode)) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Opcode == AML_REGION_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * 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. + */ + + DeferredOp->Length = ParserState->Aml - + DeferredOp->Data; + } + } + } + + if ((Op->Opcode == AML_CREATE_FIELD_OP) || + (Op->Opcode == AML_BIT_FIELD_OP) || + (Op->Opcode == AML_BYTE_FIELD_OP) || + (Op->Opcode == AML_WORD_FIELD_OP) || + (Op->Opcode == AML_DWORD_FIELD_OP)) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + * -4 for the name (last) -- TBD: namestring: may be longer + * than 4? + */ + DeferredOp = (ACPI_PARSE2_OBJECT *) Op; + + DeferredOp->Length = ParserState->Aml - DeferredOp->Data; + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + } + + +CloseThisOp: + + /* + * Finished one argument of the containing scope + */ + ParserState->Scope->ParseScope.ArgCount--; + + /* Close this Op (may result in parse subtree deletion) */ + + if (AcpiPsCompleteThisOp (WalkState, Op)) + { + Op = NULL; + } + + + if (Status == AE_CTRL_TRANSFER) + { + /* + * We are about to transfer to a called method. + */ + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = ArgTypes; + return_ACPI_STATUS (Status); + } + + else if (Status == AE_CTRL_END) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + AcpiPsCompleteThisOp (WalkState, Op); + Op = NULL; + Status = AE_OK; + } + + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + if (Op == NULL) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + } + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = ArgTypes; + + /* + * TEMP: + */ + + return_ACPI_STATUS (Status); + } + + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op)); + } + + else + { + Op = NULL; + } + + } + + + /* ArgCount is non-zero */ + + else + { + /* complex argument, push Op and prepare for argument */ + + AcpiPsPushScope (ParserState, Op, ArgTypes, ArgCount); + Op = NULL; + } + + } /* while ParserState->Aml */ + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several AML blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsParseLoop: Package complete at Op %p\n", Op)); + do + { + if (Op) + { + if (WalkState->AscendingCallback != NULL) + { + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + AcpiPsCompleteThisOp (WalkState, Op); + return_ACPI_STATUS (Status); + } + } + + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseAml + * + * PARAMETERS: StartScope - The starting point of the parse. Becomes the + * root of the parsed op tree. + * Aml - Pointer to the raw AML code to parse + * AmlSize - Length of the AML to parse + * + * RETURN: Status + * + * DESCRIPTION: Parse raw AML and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_PARSE_OBJECT *StartScope, + UINT8 *Aml, + UINT32 AmlSize, + UINT32 ParseFlags, + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_STATUS Status; + ACPI_PARSE_STATE *ParserState; + ACPI_WALK_STATE *WalkState; + ACPI_WALK_LIST WalkList; + ACPI_NAMESPACE_NODE *Node = NULL; + ACPI_WALK_LIST *PrevWalkList = AcpiGbl_CurrentWalkList; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_OPERAND_OBJECT *MthDesc = NULL; + ACPI_NAMESPACE_NODE *StartNode; + + + FUNCTION_TRACE ("PsParseAml"); + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: Entered with Scope=%p Aml=%p size=%lX\n", + StartScope, Aml, AmlSize)); + + + /* Create and initialize a new parser state */ + + ParserState = AcpiPsCreateState (Aml, AmlSize); + if (!ParserState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiPsInitScope (ParserState, StartScope); + + if (MethodNode) + { + MthDesc = AcpiNsGetAttachedObject (MethodNode); + } + + /* Create and initialize a new walk list */ + + WalkList.WalkState = NULL; + + WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, ParserState->StartOp, MthDesc, &WalkList); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + WalkState->MethodNode = MethodNode; + WalkState->ParserState = ParserState; + WalkState->ParseFlags = ParseFlags; + WalkState->DescendingCallback = DescendingCallback; + WalkState->AscendingCallback = AscendingCallback; + + /* TBD: [Restructure] TEMP until we pass WalkState to the interpreter + */ + AcpiGbl_CurrentWalkList = &WalkList; + + + if (MethodNode) + { + StartNode = MethodNode; + ParserState->StartNode = MethodNode; + WalkState->WalkType = WALK_METHOD; + + if (StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } + /* Init arguments if this is a control method */ + /* TBD: [Restructure] add walkstate as a param */ + + AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState); + } + + else + { + /* Setup the current scope */ + + Node = ParserState->StartOp->Node; + if (Node) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (Node, Node->Type, + WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + } + } + + + Status = AE_OK; + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsParseAml: State=%p\n", + WalkState)); + + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + Status = AcpiPsParseLoop (WalkState); + } + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: Completed one call to walk loop, State=%p\n", + WalkState)); + + if (Status == AE_CTRL_TRANSFER) + { + /* + * A method call was detected. + * Transfer control to the called control method + */ + + Status = AcpiDsCallControlMethod (&WalkList, WalkState, NULL); + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + continue; + } + + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + } + + /* We are done with this walk, move on to the parent if any */ + + + WalkState = AcpiDsPopWalkState (&WalkList); + + /* Extract return value before we delete WalkState */ + + ReturnDesc = WalkState->ReturnDesc; + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: ReturnValue=%p, State=%p\n", + WalkState->ReturnDesc, WalkState)); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method, + * there's lots of cleanup to do + */ + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) + { + AcpiDsTerminateControlMethod (WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiPsCleanupScope (WalkState->ParserState); + AcpiCmFree (WalkState->ParserState); + AcpiDsDeleteWalkState (WalkState); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + if (WalkState && + ACPI_SUCCESS (Status)) + { + /* There is another walk state, restart it */ + + /* + * If the method returned value is not used by the parent, + * The object is deleted + */ + + AcpiDsRestartControlMethod (WalkState, ReturnDesc); + WalkState->WalkType |= WALK_METHOD_RESTART; + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + + else if (CallerReturnDesc) + { + *CallerReturnDesc = ReturnDesc; /* NULL if no return value */ + } + + else if (ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiCmRemoveReference (ReturnDesc); + } + } + + + /* Normal exit */ + + AcpiGbl_CurrentWalkList = PrevWalkList; + return_ACPI_STATUS (Status); + + +Cleanup: + + /* Cleanup */ + + AcpiDsDeleteWalkState (WalkState); + AcpiPsCleanupScope (ParserState); + AcpiCmFree (ParserState); + + AcpiGbl_CurrentWalkList = PrevWalkList; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psscope.c b/sys/contrib/dev/acpica/Subsystem/Parser/psscope.c new file mode 100644 index 0000000..47b61dc --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psscope.c @@ -0,0 +1,375 @@ +/****************************************************************************** + * + * Module Name: psscope - Parser scope stack management routines + * $Revision: 21 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" + +#define _COMPONENT PARSER + 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; + + + FUNCTION_TRACE_PTR ("PsInitScope", RootOp); + + + Scope = AcpiCmCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + 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; + + + FUNCTION_TRACE_PTR ("PsPushScope", Op); + + + Scope = AcpiCmCreateGenericState (); + if (!Scope) + { + return (AE_NO_MEMORY); + } + + + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + + /* Push onto scope stack */ + + AcpiCmPushGenericState (&ParserState->Scope, Scope); + + + if (ArgCount == ACPI_VAR_ARGS) + { + /* multiple arguments */ + + Scope->ParseScope.ArgEnd = ParserState->PkgEnd; + } + + else + { + /* single argument */ + + Scope->ParseScope.ArgEnd = ACPI_MAX_AML; + } + + 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; + + + FUNCTION_TRACE ("PsPopScope"); + + /* + * Only pop the scope if there is in fact a next scope + */ + if (Scope->Common.Next) + { + Scope = AcpiCmPopGenericState (&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 */ + + AcpiCmDeleteGenericState (Scope); + } + + else + { + /* empty parse stack, prepare to fetch next opcode */ + + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; + } + + + DEBUG_PRINT (TRACE_PARSE, + ("PsPopScope: Popped Op %p Args %d\n", *Op, *ArgCount)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCleanupScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Status + * + * DESCRIPTION: Destroy available list, remaining stack levels, and return + * root scope + * + ******************************************************************************/ + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_GENERIC_STATE *Scope; + + FUNCTION_TRACE_PTR ("PsCleanupScope", ParserState); + + + if (!ParserState) + { + return; + } + + + /* Delete anything on the scope stack */ + + while (ParserState->Scope) + { + Scope = AcpiCmPopGenericState (&ParserState->Scope); + AcpiCmDeleteGenericState (Scope); + } + + return_VOID; +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/pstree.c b/sys/contrib/dev/acpica/Subsystem/Parser/pstree.c new file mode 100644 index 0000000..adb5c62 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/pstree.c @@ -0,0 +1,518 @@ +/****************************************************************************** + * + * Module Name: pstree - Parser op tree manipulation/traversal/search + * $Revision: 23 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __PSTREE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("pstree") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArg + * + * PARAMETERS: Op - Get an argument for this op + * Argn - Nth argument to get + * + * RETURN: The argument (as an Op object). NULL if argument does not exist + * + * DESCRIPTION: Get the specified op's argument. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetArg ( + ACPI_PARSE_OBJECT *Op, + UINT32 Argn) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_OPCODE_INFO *OpInfo; + + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Invalid opcode or ASCII character */ + + return (NULL); + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(ACPI_GET_OP_ARGS (OpInfo))) + { + /* Has no linked argument objects */ + + return (NULL); + } + + /* Get the requested argument object */ + + Arg = Op->Value.Arg; + while (Arg && Argn) + { + Argn--; + Arg = Arg->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; + ACPI_OPCODE_INFO *OpInfo; + + + if (!Op) + { + return; + } + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Invalid opcode */ + + return; + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(ACPI_GET_OP_ARGS (OpInfo))) + { + /* Has no linked argument objects */ + + return; + } + + + /* Append the argument to the linked argument list */ + + if (Op->Value.Arg) + { + /* Append to existing argument list */ + + PrevArg = Op->Value.Arg; + while (PrevArg->Next) + { + PrevArg = PrevArg->Next; + } + PrevArg->Next = Arg; + } + + else + { + /* No argument list, this will be the first argument */ + + Op->Value.Arg = Arg; + } + + + /* Set the parent in this arg and any args linked after it */ + + while (Arg) + { + Arg->Parent = Op; + Arg = Arg->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + switch (Op->Opcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_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_DEF_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; + + } + + return (Child); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetDepthNext + * + * PARAMETERS: Origin - Root of subtree to search + * Op - Last (previous) Op that was found + * + * RETURN: Next Op found in the search. + * + * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) + * Return NULL when reaching "origin" or when walking up from root + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *Arg; + + + if (!Op) + { + return (NULL); + } + + /* look for an argument or child */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + return (Next); + } + + /* look for a sibling */ + + Next = Op->Next; + if (Next) + { + return (Next); + } + + /* look for a sibling of parent */ + + Parent = Op->Parent; + + while (Parent) + { + Arg = AcpiPsGetArg (Parent, 0); + while (Arg && (Arg != Origin) && (Arg != Op)) + { + Arg = Arg->Next; + } + + if (Arg == Origin) + { + /* reached parent of origin, end search */ + + return (NULL); + } + + if (Parent->Next) + { + /* found sibling of parent */ + return (Parent->Next); + } + + Op = Parent; + Parent = Parent->Parent; + } + + return (Next); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFetchPrefix + * + * PARAMETERS: Scope - Op to fetch prefix for + * Path - A namestring containing the prefix + * io - Direction flag + * + * RETURN: Op referenced by the prefix + * + * DESCRIPTION: Fetch and handle path prefix ('\\' or '^') + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsFetchPrefix ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR **Path, + UINT32 io) +{ + UINT32 prefix = io ? GET8 (*Path):**Path; + + + switch (prefix) + { + case '\\': + case '/': + + /* go to the root */ + + *Path += 1; + while (Scope->Parent) + { + Scope = Scope->Parent; + } + break; + + + case '^': + + /* go up one level */ + + *Path += 1; + Scope = Scope->Parent; + break; + } + + if (Scope && !Scope->Parent) + { + /* searching from the root, start with its children */ + + Scope = AcpiPsGetChild (Scope); + } + + return (Scope); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFetchName + * + * PARAMETERS: Path - A string containing the name segment + * io - Direction flag + * + * RETURN: The 4-INT8 ASCII ACPI Name as a UINT32 + * + * DESCRIPTION: Fetch ACPI name segment (dot-delimited) + * + ******************************************************************************/ + +UINT32 +AcpiPsFetchName ( + NATIVE_CHAR **Path, + UINT32 io) +{ + UINT32 Name = 0; + NATIVE_CHAR *nm; + UINT32 i; + NATIVE_CHAR ch; + + + if (io) + { + /* Get the name from the path pointer */ + + MOVE_UNALIGNED32_TO_32 (&Name, *Path); + *Path += 4; + } + + else + { + if (**Path == '.') + { + *Path += 1; + } + + nm = (NATIVE_CHAR *) &Name; + for (i = 0; i < 4; i++) + { + ch = **Path; + if (ch && ch != '.') + { + *nm = ch; + *Path += 1; + } + + else + { + *nm = '_'; + } + nm++; + } + } + + return (Name); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psutils.c b/sys/contrib/dev/acpica/Subsystem/Parser/psutils.c new file mode 100644 index 0000000..0467ff8 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psutils.c @@ -0,0 +1,683 @@ +/****************************************************************************** + * + * Module Name: psutils - Parser miscellaneous utilities (Parser only) + * $Revision: 30 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psutils") + + +#define PARSEOP_GENERIC 0x01 +#define PARSEOP_NAMED 0x02 +#define PARSEOP_DEFERRED 0x03 +#define PARSEOP_BYTELIST 0x04 +#define PARSEOP_IN_CACHE 0x80 + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitOp + * + * PARAMETERS: Op - A newly allocated Op object + * Opcode - Opcode to store in the Op + * + * RETURN: Status + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode + * + ******************************************************************************/ + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *AmlOp; + + + Op->DataType = ACPI_DESC_TYPE_PARSER; + Op->Opcode = Opcode; + + AmlOp = AcpiPsGetOpcodeInfo (Opcode); + + DEBUG_ONLY_MEMBERS (STRNCPY (Op->OpName, AmlOp->Name, + sizeof (Op->OpName))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAllocOp + * + * PARAMETERS: Opcode - Opcode that will be stored in the new Op + * + * RETURN: Pointer to the new Op. + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode. A cache of opcodes is available for the pure + * GENERIC_OP, since this is by far the most commonly used. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsAllocOp ( + UINT16 Opcode) +{ + ACPI_PARSE_OBJECT *Op = NULL; + UINT32 Size; + UINT8 Flags; + + + /* Allocate the minimum required size object */ + + if (AcpiPsIsDeferredOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_DEFERRED; + } + + else if (AcpiPsIsNamedOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_NAMED; + } + + else if (AcpiPsIsBytelistOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_BYTELIST; + } + + else + { + Size = sizeof (ACPI_PARSE_OBJECT); + Flags = PARSEOP_GENERIC; + } + + + if (Size == sizeof (ACPI_PARSE_OBJECT)) + { + /* + * The generic op is by far the most common (16 to 1), and therefore + * the op cache is implemented with this type. + * + * Check if there is an Op already available in the cache + */ + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ParseCacheRequests++; + if (AcpiGbl_ParseCache) + { + /* Extract an op from the front of the cache list */ + + AcpiGbl_ParseCacheDepth--; + AcpiGbl_ParseCacheHits++; + + Op = AcpiGbl_ParseCache; + AcpiGbl_ParseCache = Op->Next; + + if (Op->DataType == 0xFF) + { + DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op)); + } + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT)); + + DEBUG_PRINT (TRACE_PARSE, + ("PsAllocOp: Op %p from Parse Cache\n", Op)); + } + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* + * The generic op is by far the most common (16 to 1), and therefore + * the op cache is implemented with this type. + * + * Check if there is an Op already available in the cache + */ + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ExtParseCacheRequests++; + if (AcpiGbl_ExtParseCache) + { + /* Extract an op from the front of the cache list */ + + AcpiGbl_ExtParseCacheDepth--; + AcpiGbl_ExtParseCacheHits++; + + Op = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache; + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op->Next; + + if (Op->DataType == 0xFF) + { + DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op)); + } + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT)); + + DEBUG_PRINT (TRACE_PARSE, + ("PsAllocOp: Op %p from ExtParse Cache\n", Op)); + } + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + + /* Allocate a new Op if necessary */ + + if (!Op) + { + Op = AcpiCmCallocate (Size); + } + + /* Initialize the Op */ + if (Op) + { + AcpiPsInitOp (Op, Opcode); + Op->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) +{ + + + if (Op->Opcode == AML_RETURN_VALUE_OP) + { + DEBUG_PRINT (ACPI_INFO, ("Free retval op: %p\n", Op)); + } + + if (Op->Flags == PARSEOP_GENERIC) + { + /* Is the cache full? */ + + if (AcpiGbl_ParseCacheDepth < MAX_PARSE_CACHE_DEPTH) + { + /* Put a GENERIC_OP back into the cache */ + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT)); + Op->Flags = PARSEOP_IN_CACHE; + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ParseCacheDepth++; + + Op->Next = AcpiGbl_ParseCache; + AcpiGbl_ParseCache = Op; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return; + } + } + + else + { + /* Is the cache full? */ + + if (AcpiGbl_ExtParseCacheDepth < MAX_EXTPARSE_CACHE_DEPTH) + { + /* Put a GENERIC_OP back into the cache */ + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT)); + Op->Flags = PARSEOP_IN_CACHE; + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ExtParseCacheDepth++; + + Op->Next = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache; + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return; + } + } + + + /* + * Not a GENERIC OP, or the cache is full, just free the Op + */ + + AcpiCmFree (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseCache + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free all objects that are on the parse cache list. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseCache ( + void) +{ + ACPI_PARSE_OBJECT *Next; + + + FUNCTION_TRACE ("PsDeleteParseCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_ParseCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ParseCache->Next; + AcpiCmFree (AcpiGbl_ParseCache); + AcpiGbl_ParseCache = Next; + AcpiGbl_ParseCacheDepth--; + } + + /* Traverse the global cache list */ + + while (AcpiGbl_ExtParseCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ExtParseCache->Next; + AcpiCmFree (AcpiGbl_ExtParseCache); + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Next; + AcpiGbl_ExtParseCacheDepth--; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: Utility functions + * + * DESCRIPTION: Low level functions + * + * TBD: [Restructure] + * 1) Some of these functions should be macros + * 2) Some can be simplified + * + ******************************************************************************/ + + +/* + * 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 == '^')); +} + + +BOOLEAN +AcpiPsIsNamespaceObjectOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_DEF_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_NAMEDFIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_METHODCALL_OP || + Opcode == AML_NAMEPATH_OP)); +} + +BOOLEAN +AcpiPsIsNamespaceOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_DEF_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_NAMEDFIELD_OP)); +} + + +/* + * Is opcode for a named object Op? + * (Includes all named object opcodes) + * + * TBD: [Restructure] Need a better way than this brute force approach! + */ +BOOLEAN +AcpiPsIsNodeOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_NAMEDFIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + + + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_METHODCALL_OP || + Opcode == AML_NAMEPATH_OP)); +} + + +/* + * Is opcode for a named Op? + */ +BOOLEAN +AcpiPsIsNamedOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_NAMEDFIELD_OP)); +} + + +BOOLEAN +AcpiPsIsDeferredOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_METHOD_OP || + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_REGION_OP)); +} + + +/* + * Is opcode for a bytelist? + */ +BOOLEAN +AcpiPsIsBytelistOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) (Opcode == AML_BYTELIST_OP)); +} + + +/* + * Is opcode for a Field, IndexField, or BankField + */ +BOOLEAN +AcpiPsIsFieldOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_CREATE_FIELD_OP + || Opcode == AML_DEF_FIELD_OP + || Opcode == AML_INDEX_FIELD_OP + || Opcode == AML_BANK_FIELD_OP)); +} + + +/* + * Is field creation op + */ +BOOLEAN +AcpiPsIsCreateFieldOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP)); +} + + +/* + * Cast an acpi_op to an acpi_extended_op if possible + */ + +/* TBD: This is very inefficient, fix */ +ACPI_PARSE2_OBJECT * +AcpiPsToExtendedOp ( + ACPI_PARSE_OBJECT *Op) +{ + return ((AcpiPsIsDeferredOp (Op->Opcode) || AcpiPsIsNamedOp (Op->Opcode) || AcpiPsIsBytelistOp (Op->Opcode)) + ? ( (ACPI_PARSE2_OBJECT *) Op) : NULL); +} + + +/* + * Get op's name (4-byte name segment) or 0 if unnamed + */ +UINT32 +AcpiPsGetName ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op); + + return (Named ? Named->Name : 0); +} + + +/* + * Set op's name + */ +void +AcpiPsSetName ( + ACPI_PARSE_OBJECT *Op, + UINT32 name) +{ + ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op); + + if (Named) + { + Named->Name = name; + } +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c b/sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c new file mode 100644 index 0000000..176a54d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/pswalk.c @@ -0,0 +1,727 @@ +/****************************************************************************** + * + * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * $Revision: 47 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT PARSER + MODULE_NAME ("pswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextWalkOp + * + * PARAMETERS: WalkState - Current state of the walk + * Op - Current Op to be walked + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Get the next Op in a walk of the parse tree. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *GrandParent; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("PsGetNextWalkOp", Op); + + + /* Check for a argument only if we are descending in the tree */ + + if (WalkState->NextOpInfo != NEXT_OP_UPWARD) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (AE_OK); + } + + + /* + * No more children, this Op is complete. Save Next and Parent + * in case the Op object gets deleted by the callback routine + */ + + Next = Op->Next; + Parent = Op->Parent; + + Status = AscendingCallback (WalkState, Op); + + switch (Status) + { + case AE_CTRL_TERMINATE: + + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + WalkState->PrevOp = WalkState->Origin; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); + 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. + */ + + Next = Parent->Next; + Status = AE_OK; + + /* + * If there is a sibling to the parent, we must close out the + * parent now, because we are going to continue to go downward (to + * the sibling) in the parse tree. + */ + if (Next) + { + Status = AscendingCallback (WalkState, Parent); + + /* The parent sibling will be next */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Continue downward */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Drop into the loop below because we are moving upwards in + * the tree + */ + + break; + + + default: + /* + * If we are back to the starting point, the walk is complete. + */ + if (Op == WalkState->Origin) + { + /* Reached the point of origin, the walk is complete */ + + WalkState->PrevOp = Op; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (Status); + } + + /* + * Check for a sibling to the current op. A sibling means + * we are still going "downward" in the tree. + */ + + if (Next) + { + /* There is a sibling, it will be next */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Continue downward */ + + return_ACPI_STATUS (Status); + } + + /* + * No sibling, but check status. + * Abort on error from callback routine + */ + if (ACPI_FAILURE (Status)) + { + /* Next op will be the parent */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Parent; + WalkState->NextOpInfo = NEXT_OP_UPWARD; + + return_ACPI_STATUS (Status); + } + + /* + * Drop into the loop below because we are moving upwards in + * the tree + */ + + break; + } + } + + else + { + /* + * We are resuming a walk, and we were (are) going upward in the tree. + * So, we want to drop into the parent loop below. + */ + + Parent = Op; + } + + + /* + * Look for a sibling of the current Op's parent + * Continue moving up the tree until we find a node that has not been + * visited, or we get back to where we started. + */ + while (Parent) + { + /* We are moving up the tree, therefore this parent Op is complete */ + + GrandParent = Parent->Parent; + Next = Parent->Next; + + Status = AscendingCallback (WalkState, Parent); + + + switch (Status) + { + 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. + */ + + Parent = GrandParent; + Next = GrandParent->Next; + GrandParent = GrandParent->Parent; + + Status = AscendingCallback (WalkState, Parent); + + /* Now continue to the next node in the tree */ + + break; + + + case AE_CTRL_TRUE: + + /* + * Predicate of a WHILE was true and the loop just completed an + * execution. Go back to the start of the loop and reevaluate the + * predicate. + */ + + Op = WalkState->ControlState->Control.PredicateOp; + + WalkState->ControlState->Common.State = CONTROL_PREDICATE_EXECUTING; + + /* + * AcpiEvaluate the predicate again (next) + * Because we will traverse WHILE tree again + */ + + WalkState->PrevOp = Op->Parent; + WalkState->NextOp = Op; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (AE_OK); + break; + + + case AE_CTRL_TERMINATE: + + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + WalkState->PrevOp = WalkState->Origin; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); + break; + } + + + /* + * If we are back to the starting point, the walk is complete. + */ + if (Parent == WalkState->Origin) + { + /* Reached the point of origin, the walk is complete */ + + WalkState->PrevOp = Parent; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (Status); + } + + + /* + * If there is a sibling to this parent (it is not the starting point + * Op), then we will visit it. + */ + if (Next) + { + /* found sibling of parent */ + + WalkState->PrevOp = Parent; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (Status); + } + + /* + * No sibling, check for an error from closing the parent + * (Also, AE_PENDING if a method call was encountered) + */ + if (ACPI_FAILURE (Status)) + { + WalkState->PrevOp = Parent; + WalkState->NextOp = GrandParent; + WalkState->NextOpInfo = NEXT_OP_UPWARD; + + return_ACPI_STATUS (Status); + } + + /* No siblings, no errors, just move up one more level in the tree */ + + Op = Parent; + Parent = GrandParent; + WalkState->PrevOp = Op; + } + + + /* Got all the way to the top of the tree, we must be done! */ + /* However, the code should have terminated in the loop above */ + + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsWalkLoop + * + * PARAMETERS: WalkList - State of the walk + * StartOp - Starting Op of the subtree to be walked + * DescendingCallback - Procedure called when a new Op is + * encountered + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Perform a walk of the parsed AML tree. Begins and terminates at + * the StartOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsWalkLoop ( + ACPI_WALK_LIST *WalkList, + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_STATUS Status = AE_OK; + ACPI_WALK_STATE *WalkState; + ACPI_PARSE_OBJECT *Op = StartOp; + + + FUNCTION_TRACE_PTR ("PsWalkLoop", StartOp); + + + WalkState = AcpiDsGetCurrentWalkState (WalkList); + + + /* Walk entire subtree, visiting all nodes depth-first */ + + while (Op) + { + if (WalkState->NextOpInfo != NEXT_OP_UPWARD) + { + Status = DescendingCallback (Op->Opcode, Op, WalkState, NULL); + } + + /* + * A TRUE exception means that an ELSE was detected, but the IF + * predicate evaluated TRUE. + */ + if (Status == AE_CTRL_TRUE) + { + /* + * Ignore the entire ELSE block by moving on to the the next opcode. + * And we do that by simply going up in the tree (either to the next + * sibling or to the parent) from here. + */ + + WalkState->NextOpInfo = NEXT_OP_UPWARD; + } + + /* Get the next node (op) in the depth-first walk */ + + Status = AcpiPsGetNextWalkOp (WalkState, Op, AscendingCallback); + + /* + * A PENDING exception means that a control method invocation has been + * detected + */ + + if (Status == AE_CTRL_PENDING) + { + /* Transfer control to the called control method */ + + Status = AcpiDsCallControlMethod (WalkList, WalkState, Op); + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + + WalkState = AcpiDsGetCurrentWalkState (WalkList); + } + + /* Abort the walk on any exception */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Op = WalkState->NextOp; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsWalkParsedAml + * + * PARAMETERS: StartOp - Starting Op of the subtree to be walked + * EndOp - Where to terminate the walk + * DescendingCallback - Procedure called when a new Op is + * encountered + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Top level interface to walk the parsed AML tree. Handles + * preemption of executing control methods. + * + * NOTE: The EndOp is usually only different from the StartOp if + * we don't want to visit the StartOp during the tree descent. + * + ******************************************************************************/ + +ACPI_STATUS +mmmmAcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_STATUS Status; + ACPI_WALK_LIST WalkList; + ACPI_WALK_LIST *PrevWalkList; + + + FUNCTION_TRACE_PTR ("PsWalkParsedAml", StartOp); + + + /* Parameter Validation */ + + if (!StartOp || !EndOp) + { + return (AE_BAD_PARAMETER); + } + + /* Initialize a new walk list */ + + WalkList.WalkState = NULL; + + WalkState = AcpiDsCreateWalkState (OwnerId, EndOp, MthDesc, &WalkList); + if (!WalkState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* TBD: [Restructure] TEMP until we pass WalkState to the interpreter + */ + PrevWalkList = AcpiGbl_CurrentWalkList; + AcpiGbl_CurrentWalkList = &WalkList; + + if (StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } + + if (MthDesc) + { + /* Init arguments if this is a control method */ + /* TBD: [Restructure] add walkstate as a param */ + + AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState); + } + + Op = StartOp; + Status = AE_OK; + + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsWalkParsedAml: Op=%p EndOp=%p State=%p\n", + Op, EndOp, WalkState)); + + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + Status = AcpiPsWalkLoop (&WalkList, Op, DescendingCallback, + AscendingCallback); + } + + DEBUG_PRINT (TRACE_PARSE, + ("PsWalkParsedAml: Completed one call to walk loop, State=%p\n", + WalkState)); + + /* We are done with this walk, move on to the parent if any */ + + BREAKPOINT3; + + WalkState = AcpiDsPopWalkState (&WalkList); + + /* Extract return value before we delete WalkState */ + + ReturnDesc = WalkState->ReturnDesc; + + DEBUG_PRINT (TRACE_PARSE, + ("PsWalkParsedAml: ReturnValue=%p, State=%p\n", + WalkState->ReturnDesc, WalkState)); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method, + * there's lots of cleanup to do + */ + + if (WalkState->MethodDesc) + { + AcpiDsTerminateControlMethod (WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiDsDeleteWalkState (WalkState); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + if (WalkState && + ACPI_SUCCESS (Status)) + { + /* There is another walk state, restart it */ + + /* + * If the method returned value is not used by the parent, + * The object is deleted + */ + + AcpiDsRestartControlMethod (WalkState, ReturnDesc); + + /* Get the next Op to process */ + + Op = WalkState->NextOp; + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + + else if (CallerReturnDesc) + { + *CallerReturnDesc = ReturnDesc; /* NULL if no return value */ + } + + else if (ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiCmRemoveReference (ReturnDesc); + } + } + + + AcpiGbl_CurrentWalkList = PrevWalkList; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Parser/psxface.c b/sys/contrib/dev/acpica/Subsystem/Parser/psxface.c new file mode 100644 index 0000000..2f65a41 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Parser/psxface.c @@ -0,0 +1,270 @@ +/****************************************************************************** + * + * Module Name: psxface - Parser external interfaces + * $Revision: 37 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSXFACE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT PARSER + MODULE_NAME ("psxface") + + +/***************************************************************************** + * + * FUNCTION: AcpiPsxExecute + * + * PARAMETERS: MethodNode - A method object containing both the AML + * address and length. + * **Params - List of parameters to pass to method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * **ReturnObjDesc - Return object from execution of the + * method. + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ****************************************************************************/ + +ACPI_STATUS +AcpiPsxExecute ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 i; + ACPI_PARSE_OBJECT *Op; + + + FUNCTION_TRACE ("PsxExecute"); + + + /* Validate the Node and get the attached object */ + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Params) + { + /* + * The caller "owns" the parameters, so give each one an extra + * reference + */ + + for (i = 0; Params[i]; i++) + { + AcpiCmAddReference (Params[i]); + } + } + + /* + * Perform the first pass parse of the method to enter any + * named objects that it creates into the namespace + */ + + DEBUG_PRINT (ACPI_INFO, + ("PsxExecute: **** Begin Method Execution **** Entry=%p obj=%p\n", + MethodNode, ObjDesc)); + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + MethodNode, Params, ReturnObjDesc, + AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + AcpiPsDeleteParseTree (Op); + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * The walk of the parse tree is where we actually execute the method + */ + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + MethodNode, Params, ReturnObjDesc, + AcpiDsExecBeginOp, AcpiDsExecEndOp); + AcpiPsDeleteParseTree (Op); + + if (Params) + { + /* Take away the extra reference that we gave the parameters above */ + + for (i = 0; Params[i]; i++) + { + AcpiCmUpdateObjectReference (Params[i], REF_DECREMENT); + } + } + + + /* + * Normal exit is with Status == AE_RETURN_VALUE when a ReturnOp has been + * executed, or with Status == AE_PENDING at end of AML block (end of + * Method code) + */ + + if (*ReturnObjDesc) + { + DEBUG_PRINT (ACPI_INFO, ("Method returned ObjDesc=%X\n", + *ReturnObjDesc)); + DUMP_STACK_ENTRY (*ReturnObjDesc); + + Status = AE_CTRL_RETURN_VALUE; + } + + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c new file mode 100644 index 0000000..478441c --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c @@ -0,0 +1,922 @@ +/******************************************************************************* + * + * Module Name: rsaddr - AcpiRsAddress16Resource + * AcpiRsAddress16Stream + * AcpiRsAddress32Resource + * AcpiRsAddress32Stream + * $Revision: 11 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSADDR_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsaddr") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress16Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress16Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16; + UINT8 Temp8; + UINT32 Index; + UINT32 StructSize = sizeof(ADDRESS16_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsAddress16Resource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = Address16; + + OutputStruct->Length = StructSize; + + /* + * Get the Resource Type (Byte3) + */ + Buffer += 2; + Temp8 = *Buffer; + + /* Values 0-2 are valid */ + if (Temp8 > 2) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03; + + /* + * Get the General Flags (Byte4) + */ + Buffer += 1; + Temp8 = *Buffer; + + /* + * Producer / Consumer + */ + OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01; + + /* + * Decode + */ + OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01; + + /* + * Min Address Fixed + */ + OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01; + + /* + * Max Address Fixed + */ + OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01; + + /* + * Get the Type Specific Flags (Byte5) + */ + Buffer += 1; + Temp8 = *Buffer; + + if (MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType) + { + OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute = + (UINT16) (Temp8 & 0x01); + OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute = + (UINT16) ((Temp8 >> 1) & 0x0F); + } + + else + { + if (IO_RANGE == OutputStruct->Data.Address16.ResourceType) + { + OutputStruct->Data.Address16.Attribute.Io.RangeAttribute = + (UINT16) (Temp8 & 0x03); + } + + else + { + /* BUS_NUMBER_RANGE == Address32Data->ResourceType */ + /* Nothing needs to be filled in */ + } + } + + /* + * Get Granularity (Bytes 6-7) + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.Granularity, + Buffer); + + /* + * Get MinAddressRange (Bytes 8-9) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MinAddressRange, + Buffer); + + /* + * Get MaxAddressRange (Bytes 10-11) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 + (&OutputStruct->Data.Address16.MaxAddressRange, + Buffer); + + /* + * Get AddressTranslationOffset (Bytes 12-13) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 + (&OutputStruct->Data.Address16.AddressTranslationOffset, + Buffer); + + /* + * Get AddressLength (Bytes 14-15) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 + (&OutputStruct->Data.Address16.AddressLength, + Buffer); + + /* + * Resource Source Index (if present) + */ + Buffer += 2; + + /* + * This will leave us pointing to the Resource Source Index + * If it is present, then save it off and calculate the + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. + */ + if (*BytesConsumed > 16) + { + /* Dereference the Index */ + + Temp8 = *Buffer; + OutputStruct->Data.Address16.ResourceSourceIndex = + (UINT32) Temp8; + + /* Point to the String */ + + Buffer += 1; + + /* Copy the string into the buffer */ + + Index = 0; + + while (0x00 != *Buffer) + { + OutputStruct->Data.Address16.ResourceSource[Index] = + *Buffer; + + Buffer += 1; + Index += 1; + } + + /* + * Add the terminating null + */ + OutputStruct->Data.Address16.ResourceSource[Index] = 0x00; + + OutputStruct->Data.Address16.ResourceSourceStringLength = + Index + 1; + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundry. + */ + Temp8 = (UINT8) (Index + 1); + StructSize += ROUND_UP_TO_32BITS (Temp8); + OutputStruct->Length = StructSize; + } + else + { + OutputStruct->Data.Address16.ResourceSourceIndex = 0x00; + OutputStruct->Data.Address16.ResourceSourceStringLength = 0; + OutputStruct->Data.Address16.ResourceSource[0] = 0x00; + } + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress16Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress16Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT8 *LengthField; + UINT8 Temp8; + NATIVE_CHAR *TempPointer = NULL; + UINT32 ActualBytes; + + + FUNCTION_TRACE ("RsAddress16Stream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x88; + Buffer += 1; + + /* + * Save a pointer to the Length field - to be filled in later + */ + LengthField = Buffer; + Buffer += 2; + + /* + * Set the Resource Type (Memory, Io, BusNumber) + */ + Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the general flags + */ + Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01); + + Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1; + Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2; + Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the type specific flags + */ + Temp8 = 0; + + if (MEMORY_RANGE == LinkedList->Data.Address16.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute & + 0x01); + + Temp8 |= + (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute & + 0x0F) << 1; + } + + else if (IO_RANGE == LinkedList->Data.Address16.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address16.Attribute.Io.RangeAttribute & + 0x03); + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the address space granularity + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.Granularity); + Buffer += 2; + + /* + * Set the address range minimum + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.MinAddressRange); + Buffer += 2; + + /* + * Set the address range maximum + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.MaxAddressRange); + Buffer += 2; + + /* + * Set the address translation offset + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.AddressTranslationOffset); + Buffer += 2; + + /* + * Set the address length + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.AddressLength); + Buffer += 2; + + /* + * Resource Source Index and Resource Source are optional + */ + if (0 != LinkedList->Data.Address16.ResourceSourceStringLength) + { + Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSourceIndex; + + *Buffer = Temp8; + Buffer += 1; + + TempPointer = (NATIVE_CHAR *) Buffer; + + /* + * Copy the string + */ + STRCPY (TempPointer, LinkedList->Data.Address16.ResourceSource); + + /* + * Buffer needs to be set to the length of the sting + one for the + * terminating null + */ + Buffer += (STRLEN (LinkedList->Data.Address16.ResourceSource) + 1); + } + + /* + * Return the number of bytes consumed in this operation + */ + ActualBytes = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + *BytesConsumed = ActualBytes; + + /* + * Set the length field to the number of bytes consumed + * minus the header size (3 bytes) + */ + ActualBytes -= 3; + MOVE_UNALIGNED16_TO_16 (LengthField, &ActualBytes); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress32Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer; + RESOURCE *OutputStruct; + UINT16 Temp16; + UINT8 Temp8; + UINT32 StructSize; + UINT32 Index; + + + FUNCTION_TRACE ("RsAddress32Resource"); + + Buffer = ByteStreamBuffer; + + OutputStruct = (RESOURCE *) *OutputBuffer; + + StructSize = sizeof (ADDRESS32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = Address32; + + /* + * Get the Resource Type (Byte3) + */ + Buffer += 2; + Temp8 = *Buffer; + + /* Values 0-2 are valid */ + if(Temp8 > 2) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03; + + /* + * Get the General Flags (Byte4) + */ + Buffer += 1; + Temp8 = *Buffer; + + /* + * Producer / Consumer + */ + OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01; + + /* + * Decode + */ + OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01; + + /* + * Min Address Fixed + */ + OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01; + + /* + * Max Address Fixed + */ + OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01; + + /* + * Get the Type Specific Flags (Byte5) + */ + Buffer += 1; + Temp8 = *Buffer; + + if (MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType) + { + OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute = + (UINT16) (Temp8 & 0x01); + + OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute = + (UINT16) ((Temp8 >> 1) & 0x0F); + } + + else + { + if (IO_RANGE == OutputStruct->Data.Address32.ResourceType) + { + OutputStruct->Data.Address32.Attribute.Io.RangeAttribute = + (UINT16) (Temp8 & 0x03); + } + + else + { + /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */ + /* Nothing needs to be filled in */ + } + } + + /* + * Get Granularity (Bytes 6-9) + */ + Buffer += 1; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.Granularity, + Buffer); + + /* + * Get MinAddressRange (Bytes 10-13) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange, + Buffer); + + /* + * Get MaxAddressRange (Bytes 14-17) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange, + Buffer); + + /* + * Get AddressTranslationOffset (Bytes 18-21) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 + (&OutputStruct->Data.Address32.AddressTranslationOffset, + Buffer); + + /* + * Get AddressLength (Bytes 22-25) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressLength, + Buffer); + + /* + * Resource Source Index (if present) + */ + Buffer += 4; + + /* + * This will leave us pointing to the Resource Source Index + * If it is present, then save it off and calculate the + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. + */ + if (*BytesConsumed > 26) + { + /* Dereference the Index */ + + Temp8 = *Buffer; + OutputStruct->Data.Address32.ResourceSourceIndex = (UINT32)Temp8; + + /* Point to the String */ + + Buffer += 1; + + /* Copy the string into the buffer */ + + Index = 0; + + while (0x00 != *Buffer) + { + OutputStruct->Data.Address32.ResourceSource[Index] = *Buffer; + Buffer += 1; + Index += 1; + } + + /* + * Add the terminating null + */ + OutputStruct->Data.Address32.ResourceSource[Index] = 0x00; + + OutputStruct->Data.Address32.ResourceSourceStringLength = Index + 1; + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundry. + */ + Temp8 = (UINT8) (Index + 1); + StructSize += ROUND_UP_TO_32BITS (Temp8); + } + + else + { + OutputStruct->Data.Address32.ResourceSourceIndex = 0x00; + OutputStruct->Data.Address32.ResourceSourceStringLength = 0; + OutputStruct->Data.Address32.ResourceSource[0] = 0x00; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress32Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer; + UINT16 *LengthField; + UINT8 Temp8; + NATIVE_CHAR *TempPointer; + + + FUNCTION_TRACE ("RsAddress32Stream"); + + Buffer = *OutputBuffer; + + /* + * The descriptor field is static + */ + *Buffer = 0x87; + Buffer += 1; + + /* + * Set a pointer to the Length field - to be filled in later + */ + + LengthField = (UINT16 *)Buffer; + Buffer += 2; + + /* + * Set the Resource Type (Memory, Io, BusNumber) + */ + Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03); + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the general flags + */ + Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01); + Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1; + Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2; + Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the type specific flags + */ + Temp8 = 0; + + if(MEMORY_RANGE == LinkedList->Data.Address32.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute & + 0x01); + + Temp8 |= + (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute & + 0x0F) << 1; + } + + else if (IO_RANGE == LinkedList->Data.Address32.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address32.Attribute.Io.RangeAttribute & + 0x03); + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the address space granularity + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.Granularity); + Buffer += 4; + + /* + * Set the address range minimum + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.MinAddressRange); + Buffer += 4; + + /* + * Set the address range maximum + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.MaxAddressRange); + Buffer += 4; + + /* + * Set the address translation offset + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.AddressTranslationOffset); + Buffer += 4; + + /* + * Set the address length + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.AddressLength); + Buffer += 4; + + /* + * Resource Source Index and Resource Source are optional + */ + if (0 != LinkedList->Data.Address32.ResourceSourceStringLength) + { + Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSourceIndex; + + *Buffer = Temp8; + Buffer += 1; + + TempPointer = (NATIVE_CHAR *) Buffer; + + /* + * Copy the string + */ + STRCPY (TempPointer, LinkedList->Data.Address32.ResourceSource); + + /* + * Buffer needs to be set to the length of the sting + one for the + * terminating null + */ + Buffer += (STRLEN (LinkedList->Data.Address32.ResourceSource) + 1); + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + /* + * Set the length field to the number of bytes consumed + * minus the header size (3 bytes) + */ + *LengthField = (UINT16) (*BytesConsumed - 3); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c b/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c new file mode 100644 index 0000000..5911adf --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c @@ -0,0 +1,986 @@ +/******************************************************************************* + * + * Module Name: rscalc - AcpiRsCalculateByteStreamLength + * AcpiRsCalculateListLength + * $Revision: 11 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSCALC_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rscalc") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCalculateByteStreamLength + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * SizeNeeded - UINT32 pointer of the size buffer needed + * to properly return the parsed data + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource byte stream and parses it once, calculating + * the size buffer needed to hold the linked list that conveys + * the resource data. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCalculateByteStreamLength ( + RESOURCE *LinkedList, + UINT32 *SizeNeeded) +{ + UINT32 ByteStreamSizeNeeded = 0; + UINT32 SegmentSize; + EXTENDED_IRQ_RESOURCE *ExIrq = NULL; + BOOLEAN Done = FALSE; + + + FUNCTION_TRACE ("RsCalculateByteStreamLength"); + + + while (!Done) + { + + /* + * Init the variable that will hold the size to add to the + * total. + */ + SegmentSize = 0; + + switch (LinkedList->Id) + { + case Irq: + /* + * IRQ Resource + */ + /* + * For an IRQ Resource, Byte 3, although optional, will + * always be created - it holds IRQ information. + */ + SegmentSize = 4; + break; + + case Dma: + /* + * DMA Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 3; + break; + + case StartDependentFunctions: + /* + * Start Dependent Functions Resource + */ + /* + * For a StartDependentFunctions Resource, Byte 1, + * although optional, will always be created. + */ + SegmentSize = 2; + break; + + case EndDependentFunctions: + /* + * End Dependent Functions Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 1; + break; + + case Io: + /* + * IO Port Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 8; + break; + + case FixedIo: + /* + * Fixed IO Port Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 4; + break; + + case VendorSpecific: + /* + * Vendor Defined Resource + */ + /* + * For a Vendor Specific resource, if the Length is + * between 1 and 7 it will be created as a Small + * Resource data type, otherwise it is a Large + * Resource data type. + */ + if(LinkedList->Data.VendorSpecific.Length > 7) + { + SegmentSize = 3; + } + else + { + SegmentSize = 1; + } + SegmentSize += + LinkedList->Data.VendorSpecific.Length; + break; + + case EndTag: + /* + * End Tag + */ + /* + * For this resource the size is static + */ + SegmentSize = 2; + Done = TRUE; + break; + + case Memory24: + /* + * 24-Bit Memory Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 12; + break; + + case Memory32: + /* + * 32-Bit Memory Range Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 20; + break; + + case FixedMemory32: + /* + * 32-Bit Fixed Memory Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 12; + break; + + case Address16: + /* + * 16-Bit Address Resource + */ + /* + * The base size of this byte stream is 16. If a + * Resource Source string is not NULL, add 1 for + * the Index + the length of the null terminated + * string Resource Source + 1 for the null. + */ + SegmentSize = 16; + + if(NULL != LinkedList->Data.Address16.ResourceSource) + { + SegmentSize += (1 + + LinkedList->Data.Address16.ResourceSourceStringLength); + } + break; + + case Address32: + /* + * 32-Bit Address Resource + */ + /* + * The base size of this byte stream is 26. If a Resource + * Source string is not NULL, add 1 for the Index + the + * length of the null terminated string Resource Source + + * 1 for the null. + */ + SegmentSize = 26; + + if(NULL != LinkedList->Data.Address16.ResourceSource) + { + SegmentSize += (1 + + LinkedList->Data.Address16.ResourceSourceStringLength); + } + break; + + case ExtendedIrq: + /* + * Extended IRQ Resource + */ + /* + * The base size of this byte stream is 9. This is for an + * Interrupt table length of 1. For each additional + * interrupt, add 4. + * If a Resource Source string is not NULL, add 1 for the + * Index + the length of the null terminated string + * Resource Source + 1 for the null. + */ + SegmentSize = 9; + + SegmentSize += + (LinkedList->Data.ExtendedIrq.NumberOfInterrupts - + 1) * 4; + + if(NULL != ExIrq->ResourceSource) + { + SegmentSize += (1 + + LinkedList->Data.ExtendedIrq.ResourceSourceStringLength); + } + break; + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + + } /* switch (LinkedList->Id) */ + + /* + * Update the total + */ + ByteStreamSizeNeeded += SegmentSize; + + /* + * Point to the next object + */ + LinkedList = (RESOURCE *) ((NATIVE_UINT) LinkedList + + (NATIVE_UINT) LinkedList->Length); + } + + /* + * This is the data the caller needs + */ + *SizeNeeded = ByteStreamSizeNeeded; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCalculateListLength + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream + * ByteStreamBufferLength - Size of ByteStreamBuffer + * SizeNeeded - UINT32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource byte stream and parses it once, calculating + * the size buffer needed to hold the linked list that conveys + * the resource data. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCalculateListLength ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT32 *SizeNeeded) +{ + UINT32 BufferSize = 0; + UINT32 BytesParsed = 0; + UINT8 NumberOfInterrupts = 0; + UINT8 NumberOfChannels = 0; + UINT8 ResourceType; + UINT32 StructureSize; + UINT32 BytesConsumed; + UINT8 *Buffer; + UINT8 Temp8; + UINT16 Temp16; + UINT8 Index; + UINT8 AdditionalBytes; + + + FUNCTION_TRACE ("RsCalculateListLength"); + + + while (BytesParsed < ByteStreamBufferLength) + { + /* + * Look at the next byte in the stream + */ + ResourceType = *ByteStreamBuffer; + + /* + * See if this is a small or large resource + */ + if(ResourceType & 0x80) + { + /* + * Large Resource Type + */ + switch (ResourceType) + { + case MEMORY_RANGE_24: + /* + * 24-Bit Memory Resource + */ + BytesConsumed = 12; + + StructureSize = sizeof (MEMORY24_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + case LARGE_VENDOR_DEFINED: + /* + * Vendor Defined Resource + */ + Buffer = ByteStreamBuffer; + ++Buffer; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + BytesConsumed = Temp16 + 3; + + /* + * Ensure a 32-bit boundary for the structure + */ + Temp16 = (UINT16) ROUND_UP_TO_32BITS (Temp16); + + StructureSize = sizeof (VENDOR_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp16 * sizeof (UINT8)); + break; + + case MEMORY_RANGE_32: + /* + * 32-Bit Memory Range Resource + */ + + BytesConsumed = 20; + + StructureSize = sizeof (MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + case FIXED_MEMORY_RANGE_32: + /* + * 32-Bit Fixed Memory Resource + */ + BytesConsumed = 12; + + StructureSize = sizeof(FIXED_MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + case DWORD_ADDRESS_SPACE: + /* + * 32-Bit Address Resource + */ + Buffer = ByteStreamBuffer; + + ++Buffer; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + BytesConsumed = Temp16 + 3; + + /* + * Resource Source Index and Resource Source are + * optional elements. Check the length of the + * Bytestream. If it is greater than 23, that + * means that an Index exists and is followed by + * a null termininated string. Therefore, set + * the temp variable to the length minus the minimum + * byte stream length plus the byte for the Index to + * determine the size of the NULL terminiated string. + */ + if (23 < Temp16) + { + Temp8 = (UINT8) (Temp16 - 24); + } + else + { + Temp8 = 0; + } + + /* + * Ensure a 32-bit boundary for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + + StructureSize = sizeof (ADDRESS32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp8 * sizeof (UINT8)); + break; + + case WORD_ADDRESS_SPACE: + /* + * 16-Bit Address Resource + */ + Buffer = ByteStreamBuffer; + + ++Buffer; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + BytesConsumed = Temp16 + 3; + + /* + * Resource Source Index and Resource Source are + * optional elements. Check the length of the + * Bytestream. If it is greater than 13, that + * means that an Index exists and is followed by + * a null termininated string. Therefore, set + * the temp variable to the length minus the minimum + * byte stream length plus the byte for the Index to + * determine the size of the NULL terminiated string. + */ + if (13 < Temp16) + { + Temp8 = (UINT8) (Temp16 - 14); + } + else + { + Temp8 = 0; + } + + /* + * Ensure a 32-bit boundry for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + + StructureSize = sizeof (ADDRESS16_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp8 * sizeof (UINT8)); + break; + + case EXTENDED_IRQ: + /* + * Extended IRQ + */ + Buffer = ByteStreamBuffer; + + ++Buffer; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + BytesConsumed = Temp16 + 3; + + /* + * Point past the length field and the + * Interrupt vector flags to save off the + * Interrupt table length to the Temp8 variable. + */ + Buffer += 3; + Temp8 = *Buffer; + + /* + * To compensate for multiple interrupt numbers, + * Add 4 bytes for each additional interrupts + * greater than 1 + */ + AdditionalBytes = (UINT8) ((Temp8 - 1) * 4); + + /* + * Resource Source Index and Resource Source are + * optional elements. Check the length of the + * Bytestream. If it is greater than 9, that + * means that an Index exists and is followed by + * a null termininated string. Therefore, set + * the temp variable to the length minus the minimum + * byte stream length plus the byte for the Index to + * determine the size of the NULL terminiated string. + */ + if (9 + AdditionalBytes < Temp16) + { + Temp8 = (UINT8) (Temp16 - (9 + AdditionalBytes)); + } + + else + { + Temp8 = 0; + } + + /* + * Ensure a 32-bit boundry for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + + StructureSize = sizeof (EXTENDED_IRQ_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (AdditionalBytes * sizeof (UINT8)) + + (Temp8 * sizeof (UINT8)); + + break; + +/* TBD: [Future] 64-bit not currently supported */ +/* + case 0x8A: + break; +*/ + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + } + } + + else + { + /* + * Small Resource Type + * Only bits 7:3 are valid + */ + ResourceType >>= 3; + + switch (ResourceType) + { + case IRQ_FORMAT: + /* + * IRQ Resource + */ + /* + * Determine if it there are two or three + * trailing bytes + */ + Buffer = ByteStreamBuffer; + Temp8 = *Buffer; + + if(Temp8 & 0x01) + { + BytesConsumed = 4; + } + + else + { + BytesConsumed = 3; + } + + /* + * Point past the descriptor + */ + ++Buffer; + + /* + * Look at the number of bits set + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + for (Index = 0; Index < 16; Index++) + { + if (Temp16 & 0x1) + { + ++NumberOfInterrupts; + } + + Temp16 >>= 1; + } + + StructureSize = sizeof (IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (NumberOfInterrupts * sizeof (UINT32)); + break; + + + case DMA_FORMAT: + + /* + * DMA Resource + */ + Buffer = ByteStreamBuffer; + + BytesConsumed = 3; + + /* + * Point past the descriptor + */ + ++Buffer; + + /* + * Look at the number of bits set + */ + Temp8 = *Buffer; + + for(Index = 0; Index < 8; Index++) + { + if(Temp8 & 0x1) + { + ++NumberOfChannels; + } + + Temp8 >>= 1; + } + + StructureSize = sizeof (DMA_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (NumberOfChannels * sizeof (UINT32)); + break; + + + case START_DEPENDENT_TAG: + + /* + * Start Dependent Functions Resource + */ + /* + * Determine if it there are two or three trailing bytes + */ + Buffer = ByteStreamBuffer; + Temp8 = *Buffer; + + if(Temp8 & 0x01) + { + BytesConsumed = 2; + } + else + { + BytesConsumed = 1; + } + + + StructureSize = + sizeof (START_DEPENDENT_FUNCTIONS_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + + case END_DEPENDENT_TAG: + + /* + * End Dependent Functions Resource + */ + BytesConsumed = 1; + StructureSize = RESOURCE_LENGTH; + break; + + + case IO_PORT_DESCRIPTOR: + /* + * IO Port Resource + */ + BytesConsumed = 8; + StructureSize = sizeof (IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + + case FIXED_LOCATION_IO_DESCRIPTOR: + + /* + * Fixed IO Port Resource + */ + BytesConsumed = 4; + StructureSize = sizeof (FIXED_IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + + case SMALL_VENDOR_DEFINED: + + /* + * Vendor Specific Resource + */ + Buffer = ByteStreamBuffer; + + Temp8 = *Buffer; + Temp8 = (UINT8) (Temp8 & 0x7); + BytesConsumed = Temp8 + 1; + + /* + * Ensure a 32-bit boundry for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + StructureSize = sizeof (VENDOR_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp8 * sizeof (UINT8)); + break; + + + case END_TAG: + + /* + * End Tag + */ + BytesConsumed = 2; + StructureSize = RESOURCE_LENGTH; + break; + + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + + } /* switch */ + + } /* if(ResourceType & 0x80) */ + + /* + * Update the return value and counter + */ + BufferSize += StructureSize; + BytesParsed += BytesConsumed; + + /* + * Set the byte stream to point to the next resource + */ + ByteStreamBuffer += BytesConsumed; + + } + + /* + * This is the data the caller needs + */ + *SizeNeeded = BufferSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCalculatePciRoutingTableLength + * + * PARAMETERS: PackageObject - Pointer to the package object + * BufferSizeNeeded - UINT32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status AE_OK + * + * DESCRIPTION: Given a package representing a PCI routing table, this + * calculates the size of the corresponding linked list of + * descriptions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCalculatePciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + UINT32 *BufferSizeNeeded) +{ + UINT32 NumberOfElements; + UINT32 TempSizeNeeded; + ACPI_OPERAND_OBJECT **TopObjectList; + UINT32 Index; + ACPI_OPERAND_OBJECT *PackageElement; + ACPI_OPERAND_OBJECT **SubObjectList; + BOOLEAN NameFound; + UINT32 TableIndex; + + + FUNCTION_TRACE ("AcpiRsCalculatePciRoutingTableLength"); + + + 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. + * + * NOTE: The NumberOfElements is incremented by one to add an end + * table structure that is essentially a structure of zeros. + */ + TempSizeNeeded = (NumberOfElements + 1) * + (sizeof (PCI_ROUTING_TABLE) - 1); + + /* + * But each PRT_ENTRY structure has a pointer to a string and + * the size of that string must be found. + */ + TopObjectList = PackageObject->Package.Elements; + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* + * Dereference the sub-package + */ + PackageElement = *TopObjectList; + + /* + * The SubObjectList will now point to an array of the + * four IRQ elements: Address, Pin, Source and SourceIndex + */ + SubObjectList = PackageElement->Package.Elements; + + /* + * Scan the IrqTableElements for the Source Name String + */ + NameFound = FALSE; + + for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) + { + if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + { + NameFound = TRUE; + } + + else + { + /* + * Look at the next element + */ + SubObjectList++; + } + } + + /* + * Was a String type found? + */ + if (TRUE == NameFound) + { + /* + * The length String.Length field includes the + * terminating NULL + */ + TempSizeNeeded += (*SubObjectList)->String.Length; + } + + else + { + /* + * If no name was found, then this is a NULL, which is + * translated as a UINT32 zero. + */ + TempSizeNeeded += sizeof(UINT32); + } + + /* + * Point to the next ACPI_OPERAND_OBJECT + */ + TopObjectList++; + } + + /* Align the count before returning it */ + + *BufferSizeNeeded = ROUND_UP_TO_32BITS (TempSizeNeeded); + + return_ACPI_STATUS (AE_OK); +} \ No newline at end of file diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c b/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c new file mode 100644 index 0000000..07f3f51 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c @@ -0,0 +1,548 @@ +/******************************************************************************* + * + * Module Name: rscreate - AcpiRsCreateResourceList + * AcpiRsCreatePciRoutingTable + * AcpiRsCreateByteStream + * $Revision: 19 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSCREATE_C__ + +#include "acpi.h" +#include "acresrc.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rscreate") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateResourceList + * + * PARAMETERS: + * ByteStreamBuffer - Pointer to the resource byte stream + * OutputBuffer - Pointer to the user's buffer + * OutputBufferLength - Pointer to the size of OutputBuffer + * + * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code + * If OutputBuffer is not large enough, OutputBufferLength + * indicates how large OutputBuffer should be, else it + * indicates how may UINT8 elements of OutputBuffer are valid. + * + * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method + * execution and parses the stream to create a linked list + * of device resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *ByteStreamBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength) +{ + + ACPI_STATUS Status; + UINT8 *ByteStreamStart = NULL; + UINT32 ListSizeNeeded = 0; + UINT32 ByteStreamBufferLength = 0; + + + FUNCTION_TRACE ("RsCreateResourceList"); + + + DEBUG_PRINT (VERBOSE_INFO, ("RsCreateResourceList: ByteStreamBuffer = %p\n", + ByteStreamBuffer)); + + /* + * Params already validated, so we don't re-validate here + */ + + ByteStreamBufferLength = ByteStreamBuffer->Buffer.Length; + ByteStreamStart = ByteStreamBuffer->Buffer.Pointer; + + /* + * Pass the ByteStreamBuffer into a module that can calculate + * the buffer size needed for the linked list + */ + Status = AcpiRsCalculateListLength (ByteStreamStart, + ByteStreamBufferLength, + &ListSizeNeeded); + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreateResourceList: Status=%d ListSizeNeeded=%d\n", + Status, ListSizeNeeded)); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * If the linked list will fit into the available buffer + * call to fill in the list + */ + + if (ListSizeNeeded <= *OutputBufferLength) + { + /* + * Zero out the return buffer before proceeding + */ + MEMSET (OutputBuffer, 0x00, *OutputBufferLength); + + Status = AcpiRsByteStreamToList (ByteStreamStart, + ByteStreamBufferLength, + &OutputBuffer); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (VERBOSE_INFO, ("RsByteStreamToList: OutputBuffer = %p\n", + OutputBuffer)); + } + + else + { + *OutputBufferLength = ListSizeNeeded; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + *OutputBufferLength = ListSizeNeeded; + return_ACPI_STATUS (AE_OK); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreatePciRoutingTable + * + * PARAMETERS: + * PackageObject - Pointer to an ACPI_OPERAND_OBJECT + * package + * OutputBuffer - Pointer to the user's buffer + * OutputBufferLength - Size of OutputBuffer + * + * 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 OutputBufferLength will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a + * linked list of PCI interrupt descriptions + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength) +{ + UINT8 *Buffer = OutputBuffer; + ACPI_OPERAND_OBJECT **TopObjectList = NULL; + ACPI_OPERAND_OBJECT **SubObjectList = NULL; + ACPI_OPERAND_OBJECT *PackageElement = NULL; + UINT32 BufferSizeNeeded = 0; + UINT32 NumberOfElements = 0; + UINT32 Index = 0; + PCI_ROUTING_TABLE *UserPrt = NULL; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("RsCreatePciRoutingTable"); + + + /* + * Params already validated, so we don't re-validate here + */ + + Status = AcpiRsCalculatePciRoutingTableLength(PackageObject, + &BufferSizeNeeded); + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreatePciRoutingTable: BufferSizeNeeded = %d\n", + BufferSizeNeeded)); + + /* + * If the data will fit into the available buffer + * call to fill in the list + */ + if (BufferSizeNeeded <= *OutputBufferLength) + { + /* + * Zero out the return buffer before proceeding + */ + MEMSET (OutputBuffer, 0x00, *OutputBufferLength); + + /* + * Loop through the ACPI_INTERNAL_OBJECTS - Each object should + * contain a UINT32 Address, a UINT8 Pin, a Name and a UINT8 + * SourceIndex. + */ + TopObjectList = PackageObject->Package.Elements; + NumberOfElements = PackageObject->Package.Count; + UserPrt = (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; + Buffer = ROUND_PTR_UP_TO_4 (Buffer, UINT8); + UserPrt = (PCI_ROUTING_TABLE *) Buffer; + + /* + * Fill in the Length field with the information we + * have at this point. + * The minus one is to subtract the size of the + * UINT8 Source[1] member because it is added below. + */ + UserPrt->Length = (sizeof (PCI_ROUTING_TABLE) - 1); + + /* + * Dereference the sub-package + */ + PackageElement = *TopObjectList; + + /* + * The SubObjectList will now point to an array of + * the four IRQ elements: Address, Pin, Source and + * SourceIndex + */ + SubObjectList = PackageElement->Package.Elements; + + /* + * Dereference the Address + */ + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + UserPrt->Data.Address = + (*SubObjectList)->Number.Value; + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Dereference the Pin + */ + SubObjectList++; + + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + UserPrt->Data.Pin = + (UINT32) (*SubObjectList)->Number.Value; + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Dereference the Source Name + */ + SubObjectList++; + + if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + { + STRCPY (UserPrt->Data.Source, + (*SubObjectList)->String.Pointer); + + /* + * Add to the Length field the length of the string + */ + UserPrt->Length += (*SubObjectList)->String.Length; + } + + else + { + /* + * If this is a number, then the Source Name + * is NULL, since the entire buffer was zeroed + * out, we can leave this alone. + */ + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + /* + * Add to the Length field the length of + * the UINT32 NULL + */ + UserPrt->Length += sizeof (UINT32); + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* Now align the current length */ + + UserPrt->Length = ROUND_UP_TO_32BITS (UserPrt->Length); + + /* + * Dereference the Source Index + */ + SubObjectList++; + + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + UserPrt->Data.SourceIndex = + (UINT32) (*SubObjectList)->Number.Value; + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Point to the next ACPI_OPERAND_OBJECT + */ + TopObjectList++; + } + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreatePciRoutingTable: OutputBuffer = %p\n", + OutputBuffer)); + } + + else + { + *OutputBufferLength = BufferSizeNeeded; + + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + /* + * Report the amount of buffer used + */ + *OutputBufferLength = BufferSizeNeeded; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateByteStream + * + * PARAMETERS: + * LinkedListBuffer - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's buffer + * OutputBufferLength - Size of OutputBuffer + * + * 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 OutputBufferLength will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the linked list of device resources and + * creates a bytestream to be used as input for the + * _SRS control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateByteStream ( + RESOURCE *LinkedListBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength) +{ + ACPI_STATUS Status; + UINT32 ByteStreamSizeNeeded = 0; + + + FUNCTION_TRACE ("RsCreateByteStream"); + + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreateByteStream: LinkedListBuffer = %p\n", + LinkedListBuffer)); + + /* + * Params already validated, so we don't re-validate here + * + * Pass the LinkedListBuffer into a module that can calculate + * the buffer size needed for the byte stream. + */ + Status = AcpiRsCalculateByteStreamLength (LinkedListBuffer, + &ByteStreamSizeNeeded); + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreateByteStream: ByteStreamSizeNeeded=%d, %s\n", + ByteStreamSizeNeeded, + AcpiCmFormatException (Status))); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * If the linked list will fit into the available buffer + * call to fill in the list + */ + + if (ByteStreamSizeNeeded <= *OutputBufferLength) + { + /* + * Zero out the return buffer before proceeding + */ + MEMSET (OutputBuffer, 0x00, *OutputBufferLength); + + Status = AcpiRsListToByteStream (LinkedListBuffer, + ByteStreamSizeNeeded, + &OutputBuffer); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (VERBOSE_INFO, + ("RsListToByteStream: OutputBuffer = %p\n", + OutputBuffer)); + } + else + { + *OutputBufferLength = ByteStreamSizeNeeded; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c new file mode 100644 index 0000000..8df18fb --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c @@ -0,0 +1,1044 @@ +/******************************************************************************* + * + * Module Name: rsdump - Functions do dump out the resource structures. + * $Revision: 11 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSDUMP_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsdump") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIrq + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpIrq ( + RESOURCE_DATA *Data) +{ + IRQ_RESOURCE *IrqData = (IRQ_RESOURCE*) Data; + UINT8 Index = 0; + + + AcpiOsPrintf ("\tIRQ Resource\n"); + + AcpiOsPrintf ("\t\t%s Triggered\n", + LEVEL_SENSITIVE == IrqData->EdgeLevel ? + "Level" : "Edge"); + + AcpiOsPrintf ("\t\tActive %s\n", + ACTIVE_LOW == IrqData->ActiveHighLow ? + "Low" : "High"); + + AcpiOsPrintf ("\t\t%s\n", + SHARED == IrqData->SharedExclusive ? + "Shared" : "Exclusive"); + + AcpiOsPrintf ("\t\t%d Interrupts ( ", + IrqData->NumberOfInterrupts); + + for (Index = 0; Index < IrqData->NumberOfInterrupts; Index++) + { + AcpiOsPrintf ("%d ", IrqData->Interrupts[Index]); + } + + AcpiOsPrintf (")\n"); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpDma + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpDma ( + RESOURCE_DATA *Data) +{ + DMA_RESOURCE *DmaData = (DMA_RESOURCE*) Data; + UINT8 Index = 0; + + + AcpiOsPrintf ("\tDMA Resource\n"); + + switch (DmaData->Type) + { + case COMPATIBILITY: + AcpiOsPrintf ("\t\tCompatibility mode\n"); + break; + + case TYPE_A: + AcpiOsPrintf ("\t\tType A\n"); + break; + + case TYPE_B: + AcpiOsPrintf ("\t\tType B\n"); + break; + + case TYPE_F: + AcpiOsPrintf ("\t\tType F\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid DMA type\n"); + break; + } + + AcpiOsPrintf ("\t\t%sBus Master\n", + BUS_MASTER == DmaData->BusMaster ? + "" : "Not a "); + + switch (DmaData->Transfer) + { + case TRANSFER_8: + AcpiOsPrintf ("\t\t8-bit only transfer\n"); + break; + + case TRANSFER_8_16: + AcpiOsPrintf ("\t\t8 and 16-bit transfer\n"); + break; + + case TRANSFER_16: + AcpiOsPrintf ("\t\t16 bit only transfer\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid transfer preference\n"); + break; + } + + AcpiOsPrintf ("\t\tNumber of Channels: %d ( ", + DmaData->NumberOfChannels); + + for (Index = 0; Index < DmaData->NumberOfChannels; Index++) + { + AcpiOsPrintf ("%d ", DmaData->Channels[Index]); + } + + AcpiOsPrintf (")\n"); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpStartDependentFunctions + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpStartDependentFunctions ( + RESOURCE_DATA *Data) +{ + START_DEPENDENT_FUNCTIONS_RESOURCE *SdfData = + (START_DEPENDENT_FUNCTIONS_RESOURCE*) Data; + + + AcpiOsPrintf ("\tStart Dependent Functions Resource\n"); + + switch (SdfData->CompatibilityPriority) + { + case GOOD_CONFIGURATION: + AcpiOsPrintf ("\t\tGood configuration\n"); + break; + + case ACCEPTABLE_CONFIGURATION: + AcpiOsPrintf ("\t\tAcceptable configuration\n"); + break; + + case SUB_OPTIMAL_CONFIGURATION: + AcpiOsPrintf ("\t\tSub-optimal configuration\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid compatibility priority\n"); + break; + } + + switch(SdfData->PerformanceRobustness) + { + case GOOD_CONFIGURATION: + AcpiOsPrintf ("\t\tGood configuration\n"); + break; + + case ACCEPTABLE_CONFIGURATION: + AcpiOsPrintf ("\t\tAcceptable configuration\n"); + break; + + case SUB_OPTIMAL_CONFIGURATION: + AcpiOsPrintf ("\t\tSub-optimal configuration\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid performance " + "robustness preference\n"); + break; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIo + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpIo ( + RESOURCE_DATA *Data) +{ + IO_RESOURCE *IoData = (IO_RESOURCE*) Data; + + + AcpiOsPrintf ("\tIo Resource\n"); + + AcpiOsPrintf ("\t\t%d bit decode\n", + DECODE_16 == IoData->IoDecode ? 16 : 10); + + AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n", + IoData->MinBaseAddress); + + AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n", + IoData->MaxBaseAddress); + + AcpiOsPrintf ("\t\tAlignment: 0x%08x\n", + IoData->Alignment); + + AcpiOsPrintf ("\t\tRange Length: 0x%08x\n", + IoData->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpFixedIo + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpFixedIo ( + RESOURCE_DATA *Data) +{ + FIXED_IO_RESOURCE *FixedIoData = (FIXED_IO_RESOURCE*) Data; + + + AcpiOsPrintf ("\tFixed Io Resource\n"); + AcpiOsPrintf ("\t\tRange base address: 0x%08x", + FixedIoData->BaseAddress); + + AcpiOsPrintf ("\t\tRange length: 0x%08x", + FixedIoData->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpVendorSpecific + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpVendorSpecific ( + RESOURCE_DATA *Data) +{ + VENDOR_RESOURCE *VendorData = (VENDOR_RESOURCE*) Data; + UINT16 Index = 0; + + + AcpiOsPrintf ("\tVendor Specific Resource\n"); + + AcpiOsPrintf ("\t\tLength: 0x%08x\n", VendorData->Length); + + for (Index = 0; Index < VendorData->Length; Index++) + { + AcpiOsPrintf ("\t\tByte %d: 0x%08x\n", + Index, VendorData->Reserved[Index]); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpMemory24 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpMemory24 ( + RESOURCE_DATA *Data) +{ + MEMORY24_RESOURCE *Memory24Data = (MEMORY24_RESOURCE*) Data; + + + AcpiOsPrintf ("\t24-Bit Memory Range Resource\n"); + + AcpiOsPrintf ("\t\tRead%s\n", + READ_WRITE_MEMORY == + Memory24Data->ReadWriteAttribute ? + "/Write" : " only"); + + AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n", + Memory24Data->MinBaseAddress); + + AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n", + Memory24Data->MaxBaseAddress); + + AcpiOsPrintf ("\t\tAlignment: 0x%08x\n", + Memory24Data->Alignment); + + AcpiOsPrintf ("\t\tRange length: 0x%08x\n", + Memory24Data->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpMemory32 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpMemory32 ( + RESOURCE_DATA *Data) +{ + MEMORY32_RESOURCE *Memory32Data = (MEMORY32_RESOURCE*) Data; + + + AcpiOsPrintf ("\t32-Bit Memory Range Resource\n"); + + AcpiOsPrintf ("\t\tRead%s\n", + READ_WRITE_MEMORY == + Memory32Data->ReadWriteAttribute ? + "/Write" : " only"); + + AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n", + Memory32Data->MinBaseAddress); + + AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n", + Memory32Data->MaxBaseAddress); + + AcpiOsPrintf ("\t\tAlignment: 0x%08x\n", + Memory32Data->Alignment); + + AcpiOsPrintf ("\t\tRange length: 0x%08x\n", + Memory32Data->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpFixedMemory32 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpFixedMemory32 ( + RESOURCE_DATA *Data) +{ + FIXED_MEMORY32_RESOURCE *FixedMemory32Data = (FIXED_MEMORY32_RESOURCE*) Data; + + + AcpiOsPrintf ("\t32-Bit Fixed Location Memory Range Resource\n"); + + AcpiOsPrintf ("\t\tRead%s\n", + READ_WRITE_MEMORY == + FixedMemory32Data->ReadWriteAttribute ? + "/Write" : " Only"); + + AcpiOsPrintf ("\t\tRange base address: 0x%08x\n", + FixedMemory32Data->RangeBaseAddress); + + AcpiOsPrintf ("\t\tRange length: 0x%08x\n", + FixedMemory32Data->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpAddress16 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpAddress16 ( + RESOURCE_DATA *Data) +{ + ADDRESS16_RESOURCE *Address16Data = (ADDRESS16_RESOURCE*) Data; + + + AcpiOsPrintf ("\t16-Bit Address Space Resource\n"); + AcpiOsPrintf ("\t\tResource Type: "); + + switch (Address16Data->ResourceType) + { + case MEMORY_RANGE: + + AcpiOsPrintf ("Memory Range\n"); + + switch (Address16Data->Attribute.Memory.CacheAttribute) + { + case NON_CACHEABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Noncacheable memory\n"); + break; + + case CACHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Cacheable memory\n"); + break; + + case WRITE_COMBINING_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Write-combining memory\n"); + break; + + case PREFETCHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Prefetchable memory\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid cache attribute\n"); + break; + } + + AcpiOsPrintf ("\t\tType Specific: Read%s\n", + READ_WRITE_MEMORY == + Address16Data->Attribute.Memory.ReadWriteAttribute ? + "/Write" : " Only"); + break; + + case IO_RANGE: + + AcpiOsPrintf ("I/O Range\n"); + + switch (Address16Data->Attribute.Io.RangeAttribute) + { + case NON_ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "Non-ISA Io Addresses\n"); + break; + + case ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "ISA Io Addresses\n"); + break; + + case ENTIRE_RANGE: + AcpiOsPrintf ("\t\tType Specific: " + "ISA and non-ISA Io Addresses\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid range attribute\n"); + break; + } + break; + + case BUS_NUMBER_RANGE: + + AcpiOsPrintf ("Bus Number Range\n"); + break; + + default: + + AcpiOsPrintf ("Invalid resource type. Exiting.\n"); + return; + } + + AcpiOsPrintf ("\t\tResource %s\n", + CONSUMER == Address16Data->ProducerConsumer ? + "Consumer" : "Producer"); + + AcpiOsPrintf ("\t\t%s decode\n", + SUB_DECODE == Address16Data->Decode ? + "Subtractive" : "Positive"); + + AcpiOsPrintf ("\t\tMin address is %s fixed\n", + ADDRESS_FIXED == Address16Data->MinAddressFixed ? + "" : "not"); + + AcpiOsPrintf ("\t\tMax address is %s fixed\n", + ADDRESS_FIXED == Address16Data->MaxAddressFixed ? + "" : "not"); + + AcpiOsPrintf ("\t\tGranularity: 0x%08x\n", + Address16Data->Granularity); + + AcpiOsPrintf ("\t\tAddress range min: 0x%08x\n", + Address16Data->MinAddressRange); + + AcpiOsPrintf ("\t\tAddress range max: 0x%08x\n", + Address16Data->MaxAddressRange); + + AcpiOsPrintf ("\t\tAddress translation offset: 0x%08x\n", + Address16Data->AddressTranslationOffset); + + AcpiOsPrintf ("\t\tAddress Length: 0x%08x\n", + Address16Data->AddressLength); + + if (0xFF != Address16Data->ResourceSourceIndex) + { + AcpiOsPrintf ("\t\tResource Source Index: %d\n", + Address16Data->ResourceSourceIndex); + AcpiOsPrintf ("\t\tResource Source: %s\n", + Address16Data->ResourceSource); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpAddress32 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpAddress32 ( + RESOURCE_DATA *Data) +{ + ADDRESS32_RESOURCE *Address32Data = (ADDRESS32_RESOURCE*) Data; + + + AcpiOsPrintf ("\t32-Bit Address Space Resource\n"); + + switch (Address32Data->ResourceType) + { + case MEMORY_RANGE: + + AcpiOsPrintf ("\t\tResource Type: Memory Range\n"); + + switch (Address32Data->Attribute.Memory.CacheAttribute) + { + case NON_CACHEABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Noncacheable memory\n"); + break; + + case CACHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Cacheable memory\n"); + break; + + case WRITE_COMBINING_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Write-combining memory\n"); + break; + + case PREFETCHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Prefetchable memory\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid cache attribute\n"); + break; + } + + AcpiOsPrintf ("\t\tType Specific: Read%s\n", + READ_WRITE_MEMORY == + Address32Data->Attribute.Memory.ReadWriteAttribute ? + "/Write" : " Only"); + break; + + case IO_RANGE: + + AcpiOsPrintf ("\t\tResource Type: Io Range\n"); + + switch (Address32Data->Attribute.Io.RangeAttribute) + { + case NON_ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "Non-ISA Io Addresses\n"); + break; + + case ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "ISA Io Addresses\n"); + break; + + case ENTIRE_RANGE: + AcpiOsPrintf ("\t\tType Specific: " + "ISA and non-ISA Io Addresses\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid Range attribute"); + break; + } + break; + + case BUS_NUMBER_RANGE: + + AcpiOsPrintf ("\t\tResource Type: Bus Number Range\n"); + break; + + default: + + AcpiOsPrintf ("\t\tInvalid Resource Type..exiting.\n"); + return; + } + + AcpiOsPrintf ("\t\tResource %s\n", + CONSUMER == Address32Data->ProducerConsumer ? + "Consumer" : "Producer"); + + AcpiOsPrintf ("\t\t%s decode\n", + SUB_DECODE == Address32Data->Decode ? + "Subtractive" : "Positive"); + + AcpiOsPrintf ("\t\tMin address is %s fixed\n", + ADDRESS_FIXED == Address32Data->MinAddressFixed ? + "" : "not "); + + AcpiOsPrintf ("\t\tMax address is %s fixed\n", + ADDRESS_FIXED == Address32Data->MaxAddressFixed ? + "" : "not "); + + AcpiOsPrintf ("\t\tGranularity: 0x%08x\n", + Address32Data->Granularity); + + AcpiOsPrintf ("\t\tAddress range min: 0x%08x\n", + Address32Data->MinAddressRange); + + AcpiOsPrintf ("\t\tAddress range max: 0x%08x\n", + Address32Data->MaxAddressRange); + + AcpiOsPrintf ("\t\tAddress translation offset: 0x%08x\n", + Address32Data->AddressTranslationOffset); + + AcpiOsPrintf ("\t\tAddress Length: 0x%08x\n", + Address32Data->AddressLength); + + if(0xFF != Address32Data->ResourceSourceIndex) + { + AcpiOsPrintf ("\t\tResource Source Index: %d\n", + Address32Data->ResourceSourceIndex); + AcpiOsPrintf ("\t\tResource Source: %s\n", + Address32Data->ResourceSource); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpExtendedIrq + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpExtendedIrq ( + RESOURCE_DATA *Data) +{ + EXTENDED_IRQ_RESOURCE *ExtIrqData = (EXTENDED_IRQ_RESOURCE*) Data; + UINT8 Index = 0; + + + AcpiOsPrintf ("\tExtended IRQ Resource\n"); + + AcpiOsPrintf ("\t\tResource %s\n", + CONSUMER == ExtIrqData->ProducerConsumer ? + "Consumer" : "Producer"); + + AcpiOsPrintf ("\t\t%s\n", + LEVEL_SENSITIVE == ExtIrqData->EdgeLevel ? + "Level" : "Edge"); + + AcpiOsPrintf ("\t\tActive %s\n", + ACTIVE_LOW == ExtIrqData->ActiveHighLow ? + "low" : "high"); + + AcpiOsPrintf ("\t\t%s\n", + SHARED == ExtIrqData->SharedExclusive ? + "Shared" : "Exclusive"); + + AcpiOsPrintf ("\t\tInterrupts : %d ( ", + ExtIrqData->NumberOfInterrupts); + + for (Index = 0; Index < ExtIrqData->NumberOfInterrupts; Index++) + { + AcpiOsPrintf ("%d ", ExtIrqData->Interrupts[Index]); + } + + AcpiOsPrintf (")\n"); + + if(0xFF != ExtIrqData->ResourceSourceIndex) + { + AcpiOsPrintf ("\t\tResource Source Index: %d", + ExtIrqData->ResourceSourceIndex); + AcpiOsPrintf ("\t\tResource Source: %s", + ExtIrqData->ResourceSource); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceList + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Dispatches the structure to the correct dump routine. + * + ******************************************************************************/ + +void +AcpiRsDumpResourceList ( + RESOURCE *Resource) +{ + UINT8 Count = 0; + BOOLEAN Done = FALSE; + + + if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer) + { + while (!Done) + { + AcpiOsPrintf ("\tResource structure %x.\n", Count++); + + switch (Resource->Id) + { + case Irq: + AcpiRsDumpIrq (&Resource->Data); + break; + + case Dma: + AcpiRsDumpDma (&Resource->Data); + break; + + case StartDependentFunctions: + AcpiRsDumpStartDependentFunctions (&Resource->Data); + break; + + case EndDependentFunctions: + AcpiOsPrintf ("\tEndDependentFunctions Resource\n"); + /* AcpiRsDumpEndDependentFunctions (Resource->Data);*/ + break; + + case Io: + AcpiRsDumpIo (&Resource->Data); + break; + + case FixedIo: + AcpiRsDumpFixedIo (&Resource->Data); + break; + + case VendorSpecific: + AcpiRsDumpVendorSpecific (&Resource->Data); + break; + + case EndTag: + /*RsDumpEndTag (Resource->Data);*/ + AcpiOsPrintf ("\tEndTag Resource\n"); + Done = TRUE; + break; + + case Memory24: + AcpiRsDumpMemory24 (&Resource->Data); + break; + + case Memory32: + AcpiRsDumpMemory32 (&Resource->Data); + break; + + case FixedMemory32: + AcpiRsDumpFixedMemory32 (&Resource->Data); + break; + + case Address16: + AcpiRsDumpAddress16 (&Resource->Data); + break; + + case Address32: + AcpiRsDumpAddress32 (&Resource->Data); + break; + + case ExtendedIrq: + AcpiRsDumpExtendedIrq (&Resource->Data); + break; + + default: + AcpiOsPrintf ("Invalid resource type\n"); + break; + + } + + Resource = (RESOURCE *) ((NATIVE_UINT) Resource + + (NATIVE_UINT) Resource->Length); + } + } + + return; +} + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIrqList + * + * PARAMETERS: Data - pointer to the routing table to dump. + * + * RETURN: + * + * DESCRIPTION: Dispatches the structures to the correct dump routine. + * + ******************************************************************************/ + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable) +{ + UINT8 *Buffer = RouteTable; + UINT8 Count = 0; + BOOLEAN Done = FALSE; + PCI_ROUTING_TABLE *PrtElement; + + + if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer) + { + PrtElement = (PCI_ROUTING_TABLE *)Buffer; + + while (!Done) + { + AcpiOsPrintf ("\tPCI IRQ Routing Table structure %x.\n", Count++); + + AcpiOsPrintf ("\t\tAddress: 0x%x\n", + PrtElement->Data.Address); + + AcpiOsPrintf ("\t\tPin: 0x%x\n", PrtElement->Data.Pin); + + AcpiOsPrintf ("\t\tSource: %s\n", PrtElement->Data.Source); + + AcpiOsPrintf ("\t\tSourceIndex: 0x%x\n", + PrtElement->Data.SourceIndex); + + Buffer += PrtElement->Length; + + PrtElement = (PCI_ROUTING_TABLE *)Buffer; + + if(0 == PrtElement->Length) + { + Done = TRUE; + } + } + } + + return; +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsio.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsio.c new file mode 100644 index 0000000..0895fcf --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsio.c @@ -0,0 +1,636 @@ +/******************************************************************************* + * + * Module Name: rsio - AcpiRsIoResource + * AcpiRsFixedIoResource + * AcpiRsIoStream + * AcpiRsFixedIoStream + * AcpiRsDmaResource + * AcpiRsDmaStream + * $Revision: 9 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIO_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsio") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIoResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsIoResource"); + + /* + * The number of bytes consumed are Constant + */ + *BytesConsumed = 8; + + OutputStruct->Id = Io; + + /* + * Check Decode + */ + Buffer += 1; + Temp8 = *Buffer; + + OutputStruct->Data.Io.IoDecode = Temp8 & 0x01; + + /* + * Check MinBase Address + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.Io.MinBaseAddress = Temp16; + + /* + * Check MaxBase Address + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.Io.MaxBaseAddress = Temp16; + + /* + * Check Base alignment + */ + Buffer += 2; + Temp8 = *Buffer; + + OutputStruct->Data.Io.Alignment = Temp8; + + /* + * Check RangeLength + */ + Buffer += 1; + Temp8 = *Buffer; + + OutputStruct->Data.Io.RangeLength = Temp8; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedIoResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (FIXED_IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsFixedIoResource"); + + /* + * The number of bytes consumed are Constant + */ + *BytesConsumed = 4; + + OutputStruct->Id = FixedIo; + + /* + * Check Range Base Address + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.FixedIo.BaseAddress = Temp16; + + /* + * Check RangeLength + */ + Buffer += 2; + Temp8 = *Buffer; + + OutputStruct->Data.FixedIo.RangeLength = Temp8; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIoStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsIoStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x47; + Buffer += 1; + + /* + * Io Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01); + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range minimum base address + */ + Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Range maximum base address + */ + Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the base alignment + */ + Temp8 = (UINT8) LinkedList->Data.Io.Alignment; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the range length + */ + Temp8 = (UINT8) LinkedList->Data.Io.RangeLength; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedIoStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsFixedIoStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x4B; + + Buffer += 1; + + /* + * Set the Range base address + */ + Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the range length + */ + Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDmaResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsDmaResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT8 Temp8 = 0; + UINT8 Index; + UINT8 i; + UINT32 StructSize = sizeof(DMA_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsDmaResource"); + + /* + * The number of bytes consumed are Constant + */ + *BytesConsumed = 3; + OutputStruct->Id = Dma; + + /* + * Point to the 8-bits of Byte 1 + */ + Buffer += 1; + Temp8 = *Buffer; + + /* Decode the IRQ bits */ + + for (i = 0, Index = 0; Index < 8; Index++) + { + if ((Temp8 >> Index) & 0x01) + { + OutputStruct->Data.Dma.Channels[i] = Index; + i++; + } + } + OutputStruct->Data.Dma.NumberOfChannels = i; + + + /* + * Calculate the structure size based upon the number of interrupts + */ + StructSize += (OutputStruct->Data.Dma.NumberOfChannels - 1) * 4; + + /* + * Point to Byte 2 + */ + Buffer += 1; + Temp8 = *Buffer; + + /* + * Check for transfer preference (Bits[1:0]) + */ + OutputStruct->Data.Dma.Transfer = Temp8 & 0x03; + + if (0x03 == OutputStruct->Data.Dma.Transfer) + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Get bus master preference (Bit[2]) + */ + OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01; + + /* + * Get channel speed support (Bits[6:5]) + */ + OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDmaStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsDmaStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + + + FUNCTION_TRACE ("RsDmaStream"); + + + /* + * The descriptor field is static + */ + *Buffer = 0x2A; + Buffer += 1; + Temp8 = 0; + + /* + * Loop through all of the Channels and set the mask bits + */ + for (Index = 0; + Index < LinkedList->Data.Dma.NumberOfChannels; + Index++) + { + Temp16 = (UINT16) LinkedList->Data.Dma.Channels[Index]; + Temp8 |= 0x1 << Temp16; + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the DMA Info + */ + Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5); + Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2); + Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03); + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c new file mode 100644 index 0000000..7f16c4d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c @@ -0,0 +1,683 @@ +/******************************************************************************* + * + * Module Name: rsirq - AcpiRsIrqResource, + * AcpiRsIrqStream + * AcpiRsExtendedIrqResource + * AcpiRsExtendedIrqStream + * $Revision: 10 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIRQ_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsirq") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIrqResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + UINT8 i; + UINT32 StructSize = sizeof (IRQ_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsIrqResource"); + + /* + * The number of bytes consumed are contained in the descriptor + * (Bits:0-1) + */ + Temp8 = *Buffer; + *BytesConsumed = (Temp8 & 0x03) + 1; + OutputStruct->Id = Irq; + + /* + * Point to the 16-bits of Bytes 1 and 2 + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.Irq.NumberOfInterrupts = 0; + + /* Decode the IRQ bits */ + + for (i = 0, Index = 0; Index < 16; Index++) + { + if((Temp16 >> Index) & 0x01) + { + OutputStruct->Data.Irq.Interrupts[i] = Index; + i++; + } + } + OutputStruct->Data.Irq.NumberOfInterrupts = i; + + /* + * Calculate the structure size based upon the number of interrupts + */ + StructSize += (OutputStruct->Data.Irq.NumberOfInterrupts - 1) * 4; + + /* + * Point to Byte 3 if it is used + */ + if (4 == *BytesConsumed) + { + Buffer += 2; + Temp8 = *Buffer; + + /* + * Check for HE, LL or HL + */ + if (Temp8 & 0x01) + { + OutputStruct->Data.Irq.EdgeLevel = EDGE_SENSITIVE; + OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_HIGH; + } + + else + { + if (Temp8 & 0x8) + { + OutputStruct->Data.Irq.EdgeLevel = LEVEL_SENSITIVE; + OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_LOW; + } + + else + { + /* + * Only _LL and _HE polarity/trigger interrupts + * are allowed (ACPI spec v1.0b ection 6.4.2.1), + * so an error will occur if we reach this point + */ + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* + * Check for sharable + */ + OutputStruct->Data.Irq.SharedExclusive = (Temp8 >> 3) & 0x01; + } + + else + { + /* + * Assume Edge Sensitive, Active High, Non-Sharable + * per ACPI Specification + */ + OutputStruct->Data.Irq.EdgeLevel = EDGE_SENSITIVE; + OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_HIGH; + OutputStruct->Data.Irq.SharedExclusive = EXCLUSIVE; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIrqStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + BOOLEAN IRQInfoByteNeeded; + + + FUNCTION_TRACE ("RsIrqStream"); + + + /* + * The descriptor field is set based upon whether a third byte is + * needed to contain the IRQ Information. + */ + if (EDGE_SENSITIVE == LinkedList->Data.Irq.EdgeLevel && + ACTIVE_HIGH == LinkedList->Data.Irq.ActiveHighLow && + EXCLUSIVE == LinkedList->Data.Irq.SharedExclusive) + { + *Buffer = 0x22; + IRQInfoByteNeeded = FALSE; + } + else + { + *Buffer = 0x23; + IRQInfoByteNeeded = TRUE; + } + + Buffer += 1; + Temp16 = 0; + + /* + * Loop through all of the interrupts and set the mask bits + */ + for(Index = 0; + Index < LinkedList->Data.Irq.NumberOfInterrupts; + Index++) + { + Temp8 = (UINT8) LinkedList->Data.Irq.Interrupts[Index]; + Temp16 |= 0x1 << Temp8; + } + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the IRQ Info byte if needed. + */ + if (IRQInfoByteNeeded) + { + Temp8 = 0; + Temp8 = (UINT8) ((LinkedList->Data.Irq.SharedExclusive & + 0x01) << 4); + + if (LEVEL_SENSITIVE == LinkedList->Data.Irq.EdgeLevel && + ACTIVE_LOW == LinkedList->Data.Irq.ActiveHighLow) + { + Temp8 |= 0x08; + } + + else + { + Temp8 |= 0x01; + } + + *Buffer = Temp8; + Buffer += 1; + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsExtendedIrqResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsExtendedIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + UINT32 StructSize = sizeof (EXTENDED_IRQ_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsExtendedIrqResource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + *BytesConsumed = Temp16 + 3; + OutputStruct->Id = ExtendedIrq; + + /* + * Point to the Byte3 + */ + Buffer += 2; + Temp8 = *Buffer; + + OutputStruct->Data.ExtendedIrq.ProducerConsumer = Temp8 & 0x01; + + /* + * Check for HE, LL or HL + */ + if(Temp8 & 0x02) + { + OutputStruct->Data.ExtendedIrq.EdgeLevel = EDGE_SENSITIVE; + OutputStruct->Data.ExtendedIrq.ActiveHighLow = ACTIVE_HIGH; + } + + else + { + if(Temp8 & 0x4) + { + OutputStruct->Data.ExtendedIrq.EdgeLevel = LEVEL_SENSITIVE; + OutputStruct->Data.ExtendedIrq.ActiveHighLow = ACTIVE_LOW; + } + + else + { + /* + * Only _LL and _HE polarity/trigger interrupts + * are allowed (ACPI spec v1.0b ection 6.4.2.1), + * so an error will occur if we reach this point + */ + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* + * Check for sharable + */ + OutputStruct->Data.ExtendedIrq.SharedExclusive = + (Temp8 >> 3) & 0x01; + + /* + * Point to Byte4 (IRQ Table length) + */ + Buffer += 1; + Temp8 = *Buffer; + + OutputStruct->Data.ExtendedIrq.NumberOfInterrupts = Temp8; + + /* + * Add any additional structure size to properly calculate + * the next pointer at the end of this function + */ + StructSize += (Temp8 - 1) * 4; + + /* + * Point to Byte5 (First IRQ Number) + */ + Buffer += 1; + + /* + * Cycle through every IRQ in the table + */ + for (Index = 0; Index < Temp8; Index++) + { + OutputStruct->Data.ExtendedIrq.Interrupts[Index] = + (UINT32)*Buffer; + + /* Point to the next IRQ */ + + Buffer += 4; + } + + /* + * This will leave us pointing to the Resource Source Index + * If it is present, then save it off and calculate the + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. + */ + if (*BytesConsumed > + (UINT32)(OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * + 4) + 5) + { + /* Dereference the Index */ + + Temp8 = *Buffer; + OutputStruct->Data.ExtendedIrq.ResourceSourceIndex = + (UINT32)Temp8; + + /* Point to the String */ + + Buffer += 1; + + /* Copy the string into the buffer */ + + Index = 0; + + while (0x00 != *Buffer) + { + OutputStruct->Data.ExtendedIrq.ResourceSource[Index] = + *Buffer; + + Buffer += 1; + Index += 1; + } + + /* + * Add the terminating null + */ + OutputStruct->Data.ExtendedIrq.ResourceSource[Index] = 0x00; + OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength = + Index + 1; + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundry. + */ + Temp8 = (UINT8) (Index + 1); + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + } + + else + { + OutputStruct->Data.ExtendedIrq.ResourceSourceIndex = 0x00; + OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength = 0; + OutputStruct->Data.ExtendedIrq.ResourceSource[0] = 0x00; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsExtendedIrqStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsExtendedIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 *LengthField; + UINT8 Temp8 = 0; + UINT8 Index; + NATIVE_CHAR *TempPointer = NULL; + + + FUNCTION_TRACE ("RsExtendedIrqStream"); + + + /* + * The descriptor field is static + */ + *Buffer = 0x89; + Buffer += 1; + + /* + * Set a pointer to the Length field - to be filled in later + */ + + LengthField = (UINT16 *)Buffer; + Buffer += 2; + + /* + * Set the Interrupt vector flags + */ + Temp8 = (UINT8)(LinkedList->Data.ExtendedIrq.ProducerConsumer & 0x01); + + Temp8 |= ((LinkedList->Data.ExtendedIrq.SharedExclusive & 0x01) << 3); + + if (LEVEL_SENSITIVE == LinkedList->Data.ExtendedIrq.EdgeLevel && + ACTIVE_LOW == LinkedList->Data.ExtendedIrq.ActiveHighLow) + { + Temp8 |= 0x04; + } + else + { + Temp8 |= 0x02; + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Interrupt table length + */ + Temp8 = (UINT8) LinkedList->Data.ExtendedIrq.NumberOfInterrupts; + + *Buffer = Temp8; + Buffer += 1; + + for (Index = 0; + Index < LinkedList->Data.ExtendedIrq.NumberOfInterrupts; + Index++) + { + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.ExtendedIrq.Interrupts[Index]); + Buffer += 4; + } + + /* + * Resource Source Index and Resource Source are optional + */ + if (0 != LinkedList->Data.ExtendedIrq.ResourceSourceStringLength) + { + *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSourceIndex; + Buffer += 1; + + TempPointer = (NATIVE_CHAR *) Buffer; + + /* + * Copy the string + */ + STRCPY (TempPointer, LinkedList->Data.ExtendedIrq.ResourceSource); + + /* + * Buffer needs to be set to the length of the sting + one for the + * terminating null + */ + Buffer += (STRLEN (LinkedList->Data.ExtendedIrq.ResourceSource) + 1); + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + /* + * Set the length field to the number of bytes consumed + * minus the header size (3 bytes) + */ + *LengthField = (UINT16) (*BytesConsumed - 3); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c b/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c new file mode 100644 index 0000000..463cee3 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c @@ -0,0 +1,606 @@ +/******************************************************************************* + * + * Module Name: rslist - AcpiRsByteStreamToList + * AcpiListToByteStream + * $Revision: 8 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSLIST_C__ + +#include "acpi.h" +#include "acresrc.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rslist") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsByteStreamToList + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream + * ByteStreamBufferLength - Length of ByteStreamBuffer + * OutputBuffer - Pointer to the buffer that will + * contain the output structures + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource byte stream and parses it, creating a + * linked list of resources in the caller's output buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsByteStreamToList ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT8 **OutputBuffer) +{ + ACPI_STATUS Status; + UINT32 BytesParsed = 0; + UINT8 ResourceType = 0; + UINT32 BytesConsumed = 0; + UINT8 **Buffer = OutputBuffer; + UINT32 StructureSize = 0; + BOOLEAN EndTagProcessed = FALSE; + + + FUNCTION_TRACE ("RsByteStreamToList"); + + + while (BytesParsed < ByteStreamBufferLength && + FALSE == EndTagProcessed) + { + /* + * Look at the next byte in the stream + */ + ResourceType = *ByteStreamBuffer; + + /* + * See if this is a small or large resource + */ + if(ResourceType & 0x80) + { + /* + * Large Resource Type + */ + switch (ResourceType) + { + case MEMORY_RANGE_24: + /* + * 24-Bit Memory Resource + */ + Status = AcpiRsMemory24Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case LARGE_VENDOR_DEFINED: + /* + * Vendor Defined Resource + */ + Status = AcpiRsVendorResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case MEMORY_RANGE_32: + /* + * 32-Bit Memory Range Resource + */ + Status = AcpiRsMemory32RangeResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case FIXED_MEMORY_RANGE_32: + /* + * 32-Bit Fixed Memory Resource + */ + Status = AcpiRsFixedMemory32Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case DWORD_ADDRESS_SPACE: + /* + * 32-Bit Address Resource + */ + Status = AcpiRsAddress32Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case WORD_ADDRESS_SPACE: + /* + * 16-Bit Address Resource + */ + Status = AcpiRsAddress16Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case EXTENDED_IRQ: + /* + * Extended IRQ + */ + Status = AcpiRsExtendedIrqResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + +/* TBD: [Future] 64-bit not currently supported */ +/* + case 0x8A: + break; +*/ + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + } + } + + else + { + /* + * Small Resource Type + * Only bits 7:3 are valid + */ + ResourceType >>= 3; + + switch(ResourceType) + { + case IRQ_FORMAT: + /* + * IRQ Resource + */ + Status = AcpiRsIrqResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case DMA_FORMAT: + /* + * DMA Resource + */ + Status = AcpiRsDmaResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case START_DEPENDENT_TAG: + /* + * Start Dependent Functions Resource + */ + Status = AcpiRsStartDependentFunctionsResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case END_DEPENDENT_TAG: + /* + * End Dependent Functions Resource + */ + Status = AcpiRsEndDependentFunctionsResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case IO_PORT_DESCRIPTOR: + /* + * IO Port Resource + */ + Status = AcpiRsIoResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case FIXED_LOCATION_IO_DESCRIPTOR: + /* + * Fixed IO Port Resource + */ + Status = AcpiRsFixedIoResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case SMALL_VENDOR_DEFINED: + /* + * Vendor Specific Resource + */ + Status = AcpiRsVendorResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case END_TAG: + /* + * End Tag + */ + Status = AcpiRsEndTagResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + EndTagProcessed = TRUE; + + break; + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + + } /* switch */ + } /* end else */ + + /* + * Update the return value and counter + */ + BytesParsed += BytesConsumed; + + /* + * Set the byte stream to point to the next resource + */ + ByteStreamBuffer += BytesConsumed; + + /* + * Set the Buffer to the next structure + */ + *Buffer += StructureSize; + + } /* end while */ + + /* + * Check the reason for exiting the while loop + */ + if (!(ByteStreamBufferLength == BytesParsed) || + (TRUE != EndTagProcessed)) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsListToByteStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * ByteSteamSizeNeeded - Calculated size of the byte stream + * needed from calling + * AcpiRsCalculateByteStreamLength() + * The size of the OutputBuffer is + * guaranteed to be >= + * ByteStreamSizeNeeded + * OutputBuffer - Pointer to the buffer that will + * contain the byte stream + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource linked list and parses it, creating a + * byte stream of resources in the caller's output buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsListToByteStream ( + RESOURCE *LinkedList, + UINT32 ByteStreamSizeNeeded, + UINT8 **OutputBuffer) +{ + ACPI_STATUS Status; + UINT8 *Buffer = *OutputBuffer; + UINT32 BytesConsumed = 0; + BOOLEAN Done = FALSE; + + + FUNCTION_TRACE ("RsListToByteStream"); + + while (!Done) + { + switch (LinkedList->Id) + { + case Irq: + /* + * IRQ Resource + */ + Status = AcpiRsIrqStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Dma: + /* + * DMA Resource + */ + Status = AcpiRsDmaStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case StartDependentFunctions: + /* + * Start Dependent Functions Resource + */ + Status = AcpiRsStartDependentFunctionsStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case EndDependentFunctions: + /* + * End Dependent Functions Resource + */ + Status = AcpiRsEndDependentFunctionsStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Io: + /* + * IO Port Resource + */ + Status = AcpiRsIoStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case FixedIo: + /* + * Fixed IO Port Resource + */ + Status = AcpiRsFixedIoStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case VendorSpecific: + /* + * Vendor Defined Resource + */ + Status = AcpiRsVendorStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case EndTag: + /* + * End Tag + */ + Status = AcpiRsEndTagStream (LinkedList, + &Buffer, + &BytesConsumed); + + /* + * An End Tag indicates the end of the Resource Template + */ + Done = TRUE; + break; + + case Memory24: + /* + * 24-Bit Memory Resource + */ + Status = AcpiRsMemory24Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Memory32: + /* + * 32-Bit Memory Range Resource + */ + Status = AcpiRsMemory32RangeStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case FixedMemory32: + /* + * 32-Bit Fixed Memory Resource + */ + Status = AcpiRsFixedMemory32Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Address16: + /* + * 16-Bit Address Descriptor Resource + */ + Status = AcpiRsAddress16Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Address32: + /* + * 32-Bit Address Descriptor Resource + */ + Status = AcpiRsAddress32Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case ExtendedIrq: + /* + * Extended IRQ Resource + */ + Status = AcpiRsExtendedIrqStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_BAD_DATA); + break; + + } /* switch (LinkedList->Id) */ + + /* + * Set the Buffer to point to the open byte + */ + Buffer += BytesConsumed; + + /* + * Point to the next object + */ + LinkedList = (RESOURCE *) ((NATIVE_UINT) LinkedList + + (NATIVE_UINT) LinkedList->Length); + } + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c new file mode 100644 index 0000000..bc1ab29 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c @@ -0,0 +1,660 @@ +/******************************************************************************* + * + * Module Name: rsmem24 - AcpiRsMemory24Resource + * AcpiRsMemory24Stream + * AcpiRsMemory32RangeResource + * AcpiRsFixedMemory32Resource + * AcpiRsMemory32RangeStream + * AcpiRsFixedMemory32Stream + * $Revision: 9 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMEMORY_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsmemory") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory24Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory24Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (MEMORY24_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsMemory24Resource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + *BytesConsumed = Temp16 + 3; + OutputStruct->Id = Memory24; + + /* + * Check Byte 3 the Read/Write bit + */ + Temp8 = *Buffer; + Buffer += 1; + OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01; + + /* + * Get MinBaseAddress (Bytes 4-5) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + OutputStruct->Data.Memory24.MinBaseAddress = Temp16; + + /* + * Get MaxBaseAddress (Bytes 6-7) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + OutputStruct->Data.Memory24.MaxBaseAddress = Temp16; + + /* + * Get Alignment (Bytes 8-9) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + OutputStruct->Data.Memory24.Alignment = Temp16; + + /* + * Get RangeLength (Bytes 10-11) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + OutputStruct->Data.Memory24.RangeLength = Temp16; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory24Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory24Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsMemory24Stream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x81; + Buffer += 1; + + /* + * The length field is static + */ + Temp16 = 0x09; + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range minimum base address + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress); + Buffer += 2; + + /* + * Set the Range maximum base address + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress); + Buffer += 2; + + /* + * Set the base alignment + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment); + Buffer += 2; + + /* + * Set the range length + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength); + Buffer += 2; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory32RangeResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory32RangeResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsMemory32RangeResource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = Memory32; + + /* + * Point to the place in the output buffer where the data portion will + * begin. + * 1. Set the RESOURCE_DATA * Data to point to it's own address, then + * 2. Set the pointer to the next address. + * + * NOTE: OutputStruct->Data is cast to UINT8, otherwise, this addition adds + * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8) + */ + + /* + * Check Byte 3 the Read/Write bit + */ + Temp8 = *Buffer; + Buffer += 1; + + OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01; + + /* + * Get MinBaseAddress (Bytes 4-7) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress, + Buffer); + Buffer += 4; + + /* + * Get MaxBaseAddress (Bytes 8-11) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress, + Buffer); + Buffer += 4; + + /* + * Get Alignment (Bytes 12-15) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer); + Buffer += 4; + + /* + * Get RangeLength (Bytes 16-19) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer); + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedMemory32Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedMemory32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (FIXED_MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsFixedMemory32Resource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + Buffer += 2; + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = FixedMemory32; + + /* + * Check Byte 3 the Read/Write bit + */ + Temp8 = *Buffer; + Buffer += 1; + OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01; + + /* + * Get RangeBaseAddress (Bytes 4-7) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress, + Buffer); + Buffer += 4; + + /* + * Get RangeLength (Bytes 8-11) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength, + Buffer); + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory32RangeStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory32RangeStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsMemory32RangeStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x85; + Buffer += 1; + + /* + * The length field is static + */ + Temp16 = 0x11; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range minimum base address + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress); + Buffer += 4; + + /* + * Set the Range maximum base address + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress); + Buffer += 4; + + /* + * Set the base alignment + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment); + Buffer += 4; + + /* + * Set the range length + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength); + Buffer += 4; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedMemory32Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedMemory32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsFixedMemory32Stream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x86; + Buffer += 1; + + /* + * The length field is static + */ + Temp16 = 0x09; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range base address + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.FixedMemory32.RangeBaseAddress); + Buffer += 4; + + /* + * Set the range length + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.FixedMemory32.RangeLength); + Buffer += 4; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c new file mode 100644 index 0000000..23170e6 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c @@ -0,0 +1,725 @@ +/******************************************************************************* + * + * Module Name: rsmisc - AcpiRsEndTagResource + * AcpiRsEndTagStream + * AcpiRsVendorResource + * AcpiRsVendorStream + * AcpiRsStartDependentFunctionsResource + * AcpiRsEndDependentFunctionsResource + * AcpiRsStartDependentFunctionsStream + * AcpiRsEndDependentFunctionsStream + * $Revision: 9 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMISC_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsmisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndTagResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndTagResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT32 StructSize = RESOURCE_LENGTH; + + + FUNCTION_TRACE ("RsEndTagResource"); + + /* + * The number of bytes consumed is static + */ + *BytesConsumed = 2; + + /* + * Fill out the structure + */ + OutputStruct->Id = EndTag; + + /* + * Set the Length parameter + */ + OutputStruct->Length = 0; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndTagStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndTagStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsEndTagStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x79; + Buffer += 1; + + /* + * Set the Checksum - zero means that the resource data is treated as if + * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) + */ + Temp8 = 0; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsVendorResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsVendorResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + UINT32 StructSize = sizeof (VENDOR_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsVendorResource"); + + /* + * Dereference the Descriptor to find if this is a large or small item. + */ + Temp8 = *Buffer; + + if (Temp8 & 0x80) + { + /* + * Large Item + */ + /* Point to the length field */ + + Buffer += 1; + + /* Dereference */ + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + /* Calculate bytes consumed */ + + *BytesConsumed = Temp16 + 3; + + /* Point to the first vendor byte */ + + Buffer += 2; + } + + else + { + /* + * Small Item + */ + + /* Dereference the size */ + + Temp16 = (UINT8)(*Buffer & 0x07); + + /* Calculate bytes consumed */ + + *BytesConsumed = Temp16 + 1; + + /* Point to the first vendor byte */ + + Buffer += 1; + } + + OutputStruct->Id = VendorSpecific; + OutputStruct->Data.VendorSpecific.Length = Temp16; + + for (Index = 0; Index < Temp16; Index++) + { + OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer; + Buffer += 1; + } + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the vendor string and expand the + * StructSize to the next 32-bit boundry. + */ + StructSize += ROUND_UP_TO_32BITS (Temp16); + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsVendorStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsVendorStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + + + FUNCTION_TRACE ("RsVendorStream"); + + /* + * Dereference the length to find if this is a large or small item. + */ + + if(LinkedList->Data.VendorSpecific.Length > 7) + { + /* + * Large Item + */ + /* + * Set the descriptor field and length bytes + */ + *Buffer = 0x84; + Buffer += 1; + + Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + } + + else + { + /* + * Small Item + */ + + /* + * Set the descriptor field + */ + Temp8 = 0x70; + Temp8 |= LinkedList->Data.VendorSpecific.Length; + + *Buffer = Temp8; + Buffer += 1; + } + + /* + * Loop through all of the Vendor Specific fields + */ + for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++) + { + Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index]; + + *Buffer = Temp8; + Buffer += 1; + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStartDependentFunctionsResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsStartDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT8 Temp8 = 0; + UINT32 StructSize = + sizeof(START_DEPENDENT_FUNCTIONS_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsStartDependentFunctionsResource"); + + /* + * The number of bytes consumed are contained in the descriptor (Bits:0-1) + */ + Temp8 = *Buffer; + + *BytesConsumed = (Temp8 & 0x01) + 1; + + OutputStruct->Id = StartDependentFunctions; + + /* + * Point to Byte 1 if it is used + */ + if (2 == *BytesConsumed) + { + Buffer += 1; + Temp8 = *Buffer; + + /* + * Check Compatibility priority + */ + OutputStruct->Data.StartDependentFunctions.CompatibilityPriority = + Temp8 & 0x03; + + if (3 == OutputStruct->Data.StartDependentFunctions.CompatibilityPriority) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + /* + * Check Performance/Robustness preference + */ + OutputStruct->Data.StartDependentFunctions.PerformanceRobustness = + (Temp8 >> 2) & 0x03; + + if (3 == OutputStruct->Data.StartDependentFunctions.PerformanceRobustness) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + } + + else + { + OutputStruct->Data.StartDependentFunctions.CompatibilityPriority = + ACCEPTABLE_CONFIGURATION; + + OutputStruct->Data.StartDependentFunctions.PerformanceRobustness = + ACCEPTABLE_CONFIGURATION; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndDependentFunctionsResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT32 StructSize = RESOURCE_LENGTH; + + + FUNCTION_TRACE ("RsEndDependentFunctionsResource"); + + /* + * The number of bytes consumed is static + */ + *BytesConsumed = 1; + + /* + * Fill out the structure + */ + OutputStruct->Id = EndDependentFunctions; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStartDependentFunctionsStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsStartDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsStartDependentFunctionsStream"); + + /* + * The descriptor field is set based upon whether a byte is needed + * to contain Priority data. + */ + if (ACCEPTABLE_CONFIGURATION == + LinkedList->Data.StartDependentFunctions.CompatibilityPriority && + ACCEPTABLE_CONFIGURATION == + LinkedList->Data.StartDependentFunctions.PerformanceRobustness) + { + *Buffer = 0x30; + } + else + { + *Buffer = 0x31; + Buffer += 1; + + /* + * Set the Priority Byte Definition + */ + Temp8 = 0; + Temp8 = (UINT8) + ((LinkedList->Data.StartDependentFunctions.PerformanceRobustness & + 0x03) << 2); + Temp8 |= + (LinkedList->Data.StartDependentFunctions.CompatibilityPriority & + 0x03); + + *Buffer = Temp8; + } + + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndDependentFunctionsStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed + ) +{ + UINT8 *Buffer = *OutputBuffer; + + + FUNCTION_TRACE ("RsEndDependentFunctionsStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x38; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c new file mode 100644 index 0000000..3ec5fa6 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c @@ -0,0 +1,511 @@ +/******************************************************************************* + * + * Module Name: rsutils - Utilities for the resource manager + * $Revision: 12 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSUTILS_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acresrc.h" + + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrtMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * RetBuffer - a pointer to a buffer structure for the + * results + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get the _PRT value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *RetObj; + ACPI_STATUS Status; + UINT32 BufferSpaceNeeded; + + + FUNCTION_TRACE ("RsGetPrtMethodData"); + + + /* already validated params, so we won't repeat here */ + + BufferSpaceNeeded = RetBuffer->Length; + + /* + * Execute the method, no parameters + */ + Status = AcpiNsEvaluateRelative (Handle, "_PRT", NULL, &RetObj); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!RetObj) + { + /* Return object is required */ + + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _PRT\n")); + return_ACPI_STATUS (AE_TYPE); + } + + + /* + * The return object will be a package, so check the + * parameters. If the return object is not a package, + * then the underlying AML code is corrupt or improperly + * written. + */ + if (ACPI_TYPE_PACKAGE != RetObj->Common.Type) + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreatePciRoutingTable (RetObj, + RetBuffer->Pointer, + &BufferSpaceNeeded); + + /* + * Tell the user how much of the buffer we have used or is needed + * and return the final status. + */ + RetBuffer->Length = BufferSpaceNeeded; + + + /* On exit, we must delete the object returned by evaluateObject */ + +Cleanup: + + AcpiCmRemoveReference (RetObj); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetCrsMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * RetBuffer - a pointer to a buffer structure for the + * results + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get the _CRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *RetObj; + ACPI_STATUS Status; + UINT32 BufferSpaceNeeded = RetBuffer->Length; + + + FUNCTION_TRACE ("RsGetCrsMethodData"); + + + /* already validated params, so we won't repeat here */ + + /* + * Execute the method, no parameters + */ + Status = AcpiNsEvaluateRelative (Handle, "_CRS", NULL, &RetObj); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!RetObj) + { + /* Return object is required */ + + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _CRS\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* + * The return object will be a buffer, but check the + * parameters. If the return object is not a buffer, + * then the underlying AML code is corrupt or improperly + * written. + */ + if (ACPI_TYPE_BUFFER != RetObj->Common.Type) + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (RetObj, + RetBuffer->Pointer, + &BufferSpaceNeeded); + + + if (ACPI_SUCCESS (Status)) + { + DUMP_RESOURCE_LIST(RetBuffer->Pointer); + } + + /* + * Tell the user how much of the buffer we have used or is needed + * and return the final status. + */ + RetBuffer->Length = BufferSpaceNeeded; + + + /* On exit, we must delete the object returned by evaluateObject */ + +Cleanup: + + AcpiCmRemoveReference (RetObj); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrsMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * RetBuffer - a pointer to a buffer structure for the + * results + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get the _PRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *RetObj; + ACPI_STATUS Status; + UINT32 BufferSpaceNeeded = RetBuffer->Length; + + + FUNCTION_TRACE ("RsGetPrsMethodData"); + + + /* already validated params, so we won't repeat here */ + + /* + * Execute the method, no parameters + */ + Status = AcpiNsEvaluateRelative (Handle, "_PRS", NULL, &RetObj); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!RetObj) + { + /* Return object is required */ + + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _PRS\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* + * The return object will be a buffer, but check the + * parameters. If the return object is not a buffer, + * then the underlying AML code is corrupt or improperly + * written.. + */ + if (ACPI_TYPE_BUFFER != RetObj->Common.Type) + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (RetObj, + RetBuffer->Pointer, + &BufferSpaceNeeded); + + /* + * Tell the user how much of the buffer we have used or is needed + * and return the final status. + */ + RetBuffer->Length = BufferSpaceNeeded; + + + /* On exit, we must delete the object returned by evaluateObject */ + +Cleanup: + + AcpiCmRemoveReference (RetObj); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetSrsMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * InBuffer - a pointer to a buffer structure of the + * parameter + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to set the _SRS of an object contained + * in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *InBuffer) +{ + ACPI_OPERAND_OBJECT *Params[2]; + ACPI_OPERAND_OBJECT ParamObj; + ACPI_STATUS Status; + UINT8 *ByteStream = NULL; + UINT32 BufferSizeNeeded = 0; + + + FUNCTION_TRACE ("RsSetSrsMethodData"); + + + /* already validated params, so we won't repeat here */ + + /* + * 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. + */ + BufferSizeNeeded = 0; + + /* + * First call is to get the buffer size needed + */ + Status = AcpiRsCreateByteStream (InBuffer->Pointer, + ByteStream, + &BufferSizeNeeded); + /* + * We expect a return of AE_BUFFER_OVERFLOW + * if not, exit with the error + */ + if (AE_BUFFER_OVERFLOW != Status) + { + return_ACPI_STATUS (Status); + } + + /* + * Allocate the buffer needed + */ + ByteStream = AcpiCmCallocate(BufferSizeNeeded); + if (NULL == ByteStream) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Now call to convert the linked list into a byte stream + */ + Status = AcpiRsCreateByteStream (InBuffer->Pointer, + ByteStream, + &BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Init the param object + */ + AcpiCmInitStaticObject (&ParamObj); + + /* + * Method requires one parameter. Set it up + */ + Params [0] = &ParamObj; + Params [1] = NULL; + + /* + * Set up the parameter object + */ + ParamObj.Common.Type = ACPI_TYPE_BUFFER; + ParamObj.Buffer.Length = BufferSizeNeeded; + ParamObj.Buffer.Pointer = ByteStream; + + /* + * Execute the method, no return value + */ + Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL); + + /* + * Clean up and return the status from AcpiNsEvaluateRelative + */ + +Cleanup: + + AcpiCmFree (ByteStream); + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c new file mode 100644 index 0000000..c3dc221 --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c @@ -0,0 +1,326 @@ +/******************************************************************************* + * + * Module Name: rsxface - Public interfaces to the ACPI subsystem + * $Revision: 8 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSXFACE_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acresrc.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiGetIrqRoutingTable + * + * PARAMETERS: DeviceHandle - a handle to the Bus device we are querying + * RetBuffer - a pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiGetIrqRoutingTable "); + + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!DeviceHandle) || + (!RetBuffer) || + ((!RetBuffer->Pointer) && (RetBuffer->Length))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetCurrentResources + * + * PARAMETERS: DeviceHandle - a handle to the device object for the + * device we are querying + * RetBuffer - a pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiGetCurrentResources"); + + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!DeviceHandle) || + (!RetBuffer) || + ((RetBuffer->Length) && (!RetBuffer->Pointer))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetPossibleResources + * + * PARAMETERS: DeviceHandle - a handle to the device object for the + * device we are querying + * RetBuffer - a pointer to a buffer to receive the + * resources for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiGetPossibleResources"); + + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!DeviceHandle) || + (!RetBuffer) || + ((RetBuffer->Length) && (!RetBuffer->Pointer))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiSetCurrentResources + * + * PARAMETERS: DeviceHandle - a handle to the device object for the + * device we are changing the resources of + * InBuffer - a pointer to a buffer containing the + * resources to be set for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiSetCurrentResources"); + + /* + * Must have a valid handle and buffer + */ + if ((!DeviceHandle) || + (!InBuffer) || + (!InBuffer->Pointer) || + (!InBuffer->Length)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer); + + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/Subsystem/Tables/tbget.c b/sys/contrib/dev/acpica/Subsystem/Tables/tbget.c new file mode 100644 index 0000000..b8b307f --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Tables/tbget.c @@ -0,0 +1,733 @@ +/****************************************************************************** + * + * Module Name: tbget - ACPI Table get* routines + * $Revision: 26 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBGET_C__ + +#include "acpi.h" +#include "achware.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbget") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTablePtr + * + * PARAMETERS: TableType - one of the defined table types + * Instance - Which table of this type + * TablePtrLoc - pointer to location to place the pointer for + * return + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the pointer to an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTablePtr ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER **TablePtrLoc) +{ + ACPI_TABLE_DESC *TableDesc; + UINT32 i; + + + FUNCTION_TRACE ("TbGetTablePtr"); + + + if (!AcpiGbl_DSDT) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + if (TableType > ACPI_TABLE_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* + * For all table types (Single/Multiple), the first + * instance is always in the list head. + */ + + if (Instance == 1) + { + /* + * Just pluck the pointer out of the global table! + * Will be null if no table is present + */ + + *TablePtrLoc = AcpiGbl_AcpiTables[TableType].Pointer; + return_ACPI_STATUS (AE_OK); + } + + + /* + * Check for instance out of range + */ + if (Instance > AcpiGbl_AcpiTables[TableType].Count) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Walk the list to get the desired table + * Since the if (Instance == 1) check above checked for the + * first table, setting TableDesc equal to the .Next member + * is actually pointing to the second table. Therefore, we + * need to walk from the 2nd table until we reach the Instance + * that the user is looking for and return its table pointer. + */ + TableDesc = AcpiGbl_AcpiTables[TableType].Next; + for (i = 2; i < Instance; i++) + { + TableDesc = TableDesc->Next; + } + + /* We are now pointing to the requested table's descriptor */ + + *TablePtrLoc = TableDesc->Pointer; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTable + * + * PARAMETERS: PhysicalAddress - Physical address of table to retrieve + * *BufferPtr - If BufferPtr is valid, read data from + * buffer rather than searching memory + * *TableInfo - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Maps the physical address of table into a logical address + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTable ( + void *PhysicalAddress, + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_TABLE_HEADER *TableHeader = NULL; + ACPI_TABLE_HEADER *FullTable = NULL; + UINT32 Size; + UINT8 Allocation; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbGetTable"); + + if (!TableInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + if (BufferPtr) + { + /* + * Getting data from a buffer, not BIOS tables + */ + + TableHeader = BufferPtr; + Status = AcpiTbValidateTableHeader (TableHeader); + if (ACPI_FAILURE (Status)) + { + /* Table failed verification, map all errors to BAD_DATA */ + + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* Allocate buffer for the entire table */ + + FullTable = AcpiCmAllocate (TableHeader->Length); + if (!FullTable) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the entire table (including header) to the local buffer */ + + Size = TableHeader->Length; + MEMCPY (FullTable, BufferPtr, Size); + + /* Save allocation type */ + + Allocation = ACPI_MEM_ALLOCATED; + } + + + /* + * Not reading from a buffer, just map the table's physical memory + * into our address space. + */ + else + { + Size = SIZE_IN_HEADER; + + Status = AcpiTbMapAcpiTable (PhysicalAddress, &Size, + (void **) &FullTable); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Save allocation type */ + + Allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + TableInfo->Pointer = FullTable; + TableInfo->Length = Size; + TableInfo->Allocation = Allocation; + TableInfo->BasePointer = FullTable; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetAllTables + * + * PARAMETERS: NumberOfTables - Number of tables to get + * TablePtr - Input buffer pointer, optional + * + * RETURN: Status + * + * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must + * already be loaded and validated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetAllTables ( + UINT32 NumberOfTables, + ACPI_TABLE_HEADER *TablePtr) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Index; + ACPI_TABLE_DESC TableInfo; + + + FUNCTION_TRACE ("TbGetAllTables"); + + DEBUG_PRINT (ACPI_INFO, ("Number of tables: %d\n", NumberOfTables)); + + + /* + * Loop through all table pointers found in RSDT. + * This will NOT include the FACS and DSDT - we must get + * them after the loop + */ + + for (Index = 0; Index < NumberOfTables; Index++) + { + /* Clear the TableInfo each time */ + + MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); + + /* Get the table via the RSDT */ + + Status = AcpiTbGetTable ((void *) AcpiGbl_RSDT->TableOffsetEntry[Index], + TablePtr, &TableInfo); + + /* Ignore a table that failed verification */ + + if (Status == AE_BAD_DATA) + { + continue; + } + + /* However, abort on serious errors */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Recognize and install the table */ + + Status = AcpiTbInstallTable (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + /* + * Unrecognized or unsupported table, delete it and ignore the + * error. Just get as many tables as we can, later we will + * determine if there are enough tables to continue. + */ + + AcpiTbUninstallTable (&TableInfo); + } + } + + + /* Dump the FACP Header */ + + DEBUG_PRINT (TRACE_TABLES, ("Hex dump of FADT Header:\n")); + DUMP_BUFFER ((UINT8 *) AcpiGbl_FACP, sizeof (ACPI_TABLE_HEADER)); + + /* Dump the entire FACP */ + + DEBUG_PRINT (TRACE_TABLES, + ("Hex dump of FADT (After header), size %d (0x%x)\n", + AcpiGbl_FACP->header.Length, AcpiGbl_FACP->header.Length)); + DUMP_BUFFER ((UINT8 *) (&AcpiGbl_FACP->FirmwareCtrl), AcpiGbl_FACP->header.Length); + + + /* + * Get the minimum set of ACPI tables, namely: + * + * 1) FACP (via RSDT in loop above) + * 2) FACS + * 3) DSDT + * + */ + + + /* + * Get the FACS (must have the FACP first, from loop above) + * AcpiTbGetTableFacs will fail if FACP pointer is not valid + */ + + Status = AcpiTbGetTableFacs (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Install the FACS */ + + Status = AcpiTbInstallTable (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Get the DSDT (We know that the FACP if valid now) */ + + Status = AcpiTbGetTable ((void *) AcpiGbl_FACP->Dsdt, TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Install the DSDT */ + + Status = AcpiTbInstallTable (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Dump the DSDT Header */ + + DEBUG_PRINT (TRACE_TABLES, ("Hex dump of DSDT Header:\n")); + DUMP_BUFFER ((UINT8 *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER)); + + /* Dump the entire DSDT */ + + DEBUG_PRINT (TRACE_TABLES, + ("Hex dump of DSDT (After header), size %d (0x%x)\n", + AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length)); + DUMP_BUFFER ((UINT8 *) (AcpiGbl_DSDT + 1), AcpiGbl_DSDT->Length); + + /* + * Initialize the capabilities flags. + * Assumes that platform supports ACPI_MODE since we have tables! + */ + + AcpiGbl_SystemFlags |= AcpiHwGetModeCapabilities (); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbVerifyRsdp + * + * PARAMETERS: NumberOfTables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyRsdp ( + void *RsdpPhysicalAddress) +{ + ACPI_TABLE_DESC TableInfo; + ACPI_STATUS Status; + UINT8 *TablePtr; + + + FUNCTION_TRACE ("AcpiTbVerifyRsdp"); + + + /* + * Obtain access to the RSDP structure + */ + Status = AcpiOsMapMemory (RsdpPhysicalAddress, + sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER), + (void **) &TablePtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The signature and checksum must both be correct + */ + if (STRNCMP ((NATIVE_CHAR *) TablePtr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) + { + /* Nope, BAD Signature */ + + Status = AE_BAD_SIGNATURE; + goto Cleanup; + } + + if (AcpiTbChecksum (TablePtr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) != 0) + { + /* Nope, BAD Checksum */ + + Status = AE_BAD_CHECKSUM; + goto Cleanup; + } + + /* The RSDP supplied is OK */ + + TableInfo.Pointer = (ACPI_TABLE_HEADER *) TablePtr; + TableInfo.Length = sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER); + TableInfo.Allocation = ACPI_MEM_MAPPED; + TableInfo.BasePointer = TablePtr; + + /* Save the table pointers and allocation info */ + + Status = AcpiTbInitTableDescriptor (ACPI_TABLE_RSDP, &TableInfo); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* Save the RSDP in a global for easy access */ + + AcpiGbl_RSDP = (ROOT_SYSTEM_DESCRIPTOR_POINTER *) TableInfo.Pointer; + return_ACPI_STATUS (Status); + + + /* Error exit */ +Cleanup: + + AcpiOsUnmapMemory (TablePtr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTableRsdt + * + * PARAMETERS: NumberOfTables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTableRsdt ( + UINT32 *NumberOfTables) +{ + ACPI_TABLE_DESC TableInfo; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiTbGetTableRsdt"); + + + /* + * Get the RSDT from the RSDP + */ + + DEBUG_PRINT (ACPI_INFO, + ("RSDP located at %p, RSDT physical=%p \n", + AcpiGbl_RSDP, AcpiGbl_RSDP->RsdtPhysicalAddress)); + + Status = AcpiTbGetTable ((void *) AcpiGbl_RSDP->RsdtPhysicalAddress, + NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("GetTableRsdt: Could not get the RSDT, %s\n", + AcpiCmFormatException (Status))); + + if (Status == AE_BAD_SIGNATURE) + { + /* Invalid RSDT signature */ + + REPORT_ERROR (("Invalid signature where RSDP indicates RSDT should be located\n")); + + DUMP_BUFFER (AcpiGbl_RSDP, 20); + + DEBUG_PRINT_RAW (ACPI_ERROR, + ("RSDP points to RSDT at %lXh, but RSDT signature is invalid\n", + (void *) AcpiGbl_RSDP->RsdtPhysicalAddress)); + } + + REPORT_ERROR (("Unable to locate the RSDT\n")); + return_ACPI_STATUS (Status); + } + + + /* Always delete the RSDP mapping */ + + AcpiTbDeleteAcpiTable (ACPI_TABLE_RSDP); + + /* Save the table pointers and allocation info */ + + Status = AcpiTbInitTableDescriptor (ACPI_TABLE_RSDT, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiGbl_RSDT = (ROOT_SYSTEM_DESCRIPTION_TABLE *) TableInfo.Pointer; + + + /* Valid RSDT signature, verify the checksum */ + + DEBUG_PRINT (ACPI_INFO, ("RSDT located at %p\n", AcpiGbl_RSDT)); + + Status = AcpiTbVerifyTableChecksum ((ACPI_TABLE_HEADER *) AcpiGbl_RSDT); + + /* + * Determine the number of tables pointed to by the RSDT. + * This is defined by the ACPI Specification to be the number of + * pointers contained within the RSDT. The size of the pointers + * is architecture-dependent. + */ + + *NumberOfTables = ((AcpiGbl_RSDT->header.Length - + sizeof (ACPI_TABLE_HEADER)) / sizeof (void *)); + + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbGetTableFacs + * + * PARAMETERS: *BufferPtr - If BufferPtr is valid, read data from + * buffer rather than searching memory + * *TableInfo - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns a pointer to the FACS as defined in FACP. This + * function assumes the global variable FACP has been + * correctly initialized. The value of FACP->FirmwareCtrl + * into a far pointer which is returned. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbGetTableFacs ( + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo) +{ + void *TablePtr = NULL; + UINT32 Size; + UINT8 Allocation; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbGetTableFacs"); + + + /* Must have a valid FACP pointer */ + + if (!AcpiGbl_FACP) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + Size = sizeof (FIRMWARE_ACPI_CONTROL_STRUCTURE); + if (BufferPtr) + { + /* + * Getting table from a file -- allocate a buffer and + * read the table. + */ + TablePtr = AcpiCmAllocate (Size); + if(!TablePtr) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MEMCPY (TablePtr, BufferPtr, Size); + + /* Save allocation type */ + + Allocation = ACPI_MEM_ALLOCATED; + } + + else + { + /* Just map the physical memory to our address space */ + + Status = AcpiTbMapAcpiTable ((void *) AcpiGbl_FACP->FirmwareCtrl, + &Size, &TablePtr); + if (ACPI_FAILURE(Status)) + { + return_ACPI_STATUS (Status); + } + + /* Save allocation type */ + + Allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + TableInfo->Pointer = TablePtr; + TableInfo->Length = Size; + TableInfo->Allocation = Allocation; + TableInfo->BasePointer = TablePtr; + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Tables/tbinstal.c b/sys/contrib/dev/acpica/Subsystem/Tables/tbinstal.c new file mode 100644 index 0000000..c63464c --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Tables/tbinstal.c @@ -0,0 +1,692 @@ +/****************************************************************************** + * + * Module Name: tbinstal - ACPI table installation and removal + * $Revision: 32 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __TBINSTAL_C__ + +#include "acpi.h" +#include "achware.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbinstal") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInstallTable + * + * PARAMETERS: TablePtr - Input buffer pointer, optional + * TableInfo - Return value from AcpiTbGetTable + * + * RETURN: Status + * + * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must + * already be loaded and validated. + * Install the table into the global data structs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInstallTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_STATUS Status; + + FUNCTION_TRACE ("TbInstallTable"); + + + /* + * Check the table signature and make sure it is recognized + * Also checks the header checksum + */ + + Status = AcpiTbRecognizeTable (TablePtr, TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Lock tables while installing */ + + AcpiCmAcquireMutex (ACPI_MTX_TABLES); + + /* Install the table into the global data structure */ + + Status = AcpiTbInitTableDescriptor (TableInfo->Type, TableInfo); + + DEBUG_PRINT (ACPI_INFO, ("%s located at %p\n", + AcpiGbl_AcpiTableData[TableInfo->Type].Name, TableInfo->Pointer)); + + AcpiCmReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbRecognizeTable + * + * PARAMETERS: TablePtr - Input buffer pointer, optional + * TableInfo - Return value from AcpiTbGetTable + * + * RETURN: Status + * + * DESCRIPTION: Check a table signature for a match against known table types + * + * NOTE: All table pointers are validated as follows: + * 1) Table pointer must point to valid physical memory + * 2) Signature must be 4 ASCII chars, even if we don't recognize the + * name + * 3) Table must be readable for length specified in the header + * 4) Table checksum must be valid (with the exception of the FACS + * which has no checksum for some odd reason) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbRecognizeTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_TABLE_HEADER *TableHeader; + ACPI_STATUS Status; + ACPI_TABLE_TYPE TableType = 0; + UINT32 i; + + + FUNCTION_TRACE ("TbRecognizeTable"); + + + /* Ensure that we have a valid table pointer */ + + TableHeader = (ACPI_TABLE_HEADER *) TableInfo->Pointer; + if (!TableHeader) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Search for a signature match among the known table types + * Start at index one -> Skip the RSDP + */ + + Status = AE_SUPPORT; + for (i = 1; i < NUM_ACPI_TABLES; i++) + { + if (!STRNCMP (TableHeader->Signature, + AcpiGbl_AcpiTableData[i].Signature, + AcpiGbl_AcpiTableData[i].SigLength)) + { + /* + * Found a signature match, get the pertinent info from the + * TableData structure + */ + + TableType = i; + Status = AcpiGbl_AcpiTableData[i].Status; + + DEBUG_PRINT (ACPI_INFO, + ("TbRecognizeTable: Found %4.4s\n", + AcpiGbl_AcpiTableData[i].Signature)); + break; + } + } + + /* Return the table type and length via the info struct */ + + TableInfo->Type = (UINT8) TableType; + TableInfo->Length = TableHeader->Length; + + + /* + * Validate checksum for _most_ tables, + * even the ones whose signature we don't recognize + */ + + if (TableType != ACPI_TABLE_FACS) + { + /* But don't abort if the checksum is wrong */ + /* TBD: [Future] make this a configuration option? */ + + AcpiTbVerifyTableChecksum (TableHeader); + } + + /* + * An AE_SUPPORT means that the table was not recognized. + * We basically ignore this; just print a debug message + */ + + if (Status == AE_SUPPORT) + { + DEBUG_PRINT (ACPI_INFO, + ("Unsupported table %s (Type %d) was found and discarded\n", + AcpiGbl_AcpiTableData[TableType].Name, TableType)); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitTableDescriptor + * + * PARAMETERS: TableType - The type of the table + * TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Install a table into the global data structs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInitTableDescriptor ( + ACPI_TABLE_TYPE TableType, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_TABLE_DESC *ListHead; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE_U32 ("TbInitTableDescriptor", TableType); + + /* + * Install the table into the global data structure + */ + + ListHead = &AcpiGbl_AcpiTables[TableType]; + TableDesc = ListHead; + + + /* + * Two major types of tables: 1) Only one instance is allowed. This + * includes most ACPI tables such as the DSDT. 2) Multiple instances of + * the table are allowed. This includes SSDT and PSDTs. + */ + + if (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags)) + { + /* + * Only one table allowed, and a table has alread been installed + * at this location, so return an error. + */ + + if (ListHead->Pointer) + { + return_ACPI_STATUS (AE_EXIST); + } + + TableDesc->Count = 1; + } + + + else + { + /* + * Multiple tables allowed for this table type, we must link + * the new table in to the list of tables of this type. + */ + + if (ListHead->Pointer) + { + TableDesc = AcpiCmCallocate (sizeof (ACPI_TABLE_DESC)); + if (!TableDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ListHead->Count++; + + /* Update the original previous */ + + ListHead->Prev->Next = TableDesc; + + /* Update new entry */ + + TableDesc->Prev = ListHead->Prev; + TableDesc->Next = ListHead; + + /* Update list head */ + + ListHead->Prev = TableDesc; + } + + else + { + TableDesc->Count = 1; + } + } + + + /* Common initialization of the table descriptor */ + + TableDesc->Pointer = TableInfo->Pointer; + TableDesc->BasePointer = TableInfo->BasePointer; + TableDesc->Length = TableInfo->Length; + TableDesc->Allocation = TableInfo->Allocation; + TableDesc->AmlPointer = (UINT8 *) (TableDesc->Pointer + 1), + TableDesc->AmlLength = (UINT32) (TableDesc->Length - + (UINT32) sizeof (ACPI_TABLE_HEADER)); + TableDesc->TableId = AcpiCmAllocateOwnerId (OWNER_TYPE_TABLE); + TableDesc->LoadedIntoNamespace = FALSE; + + /* + * Set the appropriate global pointer (if there is one) to point to the + * newly installed table + */ + + if (AcpiGbl_AcpiTableData[TableType].GlobalPtr) + { + *(AcpiGbl_AcpiTableData[TableType].GlobalPtr) = TableInfo->Pointer; + } + + + /* Return Data */ + + TableInfo->TableId = TableDesc->TableId; + TableInfo->InstalledDesc = TableDesc; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteAcpiTables + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all internal ACPI tables + * + ******************************************************************************/ + +void +AcpiTbDeleteAcpiTables (void) +{ + ACPI_TABLE_TYPE Type; + + + /* + * Free memory allocated for ACPI tables + * Memory can either be mapped or allocated + */ + + for (Type = 0; Type < NUM_ACPI_TABLES; Type++) + { + AcpiTbDeleteAcpiTable (Type); + } + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteAcpiTable + * + * PARAMETERS: Type - The table type to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Delete an internal ACPI table + * Locks the ACPI table mutex + * + ******************************************************************************/ + +void +AcpiTbDeleteAcpiTable ( + ACPI_TABLE_TYPE Type) +{ + FUNCTION_TRACE_U32 ("TbDeleteAcpiTable", Type); + + + if (Type > ACPI_TABLE_MAX) + { + return_VOID; + } + + + AcpiCmAcquireMutex (ACPI_MTX_TABLES); + + /* Free the table */ + + AcpiTbFreeAcpiTablesOfType (&AcpiGbl_AcpiTables[Type]); + + + /* Clear the appropriate "typed" global table pointer */ + + switch (Type) + { + case ACPI_TABLE_RSDP: + AcpiGbl_RSDP = NULL; + break; + + case ACPI_TABLE_APIC: + AcpiGbl_APIC = NULL; + break; + + case ACPI_TABLE_DSDT: + AcpiGbl_DSDT = NULL; + break; + + case ACPI_TABLE_FACP: + AcpiGbl_FACP = NULL; + break; + + case ACPI_TABLE_FACS: + AcpiGbl_FACS = NULL; + break; + + case ACPI_TABLE_PSDT: + break; + + case ACPI_TABLE_RSDT: + AcpiGbl_RSDT = NULL; + break; + + case ACPI_TABLE_SSDT: + break; + + case ACPI_TABLE_SBST: + AcpiGbl_SBST = NULL; + + case ACPI_TABLE_SPIC: + break; + + default: + break; + } + + AcpiCmReleaseMutex (ACPI_MTX_TABLES); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFreeAcpiTablesOfType + * + * PARAMETERS: TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Free the memory associated with an internal ACPI table + * Table mutex should be locked. + * + ******************************************************************************/ + +void +AcpiTbFreeAcpiTablesOfType ( + ACPI_TABLE_DESC *ListHead) +{ + ACPI_TABLE_DESC *TableDesc; + UINT32 Count; + UINT32 i; + + + FUNCTION_TRACE_PTR ("TbFreeAcpiTablesOfType", ListHead); + + + /* Get the head of the list */ + + TableDesc = ListHead; + Count = ListHead->Count; + + /* + * Walk the entire list, deleting both the allocated tables + * and the table descriptors + */ + + for (i = 0; i < Count; i++) + { + TableDesc = AcpiTbUninstallTable (TableDesc); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteSingleTable + * + * PARAMETERS: TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Low-level free for a single ACPI table. Handles cases where + * the table was allocated a buffer or was mapped. + * + ******************************************************************************/ + +void +AcpiTbDeleteSingleTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + if (!TableDesc) + { + return; + } + + if (TableDesc->Pointer) + { + /* Valid table, determine type of memory allocation */ + + switch (TableDesc->Allocation) + { + + case ACPI_MEM_NOT_ALLOCATED: + break; + + + case ACPI_MEM_ALLOCATED: + + AcpiCmFree (TableDesc->BasePointer); + break; + + + case ACPI_MEM_MAPPED: + + AcpiOsUnmapMemory (TableDesc->BasePointer, TableDesc->Length); + break; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbUninstallTable + * + * PARAMETERS: TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Free the memory associated with an internal ACPI table that + * is either installed or has never been installed. + * Table mutex should be locked. + * + ******************************************************************************/ + +ACPI_TABLE_DESC * +AcpiTbUninstallTable ( + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_TABLE_DESC *NextDesc; + + + FUNCTION_TRACE_PTR ("TbDeleteSingleTable", TableDesc); + + + if (!TableDesc) + { + return_PTR (NULL); + } + + + /* Unlink the descriptor */ + + if (TableDesc->Prev) + { + TableDesc->Prev->Next = TableDesc->Next; + } + + if (TableDesc->Next) + { + TableDesc->Next->Prev = TableDesc->Prev; + } + + + /* Free the memory allocated for the table itself */ + + AcpiTbDeleteSingleTable (TableDesc); + + + /* Free the table descriptor (Don't delete the list head, tho) */ + + if ((TableDesc->Prev) == (TableDesc->Next)) + { + + NextDesc = NULL; + + /* Clear the list head */ + + TableDesc->Pointer = NULL; + TableDesc->Length = 0; + TableDesc->Count = 0; + + } + + else + { + /* Free the table descriptor */ + + NextDesc = TableDesc->Next; + AcpiCmFree (TableDesc); + } + + + return_PTR (NextDesc); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Tables/tbutils.c b/sys/contrib/dev/acpica/Subsystem/Tables/tbutils.c new file mode 100644 index 0000000..dc942ed --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Tables/tbutils.c @@ -0,0 +1,486 @@ +/****************************************************************************** + * + * Module Name: tbutils - Table manipulation utilities + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBUTILS_C__ + +#include "acpi.h" +#include "actables.h" +#include "acinterp.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbHandleToObject + * + * PARAMETERS: TableId - Id for which the function is searching + * TableDesc - Pointer to return the matching table + * descriptor. + * + * RETURN: Search the tables to find one with a matching TableId and + * return a pointer to that table descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **TableDesc) +{ + UINT32 i; + ACPI_TABLE_DESC *ListHead; + + + for (i = 0; i < ACPI_TABLE_MAX; i++) + { + ListHead = &AcpiGbl_AcpiTables[i]; + do + { + if (ListHead->TableId == TableId) + { + *TableDesc = ListHead; + return (AE_OK); + } + + ListHead = ListHead->Next; + + } while (ListHead != &AcpiGbl_AcpiTables[i]); + } + + + DEBUG_PRINT (ACPI_ERROR, ("TableId=0x%X does not exist\n", TableId)); + return (AE_BAD_PARAMETER); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSystemTablePointer + * + * PARAMETERS: *Where - Pointer to be examined + * + * RETURN: TRUE if Where is within the AML stream (in one of the ACPI + * system tables such as the DSDT or an SSDT.) + * FALSE otherwise + * + ******************************************************************************/ + +BOOLEAN +AcpiTbSystemTablePointer ( + void *Where) +{ + UINT32 i; + ACPI_TABLE_DESC *TableDesc; + ACPI_TABLE_HEADER *Table; + + + /* No function trace, called too often! */ + + + /* Ignore null pointer */ + + if (!Where) + { + return (FALSE); + } + + + /* Check for a pointer within the DSDT */ + + if ((AcpiGbl_DSDT) && + (IS_IN_ACPI_TABLE (Where, AcpiGbl_DSDT))) + { + return (TRUE); + } + + + /* Check each of the loaded SSDTs (if any)*/ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_SSDT]; + + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count; i++) + { + Table = TableDesc->Pointer; + + if (IS_IN_ACPI_TABLE (Where, Table)) + { + return (TRUE); + } + + TableDesc = TableDesc->Next; + } + + + /* Check each of the loaded PSDTs (if any)*/ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_PSDT]; + + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count; i++) + { + Table = TableDesc->Pointer; + + if (IS_IN_ACPI_TABLE (Where, Table)) + { + return (TRUE); + } + + TableDesc = TableDesc->Next; + } + + + /* Pointer does not point into any system table */ + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateTableHeader + * + * PARAMETERS: TableHeader - Logical pointer to the table + * + * RETURN: Status + * + * DESCRIPTION: Check an ACPI table header for validity + * + * NOTE: Table pointers are validated as follows: + * 1) Table pointer must point to valid physical memory + * 2) Signature must be 4 ASCII chars, even if we don't recognize the + * name + * 3) Table must be readable for length specified in the header + * 4) Table checksum must be valid (with the exception of the FACS + * which has no checksum for some odd reason) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbValidateTableHeader ( + ACPI_TABLE_HEADER *TableHeader) +{ + ACPI_NAME Signature; + + + /* Verify that this is a valid address */ + + if (!AcpiOsReadable (TableHeader, sizeof (ACPI_TABLE_HEADER))) + { + DEBUG_PRINT (ACPI_ERROR, + ("Cannot read table header at %p\n", TableHeader)); + return (AE_BAD_ADDRESS); + } + + + /* Ensure that the signature is 4 ASCII characters */ + + MOVE_UNALIGNED32_TO_32 (&Signature, &TableHeader->Signature); + if (!AcpiCmValidAcpiName (Signature)) + { + DEBUG_PRINT (ACPI_ERROR, + ("Table signature at %p [%X] has invalid characters\n", + TableHeader, &Signature)); + + REPORT_WARNING (("Invalid table signature found\n")); + DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_BAD_SIGNATURE); + } + + + /* Validate the table length */ + + if (TableHeader->Length < sizeof (ACPI_TABLE_HEADER)) + { + DEBUG_PRINT (ACPI_ERROR, + ("Invalid length in table header %p name %4.4s\n", + TableHeader, &Signature)); + + REPORT_WARNING (("Invalid table header length found\n")); + DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_BAD_HEADER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbMapAcpiTable + * + * PARAMETERS: PhysicalAddress - Physical address of table to map + * *Size - Size of the table. If zero, the size + * from the table header is used. + * Actual size is returned here. + * **LogicalAddress - Logical address of mapped table + * + * RETURN: Logical address of the mapped table. + * + * DESCRIPTION: Maps the physical address of table into a logical address + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbMapAcpiTable ( + void *PhysicalAddress, + UINT32 *Size, + void **LogicalAddress) +{ + ACPI_TABLE_HEADER *Table; + UINT32 TableSize = *Size; + ACPI_STATUS Status = AE_OK; + + + /* If size is zero, look at the table header to get the actual size */ + + if ((*Size) == 0) + { + /* Get the table header so we can extract the table length */ + + Status = AcpiOsMapMemory (PhysicalAddress, sizeof (ACPI_TABLE_HEADER), + (void **) &Table); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Extract the full table length before we delete the mapping */ + + TableSize = Table->Length; + + /* + * Validate the header and delete the mapping. + * We will create a mapping for the full table below. + */ + + Status = AcpiTbValidateTableHeader (Table); + + /* Always unmap the memory for the header */ + + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + + /* Exit if header invalid */ + + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + + /* Map the physical memory for the correct length */ + + Status = AcpiOsMapMemory (PhysicalAddress, TableSize, (void **) &Table); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DEBUG_PRINT (ACPI_INFO, + ("Mapped memory for ACPI table, length=%d(0x%X) at %p\n", + TableSize, TableSize, Table)); + + *Size = TableSize; + *LogicalAddress = Table; + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbVerifyTableChecksum + * + * PARAMETERS: *TableHeader - ACPI table to verify + * + * RETURN: 8 bit checksum of table + * + * DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct + * table should have a checksum of 0. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyTableChecksum ( + ACPI_TABLE_HEADER *TableHeader) +{ + UINT8 Checksum; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbVerifyTableChecksum"); + + + /* Compute the checksum on the table */ + + Checksum = AcpiTbChecksum (TableHeader, TableHeader->Length); + + /* Return the appropriate exception */ + + if (Checksum) + { + REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n", + Checksum, &TableHeader->Signature)); + + Status = AE_BAD_CHECKSUM; + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbChecksum + * + * PARAMETERS: Buffer - Buffer to checksum + * Length - Size of the buffer + * + * RETURNS 8 bit checksum of buffer + * + * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. + * + ******************************************************************************/ + +UINT8 +AcpiTbChecksum ( + void *Buffer, + UINT32 Length) +{ + UINT8 *limit; + UINT8 *rover; + UINT8 sum = 0; + + + if (Buffer && Length) + { + /* Buffer and Length are valid */ + + limit = (UINT8 *) Buffer + Length; + + for (rover = Buffer; rover < limit; rover++) + { + sum = (UINT8) (sum + *rover); + } + } + + return (sum); +} + + diff --git a/sys/contrib/dev/acpica/Subsystem/Tables/tbxface.c b/sys/contrib/dev/acpica/Subsystem/Tables/tbxface.c new file mode 100644 index 0000000..b657f6f --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Tables/tbxface.c @@ -0,0 +1,506 @@ +/****************************************************************************** + * + * Module Name: tbxface - Public interfaces to the ACPI subsystem + * ACPI table oriented interfaces + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFACE_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiLoadTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: This function is called to load the ACPI tables from the + * provided RSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTables ( + void *RsdpPhysicalAddress) +{ + ACPI_STATUS Status = AE_OK; + UINT32 NumberOfTables = 0; + + + FUNCTION_TRACE ("AcpiLoadTables"); + + + /* Map and validate the RSDP */ + + Status = AcpiTbVerifyRsdp (RsdpPhysicalAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Get the RSDT via the RSDP */ + + Status = AcpiTbGetTableRsdt (&NumberOfTables); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Now get the rest of the tables */ + + Status = AcpiTbGetAllTables (NumberOfTables, NULL); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + DEBUG_PRINT (ACPI_OK, ("ACPI Tables successfully loaded\n")); + + + /* Load the namespace from the tables */ + + Status = AcpiNsLoadNamespace (); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + REPORT_ERROR (("AcpiLoadTables: Could not load tables: %s\n", + AcpiCmFormatException (Status))); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiLoadTable + * + * PARAMETERS: TablePtr - pointer to a buffer containing the entire + * table to be loaded + * + * RETURN: Status + * + * DESCRIPTION: This function is called to load a table from the caller's + * buffer. The buffer must contain an entire ACPI Table including + * a valid header. The header fields will be verified, and if it + * is determined that the table is invalid, the call will fail. + * + * If the call fails an appropriate status will be returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTable ( + ACPI_TABLE_HEADER *TablePtr) +{ + ACPI_STATUS Status; + ACPI_TABLE_DESC TableInfo; + + + FUNCTION_TRACE ("AcpiLoadTable"); + + if (!TablePtr) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Copy the table to a local buffer */ + + Status = AcpiTbGetTable (NULL, TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Install the new table into the local data structures */ + + Status = AcpiTbInstallTable (NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + /* Free table allocated by AcpiTbGetTable */ + + AcpiTbDeleteSingleTable (&TableInfo); + return_ACPI_STATUS (Status); + } + + + Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + /* Uninstall table and free the buffer */ + + AcpiTbUninstallTable (TableInfo.InstalledDesc); + return_ACPI_STATUS (Status); + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUnloadTable + * + * PARAMETERS: TableType - Type of table to be unloaded + * + * RETURN: Status + * + * DESCRIPTION: This routine is used to force the unload of a table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUnloadTable ( + ACPI_TABLE_TYPE TableType) +{ + ACPI_TABLE_DESC *ListHead; + + + FUNCTION_TRACE ("AcpiUnloadTable"); + + + /* Parameter validation */ + + if (TableType > ACPI_TABLE_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Find all tables of the requested type */ + + ListHead = &AcpiGbl_AcpiTables[TableType]; + do + { + /* + * Delete all namespace entries owned by this table. Note that these + * entries can appear anywhere in the namespace by virtue of the AML + * "Scope" operator. Thus, we need to track ownership by an ID, not + * simply a position within the hierarchy + */ + + AcpiNsDeleteNamespaceByOwner (ListHead->TableId); + + /* Delete (or unmap) the actual table */ + + AcpiTbDeleteAcpiTable (TableType); + + } while (ListHead != &AcpiGbl_AcpiTables[TableType]); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableHeader + * + * PARAMETERS: TableType - one of the defined table types + * Instance - the non zero instance of the table, allows + * support for multiple tables of the same type + * see AcpiGbl_AcpiTableFlag + * OutTableHeader - pointer to the ACPI_TABLE_HEADER if successful + * + * DESCRIPTION: This function is called to get an ACPI table header. The caller + * supplies an pointer to a data area sufficient to contain an ACPI + * ACPI_TABLE_HEADER structure. + * + * The header contains a length field that can be used to determine + * the size of the buffer needed to contain the entire table. This + * function is not valid for the RSD PTR table since it does not + * have a standard header and is fixed length. + * + * If the operation fails for any reason an appropriate status will + * be returned and the contents of OutTableHeader are undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableHeader ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader) +{ + ACPI_TABLE_HEADER *TblPtr; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiGetTableHeader"); + + if ((Instance == 0) || + (TableType == ACPI_TABLE_RSDP) || + (!OutTableHeader)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check the table type and instance */ + + if ((TableType > ACPI_TABLE_MAX) || + (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && + Instance > 1)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the entire table */ + + Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The function will return a NULL pointer if the table is not loaded + */ + if (TblPtr == NULL) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * Copy the header to the caller's buffer + */ + MEMCPY ((void *) OutTableHeader, (void *) TblPtr, + sizeof (ACPI_TABLE_HEADER)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTable + * + * PARAMETERS: TableType - one of the defined table types + * Instance - the non zero instance of the table, allows + * support for multiple tables of the same type + * see AcpiGbl_AcpiTableFlag + * RetBuffer - pointer to a structure containing a buffer to + * receive the table + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get an ACPI table. The caller + * supplies an OutBuffer large enough to contain the entire ACPI + * table. The caller should call the AcpiGetTableHeader function + * first to determine the buffer size needed. Upon completion + * the OutBuffer->Length field will indicate the number of bytes + * copied into the OutBuffer->BufPtr buffer. This table will be + * a complete table including the header. + * + * If the operation fails an appropriate status will be returned + * and the contents of OutBuffer are undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTable ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_BUFFER *RetBuffer) +{ + ACPI_TABLE_HEADER *TblPtr; + ACPI_STATUS Status; + UINT32 RetBufLen; + + + FUNCTION_TRACE ("AcpiGetTable"); + + /* + * If we have a buffer, we must have a length too + */ + if ((Instance == 0) || + (!RetBuffer) || + ((!RetBuffer->Pointer) && (RetBuffer->Length))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check the table type and instance */ + + if ((TableType > ACPI_TABLE_MAX) || + (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && + Instance > 1)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the entire table */ + + Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * AcpiTbGetTablePtr will return a NULL pointer if the + * table is not loaded. + */ + if (TblPtr == NULL) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * Got a table ptr, assume it's ok and copy it to the user's buffer + */ + if (TableType == ACPI_TABLE_RSDP) + { + /* + * RSD PTR is the only "table" without a header + */ + RetBufLen = sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER); + } + else + { + RetBufLen = TblPtr->Length; + } + + /* + * Verify we have space in the caller's buffer for the table + */ + if (RetBuffer->Length < RetBufLen) + { + RetBuffer->Length = RetBufLen; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + RetBuffer->Length = RetBufLen; + + MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, RetBufLen); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/Subsystem/Tables/tbxfroot.c b/sys/contrib/dev/acpica/Subsystem/Tables/tbxfroot.c new file mode 100644 index 0000000..d02a96d --- /dev/null +++ b/sys/contrib/dev/acpica/Subsystem/Tables/tbxfroot.c @@ -0,0 +1,319 @@ +/****************************************************************************** + * + * Module Name: tbxfroot - Find the root ACPI table (RSDT) + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFROOT_C__ + +#include "acpi.h" +#include "achware.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbxfroot") + + +/******************************************************************************* + * + * FUNCTION: AcpiFindRootPointer + * + * PARAMETERS: **RsdpPhysicalAddress - Where to place the RSDP address + * + * RETURN: Status, Physical address of the RSDP + * + * DESCRIPTION: Find the RSDP + * + ******************************************************************************/ + +ACPI_STATUS +AcpiFindRootPointer ( + void **RsdpPhysicalAddress) +{ + ACPI_TABLE_DESC TableInfo; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiFindRootPointer"); + + + /* Get the RSDP */ + + Status = AcpiTbFindRsdp (&TableInfo); + if (ACPI_FAILURE (Status)) + { + REPORT_WARNING (("RSDP structure not found\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + *RsdpPhysicalAddress = TableInfo.Pointer; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbScanMemoryForRsdp + * + * PARAMETERS: StartAddress - Starting pointer for search + * Length - Maximum length to search + * + * RETURN: Pointer to the RSDP if found, otherwise NULL. + * + * DESCRIPTION: Search a block of memory for the RSDP signature + * + ******************************************************************************/ + +UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length) +{ + UINT32 Offset; + UINT8 *MemRover; + + + FUNCTION_TRACE ("TbScanMemoryForRsdp"); + + /* Search from given start addr for the requested length */ + + for (Offset = 0, MemRover = StartAddress; + Offset < Length; + Offset += RSDP_SCAN_STEP, MemRover += RSDP_SCAN_STEP) + { + + /* The signature and checksum must both be correct */ + + if (STRNCMP ((NATIVE_CHAR *) MemRover, + RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && + AcpiTbChecksum (MemRover, + sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) == 0) + { + /* If so, we have found the RSDP */ + + return_PTR (MemRover); + } + } + + /* Searched entire block, no RSDP was found */ + + return_PTR (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFindRsdp + * + * PARAMETERS: *BufferPtr - If == NULL, read data from buffer + * rather than searching memory + * *TableInfo - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor + * pointer structure. If it is found, set *RSDP to point to it. + * + * NOTE: The RSDP must be either in the first 1K of the Extended + * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section + * 5.2.2; assertion #421). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbFindRsdp ( + ACPI_TABLE_DESC *TableInfo) +{ + UINT8 *TablePtr; + UINT8 *MemRover; + UINT8 *PhysAddr; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbFindRsdp"); + + + /* + * Search memory for RSDP. First map low physical memory. + */ + + Status = AcpiOsMapMemory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE, + (void **)&TablePtr); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * 1) Search EBDA (low memory) paragraphs + */ + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, LO_RSDP_WINDOW_SIZE); + + /* This mapping is no longer needed */ + + AcpiOsUnmapMemory (TablePtr, LO_RSDP_WINDOW_SIZE); + + if (MemRover) + { + /* Found it, return the physical address */ + + PhysAddr = LO_RSDP_WINDOW_BASE; + PhysAddr += (MemRover - TablePtr); + + TableInfo->Pointer = (ACPI_TABLE_HEADER *) PhysAddr; + + return_ACPI_STATUS (AE_OK); + } + + + /* + * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h + */ + + Status = AcpiOsMapMemory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE, + (void **)&TablePtr); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, HI_RSDP_WINDOW_SIZE); + + /* This mapping is no longer needed */ + + AcpiOsUnmapMemory (TablePtr, HI_RSDP_WINDOW_SIZE); + + if (MemRover) + { + /* Found it, return the physical address */ + + PhysAddr = HI_RSDP_WINDOW_BASE; + PhysAddr += (MemRover - TablePtr); + + TableInfo->Pointer = (ACPI_TABLE_HEADER *) PhysAddr; + + return_ACPI_STATUS (AE_OK); + } + + + /* RSDP signature was not found */ + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h new file mode 100644 index 0000000..116c020 --- /dev/null +++ b/sys/contrib/dev/acpica/acconfig.h @@ -0,0 +1,269 @@ +/****************************************************************************** + * + * Name: acconfig.h - Global configuration constants + * $Revision: 44 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACCONFIG_H +#define _ACCONFIG_H + + +/****************************************************************************** + * + * Compile-time options + * + *****************************************************************************/ + +/* + * ACPI_DEBUG - This switch enables all the debug facilities of the ACPI + * subsystem. This includes the DEBUG_PRINT output statements + * When disabled, all DEBUG_PRINT statements are compiled out. + * + * ACPI_APPLICATION - Use this switch if the subsystem is going to be run + * at the application level. + * + */ + + +/****************************************************************************** + * + * Subsystem Constants + * + *****************************************************************************/ + + +/* Version string */ + +#define ACPI_CA_VERSION __DATE__ + + +/* + * How and when control methods will be parsed + * The default action is to parse all methods at table load time to verify them, but delete the parse trees + * to conserve memory. Methods are parsed just in time before execution and the parse tree is deleted + * when execution completes. + */ +#define METHOD_PARSE_AT_INIT 0x0 /* Parse at table init, never delete the method parse tree */ +#define METHOD_PARSE_JUST_IN_TIME 0x1 /* Parse only when a method is invoked */ +#define METHOD_DELETE_AT_COMPLETION 0x2 /* Delete parse tree on method completion */ + +/* Default parsing configuration */ + +#define METHOD_PARSE_CONFIGURATION (METHOD_PARSE_JUST_IN_TIME | METHOD_DELETE_AT_COMPLETION) + + +/* Maximum objects in the various object caches */ + +#define MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */ +#define MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ +#define MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ +#define MAX_WALK_CACHE_DEPTH 2 /* Objects for parse tree walks (method execution) */ + +/* + * NameSpace Table size + * + * All tables are the same size to simplify the implementation. + * Tables may be extended by allocating additional tables that + * are in turn linked together to form a chain of tables. + */ + +#define NS_TABLE_SIZE 4 + +/* String size constants */ + +#define MAX_STRING_LENGTH 512 +#define PATHNAME_MAX 256 /* A full namespace pathname */ + + +/* Maximum count for a semaphore object */ + +#define MAX_SEMAPHORE_COUNT 256 + + +/* Max reference count (for debug only) */ + +#define MAX_REFERENCE_COUNT 0x200 + + +/* Size of cached memory mapping for system memory operation region */ + +#define SYSMEM_REGION_WINDOW_SIZE 4096 + + +/* + * Debugger threading model + * Use single threaded if the entire subsystem is contained in an application + * Use multiple threaded when the the subsystem is running in the kernel. + * + * By default the model is single threaded if ACPI_APPLICATION is set, + * multi-threaded if ACPI_APPLICATION is not set. + */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + +#ifdef ACPI_APPLICATION +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED + +#else +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#endif + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* + * Method info (in WALK_STATE), containing local variables and argumetns + */ + +#define MTH_NUM_LOCALS 8 +#define MTH_MAX_LOCAL 7 + +#define MTH_NUM_ARGS 7 +#define MTH_MAX_ARG 6 + +/* + * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG + */ + +#define OBJ_NUM_OPERANDS 8 +#define OBJ_MAX_OPERAND 7 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 INT8 for separator */ +#define PATH_SEPARATOR '.' + + +/* Constants used in searching for the RSDP in low memory */ + +#define LO_RSDP_WINDOW_BASE (void *) 0 +#define HI_RSDP_WINDOW_BASE (void *) 0xE0000 +#define LO_RSDP_WINDOW_SIZE 0x400 +#define HI_RSDP_WINDOW_SIZE 0x20000 +#define RSDP_SCAN_STEP 16 + + +/* Maximum nesting of package objects */ + +#define MAX_PACKAGE_DEPTH 16 + + +#endif /* _ACCONFIG_H */ + diff --git a/sys/contrib/dev/acpica/acdebug.h b/sys/contrib/dev/acpica/acdebug.h new file mode 100644 index 0000000..9e164ca --- /dev/null +++ b/sys/contrib/dev/acpica/acdebug.h @@ -0,0 +1,493 @@ +/****************************************************************************** + * + * Name: acdebug.h - ACPI/AML debugger + * $Revision: 37 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDEBUG_H__ +#define __ACDEBUG_H__ + + +#define DB_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define DB_COMMAND_PROMPT '-' +#define DB_EXECUTE_PROMPT '%' + + +extern int optind; +extern NATIVE_CHAR *optarg; +extern UINT8 *AmlPtr; +extern UINT32 AcpiAmlLength; + +extern BOOLEAN opt_tables; +extern BOOLEAN opt_disasm; +extern BOOLEAN opt_stats; +extern BOOLEAN opt_parse_jit; +extern BOOLEAN opt_verbose; + + +extern NATIVE_CHAR *Args[DB_MAX_ARGS]; +extern NATIVE_CHAR LineBuf[80]; +extern NATIVE_CHAR ScopeBuf[40]; +extern NATIVE_CHAR DebugFilename[40]; +extern BOOLEAN OutputToFile; +extern NATIVE_CHAR *Buffer; +extern NATIVE_CHAR *Filename; +extern NATIVE_CHAR *INDENT_STRING; +extern UINT8 AcpiGbl_DbOutputFlags; +extern UINT32 AcpiGbl_DbDebugLevel; +extern UINT32 AcpiGbl_DbConsoleDebugLevel; + +extern UINT32 NumNames; +extern UINT32 NumMethods; +extern UINT32 NumRegions; +extern UINT32 NumPackages; +extern UINT32 NumAliases; +extern UINT32 NumDevices; +extern UINT32 NumFieldDefs; +extern UINT32 NumThermalZones; +extern UINT32 NumNodes; +extern UINT32 NumGrammarElements; +extern UINT32 NumMethodElements ; +extern UINT32 NumMutexes; +extern UINT32 NumPowerResources; +extern UINT32 NumBankFields ; +extern UINT32 NumIndexFields; +extern UINT32 NumEvents; + +extern UINT32 SizeOfParseTree; +extern UINT32 SizeOfMethodTrees; +extern UINT32 SizeOfNTEs; +extern UINT32 SizeOfAcpiObjects; + + +#define BUFFER_SIZE 4196 + +#define DB_REDIRECTABLE_OUTPUT 0x01 +#define DB_CONSOLE_OUTPUT 0x02 +#define DB_DUPLICATE_OUTPUT 0x03 + + +typedef struct CommandInfo +{ + NATIVE_CHAR *Name; /* Command Name */ + UINT8 MinArgs; /* Minimum arguments required */ + +} COMMAND_INFO; + + +typedef struct ArgumentInfo +{ + NATIVE_CHAR *Name; /* Argument Name */ + +} ARGUMENT_INFO; + + +#define PARAM_LIST(pl) pl + +#define DBTEST_OUTPUT_LEVEL(lvl) if (opt_verbose) + +#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ + AcpiOsPrintf PARAM_LIST(fp);} + +#define EX_NO_SINGLE_STEP 1 +#define EX_SINGLE_STEP 2 + + +/* Prototypes */ + + +/* + * dbapi - external debugger interfaces + */ + +int +AcpiDbInitialize ( + void); + +ACPI_STATUS +AcpiDbSingleStep ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT8 OpType); + + +/* + * dbcmds - debug commands and output routines + */ + + +void +AcpiDbDisplayTableInfo ( + NATIVE_CHAR *TableArg); + +void +AcpiDbUnloadAcpiTable ( + NATIVE_CHAR *TableArg, + NATIVE_CHAR *InstanceArg); + +void +AcpiDbSetMethodBreakpoint ( + NATIVE_CHAR *Location, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDisassembleAml ( + NATIVE_CHAR *Statements, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDumpNamespace ( + NATIVE_CHAR *StartArg, + NATIVE_CHAR *DepthArg); + +void +AcpiDbDumpNamespaceByOwner ( + NATIVE_CHAR *OwnerArg, + NATIVE_CHAR *DepthArg); + +void +AcpiDbSendNotify ( + NATIVE_CHAR *Name, + UINT32 Value); + +void +AcpiDbSetMethodData ( + NATIVE_CHAR *TypeArg, + NATIVE_CHAR *IndexArg, + NATIVE_CHAR *ValueArg); + +ACPI_STATUS +AcpiDbDisplayObjects ( + NATIVE_CHAR *ObjTypeArg, + NATIVE_CHAR *DisplayCountArg); + +ACPI_STATUS +AcpiDbFindNameInNamespace ( + NATIVE_CHAR *NameArg); + +void +AcpiDbSetScope ( + NATIVE_CHAR *Name); + +void +AcpiDbFindReferences ( + NATIVE_CHAR *ObjectArg); + + +/* + * dbdisasm - AML disassembler + */ + +void +AcpiDbDisplayOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes); + +void +AcpiDbDisplayNamestring ( + NATIVE_CHAR *Name); + +void +AcpiDbDisplayPath ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDisplayOpcode ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * dbdisply - debug display commands + */ + + +void +AcpiDbDisplayMethodInfo ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDecodeAndDisplayObject ( + NATIVE_CHAR *Target, + NATIVE_CHAR *OutputType); + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDbDisplayAllMethods ( + NATIVE_CHAR *DisplayCountArg); + +void +AcpiDbDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiDbDisplayArguments ( + void); + +void +AcpiDbDisplayLocals ( + void); + +void +AcpiDbDisplayResults ( + void); + +void +AcpiDbDisplayCallingTree ( + void); + +void +AcpiDbDisplayArgumentObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * dbexec - debugger control method execution + */ + +void +AcpiDbExecute ( + NATIVE_CHAR *Name, + NATIVE_CHAR **Args, + UINT32 Flags); + +void +AcpiDbCreateExecutionThreads ( + NATIVE_CHAR *NumThreadsArg, + NATIVE_CHAR *NumLoopsArg, + NATIVE_CHAR *MethodNameArg); + + +/* + * dbfileio - Debugger file I/O commands + */ + +OBJECT_TYPE_INTERNAL +AcpiDbMatchArgument ( + NATIVE_CHAR *UserArgument, + ARGUMENT_INFO *Arguments); + + +void +AcpiDbCloseDebugFile ( + void); + +void +AcpiDbOpenDebugFile ( + NATIVE_CHAR *Name); + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + NATIVE_CHAR *Filename); + + +/* + * dbhistry - debugger HISTORY command + */ + +void +AcpiDbAddToHistory ( + NATIVE_CHAR *CommandLine); + +void +AcpiDbDisplayHistory (void); + +NATIVE_CHAR * +AcpiDbGetFromHistory ( + NATIVE_CHAR *CommandNumArg); + + +/* + * dbinput - user front-end to the AML debugger + */ + +ACPI_STATUS +AcpiDbCommandDispatch ( + NATIVE_CHAR *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbExecuteThread ( + void *Context); + +ACPI_STATUS +AcpiDbUserCommands ( + NATIVE_CHAR Prompt, + ACPI_PARSE_OBJECT *Op); + + +/* + * dbstats - Generation and display of ACPI table statistics + */ + +void +AcpiDbGenerateStatistics ( + ACPI_PARSE_OBJECT *Root, + BOOLEAN IsMethod); + + +ACPI_STATUS +AcpiDbDisplayStatistics ( + NATIVE_CHAR *TypeArg); + + +/* + * dbutils - AML debugger utilities + */ + +void +AcpiDbSetOutputDestination ( + UINT32 Where); + +void +AcpiDbDumpBuffer ( + UINT32 Address); + +void +AcpiDbDumpObject ( + ACPI_OBJECT *ObjDesc, + UINT32 Level); + +void +AcpiDbPrepNamestring ( + NATIVE_CHAR *Name); + + +ACPI_STATUS +AcpiDbSecondPassParse ( + ACPI_PARSE_OBJECT *Root); + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + NATIVE_CHAR *Name); + + +#endif /* __ACDEBUG_H__ */ diff --git a/sys/contrib/dev/acpica/acdispat.h b/sys/contrib/dev/acpica/acdispat.h new file mode 100644 index 0000000..2266e9f --- /dev/null +++ b/sys/contrib/dev/acpica/acdispat.h @@ -0,0 +1,523 @@ +/****************************************************************************** + * + * Name: acdispat.h - dispatcher (parser to interpreter interface) + * $Revision: 31 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef _ACDISPAT_H_ +#define _ACDISPAT_H_ + + +#define NAMEOF_LOCAL_NTE "__L0" +#define NAMEOF_ARG_NTE "__A0" + + +/* For AcpiDsMethodDataSetValue */ + +#define MTH_TYPE_LOCAL 0 +#define MTH_TYPE_ARG 1 + + + + +/* Common interfaces */ + +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); + + +/* dsopcode - support for late evaluation */ + +ACPI_STATUS +AcpiDsGetFieldUnitArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *RgnDesc); + + +/* dsctrl - Parser/Interpreter interface, control stack routines */ + + +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* dsexec - Parser/Interpreter interface, method execution callbacks */ + + +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 HasResultObj); + +ACPI_STATUS +AcpiDsExecBeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op); + + +/* dsfield - Parser/Interpreter interface for AML fields */ + + +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE RegionNode, + ACPI_WALK_STATE *WalkState); + + +/* dsload - Parser/Interpreter interface, namespace load callbacks */ + +ACPI_STATUS +AcpiDsLoad1BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsLoad3BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad3EndOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op); + + +/* dsmthdat - method data (locals/args) */ + + +ACPI_STATUS +AcpiDsMethodDataGetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT ***Node); + +ACPI_STATUS +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsIsMethodValue ( + ACPI_OPERAND_OBJECT *ObjDesc); + +OBJECT_TYPE_INTERNAL +AcpiDsMethodDataGetType ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc); + +ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataDeleteValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState); + +ACPI_NAMESPACE_NODE * +AcpiDsMethodDataGetNte ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataSetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + + +/* dsmethod - Parser/Interpreter interface - control method parsing */ + +ACPI_STATUS +AcpiDsParseMethod ( + ACPI_HANDLE ObjHandle); + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_WALK_LIST *WalkList, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc); + +ACPI_STATUS +AcpiDsTerminateControlMethod ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* dsobj - Parser/Interpreter interface - object initialization and conversion */ + +ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiDsInitializeObjects ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *StartNode); + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **ObjDescPtr); + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + + +/* dsregn - Parser/Interpreter interface - Op Region parsing */ + +ACPI_STATUS +AcpiDsEvalFieldUnitOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle); + + +/* dsutils - Parser/Interpreter interface utility routines */ + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg); + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg); + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState); + +OBJECT_TYPE_INTERNAL +AcpiDsMapOpcodeToDataType ( + UINT16 Opcode, + UINT32 *OutFlags); + +OBJECT_TYPE_INTERNAL +AcpiDsMapNamedOpcodeToDataType ( + UINT16 Opcode); + + +/* + * dswscope - Scope Stack manipulation + */ + +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_WALK_STATE *WalkState); + + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState); + + +/* AcpiDswstate - parser WALK_STATE management routines */ + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_WALK_LIST *WalkList); + +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_WALK_LIST *WalkList); + +ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsResultStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsResultStackClear ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_WALK_LIST *WalkList); + +void +AcpiDsDeleteWalkStateCache ( + void); + + +#endif /* _ACDISPAT_H_ */ diff --git a/sys/contrib/dev/acpica/acefi.h b/sys/contrib/dev/acpica/acefi.h new file mode 100644 index 0000000..6875d04 --- /dev/null +++ b/sys/contrib/dev/acpica/acefi.h @@ -0,0 +1,127 @@ +/****************************************************************************** + * + * Name: acefi.h - OS specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEFI_H__ +#define __ACEFI_H__ + +#define ACPI_OS_NAME "AED EFI" + +#include +#include +#include + + +#endif /* __ACEFI_H__ */ \ No newline at end of file diff --git a/sys/contrib/dev/acpica/acenv.h b/sys/contrib/dev/acpica/acenv.h new file mode 100644 index 0000000..1d44537 --- /dev/null +++ b/sys/contrib/dev/acpica/acenv.h @@ -0,0 +1,374 @@ +/****************************************************************************** + * + * Name: acenv.h - Generation environment specific items + * $Revision: 61 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACENV_H__ +#define __ACENV_H__ + + +/* + * Configuration for ACPI Utilities + */ + +#ifdef _ACPI_DUMP_APP +#define ACPI_DEBUG +#define ACPI_APPLICATION +#define ENABLE_DEBUGGER +#define ACPI_USE_SYSTEM_CLIBRARY +#define PARSER_ONLY +#endif + +#ifdef _ACPI_EXEC_APP +#undef DEBUGGER_THREADING +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED +#define ACPI_DEBUG +#define ACPI_APPLICATION +#define ENABLE_DEBUGGER +#define ACPI_USE_SYSTEM_CLIBRARY +#endif + + +/* + * Environment configuration. The purpose of this file is to interface to the + * local generation environment. + * + * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. + * Otherwise, local versions of string/memory functions will be used. + * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and + * the standard header files may be used. + * + * The ACPI subsystem only uses low level C library functions that do not call + * operating system services and may therefore be inlined in the code. + * + * It may be necessary to tailor these include files to the target + * generation environment. + * + * + * Functions and constants used from each header: + * + * string.h: memcpy + * memset + * strcat + * strcmp + * strcpy + * strlen + * strncmp + * strncat + * strncpy + * + * stdlib.h: strtoul + * + * stdarg.h: va_list + * va_arg + * va_start + * va_end + * + */ + +/*! [Begin] no source code translation */ + +#ifdef _LINUX +#include "aclinux.h" + +#elif _AED_EFI +#include "acefi.h" + +#elif WIN32 +#include "acwin.h" + +#elif __FreeBSD__ +#include "acfreebsd.h" + +#else + +/* All other environments */ + +#define ACPI_USE_STANDARD_HEADERS + +/* Name of host operating system (returned by the _OS_ namespace object) */ + +#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" + +#endif + + +/*! [End] no source code translation !*/ + +/****************************************************************************** + * + * C library configuration + * + *****************************************************************************/ + +#ifdef ACPI_USE_SYSTEM_CLIBRARY +/* + * Use the standard C library headers. + * We want to keep these to a minimum. + * + */ + +#ifdef ACPI_USE_STANDARD_HEADERS +/* + * Use the standard headers from the standard locations + */ +#include +#include +#include +#include + +#endif /* ACPI_USE_STANDARD_HEADERS */ + +/* + * We will be linking to the standard Clib functions + */ + +#define STRSTR(s1,s2) strstr((s1), (s2)) +#define STRUPR(s) strupr((s)) +#define STRLEN(s) strlen((s)) +#define STRCPY(d,s) strcpy((d), (s)) +#define STRNCPY(d,s,n) strncpy((d), (s), (n)) +#define STRNCMP(d,s,n) strncmp((d), (s), (n)) +#define STRCMP(d,s) strcmp((d), (s)) +#define STRCAT(d,s) strcat((d), (s)) +#define STRNCAT(d,s,n) strncat((d), (s), (n)) +#define STRTOUL(d,s,n) strtoul((d), (s), (n)) +#define MEMCPY(d,s,n) memcpy((d), (s), (n)) +#define MEMSET(d,s,n) memset((d), (s), (n)) +#define TOUPPER toupper +#define TOLOWER tolower + + +/****************************************************************************** + * + * Not using native C library, use local implementations + * + *****************************************************************************/ +#else + +/* + * Use local definitions of C library macros and functions + * NOTE: The function implementations may not be as efficient + * as an inline or assembly code implementation provided by a + * native C library. + */ + +#ifndef va_arg + +#ifndef _VALIST +#define _VALIST +typedef char *va_list; +#endif /* _VALIST */ + +/* + * Storage alignment properties + */ + +#define _AUPBND (sizeof(int) - 1) +#define _ADNBND (sizeof(int) - 1) + +/* + * Variable argument list macro definitions + */ + +#define _Bnd(X, bnd) (((sizeof(X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap)+=((_Bnd(T, _AUPBND)))-(_Bnd(T,_ADNBND))))) +#define va_end(ap) (void)0 +#define va_start(ap, A) (void)((ap)=(((char*)&(A))+(_Bnd(A,_AUPBND)))) + +#endif /* va_arg */ + + +#define STRSTR(s1,s2) AcpiCmStrstr ((s1), (s2)) +#define STRUPR(s) AcpiCmStrupr ((s)) +#define STRLEN(s) AcpiCmStrlen ((s)) +#define STRCPY(d,s) AcpiCmStrcpy ((d), (s)) +#define STRNCPY(d,s,n) AcpiCmStrncpy ((d), (s), (n)) +#define STRNCMP(d,s,n) AcpiCmStrncmp ((d), (s), (n)) +#define STRCMP(d,s) AcpiCmStrcmp ((d), (s)) +#define STRCAT(d,s) AcpiCmStrcat ((d), (s)) +#define STRNCAT(d,s,n) AcpiCmStrncat ((d), (s), (n)) +#define STRTOUL(d,s,n) AcpiCmStrtoul ((d), (s),(n)) +#define MEMCPY(d,s,n) AcpiCmMemcpy ((d), (s), (n)) +#define MEMSET(d,v,n) AcpiCmMemset ((d), (v), (n)) +#define TOUPPER AcpiCmToUpper +#define TOLOWER AcpiCmToLower + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + + +/****************************************************************************** + * + * Assembly code macros + * + *****************************************************************************/ + +/* + * Handle platform- and compiler-specific assembly language differences. + * These should already have been defined by the platform includes above. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +/* Unrecognized compiler, use defaults */ +#ifndef ACPI_ASM_MACROS + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() +#define enable() +#define halt() +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) + +#endif /* ACPI_ASM_MACROS */ + + +#ifdef ACPI_APPLICATION + +/* Don't want software interrupts within a ring3 application */ + +#undef causeinterrupt +#undef BREAKPOINT3 +#define causeinterrupt(level) +#define BREAKPOINT3 +#endif + + +/****************************************************************************** + * + * Compiler-specific + * + *****************************************************************************/ + +/* this has been moved to compiler-specific headers, which are included from the + platform header. */ + + + +/* TBD: move this elsewhere! */ + +#ifdef __ia64__ +/* Look at interim FADT to determine IO or memory mapped */ +#define IoAddressSpace(flag) (AcpiGbl_FACP->AddressSpace & flag) +#else +/* always IO space */ +#define IoAddressSpace(flag) (1) +#endif + + +#endif /* __ACENV_H__ */ diff --git a/sys/contrib/dev/acpica/acevents.h b/sys/contrib/dev/acpica/acevents.h new file mode 100644 index 0000000..5253b95 --- /dev/null +++ b/sys/contrib/dev/acpica/acevents.h @@ -0,0 +1,306 @@ +/****************************************************************************** + * + * Name: acevents.h - Event subcomponent prototypes and defines + * $Revision: 59 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEVENTS_H__ +#define __ACEVENTS_H__ + + +ACPI_STATUS +AcpiEvInitialize ( + void); + + +/* + * AcpiEvfixed - Fixed event handling + */ + +ACPI_STATUS +AcpiEvFixedEventInitialize ( + void); + +UINT32 +AcpiEvFixedEventDetect ( + void); + +UINT32 +AcpiEvFixedEventDispatch ( + UINT32 AcpiEvent); + + +/* + * AcpiEvglock - Global Lock support + */ + +ACPI_STATUS +AcpiEvAcquireGlobalLock( + void); + +void +AcpiEvReleaseGlobalLock( + void); + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void); + + +/* + * AcpiEvgpe - GPE handling and dispatch + */ + +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + +ACPI_STATUS +AcpiEvInitGpeControlMethods ( + void); + +UINT32 +AcpiEvGpeDispatch ( + UINT32 GpeNumber); + +UINT32 +AcpiEvGpeDetect ( + void); + + +/* + * AcpiEvnotify - Device Notify handling and dispatch + */ + +void +AcpiEvNotifyDispatch ( + ACPI_HANDLE Device, + UINT32 NotifyValue); + + +/* + * AcpiEvregion - Address Space handling + */ + +ACPI_STATUS +AcpiEvInstallDefaultAddressSpaceHandlers ( + void); + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value); + + +ACPI_STATUS +AcpiEvAddrHandlerHelper ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +void +AcpiEvDisassociateRegionFromHandler( + ACPI_OPERAND_OBJECT *RegionObj); + + +ACPI_STATUS +AcpiEvAssociateRegionAndHandler ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + + +/* + * AcpiEvregini - Region initialization and setup + */ + +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked); + + +/* + * Evsci - SCI (System Control Interrupt) handling/dispatch + */ + +UINT32 +AcpiEvInstallSciHandler ( + void); + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void); + +UINT32 +AcpiEvInitializeSCI ( + UINT32 ProgramSCI); + +void +AcpiEvRestoreAcpiState ( + void); + +void +AcpiEvTerminate ( + void); + + +/* Debug support */ + +#ifdef ACPI_DEBUG + +UINT32 +AcpiEvSciCount ( + UINT32 AcpiEvent); + +#define DEBUG_INCREMENT_EVENT_COUNT(a) AcpiGbl_EventCount[a]++; + +#else + +#define DEBUG_INCREMENT_EVENT_COUNT(a) +#endif + + +#endif /* __ACEVENTS_H__ */ diff --git a/sys/contrib/dev/acpica/acexcep.h b/sys/contrib/dev/acpica/acexcep.h new file mode 100644 index 0000000..87b2ecc --- /dev/null +++ b/sys/contrib/dev/acpica/acexcep.h @@ -0,0 +1,312 @@ +/****************************************************************************** + * + * Name: acexcep.h - Exception codes returned by the ACPI subsystem + * $Revision: 36 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEXCEP_H__ +#define __ACEXCEP_H__ + + +/* + * Exceptions returned by external ACPI interfaces + */ + +#define AE_CODE_ENVIRONMENTAL 0x0000 +#define AE_CODE_PROGRAMMER 0x1000 +#define AE_CODE_ACPI_TABLES 0x2000 +#define AE_CODE_AML 0x3000 +#define AE_CODE_CONTROL 0x4000 +#define AE_CODE_MASK 0xF000 + + +#define ACPI_SUCCESS(a) (!(a)) +#define ACPI_FAILURE(a) (a) + + +#define AE_OK (ACPI_STATUS) 0x0000 + +/* + * Environmental exceptions + */ +#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL) +#define AE_EXIST (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL) +#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL) +#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) +#define AE_VERSION_MISMATCH (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) +#define AE_SUPPORT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) +#define AE_SHARE (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) +#define AE_LIMIT (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) +#define AE_TIME (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) +#define AE_UNKNOWN_STATUS (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x0014 + +/* + * Programmer exceptions + */ +#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER) +#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) +#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) +#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) +#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) + +#define AE_CODE_PGM_MAX 0x0005 + + +/* + * Acpi table exceptions + */ +#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES) +#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) +#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) +#define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES) + +#define AE_CODE_TBL_MAX 0x0003 + + +/* + * AML exceptions. These are caused by problems with + * the actual AML byte stream + */ +#define AE_AML_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_AML) +#define AE_AML_PARSE (ACPI_STATUS) (0x0002 | AE_CODE_AML) +#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0003 | AE_CODE_AML) +#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0004 | AE_CODE_AML) +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0005 | AE_CODE_AML) +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0006 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0007 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0008 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0009 | AE_CODE_AML) +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x000A | AE_CODE_AML) +#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000C | AE_CODE_AML) +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000D | AE_CODE_AML) +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000E | AE_CODE_AML) +#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000F | AE_CODE_AML) +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x0010 | AE_CODE_AML) +#define AE_AML_INTERNAL (ACPI_STATUS) (0x0011 | AE_CODE_AML) + +#define AE_CODE_AML_MAX 0x0011 + +/* + * Internal exceptions used for control + */ +#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL) +#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL) +#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL) +#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL) +#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL) +#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL) +#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL) +#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL) + +#define AE_CODE_CTRL_MAX 0x0008 + + +#ifdef DEFINE_ACPI_GLOBALS + +/* + * String versions of the exception codes above + * These strings must match the corresponding defines exactly + */ +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Env[] = +{ + "AE_OK", + "AE_ERROR", + "AE_NO_ACPI_TABLES", + "AE_NO_NAMESPACE", + "AE_NO_MEMORY", + "AE_NOT_FOUND", + "AE_NOT_EXIST", + "AE_EXIST", + "AE_TYPE", + "AE_NULL_OBJECT", + "AE_NULL_ENTRY", + "AE_BUFFER_OVERFLOW", + "AE_STACK_OVERFLOW", + "AE_STACK_UNDERFLOW", + "AE_NOT_IMPLEMENTED", + "AE_VERSION_MISMATCH", + "AE_SUPPORT", + "AE_SHARE", + "AE_LIMIT", + "AE_TIME", + "AE_UNKNOWN_STATUS", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Pgm[] = +{ + "AE_BAD_PARAMETER", + "AE_BAD_CHARACTER", + "AE_BAD_PATHNAME", + "AE_BAD_DATA", + "AE_BAD_ADDRESS", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Tbl[] = +{ + "AE_BAD_SIGNATURE", + "AE_BAD_HEADER", + "AE_BAD_CHECKSUM", + "AE_BAD_VALUE", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Aml[] = +{ + "AE_AML_ERROR", + "AE_AML_PARSE", + "AE_AML_BAD_OPCODE", + "AE_AML_NO_OPERAND", + "AE_AML_OPERAND_TYPE", + "AE_AML_OPERAND_VALUE", + "AE_AML_UNINITIALIZED_LOCAL", + "AE_AML_UNINITIALIZED_ARG", + "AE_AML_UNINITIALIZED_ELEMENT", + "AE_AML_NUMERIC_OVERFLOW", + "AE_AML_REGION_LIMIT", + "AE_AML_BUFFER_LIMIT", + "AE_AML_PACKAGE_LIMIT", + "AE_AML_DIVIDE_BY_ZERO", + "AE_AML_BAD_NAME", + "AE_AML_NAME_NOT_FOUND", + "AE_AML_INTERNAL", +}; + +static NATIVE_CHAR *AcpiGbl_ExceptionNames_Ctrl[] = +{ + "AE_CTRL_RETURN_VALUE", + "AE_CTRL_PENDING", + "AE_CTRL_TERMINATE", + "AE_CTRL_TRUE", + "AE_CTRL_FALSE", + "AE_CTRL_DEPTH", + "AE_CTRL_END", + "AE_CTRL_TRANSFER", +}; + + +#endif /* DEFINE_ACPI_GLOBALS */ + + +#endif /* __ACEXCEP_H__ */ diff --git a/sys/contrib/dev/acpica/acfreebsd.h b/sys/contrib/dev/acpica/acfreebsd.h new file mode 100644 index 0000000..36ba77a --- /dev/null +++ b/sys/contrib/dev/acpica/acfreebsd.h @@ -0,0 +1,134 @@ +/****************************************************************************** + * + * Name: acfreebsd.h - OS specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACFREEBSD_H__ +#define __ACFREEBSD_H__ + +#define ACPI_OS_NAME "FreeBSD" + +#ifdef _KERNEL +#include +#include +#include +#include +#include + +#define asm __asm +#define __cli() disable_intr() +#define __sti() enable_intr() + + +#endif /* __ACFREEBSD_H__ */ \ No newline at end of file diff --git a/sys/contrib/dev/acpica/acgcc.h b/sys/contrib/dev/acpica/acgcc.h new file mode 100644 index 0000000..9689664 --- /dev/null +++ b/sys/contrib/dev/acpica/acgcc.h @@ -0,0 +1,240 @@ +/****************************************************************************** + * + * Name: acgcc.h - GCC specific defines, etc. + * $Revision: 1 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGCC_H__ +#define __ACGCC_H__ + +#define COMPILER_DEPENDENT_UINT64 unsigned long long + + +#ifdef __ia64__ +#define _IA64 + +/* Single threaded */ +#define ACPI_APPLICATION + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() __cli() +#define enable() __sti() +#define wbinvd() + +/*! [Begin] no source code translation */ + +#include + +#define halt() ia64_pal_halt_light() /* PAL_HALT[_LIGHT] */ +#define safe_halt() ia64_pal_halt(1) /* PAL_HALT */ + + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + __asm__ volatile ("1: ld4 r29=%1\n" \ + ";;\n" \ + "mov ar.ccv=r29\n" \ + "mov r2=r29\n" \ + "shr.u r30=r29,1\n" \ + "and r29=-4,r29\n" \ + ";;\n" \ + "add r29=2,r29\n" \ + "and r30=1,r30\n" \ + ";;\n" \ + "add r29=r29,r30\n" \ + ";;\n" \ + "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ + ";;\n" \ + "cmp.eq p6,p7=r2,r30\n" \ + "(p7) br.dpnt.few 1b\n" \ + "cmp.gt p8,p9=3,r29\n" \ + ";;\n" \ + "(p8) mov %0=-1\n" \ + "(p9) mov %0=r0\n" \ + :"=r"(Acq):"m" __atomic_fool_gcc((GLptr)):"r2","r29","r30","memory"); \ + } while (0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + __asm__ volatile ("1: ld4 r29=%1\n" \ + ";;\n" \ + "mov ar.ccv=r29\n" \ + "mov r2=r29\n" \ + "and r29=-4,r29\n" \ + ";;\n" \ + "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ + ";;\n" \ + "cmp.eq p6,p7=r2,r30\n" \ + "(p7) br.dpnt.few 1b\n" \ + "and %0=1,r2\n" \ + ";;\n" \ + :"=r"(Acq):"m" __atomic_fool_gcc((GLptr)):"r2","r29","r30","memory"); \ + } while (0) +/*! [End] no source code translation !*/ + + +#else /* DO IA32 */ + + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() __cli() +#define enable() __sti() +#define halt() __asm__ __volatile__ ("sti; hlt":::"memory") +#define wbinvd() + +/*! [Begin] no source code translation + * + * A brief explanation as GNU inline assembly is a bit hairy + * %0 is the output parameter in EAX ("=a") + * %1 and %2 are the input parameters in ECX ("c") + * and an immediate value ("i") respectively + * All actual register references are preceded with "%%" as in "%%edx" + * Immediate values in the assembly are preceded by "$" as in "$0x1" + * The final asm parameter are the operation altered non-output registers. + */ +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "btsl $0x1,%%edx;" \ + "adcl $0x0,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "cmpb $0x3,%%dl;" \ + "sbbl %%eax,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + } while(0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "andl $0x1,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + } while(0) + +/*! [End] no source code translation !*/ + +#endif /* IA 32 */ + +#endif /* __ACGCC_H__ */ diff --git a/sys/contrib/dev/acpica/acglobal.h b/sys/contrib/dev/acpica/acglobal.h new file mode 100644 index 0000000..45bfa70 --- /dev/null +++ b/sys/contrib/dev/acpica/acglobal.h @@ -0,0 +1,410 @@ +/****************************************************************************** + * + * Name: acglobal.h - Declarations for global variables + * $Revision: 85 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACGLOBAL_H__ +#define __ACGLOBAL_H__ + + +/* + * Ensure that the globals are actually defined only once. + * + * The use of these defines allows a single list of globals (here) in order + * to simplify maintenance of the code. + */ +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_EXTERN +#else +#define ACPI_EXTERN extern +#endif + + +extern NATIVE_CHAR *MsgAcpiErrorBreak; + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Runtime configuration of debug print levels */ + +extern UINT32 AcpiDbgLevel; +extern UINT32 AcpiDbgLayer; + + +/* Procedure nesting level for debug output */ + +extern UINT32 AcpiGbl_NestingLevel; + + +/***************************************************************************** + * + * ACPI Table globals + * + ****************************************************************************/ + +/* + * Table pointers. + * Although these pointers are somewhat redundant with the global AcpiTable, + * they are convenient because they are typed pointers. + * + * These tables are single-table only; meaning that there can be at most one + * of each in the system. Each global points to the actual table. + * + */ +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTOR_POINTER *AcpiGbl_RSDP; +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTION_TABLE *AcpiGbl_RSDT; +ACPI_EXTERN FIRMWARE_ACPI_CONTROL_STRUCTURE *AcpiGbl_FACS; +ACPI_EXTERN FIXED_ACPI_DESCRIPTION_TABLE *AcpiGbl_FACP; +ACPI_EXTERN APIC_TABLE *AcpiGbl_APIC; +ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; +ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_SBST; +/* + * Since there may be multiple SSDTs and PSDTS, a single pointer is not + * sufficient; Therefore, there isn't one! + */ + + +/* + * ACPI Table info arrays + */ +extern ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES]; +extern ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES]; + +/* + * Predefined mutex objects. This array contains the + * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. + * (The table maps local handles to the real OS handles) + */ +ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_AcpiMutexInfo [NUM_MTX]; + + +/***************************************************************************** + * + * Miscellaneous globals + * + ****************************************************************************/ + + +ACPI_EXTERN UINT8 *AcpiGbl_Gpe0EnableRegisterSave; +ACPI_EXTERN UINT8 *AcpiGbl_Gpe1EnableRegisterSave; +ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; +ACPI_EXTERN ACPI_GENERIC_STATE *AcpiGbl_GenericStateCache; +ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParseCache; +ACPI_EXTERN ACPI_PARSE2_OBJECT *AcpiGbl_ExtParseCache; +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_ObjectCache; +ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_WalkStateCache; +ACPI_EXTERN ACPI_HANDLE AcpiGbl_GlobalLockSemaphore; + + +ACPI_EXTERN UINT32 AcpiGbl_GlobalLockThreadCount; +ACPI_EXTERN UINT32 AcpiGbl_RestoreAcpiChipset; +ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; +ACPI_EXTERN UINT32 AcpiGbl_EdgeLevelSave; +ACPI_EXTERN UINT32 AcpiGbl_IrqEnableSave; +ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; + +ACPI_EXTERN UINT32 AcpiGbl_StateCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_StateCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_ParseCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_ParseCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_ExtParseCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_ExtParseCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_ObjectCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_ObjectCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_WalkStateCacheRequests; +ACPI_EXTERN UINT32 AcpiGbl_WalkStateCacheHits; +ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; +ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; + + +ACPI_EXTERN UINT16 AcpiGbl_GenericStateCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_ParseCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_ExtParseCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_ObjectCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_WalkStateCacheDepth; +ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; +ACPI_EXTERN UINT16 AcpiGbl_NextTableOwnerId; +ACPI_EXTERN UINT16 AcpiGbl_NextMethodOwnerId; + +ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockSet; /* TBD: [Restructure] OBSOLETE?? */ +ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; +ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; + + +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DrvNotify; +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SysNotify; + + +extern BOOLEAN AcpiGbl_Shutdown; +extern UINT32 AcpiGbl_SystemFlags; +extern UINT32 AcpiGbl_StartupFlags; + + +/***************************************************************************** + * + * Namespace globals + * + ****************************************************************************/ + +#define NUM_NS_TYPES INTERNAL_TYPE_INVALID+1 +#define NUM_PREDEFINED_NAMES 9 + + +ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; + +extern UINT8 AcpiGbl_NsProperties[NUM_NS_TYPES]; +extern PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; + + +/* Used to detect memory leaks (DEBUG ONLY) */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN ALLOCATION_INFO *AcpiGbl_HeadAllocPtr; +ACPI_EXTERN ALLOCATION_INFO *AcpiGbl_TailAllocPtr; +#endif + + +/***************************************************************************** + * + * Interpreter globals + * + ****************************************************************************/ + + +ACPI_EXTERN UINT32 AcpiGbl_WhenToParseMethods; +ACPI_EXTERN ACPI_WALK_LIST *AcpiGbl_CurrentWalkList; + +/* Base of AML block, and pointer to current location in it */ + +ACPI_EXTERN UINT8 *AcpiGbl_PCodeBase; +ACPI_EXTERN UINT8 *AcpiGbl_PCode; + +/* + * Length of AML block, and remaining length of current package. + */ +ACPI_EXTERN UINT32 AcpiGbl_PCodeBlockLen; +ACPI_EXTERN UINT32 AcpiGbl_PCodeLen; + +ACPI_EXTERN UINT32 AcpiGbl_BufSeq; /* Counts allocated Buffer descriptors */ +ACPI_EXTERN UINT32 AcpiGbl_NodeErr; /* Indicate if inc_error should be called */ + +/* + * Handle to the last method found - used during pass1 of load + */ +ACPI_EXTERN ACPI_HANDLE AcpiGbl_LastMethod; + +/* + * Table of Address Space handlers + */ + +ACPI_EXTERN ACPI_ADDRESS_SPACE_INFO AcpiGbl_AddressSpaces[ACPI_NUM_ADDRESS_SPACES]; + + +/* Control method single step flag */ + +ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; + + +/***************************************************************************** + * + * Parser globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; + +extern ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[]; +extern UINT8 AcpiGbl_AmlOpInfoIndex[256]; + + +/***************************************************************************** + * + * Hardware globals + * + ****************************************************************************/ + +extern ACPI_C_STATE_HANDLER AcpiHwCxHandlers[MAX_CX_STATES]; +extern UINT32 AcpiHwActiveCxState; + + +/***************************************************************************** + * + * Event globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventHandlers[NUM_FIXED_EVENTS]; + +ACPI_EXTERN ACPI_HANDLE AcpiGbl_GpeObjHandle; +ACPI_EXTERN UINT32 AcpiGbl_GpeRegisterCount; +ACPI_EXTERN ACPI_GPE_REGISTERS *AcpiGbl_GpeRegisters; +ACPI_EXTERN ACPI_GPE_LEVEL_INFO *AcpiGbl_GpeInfo; + +/* + * Gpe validation and translation table + * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported. + * Otherwise, returns a valid index into the global GPE table. + * + * This table is needed because the GPE numbers supported by block 1 do not + * have to be contiguous with the GPE numbers supported by block 0. + */ +ACPI_EXTERN UINT8 AcpiGbl_GpeValid [NUM_GPE]; + +/* AcpiEvent counter for debug only */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN UINT32 AcpiGbl_EventCount[NUM_FIXED_EVENTS]; +#endif + + +/***************************************************************************** + * + * Debugger globals + * + ****************************************************************************/ + +ACPI_EXTERN BOOLEAN AcpiGbl_MethodExecuting; +ACPI_EXTERN BOOLEAN AcpiGbl_DbTerminateThreads; + + +/* Memory allocation metrics - Debug Only! */ + +#ifdef ACPI_DEBUG + +ACPI_EXTERN UINT32 AcpiGbl_CurrentAllocSize; +ACPI_EXTERN UINT32 AcpiGbl_CurrentAllocCount; +ACPI_EXTERN UINT32 AcpiGbl_RunningAllocSize; +ACPI_EXTERN UINT32 AcpiGbl_RunningAllocCount; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentAllocSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentAllocCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentObjectCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentObjectSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentObjectCount; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentObjectSize; +ACPI_EXTERN UINT32 AcpiGbl_RunningObjectCount; +ACPI_EXTERN UINT32 AcpiGbl_RunningObjectSize; +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentNodeCount; + +#endif + + +#endif /* __ACGLOBAL_H__ */ diff --git a/sys/contrib/dev/acpica/achware.h b/sys/contrib/dev/acpica/achware.h new file mode 100644 index 0000000..046bbaf --- /dev/null +++ b/sys/contrib/dev/acpica/achware.h @@ -0,0 +1,260 @@ +/****************************************************************************** + * + * Name: achware.h -- hardware specific interfaces + * $Revision: 42 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACHWARE_H__ +#define __ACHWARE_H__ + + +/* Prototypes */ + + +ACPI_STATUS +AcpiHwInitialize ( + void); + +ACPI_STATUS +AcpiHwShutdown ( + void); + +ACPI_STATUS +AcpiHwInitializeSystemInfo ( + void); + +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode); + +UINT32 +AcpiHwGetMode ( + void); + +UINT32 +AcpiHwGetModeCapabilities ( + void); + +/* Register I/O Prototypes */ + +UINT32 +AcpiHwRegisterAccess ( + NATIVE_UINT ReadWrite, + BOOLEAN UseLock, + UINT32 RegisterId, ... /* DWORD Value */); + +void +AcpiHwClearAcpiStatus ( + void); + + +/* GPE support */ + +void +AcpiHwEnableGpe ( + UINT32 GpeIndex); + +void +AcpiHwDisableGpe ( + UINT32 GpeIndex); + +void +AcpiHwClearGpe ( + UINT32 GpeIndex); + +void +AcpiHwGetGpeStatus ( + UINT32 GpeNumber, + ACPI_EVENT_STATUS *EventStatus); + +/* Sleep Prototypes */ + +ACPI_STATUS +AcpiHwObtainSleepTypeRegisterData ( + UINT8 SleepState, + UINT8 *Slp_TypA, + UINT8 *Slp_TypB); + + +/* Cx State Prototypes */ + +ACPI_STATUS +AcpiHwEnterC1( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwEnterC2( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwEnterC3( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwEnterCx ( + ACPI_IO_ADDRESS PblkAddress, + UINT32 *PmTimerTicks); + +ACPI_STATUS +AcpiHwSetCx ( + UINT32 CxState); + +ACPI_STATUS +AcpiHwGetCxInfo ( + UINT32 CxStates[]); + + +/* Throttling Prototypes */ + +void +AcpiHwEnableThrottling ( + ACPI_IO_ADDRESS PblkAddress); + +void +AcpiHwDisableThrottling ( + ACPI_IO_ADDRESS PblkAddress); + +UINT32 +AcpiHwGetDutyCycle ( + UINT8 DutyOffset, + ACPI_IO_ADDRESS PblkAddress, + UINT32 NumThrottleStates); + +void +AcpiHwProgramDutyCycle ( + UINT8 DutyOffset, + UINT32 DutyCycle, + ACPI_IO_ADDRESS PblkAddress, + UINT32 NumThrottleStates); + +NATIVE_UINT +AcpiHwLocalPow ( + NATIVE_UINT x, + NATIVE_UINT y); + + +/* ACPI Timer prototypes */ + +UINT32 +AcpiHwPmtTicks ( + void); + +UINT32 +AcpiHwPmtResolution ( + void); + + +#endif /* __ACHWARE_H__ */ diff --git a/sys/contrib/dev/acpica/acinterp.h b/sys/contrib/dev/acpica/acinterp.h new file mode 100644 index 0000000..0a4e7a8 --- /dev/null +++ b/sys/contrib/dev/acpica/acinterp.h @@ -0,0 +1,624 @@ +/****************************************************************************** + * + * Name: acinterp.h - Interpreter subcomponent prototypes and defines + * $Revision: 82 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACINTERP_H__ +#define __ACINTERP_H__ + + +#define WALK_OPERANDS &(WalkState->Operands [WalkState->NumOperands -1]) + + +/* Interpreter constants */ + +#define AML_END_OF_BLOCK -1 +#define PUSH_PKG_LENGTH 1 +#define DO_NOT_PUSH_PKG_LENGTH 0 + + +#define STACK_TOP 0 +#define STACK_BOTTOM (UINT32) -1 + +/* Constants for global "WhenToParseMethods" */ + +#define METHOD_PARSE_AT_INIT 0x0 +#define METHOD_PARSE_JUST_IN_TIME 0x1 +#define METHOD_DELETE_AT_COMPLETION 0x2 + + +ACPI_STATUS +AcpiAmlResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * amxface - External interpreter interfaces + */ + +ACPI_STATUS +AcpiAmlLoadTable ( + ACPI_TABLE_TYPE TableId); + +ACPI_STATUS +AcpiAmlExecuteMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + + +/* + * amfield - ACPI AML (p-code) execution - field manipulation + */ + + +ACPI_STATUS +AcpiAmlReadField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity); + +ACPI_STATUS +AcpiAmlWriteField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity); + +ACPI_STATUS +AcpiAmlSetupField ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *RgnDesc, + UINT32 FieldBitWidth); + +ACPI_STATUS +AcpiAmlReadFieldData ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldByteOffset, + UINT32 FieldBitWidth, + UINT32 *Value); + +ACPI_STATUS +AcpiAmlAccessNamedField ( + UINT32 Mode, + ACPI_HANDLE NamedField, + void *Buffer, + UINT32 Length); + +/* + * ammisc - ACPI AML (p-code) execution - specific opcodes + */ + +ACPI_STATUS +AcpiAmlExecCreateField ( + UINT8 *AmlPtr, + UINT32 AmlLength, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecReconfiguration ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecFatal ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecIndex ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecMatch ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecCreateMutex ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateProcessor ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE ProcessorNTE); + +ACPI_STATUS +AcpiAmlExecCreatePowerResource ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE ProcessorNTE); + +ACPI_STATUS +AcpiAmlExecCreateRegion ( + UINT8 *AmlPtr, + UINT32 AcpiAmlLength, + UINT32 RegionSpace, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateEvent ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateAlias ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecCreateMethod ( + UINT8 *AmlPtr, + UINT32 AcpiAmlLength, + UINT32 MethodFlags, + ACPI_HANDLE Method); + + +/* + * amprep - ACPI AML (p-code) execution - prep utilities + */ + +ACPI_STATUS +AcpiAmlPrepDefFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength); + +ACPI_STATUS +AcpiAmlPrepBankFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + ACPI_HANDLE BankReg, + UINT32 BankVal, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength); + +ACPI_STATUS +AcpiAmlPrepIndexFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE IndexReg, + ACPI_HANDLE DataReg, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength); + + +/* + * amsystem - Interface to OS services + */ + +UINT16 +AcpiAmlSystemThreadId ( + void); + +ACPI_STATUS +AcpiAmlSystemDoNotifyOp ( + ACPI_OPERAND_OBJECT *Value, + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiAmlSystemDoSuspend( + UINT32 Time); + +void +AcpiAmlSystemDoStall ( + UINT32 Time); + +ACPI_STATUS +AcpiAmlSystemAcquireMutex( + ACPI_OPERAND_OBJECT *Time, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemReleaseMutex( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemSignalEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemWaitEvent( + ACPI_OPERAND_OBJECT *Time, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemResetEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiAmlSystemWaitSemaphore ( + ACPI_HANDLE Semaphore, + UINT32 Timeout); + + +/* + * ammonadic - ACPI AML (p-code) execution, monadic operators + */ + +ACPI_STATUS +AcpiAmlExecMonadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecMonadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecMonadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * amdyadic - ACPI AML (p-code) execution, dyadic operators + */ + +ACPI_STATUS +AcpiAmlExecDyadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlExecDyadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecDyadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiAmlExecDyadic2S ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * amresolv - Object resolution and get value functions + */ + +ACPI_STATUS +AcpiAmlResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlResolveNodeToValue ( + ACPI_NAMESPACE_NODE **StackPtr); + +ACPI_STATUS +AcpiAmlResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlGetFieldUnitValue ( + ACPI_OPERAND_OBJECT *FieldDesc, + ACPI_OPERAND_OBJECT *ResultDesc); + + +/* + * amdump - Scanner debug output routines + */ + +void +AcpiAmlShowHexValue ( + UINT32 ByteCount, + UINT8 *AmlPtr, + UINT32 LeadSpace); + + +ACPI_STATUS +AcpiAmlDumpOperand ( + ACPI_OPERAND_OBJECT *EntryDesc); + +void +AcpiAmlDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + OPERATING_MODE InterpreterMode, + NATIVE_CHAR *Ident, + UINT32 NumLevels, + NATIVE_CHAR *Note, + NATIVE_CHAR *ModuleName, + UINT32 LineNumber); + +void +AcpiAmlDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Flags); + + +void +AcpiAmlDumpNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags); + + +/* + * amnames - interpreter/scanner name load/execute + */ + +NATIVE_CHAR * +AcpiAmlAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs); + +UINT32 +AcpiAmlGoodChar ( + UINT32 Character); + +ACPI_STATUS +AcpiAmlExecNameSegment ( + UINT8 **InAmlAddress, + NATIVE_CHAR *NameString); + +ACPI_STATUS +AcpiAmlGetNameString ( + OBJECT_TYPE_INTERNAL DataType, + UINT8 *InAmlAddress, + NATIVE_CHAR **OutNameString, + UINT32 *OutNameLength); + +ACPI_STATUS +AcpiAmlDoName ( + ACPI_OBJECT_TYPE DataType, + OPERATING_MODE LoadExecMode); + + +/* + * amstore - Object store support + */ + +ACPI_STATUS +AcpiAmlExecStore ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlStoreObjectToObject ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiAmlStoreObjectToNode ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState); + + +/* + * amutils - interpreter/scanner utilities + */ + +void +AcpiAmlEnterInterpreter ( + void); + +void +AcpiAmlExitInterpreter ( + void); + +BOOLEAN +AcpiAmlValidateObjectType ( + ACPI_OBJECT_TYPE Type); + +BOOLEAN +AcpiAmlAcquireGlobalLock ( + UINT32 Rule); + +ACPI_STATUS +AcpiAmlReleaseGlobalLock ( + BOOLEAN Locked); + +UINT32 +AcpiAmlBufSeq ( + void); + +UINT32 +AcpiAmlDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base); + +ACPI_STATUS +AcpiAmlEisaIdToString ( + UINT32 NumericId, + NATIVE_CHAR *OutString); + +ACPI_STATUS +AcpiAmlUnsignedIntegerToString ( + ACPI_INTEGER Value, + NATIVE_CHAR *OutString); + +ACPI_STATUS +AcpiAmlBuildCopyInternalPackageObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); + + +/* + * amregion - default OpRegion handlers + */ + +ACPI_STATUS +AcpiAmlSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlSystemIoSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlPciConfigSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlEmbeddedControllerSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiAmlSmBusSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + + +#endif /* __INTERP_H__ */ diff --git a/sys/contrib/dev/acpica/aclocal.h b/sys/contrib/dev/acpica/aclocal.h new file mode 100644 index 0000000..0a3868b --- /dev/null +++ b/sys/contrib/dev/acpica/aclocal.h @@ -0,0 +1,963 @@ +/****************************************************************************** + * + * Name: aclocal.h - Internal data types used across the ACPI subsystem + * $Revision: 82 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACLOCAL_H__ +#define __ACLOCAL_H__ + + +#define WAIT_FOREVER ((UINT32) -1) + +typedef void* ACPI_MUTEX; +typedef UINT32 ACPI_MUTEX_HANDLE; + + +/* Object descriptor types */ + +#define ACPI_CACHED_OBJECT 0x11 /* ORed in when object is cached */ +#define ACPI_DESC_TYPE_STATE 0x22 +#define ACPI_DESC_TYPE_WALK 0x44 +#define ACPI_DESC_TYPE_PARSER 0x66 +#define ACPI_DESC_TYPE_INTERNAL 0x88 +#define ACPI_DESC_TYPE_NAMED 0xAA + + +/***************************************************************************** + * + * Mutex typedefs and structs + * + ****************************************************************************/ + + +/* + * Predefined handles for the mutex objects used within the subsystem + * All mutex objects are automatically created by AcpiCmMutexInitialize. + * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also! + */ + +#define ACPI_MTX_HARDWARE 0 +#define ACPI_MTX_MEMORY 1 +#define ACPI_MTX_CACHES 2 +#define ACPI_MTX_TABLES 3 +#define ACPI_MTX_PARSER 4 +#define ACPI_MTX_DISPATCHER 5 +#define ACPI_MTX_INTERPRETER 6 +#define ACPI_MTX_EXECUTE 7 +#define ACPI_MTX_NAMESPACE 8 +#define ACPI_MTX_EVENTS 9 +#define ACPI_MTX_OP_REGIONS 10 +#define ACPI_MTX_DEBUG_CMD_READY 11 +#define ACPI_MTX_DEBUG_CMD_COMPLETE 12 + +#define MAX_MTX 12 +#define NUM_MTX MAX_MTX+1 + + +#ifdef ACPI_DEBUG +#ifdef DEFINE_ACPI_GLOBALS + +/* Names for the mutexes used in the subsystem */ + +static NATIVE_CHAR *AcpiGbl_MutexNames[] = +{ + "ACPI_MTX_Hardware", + "ACPI_MTX_Memory", + "ACPI_MTX_Caches", + "ACPI_MTX_Tables", + "ACPI_MTX_Parser", + "ACPI_MTX_Dispatcher", + "ACPI_MTX_Interpreter", + "ACPI_MTX_Execute", + "ACPI_MTX_Namespace", + "ACPI_MTX_Events", + "ACPI_MTX_OpRegions", + "ACPI_MTX_DebugCmdReady", + "ACPI_MTX_DebugCmdComplete" +}; + +#endif +#endif + + +/* Table for the global mutexes */ + +typedef struct AcpiMutexInfo +{ + ACPI_MUTEX Mutex; + UINT32 UseCount; + BOOLEAN Locked; + +} ACPI_MUTEX_INFO; + + +/* Lock flag parameter for various interfaces */ + +#define ACPI_MTX_DO_NOT_LOCK 0 +#define ACPI_MTX_LOCK 1 + + +typedef UINT16 ACPI_OWNER_ID; +#define OWNER_TYPE_TABLE 0x0 +#define OWNER_TYPE_METHOD 0x1 +#define FIRST_METHOD_ID 0x0000 +#define FIRST_TABLE_ID 0x8000 + +/* TBD: [Restructure] get rid of the need for this! */ + +#define TABLE_ID_DSDT (ACPI_OWNER_ID) 0x8000 + +/***************************************************************************** + * + * Namespace typedefs and structs + * + ****************************************************************************/ + + +/* Operational modes of the AML interpreter/scanner */ + +typedef enum +{ + IMODE_LOAD_PASS1 = 0x01, + IMODE_LOAD_PASS2 = 0x02, + IMODE_EXECUTE = 0x0E + +} OPERATING_MODE; + + +/* + * The Node describes a named object that appears in the AML + * An AcpiNode is used to store Nodes. + * + * DataType is used to differentiate between internal descriptors, and MUST + * be the first byte in this structure. + */ + +typedef struct acpi_node +{ + UINT8 DataType; + UINT8 Type; /* Type associated with this name */ + UINT16 OwnerId; + UINT32 Name; /* ACPI Name, always 4 chars per ACPI spec */ + + + void *Object; /* Pointer to attached ACPI object (optional) */ + struct acpi_node *Child; /* first child */ + struct acpi_node *Peer; /* Next peer*/ + UINT16 ReferenceCount; /* Current count of references and children */ + UINT8 Flags; + +} ACPI_NAMESPACE_NODE; + + +#define ENTRY_NOT_FOUND NULL + + +/* Node flags */ + +#define ANOBJ_AML_ATTACHMENT 0x1 +#define ANOBJ_END_OF_PEER_LIST 0x2 + + +/* + * ACPI Table Descriptor. One per ACPI table + */ +typedef struct AcpiTableDesc +{ + struct AcpiTableDesc *Prev; + struct AcpiTableDesc *Next; + struct AcpiTableDesc *InstalledDesc; + ACPI_TABLE_HEADER *Pointer; + void *BasePointer; + UINT8 *AmlPointer; + UINT32 AmlLength; + UINT32 Length; + UINT32 Count; + ACPI_OWNER_ID TableId; + UINT8 Type; + UINT8 Allocation; + BOOLEAN LoadedIntoNamespace; + +} ACPI_TABLE_DESC; + + +typedef struct +{ + NATIVE_CHAR *SearchFor; + ACPI_HANDLE *List; + UINT32 *Count; + +} FIND_CONTEXT; + + +typedef struct +{ + ACPI_NAMESPACE_NODE *Node; +} NS_SEARCH_DATA; + + +/* + * Predefined Namespace items + */ +#define ACPI_MAX_ADDRESS_SPACE 255 +#define ACPI_NUM_ADDRESS_SPACES 256 + + +typedef struct +{ + NATIVE_CHAR *Name; + ACPI_OBJECT_TYPE Type; + NATIVE_CHAR *Val; + +} PREDEFINED_NAMES; + + +/***************************************************************************** + * + * Event typedefs and structs + * + ****************************************************************************/ + + +/* Status bits. */ + +#define ACPI_STATUS_PMTIMER 0x0001 +#define ACPI_STATUS_GLOBAL 0x0020 +#define ACPI_STATUS_POWER_BUTTON 0x0100 +#define ACPI_STATUS_SLEEP_BUTTON 0x0200 +#define ACPI_STATUS_RTC_ALARM 0x0400 + +/* Enable bits. */ + +#define ACPI_ENABLE_PMTIMER 0x0001 +#define ACPI_ENABLE_GLOBAL 0x0020 +#define ACPI_ENABLE_POWER_BUTTON 0x0100 +#define ACPI_ENABLE_SLEEP_BUTTON 0x0200 +#define ACPI_ENABLE_RTC_ALARM 0x0400 + + +/* + * Entry in the AddressSpace (AKA Operation Region) table + */ + +typedef struct +{ + ADDRESS_SPACE_HANDLER Handler; + void *Context; + +} ACPI_ADDRESS_SPACE_INFO; + + +/* Values and addresses of the GPE registers (both banks) */ + +typedef struct +{ + UINT8 Status; /* Current value of status reg */ + UINT8 Enable; /* Current value of enable reg */ + UINT16 StatusAddr; /* Address of status reg */ + UINT16 EnableAddr; /* Address of enable reg */ + UINT8 GpeBase; /* Base GPE number */ + +} ACPI_GPE_REGISTERS; + + +#define ACPI_GPE_LEVEL_TRIGGERED 1 +#define ACPI_GPE_EDGE_TRIGGERED 2 + + +/* Information about each particular GPE level */ + +typedef struct +{ + UINT8 Type; /* Level or Edge */ + + ACPI_HANDLE MethodHandle; /* Method handle for direct (fast) execution */ + GPE_HANDLER Handler; /* Address of handler, if any */ + void *Context; /* Context to be passed to handler */ + +} ACPI_GPE_LEVEL_INFO; + + +/* Information about each particular fixed event */ + +typedef struct +{ + FIXED_EVENT_HANDLER Handler; /* Address of handler. */ + void *Context; /* Context to be passed to handler */ + +} ACPI_FIXED_EVENT_INFO; + + +/* Information used during field processing */ + +typedef struct +{ + UINT8 SkipField; + UINT8 FieldFlag; + UINT32 PkgLength; + +} ACPI_FIELD_INFO; + + +/***************************************************************************** + * + * Generic "state" object for stacks + * + ****************************************************************************/ + + +#define CONTROL_NORMAL 0xC0 +#define CONTROL_CONDITIONAL_EXECUTING 0xC1 +#define CONTROL_PREDICATE_EXECUTING 0xC2 +#define CONTROL_PREDICATE_FALSE 0xC3 +#define CONTROL_PREDICATE_TRUE 0xC4 + + +/* Forward declaration */ +struct acpi_walk_state; +struct acpi_parse_obj ; + + +#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ + UINT8 DataType; /* To differentiate various internal objs */\ + UINT8 Flags; \ + UINT16 Value; \ + UINT16 State; \ + UINT16 AcpiEval; \ + void *Next; \ + +typedef struct acpi_common_state +{ + ACPI_STATE_COMMON +} ACPI_COMMON_STATE; + + +/* + * Update state - used to traverse complex objects such as packages + */ +typedef struct acpi_update_state +{ + ACPI_STATE_COMMON + union acpi_operand_obj *Object; + +} ACPI_UPDATE_STATE; + +/* + * Control state - one per if/else and while constructs. + * Allows nesting of these constructs + */ +typedef struct acpi_control_state +{ + ACPI_STATE_COMMON + struct acpi_parse_obj *PredicateOp; + UINT8 *AmlPredicateStart; /* Start of if/while predicate */ + +} ACPI_CONTROL_STATE; + + +/* + * Scope state - current scope during namespace lookups + */ + +typedef struct acpi_scope_state +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + +} ACPI_SCOPE_STATE; + + +typedef struct acpi_pscope_state +{ + ACPI_STATE_COMMON + struct acpi_parse_obj *Op; /* current op being parsed */ + UINT8 *ArgEnd; /* current argument end */ + UINT8 *PkgEnd; /* current package end */ + UINT32 ArgList; /* next argument to parse */ + UINT32 ArgCount; /* Number of fixed arguments */ + +} ACPI_PSCOPE_STATE; + + +typedef union acpi_gen_state +{ + ACPI_COMMON_STATE Common; + ACPI_CONTROL_STATE Control; + ACPI_UPDATE_STATE Update; + ACPI_SCOPE_STATE Scope; + ACPI_PSCOPE_STATE ParseScope; + +} ACPI_GENERIC_STATE; + + +typedef +ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( + UINT16 Opcode, + struct acpi_parse_obj *Op, + struct acpi_walk_state *WalkState, + struct acpi_parse_obj **OutOp); + +typedef +ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( + struct acpi_walk_state *WalkState, + struct acpi_parse_obj *Op); + + +/***************************************************************************** + * + * Parser typedefs and structs + * + ****************************************************************************/ + + +#define ACPI_OP_CLASS_MASK 0x1F +#define ACPI_OP_ARGS_MASK 0x20 +#define ACPI_OP_TYPE_MASK 0xC0 + +#define ACPI_OP_TYPE_OPCODE 0x00 +#define ACPI_OP_TYPE_ASCII 0x40 +#define ACPI_OP_TYPE_PREFIX 0x80 +#define ACPI_OP_TYPE_UNKNOWN 0xC0 + +#define ACPI_GET_OP_CLASS(a) ((a)->Flags & ACPI_OP_CLASS_MASK) +#define ACPI_GET_OP_ARGS(a) ((a)->Flags & ACPI_OP_ARGS_MASK) +#define ACPI_GET_OP_TYPE(a) ((a)->Flags & ACPI_OP_TYPE_MASK) + + +/* + * AML opcode, name, and argument layout + */ +typedef struct acpi_opcode_info +{ + UINT8 Flags; /* Opcode type, HasArgs flag */ + UINT32 ParseArgs; /* Grammar/Parse time arguments */ + UINT32 RuntimeArgs; /* Interpret time arguments */ + + DEBUG_ONLY_MEMBERS ( + NATIVE_CHAR *Name) /* op name (debug only) */ + +} ACPI_OPCODE_INFO; + + +typedef union acpi_parse_val +{ + UINT32 Integer; /* integer constant */ + UINT32 Size; /* bytelist or field size */ + NATIVE_CHAR *String; /* NULL terminated string */ + UINT8 *Buffer; /* buffer or string */ + NATIVE_CHAR *Name; /* NULL terminated string */ + struct acpi_parse_obj *Arg; /* arguments and contained ops */ + +} ACPI_PARSE_VALUE; + + +#define ACPI_PARSE_COMMON \ + UINT8 DataType; /* To differentiate various internal objs */\ + UINT8 Flags; /* Type of Op */\ + UINT16 Opcode; /* AML opcode */\ + UINT32 AmlOffset; /* offset of declaration in AML */\ + struct acpi_parse_obj *Parent; /* parent op */\ + struct acpi_parse_obj *Next; /* next op */\ + DEBUG_ONLY_MEMBERS (\ + NATIVE_CHAR OpName[16]) /* op name (debug only) */\ + /* NON-DEBUG members below: */\ + ACPI_NAMESPACE_NODE *Node;/* for use by interpreter */\ + ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ + + +/* + * generic operation (eg. If, While, Store) + */ +typedef struct acpi_parse_obj +{ + ACPI_PARSE_COMMON +} ACPI_PARSE_OBJECT; + + +/* + * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions), + * and bytelists. + */ +typedef struct acpi_parse2_obj +{ + ACPI_PARSE_COMMON + UINT8 *Data; /* AML body or bytelist data */ + UINT32 Length; /* AML length */ + UINT32 Name; /* 4-byte name or zero if no name */ + +} ACPI_PARSE2_OBJECT; + + +/* + * Parse state - one state per parser invocation and each control + * method. + */ + +typedef struct acpi_parse_state +{ + UINT8 *AmlStart; /* first AML byte */ + UINT8 *Aml; /* next AML byte */ + UINT8 *AmlEnd; /* (last + 1) AML byte */ + UINT8 *PkgStart; /* current package begin */ + UINT8 *PkgEnd; /* current package end */ + ACPI_PARSE_OBJECT *StartOp; /* root of parse tree */ + struct acpi_node *StartNode; + ACPI_GENERIC_STATE *Scope; /* current scope */ + struct acpi_parse_state *Next; + +} ACPI_PARSE_STATE; + + +/***************************************************************************** + * + * Tree walking typedefs and structs + * + ****************************************************************************/ + + +/* + * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through + * the tree (for whatever reason), and for control method execution. + */ + +#define NEXT_OP_DOWNWARD 1 +#define NEXT_OP_UPWARD 2 + +#define WALK_NON_METHOD 0 +#define WALK_METHOD 1 +#define WALK_METHOD_RESTART 2 + +typedef struct acpi_walk_state +{ + UINT8 DataType; /* To differentiate various internal objs */\ + ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ + BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 NextOpInfo; /* Info about NextOp */ + UINT8 NumOperands; /* Stack pointer for Operands[] array */ + UINT8 NumResults; /* Stack pointer for Results[] array */ + UINT8 CurrentResult; /* */ + + struct acpi_walk_state *Next; /* Next WalkState in list */ + ACPI_PARSE_OBJECT *Origin; /* Start of walk */ + +/* TBD: Obsolete with removal of WALK procedure ? */ + ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ + ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ + + + ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ + ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ + ACPI_PARSE_STATE *ParserState; /* Current state of parser */ + UINT8 *AmlLastWhile; + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; + + union acpi_operand_obj *ReturnDesc; /* Return object, if any */ + union acpi_operand_obj *MethodDesc; /* Method descriptor if running a method */ + struct acpi_node *MethodNode; /* Method Node if running a method */ + ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ + struct acpi_node *MethodCallNode; /* Called method Node*/ + union acpi_operand_obj *Operands[OBJ_NUM_OPERANDS]; /* Operands passed to the interpreter */ + union acpi_operand_obj *Results[OBJ_NUM_OPERANDS]; /* Accumulated results */ + struct acpi_node Arguments[MTH_NUM_ARGS]; /* Control method arguments */ + struct acpi_node LocalVariables[MTH_NUM_LOCALS]; /* Control method locals */ + UINT32 ParseFlags; + UINT8 WalkType; + UINT8 ReturnUsed; + UINT32 PrevArgTypes; + + /* Debug support */ + + UINT32 MethodBreakpoint; + + +} ACPI_WALK_STATE; + + +/* + * Walk list - head of a tree of walk states. Multiple walk states are created when there + * are nested control methods executing. + */ +typedef struct acpi_walk_list +{ + + ACPI_WALK_STATE *WalkState; + +} ACPI_WALK_LIST; + + +/* Info used by AcpiPsInitObjects */ + +typedef struct acpi_init_walk_info +{ + UINT16 MethodCount; + UINT16 OpRegionCount; + UINT16 FieldCount; + UINT16 OpRegionInit; + UINT16 FieldInit; + UINT16 ObjectCount; + ACPI_TABLE_DESC *TableDesc; + +} ACPI_INIT_WALK_INFO; + + +/* Info used by TBD */ + +typedef struct acpi_device_walk_info +{ + UINT32 Flags; + UINT16 DeviceCount; + UINT16 Num_STA; + UINT16 Num_INI; + UINT16 Num_HID; + UINT16 Num_PCI; + ACPI_TABLE_DESC *TableDesc; + +} ACPI_DEVICE_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + UINT32 DebugLevel; + UINT32 OwnerId; + +} ACPI_WALK_INFO; + +typedef struct acpi_get_devices_info +{ + WALK_CALLBACK UserFunction; + void *Context; + NATIVE_CHAR *Hid; + +} ACPI_GET_DEVICES_INFO; + + +/***************************************************************************** + * + * Hardware and PNP + * + ****************************************************************************/ + + +/* PCI */ + +#define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_ROOT_HID_VALUE 0x030AD041 /* EISAID("PNP0A03") */ + + +/* Sleep states */ + +#define SLWA_DEBUG_LEVEL 4 +#define GTS_CALL 0 +#define GTS_WAKE 1 + +/* Cx States */ + +#define MAX_CX_STATE_LATENCY 0xFFFFFFFF +#define MAX_CX_STATES 4 + +/* + * The #define's and enum below establish an abstract way of identifying what + * register block and register is to be accessed. Do not change any of the + * values as they are used in switch statements and offset calculations. + */ + +#define REGISTER_BLOCK_MASK 0xFF00 +#define BIT_IN_REGISTER_MASK 0x00FF +#define PM1_EVT 0x0100 +#define PM1_CONTROL 0x0200 +#define PM2_CONTROL 0x0300 +#define PM_TIMER 0x0400 +#define PROCESSOR_BLOCK 0x0500 +#define GPE0_STS_BLOCK 0x0600 +#define GPE0_EN_BLOCK 0x0700 +#define GPE1_STS_BLOCK 0x0800 +#define GPE1_EN_BLOCK 0x0900 + +enum +{ + /* PM1 status register ids */ + + TMR_STS = (PM1_EVT | 0x01), + BM_STS, + GBL_STS, + PWRBTN_STS, + SLPBTN_STS, + RTC_STS, + WAK_STS, + + /* PM1 enable register ids */ + + TMR_EN, + /* need to skip 1 enable number since there's no bus master enable register */ + GBL_EN = (PM1_EVT | 0x0A), + PWRBTN_EN, + SLPBTN_EN, + RTC_EN, + + /* PM1 control register ids */ + + SCI_EN = (PM1_CONTROL | 0x01), + BM_RLD, + GBL_RLS, + SLP_TYPE_A, + SLP_TYPE_B, + SLP_EN, + + /* PM2 control register ids */ + + ARB_DIS = (PM2_CONTROL | 0x01), + + /* PM Timer register ids */ + + TMR_VAL = (PM_TIMER | 0x01), + + GPE0_STS = (GPE0_STS_BLOCK | 0x01), + GPE0_EN = (GPE0_EN_BLOCK | 0x01), + + GPE1_STS = (GPE1_STS_BLOCK | 0x01), + GPE1_EN = (GPE0_EN_BLOCK | 0x01), + + /* Last register value is one less than LAST_REG */ + + LAST_REG +}; + + +#define TMR_STS_MASK 0x0001 +#define BM_STS_MASK 0x0010 +#define GBL_STS_MASK 0x0020 +#define PWRBTN_STS_MASK 0x0100 +#define SLPBTN_STS_MASK 0x0200 +#define RTC_STS_MASK 0x0400 +#define WAK_STS_MASK 0x8000 + +#define ALL_FIXED_STS_BITS (TMR_STS_MASK | BM_STS_MASK | GBL_STS_MASK | PWRBTN_STS_MASK | \ + SLPBTN_STS_MASK | RTC_STS_MASK | WAK_STS_MASK) + +#define TMR_EN_MASK 0x0001 +#define GBL_EN_MASK 0x0020 +#define PWRBTN_EN_MASK 0x0100 +#define SLPBTN_EN_MASK 0x0200 +#define RTC_EN_MASK 0x0400 + +#define SCI_EN_MASK 0x0001 +#define BM_RLD_MASK 0x0002 +#define GBL_RLS_MASK 0x0004 +#define SLP_TYPE_X_MASK 0x1C00 +#define SLP_EN_MASK 0x2000 + +#define ARB_DIS_MASK 0x0001 + +#define GPE0_STS_MASK +#define GPE0_EN_MASK + +#define GPE1_STS_MASK +#define GPE1_EN_MASK + + +#define ACPI_READ 1 +#define ACPI_WRITE 2 + +#define LOW_BYTE 0x00FF +#define ONE_BYTE 0x08 + +#ifndef SET + #define SET 1 +#endif +#ifndef CLEAR + #define CLEAR 0 +#endif + + +/* Plug and play */ + +/* Pnp and ACPI data */ + +#define VERSION_NO 0x01 +#define LOGICAL_DEVICE_ID 0x02 +#define COMPATIBLE_DEVICE_ID 0x03 +#define IRQ_FORMAT 0x04 +#define DMA_FORMAT 0x05 +#define START_DEPENDENT_TAG 0x06 +#define END_DEPENDENT_TAG 0x07 +#define IO_PORT_DESCRIPTOR 0x08 +#define FIXED_LOCATION_IO_DESCRIPTOR 0x09 +#define RESERVED_TYPE0 0x0A +#define RESERVED_TYPE1 0x0B +#define RESERVED_TYPE2 0x0C +#define RESERVED_TYPE3 0x0D +#define SMALL_VENDOR_DEFINED 0x0E +#define END_TAG 0x0F + +/* Pnp and ACPI data */ + +#define MEMORY_RANGE_24 0x81 +#define ISA_MEMORY_RANGE 0x81 +#define LARGE_VENDOR_DEFINED 0x84 +#define EISA_MEMORY_RANGE 0x85 +#define MEMORY_RANGE_32 0x85 +#define FIXED_EISA_MEMORY_RANGE 0x86 +#define FIXED_MEMORY_RANGE_32 0x86 + +/* ACPI only data */ + +#define DWORD_ADDRESS_SPACE 0x87 +#define WORD_ADDRESS_SPACE 0x88 +#define EXTENDED_IRQ 0x89 + +/* MUST HAVES */ + +#define DEVICE_ID_LENGTH 0x09 + +typedef struct +{ + NATIVE_CHAR Buffer[DEVICE_ID_LENGTH]; + +} DEVICE_ID; + + +/***************************************************************************** + * + * Debug + * + ****************************************************************************/ + + +/* Entry for a memory allocation (debug only) */ + +#ifdef ACPI_DEBUG + +#define MEM_MALLOC 0 +#define MEM_CALLOC 1 +#define MAX_MODULE_NAME 16 + +typedef struct AllocationInfo +{ + struct AllocationInfo *Previous; + struct AllocationInfo *Next; + void *Address; + UINT32 Size; + UINT32 Component; + UINT32 Line; + NATIVE_CHAR Module[MAX_MODULE_NAME]; + UINT8 AllocType; + +} ALLOCATION_INFO; + +#endif + +#endif /* __ACLOCAL_H__ */ diff --git a/sys/contrib/dev/acpica/acmacros.h b/sys/contrib/dev/acpica/acmacros.h new file mode 100644 index 0000000..e594b50 --- /dev/null +++ b/sys/contrib/dev/acpica/acmacros.h @@ -0,0 +1,536 @@ +/****************************************************************************** + * + * Name: acmacros.h - C macros for the entire subsystem. + * $Revision: 50 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACMACROS_H__ +#define __ACMACROS_H__ + +/* + * Data manipulation macros + */ + +#ifndef LOWORD +#define LOWORD(l) ((UINT16)(NATIVE_UINT)(l)) +#endif + +#ifndef HIWORD +#define HIWORD(l) ((UINT16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) +#endif + +#ifndef LOBYTE +#define LOBYTE(l) ((UINT8)(UINT16)(l)) +#endif + +#ifndef HIBYTE +#define HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF)) +#endif + +#define BIT0(x) ((((x) & 0x01) > 0) ? 1 : 0) +#define BIT1(x) ((((x) & 0x02) > 0) ? 1 : 0) +#define BIT2(x) ((((x) & 0x04) > 0) ? 1 : 0) + +#define BIT3(x) ((((x) & 0x08) > 0) ? 1 : 0) +#define BIT4(x) ((((x) & 0x10) > 0) ? 1 : 0) +#define BIT5(x) ((((x) & 0x20) > 0) ? 1 : 0) +#define BIT6(x) ((((x) & 0x40) > 0) ? 1 : 0) +#define BIT7(x) ((((x) & 0x80) > 0) ? 1 : 0) + +#define LOW_BASE(w) ((UINT16) ((w) & 0x0000FFFF)) +#define MID_BASE(b) ((UINT8) (((b) & 0x00FF0000) >> 16)) +#define HI_BASE(b) ((UINT8) (((b) & 0xFF000000) >> 24)) +#define LOW_LIMIT(w) ((UINT16) ((w) & 0x0000FFFF)) +#define HI_LIMIT(b) ((UINT8) (((b) & 0x00FF0000) >> 16)) + + + /* + * Extract a byte of data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below + */ +#define GET8(addr) (*(UINT8*)(addr)) + + +/* + * Macros for moving data around to/from buffers that are possibly unaligned. + * If the hardware supports the transfer of unaligned data, just do the store. + * Otherwise, we have to move one byte at a time. + */ + +#ifdef _HW_ALIGNMENT_SUPPORT + +/* The hardware supports unaligned transfers, just do the move */ + +#define MOVE_UNALIGNED16_TO_16(d,s) *(UINT16*)(d) = *(UINT16*)(s) +#define MOVE_UNALIGNED32_TO_32(d,s) *(UINT32*)(d) = *(UINT32*)(s) +#define MOVE_UNALIGNED16_TO_32(d,s) *(UINT32*)(d) = *(UINT16*)(s) + +#else +/* + * The hardware does not support unaligned transfers. We must move the + * data one byte at a time. These macros work whether the source or + * the destination (or both) is/are unaligned. + */ + +#define MOVE_UNALIGNED16_TO_16(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ + ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];} + +#define MOVE_UNALIGNED32_TO_32(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ + ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];\ + ((UINT8 *)(d))[2] = ((UINT8 *)(s))[2];\ + ((UINT8 *)(d))[3] = ((UINT8 *)(s))[3];} + +#define MOVE_UNALIGNED16_TO_32(d,s) {(*(UINT32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);} + +#endif + + +/* + * Fast power-of-two math macros for non-optimized compilers + */ + +#define _DIV(value,PowerOf2) ((UINT32) ((value) >> (PowerOf2))) +#define _MUL(value,PowerOf2) ((UINT32) ((value) << (PowerOf2))) +#define _MOD(value,Divisor) ((UINT32) ((value) & ((Divisor) -1))) + +#define DIV_2(a) _DIV(a,1) +#define MUL_2(a) _MUL(a,1) +#define MOD_2(a) _MOD(a,2) + +#define DIV_4(a) _DIV(a,2) +#define MUL_4(a) _MUL(a,2) +#define MOD_4(a) _MOD(a,4) + +#define DIV_8(a) _DIV(a,3) +#define MUL_8(a) _MUL(a,3) +#define MOD_8(a) _MOD(a,8) + +#define DIV_16(a) _DIV(a,4) +#define MUL_16(a) _MUL(a,4) +#define MOD_16(a) _MOD(a,16) + + +/* + * Rounding macros (Power of two boundaries only) + */ + +#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) +#define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) + +#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4) +#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) + +#define ROUND_UP_TO_32BITS(a) ROUND_UP(a,4) +#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) + +#define ROUND_PTR_UP_TO_4(a,b) ((b *)(((NATIVE_UINT)(a) + 3) & ~3)) + +#ifdef DEBUG_ASSERT +#undef DEBUG_ASSERT +#endif + + +/* + * An ACPI_HANDLE (which is actually an ACPI_NAMESPACE_NODE *) can appear in some contexts, + * such as on apObjStack, where a pointer to an ACPI_OPERAND_OBJECT can also + * appear. This macro is used to distinguish them. + * + * The DataType field is the first field in both structures. + */ + +#define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMESPACE_NODE *)d)->DataType == t) + + +/* Macro to test the object type */ + +#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OPERAND_OBJECT *)d)->Common.Type == (UINT8)t) + +/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ + +#define IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0) + +/* + * Macro to check if a pointer is within an ACPI table. + * Parameter (a) is the pointer to check. Parameter (b) must be defined + * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, + * and ((UINT8 *)b+b->Length) points one byte past the end of the table. + */ + +#ifndef _IA16 +#define IS_IN_ACPI_TABLE(a,b) (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ + ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) + +#else +#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ + (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ + ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) +#endif + +/* + * Macros for the master AML opcode table + */ + +#ifdef ACPI_DEBUG +#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs,Name} +#else +#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs} +#endif + +#define ARG_TYPE_WIDTH 5 +#define ARG_1(x) ((UINT32)(x)) +#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) +#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH)) +#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH)) +#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH)) +#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH)) + +#define ARGI_LIST1(a) (ARG_1(a)) +#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) +#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) +#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) +#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) +#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) + +#define ARGP_LIST1(a) (ARG_1(a)) +#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) +#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) +#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) +#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) +#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) + +#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) +#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) + + +/* + * Reporting macros that are never compiled out + */ + +#define PARAM_LIST(pl) pl + +/* + * Error reporting. These versions add callers module and line#. Since + * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only + * use it in debug mode. + */ + +#ifdef ACPI_DEBUG + +#define REPORT_INFO(fp) {_ReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_ERROR(fp) {_ReportError(_THIS_MODULE,__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_WARNING(fp) {_ReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} + +#else + +#define REPORT_INFO(fp) {_ReportInfo("",__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_ERROR(fp) {_ReportError("",__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} +#define REPORT_WARNING(fp) {_ReportWarning("",__LINE__,_COMPONENT); \ + DebugPrintRaw PARAM_LIST(fp);} + +#endif + +/* Error reporting. These versions pass thru the module and line# */ + +#define _REPORT_INFO(a,b,c,fp) {_ReportInfo(a,b,c); \ + DebugPrintRaw PARAM_LIST(fp);} +#define _REPORT_ERROR(a,b,c,fp) {_ReportError(a,b,c); \ + DebugPrintRaw PARAM_LIST(fp);} +#define _REPORT_WARNING(a,b,c,fp) {_ReportWarning(a,b,c); \ + DebugPrintRaw PARAM_LIST(fp);} + +/* Buffer dump macros */ + +#define DUMP_BUFFER(a,b) AcpiCmDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) + +/* + * Debug macros that are conditionally compiled + */ + +#ifdef ACPI_DEBUG + +#define MODULE_NAME(name) static char *_THIS_MODULE = name; + +/* + * Function entry tracing. + * The first parameter should be the procedure name as a quoted string. This is declared + * as a local string ("_ProcName) so that it can be also used by the function exit macros below. + */ + +#define FUNCTION_TRACE(a) char * _ProcName = a;\ + FunctionTrace(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define FUNCTION_TRACE_PTR(a,b) char * _ProcName = a;\ + FunctionTracePtr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b) +#define FUNCTION_TRACE_U32(a,b) char * _ProcName = a;\ + FunctionTraceU32(_THIS_MODULE,__LINE__,_COMPONENT,a,(UINT32)b) +#define FUNCTION_TRACE_STR(a,b) char * _ProcName = a;\ + FunctionTraceStr(_THIS_MODULE,__LINE__,_COMPONENT,a,(NATIVE_CHAR *)b) +/* + * Function exit tracing. + * WARNING: These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro is very ugly and difficult to maintain. + * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros + * so that "_ProcName" is defined. + */ +#define return_VOID {FunctionExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName);return;} +#define return_ACPI_STATUS(s) {FunctionStatusExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,s);return(s);} +#define return_VALUE(s) {FunctionValueExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(NATIVE_UINT)s);return(s);} +#define return_PTR(s) {FunctionPtrExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(UINT8 *)s);return(s);} + + +/* Conditional execution */ + +#define DEBUG_EXEC(a) a; +#define NORMAL_EXEC(a) + +#define DEBUG_DEFINE(a) a; +#define DEBUG_ONLY_MEMBERS(a) a; + + +/* Stack and buffer dumping */ + +#define DUMP_STACK_ENTRY(a) AcpiAmlDumpOperand(a) +#define DUMP_OPERANDS(a,b,c,d,e) AcpiAmlDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) + + +#define DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b) +#define DUMP_TABLES(a,b) AcpiNsDumpTables(a,b) +#define DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d) +#define DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a) +#define BREAK_MSG(a) AcpiOsBreakpoint (a) + +/* + * Generate INT3 on ACPI_ERROR (Debug only!) + */ + +#define ERROR_BREAK +#ifdef ERROR_BREAK +#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) AcpiOsBreakpoint("Fatal error encountered\n") +#else +#define BREAK_ON_ERROR(lvl) +#endif + +/* + * Master debug print macros + * Print iff: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + * + */ + +#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)) + +#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + DebugPrintPrefix (_THIS_MODULE,__LINE__);\ + DebugPrintRaw PARAM_LIST(fp);\ + BREAK_ON_ERROR(lvl);} + +#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + DebugPrintRaw PARAM_LIST(fp);} + + +/* Assert macros */ + +#define ACPI_ASSERT(exp) if(!(exp)) \ + AcpiOsDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion") + +#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ + AcpiOsDbgAssert(#exp, __FILE__, __LINE__, msg) + + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ + +#define MODULE_NAME(name) +#define _THIS_MODULE "" + +#define DEBUG_EXEC(a) +#define NORMAL_EXEC(a) a; + +#define DEBUG_DEFINE(a) +#define DEBUG_ONLY_MEMBERS(a) +#define FUNCTION_TRACE(a) +#define FUNCTION_TRACE_PTR(a,b) +#define FUNCTION_TRACE_U32(a,b) +#define FUNCTION_TRACE_STR(a,b) +#define FUNCTION_EXIT +#define FUNCTION_STATUS_EXIT(s) +#define FUNCTION_VALUE_EXIT(s) +#define DUMP_STACK_ENTRY(a) +#define DUMP_OPERANDS(a,b,c,d,e) +#define DUMP_ENTRY(a,b) +#define DUMP_TABLES(a,b) +#define DUMP_PATHNAME(a,b,c,d) +#define DUMP_RESOURCE_LIST(a) +#define DEBUG_PRINT(l,f) +#define DEBUG_PRINT_RAW(l,f) +#define BREAK_MSG(a) + +#define return_VOID return +#define return_ACPI_STATUS(s) return(s) +#define return_VALUE(s) return(s) +#define return_PTR(s) return(s) + +#define ACPI_ASSERT(exp) +#define DEBUG_ASSERT(msg, exp) + +#endif + +/* + * Some code only gets executed when the debugger is built in. + * Note that this is entirely independent of whether the + * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not. + */ +#ifdef ENABLE_DEBUGGER +#define DEBUGGER_EXEC(a) a; +#else +#define DEBUGGER_EXEC(a) +#endif + + +/* + * For 16-bit code, we want to shrink some things even though + * we are using ACPI_DEBUG to get the debug output + */ +#ifdef _IA16 +#undef DEBUG_ONLY_MEMBERS +#define DEBUG_ONLY_MEMBERS(a) +#undef OP_INFO_ENTRY +#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs} +#endif + + +#ifdef ACPI_DEBUG + +/* + * 1) Set name to blanks + * 2) Copy the object name + */ + +#define ADD_OBJECT_NAME(a,b) MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\ + STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name)) + +#else + +#define ADD_OBJECT_NAME(a,b) + +#endif + +#endif /* ACMACROS_H */ diff --git a/sys/contrib/dev/acpica/acnamesp.h b/sys/contrib/dev/acpica/acnamesp.h new file mode 100644 index 0000000..8681df7 --- /dev/null +++ b/sys/contrib/dev/acpica/acnamesp.h @@ -0,0 +1,519 @@ +/****************************************************************************** + * + * Name: acnamesp.h - Namespace subcomponent prototypes and defines + * $Revision: 97 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNAMESP_H__ +#define __ACNAMESP_H__ + + +/* To search the entire name space, pass this as SearchBase */ + +#define NS_ALL ((ACPI_HANDLE)0) + +/* + * Elements of AcpiNsProperties are bit significant + * and should be one-to-one with values of ACPI_OBJECT_TYPE + */ +#define NSP_NORMAL 0 +#define NSP_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define NSP_LOCAL 2 /* suppress search of enclosing scopes */ + + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (UINT32) 0x2F202020 /* Root name is "/ " */ +#define ACPI_SYS_BUS_NAME (UINT32) 0x5F53425F /* Sys bus name is "_SB_" */ + +#define NS_ROOT_PATH "/" +#define NS_SYSTEM_BUS "_SB_" + + +/* Flags for AcpiNsLookup, AcpiNsSearchAndEnter */ + +#define NS_NO_UPSEARCH 0 +#define NS_SEARCH_PARENT 0x01 +#define NS_DONT_OPEN_SCOPE 0x02 +#define NS_NO_PEER_SEARCH 0x04 + +#define NS_WALK_UNLOCK TRUE +#define NS_WALK_NO_UNLOCK FALSE + + +ACPI_STATUS +AcpiNsLoadNamespace ( + void); + +ACPI_STATUS +AcpiNsInitializeObjects ( + void); + +ACPI_STATUS +AcpiNsInitializeDevices ( + UINT32 Flags); + + +/* Namespace init - nsxfinit */ + +ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + + +ACPI_STATUS +AcpiNsWalkNamespace ( + OBJECT_TYPE_INTERNAL Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + BOOLEAN UnlockBeforeCallback, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue); + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextObject ( + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + + +ACPI_STATUS +AcpiNsDeleteNamespaceByOwner ( + UINT16 TableId); + + +/* Namespace loading - nsload */ + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiNsParseTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Scope); + +ACPI_STATUS +AcpiNsLoadTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiNsLoadTableByType ( + ACPI_TABLE_TYPE TableType); + + +/* + * Top-level namespace access - nsaccess + */ + + +ACPI_STATUS +AcpiNsRootInitialize ( + void); + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + NATIVE_CHAR *Name, + OBJECT_TYPE_INTERNAL Type, + OPERATING_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **RetNode); + + +/* + * Named object allocation/deallocation - nsalloc + */ + + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 AcpiName); + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentHandle); + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *Parent); + + +/* + * Namespace modification - nsmodify + */ + +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle); + +ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle); + + +/* + * Namespace dump/print utilities - nsdump + */ + +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth); + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel); + +ACPI_STATUS +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + NATIVE_CHAR *Msg, + UINT32 Level, + UINT32 Component); + +void +AcpiNsDumpRootDevices ( + void); + +void +AcpiNsDumpObjects ( + OBJECT_TYPE_INTERNAL Type, + UINT32 MaxDepth, + UINT32 OwnderId, + ACPI_HANDLE StartHandle); + + +/* + * Namespace evaluation functions - nseval + */ + +ACPI_STATUS +AcpiNsEvaluateByHandle ( + ACPI_NAMESPACE_NODE *PrefixNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject); + +ACPI_STATUS +AcpiNsEvaluateByName ( + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject); + +ACPI_STATUS +AcpiNsEvaluateRelative ( + ACPI_NAMESPACE_NODE *PrefixNode, + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject); + +ACPI_STATUS +AcpiNsExecuteControlMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + +ACPI_STATUS +AcpiNsGetObjectValue ( + ACPI_NAMESPACE_NODE *ObjectNode, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + + +/* + * Parent/Child/Peer utility functions - nsfamily + */ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *NodeToSearch); + +BOOLEAN +AcpiNsExistDownstreamSibling ( + ACPI_NAMESPACE_NODE *ThisNode); + + +/* + * Scope manipulation - nsscope + */ + +UINT32 +AcpiNsOpensScope ( + OBJECT_TYPE_INTERNAL Type); + +NATIVE_CHAR * +AcpiNsGetTablePathname ( + ACPI_NAMESPACE_NODE *Node); + +NATIVE_CHAR * +AcpiNsNameOfCurrentScope ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE ObjHandle, + UINT32 *BufSize, + NATIVE_CHAR *UserBuffer); + +BOOLEAN +AcpiNsPatternMatch ( + ACPI_NAMESPACE_NODE *ObjNode, + NATIVE_CHAR *SearchFor); + +ACPI_STATUS +AcpiNsNameCompare ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiNsGetNode ( + NATIVE_CHAR *Pathname, + ACPI_NAMESPACE_NODE *InPrefixNode, + ACPI_NAMESPACE_NODE **OutNode); + +/* + * Object management for NTEs - nsobject + */ + +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + OBJECT_TYPE_INTERNAL Type); + + +void * +AcpiNsCompareValue ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc); + + +/* + * Namespace searching and entry - nssearch + */ + +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 EntryName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + OPERATING_MODE InterpreterMode, + OBJECT_TYPE_INTERNAL Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **RetNode); + +ACPI_STATUS +AcpiNsSearchNode ( + UINT32 EntryName, + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE **RetNode); + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 AcpiName); + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ + ACPI_NAMESPACE_NODE *Node, /* New Child*/ + OBJECT_TYPE_INTERNAL Type); + + +/* + * Utility functions - nsutils + */ + +BOOLEAN +AcpiNsValidRootPrefix ( + NATIVE_CHAR Prefix); + +BOOLEAN +AcpiNsValidPathSeparator ( + NATIVE_CHAR Sep); + +OBJECT_TYPE_INTERNAL +AcpiNsGetType ( + ACPI_HANDLE ObjHandle); + +void * +AcpiNsGetAttachedObject ( + ACPI_HANDLE ObjHandle); + +UINT32 +AcpiNsLocal ( + OBJECT_TYPE_INTERNAL Type); + +ACPI_STATUS +AcpiNsInternalizeName ( + NATIVE_CHAR *DottedName, + NATIVE_CHAR **ConvertedName); + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + NATIVE_CHAR *InternalName, + UINT32 *ConvertedNameLength, + NATIVE_CHAR **ConvertedName); + +ACPI_NAMESPACE_NODE * +AcpiNsConvertHandleToEntry ( + ACPI_HANDLE Handle); + +ACPI_HANDLE +AcpiNsConvertEntryToHandle( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsTerminate ( + void); + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentObject ( + ACPI_NAMESPACE_NODE *Node); + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidObject ( + ACPI_NAMESPACE_NODE *Node); + + +#endif /* __ACNAMESP_H__ */ diff --git a/sys/contrib/dev/acpica/acobject.h b/sys/contrib/dev/acpica/acobject.h new file mode 100644 index 0000000..a3b9d40 --- /dev/null +++ b/sys/contrib/dev/acpica/acobject.h @@ -0,0 +1,515 @@ + +/****************************************************************************** + * + * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) + * $Revision: 74 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACOBJECT_H +#define _ACOBJECT_H + + +/* + * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher + * to the interpreter, and to keep track of the various handlers such as + * address space handlers and notify handlers. The object is a constant + * size in order to allow them to be cached and reused. + * + * All variants of the ACPI_OPERAND_OBJECT are defined with the same + * sequence of field types, with fields that are not used in a particular + * variant being named "Reserved". This is not strictly necessary, but + * may in some circumstances simplify understanding if these structures + * need to be displayed in a debugger having limited (or no) support for + * union types. It also simplifies some debug code in DumpTable() which + * dumps multi-level values: fetching Buffer.Pointer suffices to pick up + * the value or next level for any of several types. + */ + +/****************************************************************************** + * + * Common Descriptors + * + *****************************************************************************/ + +/* + * Common area for all objects. + * + * DataType is used to differentiate between internal descriptors, and MUST + * be the first byte in this structure. + */ + + +#define ACPI_OBJECT_COMMON_HEADER /* 32-bits plus 8-bit flag */\ + UINT8 DataType; /* To differentiate various internal objs */\ + UINT8 Type; /* ACPI_OBJECT_TYPE */\ + UINT16 ReferenceCount; /* For object deletion management */\ + UINT8 Flags; \ + +/* Defines for flag byte above */ + +#define AOPOBJ_STATIC_ALLOCATION 0x1 +#define AOPOBJ_DATA_VALID 0x2 +#define AOPOBJ_INITIALIZED 0x4 + + +/* + * Common bitfield for the field objects + */ +#define ACPI_COMMON_FIELD_INFO /* Three 32-bit values plus 8*/\ + UINT8 Granularity;\ + UINT16 Length; \ + UINT32 Offset; /* Byte offset within containing object */\ + UINT8 BitOffset; /* Bit offset within min read/write data unit */\ + UINT8 Access; /* AccessType */\ + UINT8 LockRule;\ + UINT8 UpdateRule;\ + UINT8 AccessAttribute; + + +/****************************************************************************** + * + * Individual Object Descriptors + * + *****************************************************************************/ + + +typedef struct /* COMMON */ +{ + ACPI_OBJECT_COMMON_HEADER + +} ACPI_OBJECT_COMMON; + + +typedef struct /* CACHE_LIST */ +{ + ACPI_OBJECT_COMMON_HEADER + union acpi_operand_obj *Next; /* Link for object cache and internal lists*/ + +} ACPI_OBJECT_CACHE_LIST; + + +typedef struct /* NUMBER - has value */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_INTEGER Value; + +} ACPI_OBJECT_NUMBER; + + +typedef struct /* STRING - has length and pointer */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 Length; + NATIVE_CHAR *Pointer; /* String value in AML stream or in allocated space */ + +} ACPI_OBJECT_STRING; + + +typedef struct /* BUFFER - has length, sequence, and pointer */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 Length; + UINT32 Sequence; /* Sequential count of buffers created */ + + UINT8 *Pointer; /* points to the buffer in allocated space */ + +} ACPI_OBJECT_BUFFER; + + +typedef struct /* PACKAGE - has count, elements, next element */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 Count; /* # of elements in package */ + + union acpi_operand_obj **Elements; /* Array of pointers to AcpiObjects */ + union acpi_operand_obj **NextElement; /* used only while initializing */ + +} ACPI_OBJECT_PACKAGE; + + +typedef struct /* FIELD UNIT */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + + union acpi_operand_obj *Extra; /* Pointer to executable AML (in field definition) */ + ACPI_NAMESPACE_NODE *Node; /* containing object */ + union acpi_operand_obj *Container; /* Containing object (Buffer) */ + +} ACPI_OBJECT_FIELD_UNIT; + + +typedef struct /* DEVICE - has handle and notification handler/context */ +{ + ACPI_OBJECT_COMMON_HEADER + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + union acpi_operand_obj *AddrHandler; /* Handler for Address space */ + +} ACPI_OBJECT_DEVICE; + + +typedef struct /* EVENT */ +{ + ACPI_OBJECT_COMMON_HEADER + + void *Semaphore; + +} ACPI_OBJECT_EVENT; + + +#define INFINITE_CONCURRENCY 0xFF + +typedef struct /* METHOD */ +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 MethodFlags; + UINT8 ParamCount; + + UINT32 PcodeLength; + + void *Semaphore; + UINT8 *Pcode; + + UINT8 Concurrency; + UINT8 ThreadCount; + ACPI_OWNER_ID OwningId; + +} ACPI_OBJECT_METHOD; + + +typedef struct /* MUTEX */ +{ + ACPI_OBJECT_COMMON_HEADER + UINT16 SyncLevel; + + void *Semaphore; + +} ACPI_OBJECT_MUTEX; + + +typedef struct /* REGION */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT8 SpaceId; + UINT32 Length; + ACPI_INTEGER Address; + union acpi_operand_obj *Extra; /* Pointer to executable AML (in region definition) */ + + union acpi_operand_obj *AddrHandler; /* Handler for system notifies */ + ACPI_NAMESPACE_NODE *Node; /* containing object */ + union acpi_operand_obj *Next; + +} ACPI_OBJECT_REGION; + + +typedef struct /* POWER RESOURCE - has Handle and notification handler/context*/ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 SystemLevel; + UINT32 ResourceOrder; + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + +} ACPI_OBJECT_POWER_RESOURCE; + + +typedef struct /* PROCESSOR - has Handle and notification handler/context*/ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT32 ProcId; + UINT32 Length; + ACPI_IO_ADDRESS Address; + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + union acpi_operand_obj *AddrHandler; /* Handler for Address space */ + +} ACPI_OBJECT_PROCESSOR; + + +typedef struct /* THERMAL ZONE - has Handle and Handler/Context */ +{ + ACPI_OBJECT_COMMON_HEADER + + union acpi_operand_obj *SysHandler; /* Handler for system notifies */ + union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */ + union acpi_operand_obj *AddrHandler; /* Handler for Address space */ + +} ACPI_OBJECT_THERMAL_ZONE; + + +/* + * Internal types + */ + + +typedef struct /* FIELD */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + + union acpi_operand_obj *Container; /* Containing object */ + +} ACPI_OBJECT_FIELD; + + +typedef struct /* BANK FIELD */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + UINT32 Value; /* Value to store into BankSelect */ + + ACPI_HANDLE BankSelect; /* Bank select register */ + union acpi_operand_obj *Container; /* Containing object */ + +} ACPI_OBJECT_BANK_FIELD; + + +typedef struct /* INDEX FIELD */ +{ + /* + * No container pointer needed since the index and data register definitions + * will define how to access the respective registers + */ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + UINT32 Value; /* Value to store into Index register */ + + ACPI_HANDLE Index; /* Index register */ + ACPI_HANDLE Data; /* Data register */ + +} ACPI_OBJECT_INDEX_FIELD; + + +typedef struct /* NOTIFY HANDLER */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + NOTIFY_HANDLER Handler; + void *Context; + +} ACPI_OBJECT_NOTIFY_HANDLER; + + +/* Flags for address handler */ + +#define ADDR_HANDLER_DEFAULT_INSTALLED 0x1 + + +typedef struct /* ADDRESS HANDLER */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT8 SpaceId; + UINT16 Hflags; + ADDRESS_SPACE_HANDLER Handler; + + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + void *Context; + ADDRESS_SPACE_SETUP Setup; + union acpi_operand_obj *RegionList; /* regions using this handler */ + union acpi_operand_obj *Next; + +} ACPI_OBJECT_ADDR_HANDLER; + + +/* + * The Reference object type is used for these opcodes: + * Arg[0-6], Local[0-7], IndexOp, NameOp, ZeroOp, OneOp, OnesOp, DebugOp + */ + +typedef struct /* Reference - Local object type */ +{ + ACPI_OBJECT_COMMON_HEADER + + UINT8 TargetType; /* Used for IndexOp */ + UINT16 OpCode; + UINT32 Offset; /* Used for ArgOp, LocalOp, and IndexOp */ + + void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *Node; + union acpi_operand_obj **Where; + +} ACPI_OBJECT_REFERENCE; + + +/* + * Extra object is used as additional storage for types that + * have AML code in their declarations (TermArgs) that must be + * evaluated at run time. + * + * Currently: Region and FieldUnit types + */ + +typedef struct /* EXTRA */ +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 ByteFill1; + UINT16 WordFill1; + UINT32 PcodeLength; + UINT8 *Pcode; + ACPI_NAMESPACE_NODE *Method_REG; /* _REG method for this region (if any) */ + void *RegionContext; /* Region-specific data */ + +} ACPI_OBJECT_EXTRA; + + +/****************************************************************************** + * + * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above + * + *****************************************************************************/ + +typedef union acpi_operand_obj +{ + ACPI_OBJECT_COMMON Common; + ACPI_OBJECT_CACHE_LIST Cache; + ACPI_OBJECT_NUMBER Number; + ACPI_OBJECT_STRING String; + ACPI_OBJECT_BUFFER Buffer; + ACPI_OBJECT_PACKAGE Package; + ACPI_OBJECT_FIELD_UNIT FieldUnit; + ACPI_OBJECT_DEVICE Device; + ACPI_OBJECT_EVENT Event; + ACPI_OBJECT_METHOD Method; + ACPI_OBJECT_MUTEX Mutex; + ACPI_OBJECT_REGION Region; + ACPI_OBJECT_POWER_RESOURCE PowerResource; + ACPI_OBJECT_PROCESSOR Processor; + ACPI_OBJECT_THERMAL_ZONE ThermalZone; + ACPI_OBJECT_FIELD Field; + ACPI_OBJECT_BANK_FIELD BankField; + ACPI_OBJECT_INDEX_FIELD IndexField; + ACPI_OBJECT_REFERENCE Reference; + ACPI_OBJECT_NOTIFY_HANDLER NotifyHandler; + ACPI_OBJECT_ADDR_HANDLER AddrHandler; + ACPI_OBJECT_EXTRA Extra; + +} ACPI_OPERAND_OBJECT; + +#endif /* _ACOBJECT_H */ diff --git a/sys/contrib/dev/acpica/acoutput.h b/sys/contrib/dev/acpica/acoutput.h new file mode 100644 index 0000000..93da0e8 --- /dev/null +++ b/sys/contrib/dev/acpica/acoutput.h @@ -0,0 +1,217 @@ +/****************************************************************************** + * + * Name: acoutput.h -- debug output + * $Revision: 66 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOUTPUT_H__ +#define __ACOUTPUT_H__ + +/* + * Debug levels and component IDs. These are used to control the + * granularity of the output of the DEBUG_PRINT macro -- on a per- + * component basis and a per-exception-type basis. + */ + +/* Component IDs -- used in the global "DebugLayer" */ + +#define GLOBAL 0x00000001 +#define COMMON 0x00000002 +#define PARSER 0x00000004 +#define DISPATCHER 0x00000008 +#define INTERPRETER 0x00000010 +#define NAMESPACE 0x00000020 +#define RESOURCE_MANAGER 0x00000040 +#define TABLE_MANAGER 0x00000080 +#define EVENT_HANDLING 0x00000100 +#define HARDWARE 0x00000200 +#define MISCELLANEOUS 0x00000400 +#define OS_DEPENDENT 0x00000800 + +#define BUS_MANAGER 0x00001000 + +#define PROCESSOR_CONTROL 0x00002000 +#define SYSTEM_CONTROL 0x00004000 +#define THERMAL_CONTROL 0x00008000 +#define POWER_CONTROL 0x00010000 + +#define EMBEDDED_CONTROLLER 0x00020000 +#define BATTERY 0x00040000 + +#define DEBUGGER 0x00100000 +#define ALL_COMPONENTS 0x001FFFFF + +#define COMPONENT_DEFAULT (ALL_COMPONENTS) + + +/* Exception level -- used in the global "DebugLevel" */ + +#define ACPI_OK 0x00000001 +#define ACPI_INFO 0x00000002 +#define ACPI_WARN 0x00000004 +#define ACPI_ERROR 0x00000008 +#define ACPI_FATAL 0x00000010 +#define ACPI_DEBUG_OBJECT 0x00000020 +#define ACPI_ALL 0x0000003F + + +/* Trace level -- also used in the global "DebugLevel" */ + +#define TRACE_PARSE 0x00000100 +#define TRACE_DISPATCH 0x00000200 +#define TRACE_LOAD 0x00000400 +#define TRACE_EXEC 0x00000800 +#define TRACE_NAMES 0x00001000 +#define TRACE_OPREGION 0x00002000 +#define TRACE_BFIELD 0x00004000 +#define TRACE_TRASH 0x00008000 +#define TRACE_TABLES 0x00010000 +#define TRACE_FUNCTIONS 0x00020000 +#define TRACE_VALUES 0x00040000 +#define TRACE_OBJECTS 0x00080000 +#define TRACE_ALLOCATIONS 0x00100000 +#define TRACE_RESOURCES 0x00200000 +#define TRACE_IO 0x00400000 +#define TRACE_INTERRUPTS 0x00800000 +#define TRACE_USER_REQUESTS 0x01000000 +#define TRACE_PACKAGE 0x02000000 +#define TRACE_MUTEX 0x04000000 + +#define TRACE_ALL 0x0FFFFF00 + + +/* Exceptionally verbose output -- also used in the global "DebugLevel" */ + +#define VERBOSE_AML_DISASSEMBLE 0x10000000 +#define VERBOSE_INFO 0x20000000 +#define VERBOSE_TABLES 0x40000000 +#define VERBOSE_EVENTS 0x80000000 + +#define VERBOSE_ALL 0xF0000000 + + +/* Defaults for DebugLevel, debug and normal */ + +#define DEBUG_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) +#define NORMAL_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) +#define DEBUG_ALL (VERBOSE_AML_DISASSEMBLE | TRACE_ALL | ACPI_ALL) + +/* Misc defines */ + +#define HEX 0x01 +#define ASCII 0x02 +#define FULL_ADDRESS 0x04 +#define CHARS_PER_LINE 16 /* used in DumpBuf function */ + + +#endif /* __ACOUTPUT_H__ */ diff --git a/sys/contrib/dev/acpica/acparser.h b/sys/contrib/dev/acpica/acparser.h new file mode 100644 index 0000000..876c1de --- /dev/null +++ b/sys/contrib/dev/acpica/acparser.h @@ -0,0 +1,437 @@ +/****************************************************************************** + * + * Module Name: acparser.h - AML Parser subcomponent prototypes and defines + * $Revision: 47 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACPARSER_H__ +#define __ACPARSER_H__ + + +#define OP_HAS_RETURN_VALUE 1 + +/* variable # arguments */ + +#define ACPI_VAR_ARGS ACPI_UINT32_MAX + +/* maximum virtual address */ + +#define ACPI_MAX_AML ((UINT8 *)(~0UL)) + + +#define ACPI_PARSE_DELETE_TREE 0x0001 +#define ACPI_PARSE_NO_TREE_DELETE 0x0000 +#define ACPI_PARSE_TREE_MASK 0x0001 + +#define ACPI_PARSE_LOAD_PASS1 0x0010 +#define ACPI_PARSE_LOAD_PASS2 0x0020 +#define ACPI_PARSE_EXECUTE 0x0030 +#define ACPI_PARSE_MODE_MASK 0x0030 + +/* psapi - Parser external interfaces */ + +ACPI_STATUS +AcpiPsxLoadTable ( + UINT8 *PcodeAddr, + UINT32 PcodeLength); + +ACPI_STATUS +AcpiPsxExecute ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc); + + +BOOLEAN +AcpiPsIsNamespaceObjectOp ( + UINT16 Opcode); +BOOLEAN +AcpiPsIsNamespaceOp ( + UINT16 Opcode); + + +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* psargs - Parse AML opcode arguments */ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState); + +UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState); + +NATIVE_CHAR * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, /* type of argument */ + ACPI_PARSE_OBJECT *Arg); /* (OUT) argument data */ + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall); + +ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState); + +ACPI_PARSE_OBJECT * +AcpiPsGetNextArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + UINT32 *ArgCount); + + +/* psopcode - AML Opcode information */ + +ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode); + +NATIVE_CHAR * +AcpiPsGetOpcodeName ( + UINT16 Opcode); + + +/* psparse - top level parsing routines */ + +ACPI_STATUS +AcpiPsFindObject ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *root); + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_PARSE_OBJECT *StartScope, + UINT8 *Aml, + UINT32 AmlSize, + UINT32 ParseFlags, + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsParseTable ( + UINT8 *aml, + UINT32 amlSize, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback, + ACPI_PARSE_OBJECT **RootObject); + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *state); + + +/* psscope - Scope stack management routines */ + + +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Root); + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *state); + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount); + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount); + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *state); + + +/* pstree - parse tree manipulation routines */ + +void +AcpiPsAppendArg( + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_OBJECT *arg); + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR *Path, + UINT16 Opcode, + UINT32 Create); + +ACPI_PARSE_OBJECT * +AcpiPsGetArg( + ACPI_PARSE_OBJECT *op, + UINT32 argn); + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *op); + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op); + + +/* pswalk - parse tree walk routines */ + +ACPI_STATUS +AcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback); + + +/* psutils - parser utilities */ + + +ACPI_PARSE_STATE * +AcpiPsCreateState ( + UINT8 *Aml, + UINT32 AmlSize); + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *op, + UINT16 opcode); + +ACPI_PARSE_OBJECT * +AcpiPsAllocOp ( + UINT16 opcode); + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiPsDeleteParseCache ( + void); + +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c); + +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c); + +BOOLEAN +AcpiPsIsNamedOp ( + UINT16 opcode); + +BOOLEAN +AcpiPsIsNodeOp ( + UINT16 opcode); + +BOOLEAN +AcpiPsIsDeferredOp ( + UINT16 opcode); + +BOOLEAN +AcpiPsIsBytelistOp( + UINT16 opcode); + +BOOLEAN +AcpiPsIsFieldOp( + UINT16 opcode); + +BOOLEAN +AcpiPsIsCreateFieldOp ( + UINT16 Opcode); + +ACPI_PARSE2_OBJECT* +AcpiPsToExtendedOp( + ACPI_PARSE_OBJECT *op); + +UINT32 +AcpiPsGetName( + ACPI_PARSE_OBJECT *op); + +void +AcpiPsSetName( + ACPI_PARSE_OBJECT *op, + UINT32 name); + + +/* psdump - display parser tree */ + +UINT32 +AcpiPsSprintPath ( + NATIVE_CHAR *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +UINT32 +AcpiPsSprintOp ( + NATIVE_CHAR *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +void +AcpiPsShow ( + ACPI_PARSE_OBJECT *op); + + +#endif /* __ACPARSER_H__ */ diff --git a/sys/contrib/dev/acpica/acpi.h b/sys/contrib/dev/acpica/acpi.h new file mode 100644 index 0000000..e8591d4 --- /dev/null +++ b/sys/contrib/dev/acpica/acpi.h @@ -0,0 +1,141 @@ +/****************************************************************************** + * + * Name: acpi.h - Master include file, Publics and external data. + * $Revision: 48 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPI_H__ +#define __ACPI_H__ + +/* + * Common includes for all ACPI driver files + * We put them here because we don't want to duplicate them + * in the rest of the source code again and again. + */ +#include "acconfig.h" /* Configuration constants */ +#include "acenv.h" /* Target environment specific items */ +#include "actypes.h" /* Fundamental data types */ +#include "acexcep.h" /* Local exception codes */ +#include "acmacros.h" /* C macros */ +#include "actbl.h" /* Acpi table definitions */ +#include "aclocal.h" /* Internal data types */ +#include "acoutput.h" /* Error output and Debug macros */ +#include "acpiosxf.h" /* Interfaces to the Acpi-to-OS layer*/ +#include "acpixf.h" /* Acpi core external interfaces */ +#include "acobject.h" /* Acpi internal object */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "accommon.h" /* Common (global) interfaces */ + + +#endif /* __ACPI_H__ */ diff --git a/sys/contrib/dev/acpica/acpiosxf.h b/sys/contrib/dev/acpica/acpiosxf.h new file mode 100644 index 0000000..c371c49 --- /dev/null +++ b/sys/contrib/dev/acpica/acpiosxf.h @@ -0,0 +1,419 @@ + +/****************************************************************************** + * + * Name: acpiosd.h - All interfaces to the OS-dependent layer. These + * interfaces must be implemented by the OS-dependent + * front-end to the ACPI subsystem. + * + *****************************************************************************/ + + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPIOSD_H__ +#define __ACPIOSD_H__ + +#include "acenv.h" +#include "actypes.h" + + +/* Priorities for AcpiOsQueueForExecution */ + +#define OSD_PRIORITY_HIGH 1 +#define OSD_PRIORITY_MED 2 +#define OSD_PRIORITY_LO 3 +#define OSD_PRIORITY_GPE OSD_PRIORITY_HIGH + +#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) +#define ACPI_MUTEX_SEM 1 + + +/* + * Types specific to the OS-dependent layer interfaces + */ + +typedef +UINT32 (*OSD_HANDLER) ( + void *Context); + +typedef +void (*OSD_EXECUTION_CALLBACK) ( + void *Context); + + +/* + * Initialization and shutdown primitives (Optional) + */ + +ACPI_STATUS +AcpiOsInitialize ( + void); + +ACPI_STATUS +AcpiOsTerminate ( + void); + +/* + * Synchronization primitives + */ + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle); + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_HANDLE Handle); + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units, + UINT32 Timeout); + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units); + +/* + * Memory allocation and mapping + */ + +void * +AcpiOsAllocate ( + UINT32 Size); + +void * +AcpiOsCallocate ( + UINT32 Size); + +void +AcpiOsFree ( + void * Memory); + +ACPI_STATUS +AcpiOsMapMemory ( + void *PhysicalAddress, + UINT32 Length, + void **LogicalAddress); + +void +AcpiOsUnmapMemory ( + void *LogicalAddress, + UINT32 Length); + + +/* + * Interrupt handlers + */ + +ACPI_STATUS +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + OSD_HANDLER ServiceRoutine, + void *Context); + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + OSD_HANDLER ServiceRoutine); + + +/* + * Scheduling + */ + +ACPI_STATUS +AcpiOsQueueForExecution ( + UINT32 Priority, + OSD_EXECUTION_CALLBACK Function, + void *Context); + +void +AcpiOsSleep ( + UINT32 Seconds, + UINT32 Milliseconds); + +void +AcpiOsSleepUsec ( + UINT32 Microseconds); + +/* + * Platform/Hardware independent I/O interfaces + */ + +UINT8 +AcpiOsIn8 ( + ACPI_IO_ADDRESS InPort); + + +UINT16 +AcpiOsIn16 ( + ACPI_IO_ADDRESS InPort); + +UINT32 +AcpiOsIn32 ( + ACPI_IO_ADDRESS InPort); + +void +AcpiOsOut8 ( + ACPI_IO_ADDRESS OutPort, + UINT8 Value); + +void +AcpiOsOut16 ( + ACPI_IO_ADDRESS OutPort, + UINT16 Value); + +void +AcpiOsOut32 ( + ACPI_IO_ADDRESS OutPort, + UINT32 Value); + +/* + * Platform/Hardware independent physical memory interfaces + */ + +UINT8 +AcpiOsMemIn8 ( + ACPI_MEM_ADDRESS InAddr); + + +UINT16 +AcpiOsMemIn16 ( + ACPI_MEM_ADDRESS InAddr); + +UINT32 +AcpiOsMemIn32 ( + ACPI_MEM_ADDRESS InAddr); + +void +AcpiOsMemOut8 ( + ACPI_MEM_ADDRESS OutAddr, + UINT8 Value); + +void +AcpiOsMemOut16 ( + ACPI_MEM_ADDRESS OutAddr, + UINT16 Value); + +void +AcpiOsMemOut32 ( + ACPI_MEM_ADDRESS OutAddr, + UINT32 Value); + + +/* + * Standard access to PCI configuration space + */ + +ACPI_STATUS +AcpiOsReadPciCfgByte ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT8 *Value); + +ACPI_STATUS +AcpiOsReadPciCfgWord ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT16 *Value); + +ACPI_STATUS +AcpiOsReadPciCfgDword ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT32 *Value); + +ACPI_STATUS +AcpiOsWritePciCfgByte ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT8 Value); + +ACPI_STATUS +AcpiOsWritePciCfgWord ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT16 Value); + + +ACPI_STATUS +AcpiOsWritePciCfgDword ( + UINT32 Bus, + UINT32 DeviceFunction, + UINT32 Register, + UINT32 Value); + + +/* + * Miscellaneous + */ + +ACPI_STATUS +AcpiOsBreakpoint ( + NATIVE_CHAR *Message); + +BOOLEAN +AcpiOsReadable ( + void *Pointer, + UINT32 Length); + + +BOOLEAN +AcpiOsWritable ( + void *Pointer, + UINT32 Length); + + +/* + * Debug print routines + */ + +INT32 +AcpiOsPrintf ( + const NATIVE_CHAR *Format, + ...); + +INT32 +AcpiOsVprintf ( + const NATIVE_CHAR *Format, + va_list Args); + +/* + * Debug input + */ + +UINT32 +AcpiOsGetLine ( + NATIVE_CHAR *Buffer); + + +/* + * Debug + */ + +void +AcpiOsDbgAssert( + void *FailedAssertion, + void *FileName, + UINT32 LineNumber, + NATIVE_CHAR *Message); + + +#endif /* __ACPIOSD_H__ */ diff --git a/sys/contrib/dev/acpica/acpixf.h b/sys/contrib/dev/acpica/acpixf.h new file mode 100644 index 0000000..b1c52c8 --- /dev/null +++ b/sys/contrib/dev/acpica/acpixf.h @@ -0,0 +1,410 @@ + +/****************************************************************************** + * + * Name: acxface.h - External interfaces to the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ACXFACE_H__ +#define __ACXFACE_H__ + +#include "actypes.h" +#include "actbl.h" + +/* + * Global interfaces + */ + +ACPI_STATUS +AcpiInitializeSubsystem ( + void); + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags); + +ACPI_STATUS +AcpiTerminate ( + void); + +ACPI_STATUS +AcpiEnable ( + void); + +ACPI_STATUS +AcpiDisable ( + void); + +ACPI_STATUS +AcpiGetSystemInfo( + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiFormatException ( + ACPI_STATUS Exception, + ACPI_BUFFER *OutBuffer); + + +/* + * ACPI table manipulation interfaces + */ + +ACPI_STATUS +AcpiFindRootPointer ( + void **RsdpPhysicalAddress); + +ACPI_STATUS +AcpiLoadTables ( + void *RsdpPhysicalAddress); + +ACPI_STATUS +AcpiLoadTable ( + ACPI_TABLE_HEADER *TablePtr); + +ACPI_STATUS +AcpiUnloadTable ( + ACPI_TABLE_TYPE TableType); + +ACPI_STATUS +AcpiGetTableHeader ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader); + +ACPI_STATUS +AcpiGetTable ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_BUFFER *RetBuffer); + + +/* + * Namespace and name interfaces + */ + +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + WALK_CALLBACK UserFunction, + void *Context, + void * *ReturnValue); + + +ACPI_STATUS +AcpiGetDevices ( + NATIVE_CHAR *HID, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *RetPathPtr); + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle); + + +/* + * Object manipulation and enumeration + */ + +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ParameterObjects, + ACPI_BUFFER *ReturnObjectBuffer); + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Device, + ACPI_DEVICE_INFO *Info); + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *OutHandle); + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Object, + ACPI_OBJECT_TYPE *OutType); + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Object, + ACPI_HANDLE *OutHandle); + + +/* + * AcpiEvent handler interfaces + */ + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 AcpiEvent, + FIXED_EVENT_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 AcpiEvent, + FIXED_EVENT_HANDLER Handler); + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler); + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_SPACE_HANDLER Handler, + ADDRESS_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_SPACE_HANDLER Handler); + +ACPI_STATUS +AcpiInstallGpeHandler ( + UINT32 GpeNumber, + UINT32 Type, + GPE_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiAcquireGlobalLock ( + void); + +ACPI_STATUS +AcpiReleaseGlobalLock ( + void); + +ACPI_STATUS +AcpiRemoveGpeHandler ( + UINT32 GpeNumber, + GPE_HANDLER Handler); + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 AcpiEvent, + UINT32 Type); + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 AcpiEvent, + UINT32 Type); + +ACPI_STATUS +AcpiClearEvent ( + UINT32 AcpiEvent, + UINT32 Type); + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 AcpiEvent, + UINT32 Type, + ACPI_EVENT_STATUS *EventStatus); + +/* + * Resource interfaces + */ + +ACPI_STATUS +AcpiGetCurrentResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetPossibleResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer); + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE BusDeviceHandle, + ACPI_BUFFER *RetBuffer); + + +/* + * Hardware (ACPI device) interfaces + */ + +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + void *PhysicalAddress); + +ACPI_STATUS +AcpiGetFirmwareWakingVector ( + void **PhysicalAddress); + +ACPI_STATUS +AcpiGetProcessorThrottlingInfo ( + ACPI_HANDLE ProcessorHandle, + ACPI_BUFFER *UserBuffer); + +ACPI_STATUS +AcpiSetProcessorThrottlingState ( + ACPI_HANDLE ProcessorHandle, + UINT32 ThrottleState); + +ACPI_STATUS +AcpiGetProcessorThrottlingState ( + ACPI_HANDLE ProcessorHandle, + UINT32 *ThrottleState); + +ACPI_STATUS +AcpiGetProcessorCxInfo ( + ACPI_HANDLE ProcessorHandle, + ACPI_BUFFER *UserBuffer); + +ACPI_STATUS +AcpiSetProcessorSleepState ( + ACPI_HANDLE ProcessorHandle, + UINT32 CxState); + +ACPI_STATUS +AcpiProcessorSleep ( + ACPI_HANDLE ProcessorHandle, + UINT32 *PmTimerTicks); + + +#endif /* __ACXFACE_H__ */ diff --git a/sys/contrib/dev/acpica/acresrc.h b/sys/contrib/dev/acpica/acresrc.h new file mode 100644 index 0000000..c5d8add --- /dev/null +++ b/sys/contrib/dev/acpica/acresrc.h @@ -0,0 +1,396 @@ +/****************************************************************************** + * + * Name: acresrc.h - Resource Manager function prototypes + * $Revision: 20 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACRESRC_H__ +#define __ACRESRC_H__ + + +/* + * Function prototypes called from Acpi* APIs + */ + +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *ByteStreamBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength); + +ACPI_STATUS +AcpiRsCreateByteStream ( + RESOURCE *LinkedListBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength); + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *MethodReturnObject, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength); + + +/* + *Function prototypes called from AcpiRsCreate*APIs + */ + +void +AcpiRsDumpResourceList ( + RESOURCE *Resource); + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable); + +ACPI_STATUS +AcpiRsGetByteStreamStart ( + UINT8 *ByteStreamBuffer, + UINT8 **ByteStreamStart, + UINT32 *Size); + +ACPI_STATUS +AcpiRsCalculateListLength ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT32 *SizeNeeded); + +ACPI_STATUS +AcpiRsCalculateByteStreamLength ( + RESOURCE *LinkedListBuffer, + UINT32 *SizeNeeded); + +ACPI_STATUS +AcpiRsCalculatePciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + UINT32 *BufferSizeNeeded); + +ACPI_STATUS +AcpiRsByteStreamToList ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT8 **OutputBuffer); + +ACPI_STATUS +AcpiRsListToByteStream ( + RESOURCE *LinkedList, + UINT32 ByteStreamSizeNeeded, + UINT8 **OutputBuffer); + +ACPI_STATUS +AcpiRsIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsFixedIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsFixedIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsDmaResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsDmaStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsAddress16Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsAddress16Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsAddress32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsAddress32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsStartDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsEndDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsStartDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsEndDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsMemory24Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsMemory24Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsMemory32RangeResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize +); + +ACPI_STATUS +AcpiRsFixedMemory32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsMemory32RangeStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsFixedMemory32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsExtendedIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsExtendedIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsEndTagResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsEndTagStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + +ACPI_STATUS +AcpiRsVendorResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize); + +ACPI_STATUS +AcpiRsVendorStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed); + + +#endif /* __ACRESRC_H__ */ diff --git a/sys/contrib/dev/acpica/actables.h b/sys/contrib/dev/acpica/actables.h new file mode 100644 index 0000000..18fe18b --- /dev/null +++ b/sys/contrib/dev/acpica/actables.h @@ -0,0 +1,259 @@ +/****************************************************************************** + * + * Name: actables.h - ACPI table management + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTABLES_H__ +#define __ACTABLES_H__ + + +/* Used in AcpiTbMapAcpiTable for size parameter if table header is to be used */ + +#define SIZE_IN_HEADER 0 + + +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **TableDesc); + + +/* + * tbget - Table "get" routines + */ + +ACPI_STATUS +AcpiTbGetTablePtr ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER **TablePtrLoc); + +ACPI_STATUS +AcpiTbGetTable ( + void *PhysicalAddress, + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo); + +ACPI_STATUS +AcpiTbVerifyRsdp ( + void *RSDP_PhysicalAddress); + +ACPI_STATUS +AcpiTbGetTableFacs ( + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbgetall - Get all firmware ACPI tables + */ + +ACPI_STATUS +AcpiTbGetAllTables ( + UINT32 NumberOfTables, + ACPI_TABLE_HEADER *BufferPtr); + + +/* + * tbinstall - Table installation + */ + +ACPI_STATUS +AcpiTbInstallTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo); + +ACPI_STATUS +AcpiTbRecognizeTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo); + +ACPI_STATUS +AcpiTbInitTableDescriptor ( + ACPI_TABLE_TYPE TableType, + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbremove - Table removal and deletion + */ + +void +AcpiTbDeleteAcpiTables ( + void); + +void +AcpiTbDeleteAcpiTable ( + ACPI_TABLE_TYPE Type); + +void +AcpiTbDeleteSingleTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_TABLE_DESC * +AcpiTbUninstallTable ( + ACPI_TABLE_DESC *TableDesc); + +void +AcpiTbFreeAcpiTablesOfType ( + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbrsd - RSDP, RSDT utilities + */ + +ACPI_STATUS +AcpiTbGetTableRsdt ( + UINT32 *NumberOfTables); + +UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length); + +ACPI_STATUS +AcpiTbFindRsdp ( + ACPI_TABLE_DESC *TableInfo); + + +/* + * tbutils - common table utilities + */ + +BOOLEAN +AcpiTbSystemTablePointer ( + void *Where); + +ACPI_STATUS +AcpiTbMapAcpiTable ( + void *PhysicalAddress, + UINT32 *Size, + void **LogicalAddress); + +ACPI_STATUS +AcpiTbVerifyTableChecksum ( + ACPI_TABLE_HEADER *TableHeader); + +UINT8 +AcpiTbChecksum ( + void *Buffer, + UINT32 Length); + +ACPI_STATUS +AcpiTbValidateTableHeader ( + ACPI_TABLE_HEADER *TableHeader); + + +#endif /* __ACTABLES_H__ */ diff --git a/sys/contrib/dev/acpica/actbl.h b/sys/contrib/dev/acpica/actbl.h new file mode 100644 index 0000000..53232e3 --- /dev/null +++ b/sys/contrib/dev/acpica/actbl.h @@ -0,0 +1,282 @@ +/****************************************************************************** + * + * Name: actbl.h - Table data structures defined in ACPI specification + * $Revision: 35 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL_H__ +#define __ACTBL_H__ + + +/* + * Values for description table header signatures + */ + +#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ +#define APIC_SIG "APIC" /* Multiple APIC Description Table */ +#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ +#define FACP_SIG "FACP" /* Fixed ACPI Description Table */ +#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ +#define PSDT_SIG "PSDT" /* Persistent System Description Table */ +#define RSDT_SIG "RSDT" /* Root System Description Table */ +#define SSDT_SIG "SSDT" /* Secondary System Description Table */ +#define SBST_SIG "SBST" /* Smart Battery Specification Table */ +#define SPIC_SIG "SPIC" /* iosapic table */ +#define BOOT_SIG "BOOT" /* Boot table */ + + +#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ + +/* values of Mapic.Model */ + +#define DUAL_PIC 0 +#define MULTIPLE_APIC 1 + +/* values of Type in APIC_HEADER */ + +#define APIC_PROC 0 +#define APIC_IO 1 + + +/* + * Architecture-independent tables + * The architecture dependent tables are in separate files + */ + +typedef struct /* Root System Descriptor Pointer */ +{ + NATIVE_CHAR Signature [8]; /* contains "RSD PTR " */ + UINT8 Checksum; /* to make sum of struct == 0 */ + NATIVE_CHAR OemId [6]; /* OEM identification */ + UINT8 Reserved; /* reserved - must be zero */ + UINT32 RsdtPhysicalAddress; /* physical address of RSDT */ + +} ROOT_SYSTEM_DESCRIPTOR_POINTER; + + +typedef struct /* ACPI common table header */ +{ + NATIVE_CHAR Signature [4]; /* identifies type of table */ + UINT32 Length; /* length of table, in bytes, + * including header */ + UINT8 Revision; /* specification minor version # */ + UINT8 Checksum; /* to make sum of entire table == 0 */ + NATIVE_CHAR OemId [6]; /* OEM identification */ + NATIVE_CHAR OemTableId [8]; /* OEM table identification */ + UINT32 OemRevision; /* OEM revision number */ + NATIVE_CHAR AslCompilerId [4]; /* ASL compiler vendor ID */ + UINT32 AslCompilerRevision; /* ASL compiler revision number */ + +} ACPI_TABLE_HEADER; + + +typedef struct /* APIC Table */ +{ + ACPI_TABLE_HEADER header; /* table header */ + UINT32 LocalApicAddress; /* Physical address for accessing local APICs */ + UINT32_BIT PCATCompat : 1; /* a one indicates system also has dual 8259s */ + UINT32_BIT Reserved1 : 31; + +} APIC_TABLE; + + +typedef struct /* APIC Header */ +{ + UINT8 Type; /* APIC type. Either APIC_PROC or APIC_IO */ + UINT8 Length; /* Length of APIC structure */ + +} APIC_HEADER; + + +typedef struct /* Processor APIC */ +{ + APIC_HEADER header; + UINT8 ProcessorApicId; /* ACPI processor id */ + UINT8 LocalApicId; /* processor's local APIC id */ + UINT32_BIT ProcessorEnabled: 1; /* Processor is usable if set */ + UINT32_BIT Reserved1 : 32; + +} PROCESSOR_APIC; + + +typedef struct /* IO APIC */ +{ + APIC_HEADER header; + UINT8 IoApicId; /* I/O APIC ID */ + UINT8 Reserved; /* reserved - must be zero */ + UINT32 IoApicAddress; /* APIC's physical address */ + UINT32 Vector; /* interrupt vector index where INTI + * lines start */ +} IO_APIC; + + +/* +** IA64 TODO: Add SAPIC Tables +*/ + +/* +** IA64 TODO: Modify Smart Battery Description to comply with ACPI IA64 +** extensions. +*/ +typedef struct /* Smart Battery Description Table */ +{ + ACPI_TABLE_HEADER header; + UINT32 WarningLevel; + UINT32 LowLevel; + UINT32 CriticalLevel; + +} SMART_BATTERY_DESCRIPTION_TABLE; + + +/* + * ACPI Table information. We save the table address, length, + * and type of memory allocation (mapped or allocated) for each + * table for 1) when we exit, and 2) if a new table is installed + */ + +#define ACPI_MEM_NOT_ALLOCATED 0 +#define ACPI_MEM_ALLOCATED 1 +#define ACPI_MEM_MAPPED 2 + +/* Definitions for the Flags bitfield member of ACPI_TABLE_SUPPORT */ + +#define ACPI_TABLE_SINGLE 0 +#define ACPI_TABLE_MULTIPLE 1 + + +/* Data about each known table type */ + +typedef struct _AcpiTableSupport +{ + NATIVE_CHAR *Name; + NATIVE_CHAR *Signature; + UINT8 SigLength; + UINT8 Flags; + UINT16 Status; + void **GlobalPtr; + +} ACPI_TABLE_SUPPORT; + + +/* + * Get the architecture-specific tables + */ + +#ifdef IA64 +#include "actbl64.h" +#else +#include "actbl32.h" +#endif + + +#endif /* __ACTBL_H__ */ diff --git a/sys/contrib/dev/acpica/actypes.h b/sys/contrib/dev/acpica/actypes.h new file mode 100644 index 0000000..446f01f --- /dev/null +++ b/sys/contrib/dev/acpica/actypes.h @@ -0,0 +1,1111 @@ +/****************************************************************************** + * + * Name: actypes.h - Common data types for the entire ACPI subsystem + * $Revision: 143 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTYPES_H__ +#define __ACTYPES_H__ + +/*! [Begin] no source code translation (keep the typedefs) */ + +/* + * Data types - Fixed across all compilation models + * + * BOOLEAN Logical Boolean. + * 1 byte value containing a 0 for FALSE or a 1 for TRUE. + * Other values are undefined. + * + * INT8 8-bit (1 byte) signed value + * UINT8 8-bit (1 byte) unsigned value + * INT16 16-bit (2 byte) signed value + * UINT16 16-bit (2 byte) unsigned value + * INT32 32-bit (4 byte) signed value + * UINT32 32-bit (4 byte) unsigned value + * INT64 64-bit (8 byte) signed value + * UINT64 64-bit (8 byte) unsigned value + * NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value + * NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value + * UCHAR Character. 1 byte unsigned value. + */ + + +#ifdef _IA64 +/* + * 64-bit type definitions + */ +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned char UCHAR; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef long INT64; +typedef unsigned long UINT64; + +typedef UINT64 NATIVE_UINT; +typedef INT64 NATIVE_INT; + +typedef NATIVE_UINT ACPI_TBLPTR; +typedef UINT64 ACPI_IO_ADDRESS; +typedef UINT64 ACPI_MEM_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 + +/* (No hardware alignment support in IA64) */ + + +#elif _IA16 +/* + * 16-bit type definitions + */ +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned char UCHAR; +typedef unsigned int UINT16; +typedef long INT32; +typedef int INT16; +typedef unsigned long UINT32; + +typedef UINT16 NATIVE_UINT; +typedef INT16 NATIVE_INT; + +typedef UINT32 ACPI_TBLPTR; +typedef UINT32 ACPI_IO_ADDRESS; +typedef UINT32 ACPI_MEM_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 +#define _HW_ALIGNMENT_SUPPORT + +/* (16-bit only) Force internal integers to be 32, not 64 bits */ + +#define ACPI_VERSION_1 + + +#else +/* + * 32-bit type definitions (default) + */ +typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; +typedef unsigned char UCHAR; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef COMPILER_DEPENDENT_UINT64 UINT64; + +typedef UINT32 NATIVE_UINT; +typedef INT32 NATIVE_INT; + +typedef NATIVE_UINT ACPI_TBLPTR; +typedef UINT32 ACPI_IO_ADDRESS; +typedef UINT32 ACPI_MEM_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 +#define _HW_ALIGNMENT_SUPPORT + +#endif + + + +/* + * Miscellaneous common types + */ + +typedef UINT32 UINT32_BIT; +typedef NATIVE_UINT ACPI_PTRDIFF; +typedef char NATIVE_CHAR; + + +/* + * Data type ranges + */ + +#define ACPI_UINT8_MAX (UINT8) 0xFF +#define ACPI_UINT16_MAX (UINT16) 0xFFFF +#define ACPI_UINT32_MAX (UINT32) 0xFFFFFFFF +#define ACPI_UINT64_MAX (UINT64) 0xFFFFFFFFFFFFFFFF + + +#ifdef DEFINE_ALTERNATE_TYPES +/* + * Types used only in translated source + */ +typedef INT32 s32; +typedef UINT8 u8; +typedef UINT16 u16; +typedef UINT32 u32; +typedef UINT64 u64; +#endif +/*! [End] no source code translation !*/ + + +/* + * Useful defines + */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE (1 == 0) + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE (1 == 1) + +#ifndef NULL +#define NULL (void *) 0 +#endif + + +/* + * Local datatypes + */ + +typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ +typedef UINT32 ACPI_NAME; /* 4-INT8 ACPI name */ +typedef char* ACPI_STRING; /* Null terminated ASCII string */ +typedef void* ACPI_HANDLE; /* Actually a ptr to an Node */ + + +/* TBD: TEMP ONLY! */ + +#define ACPI_VERSION_1 + +/* + * Acpi integer width. In ACPI version 1, integers are + * 32 bits. In ACPI version 2, integers are 64 bits. Period. + * Note that this pertains to the ACPI integer type only, not + * other integers used in the implementation of the ACPI CA + * subsystem. + */ + +#ifdef ACPI_VERSION_1 + +/* 32-bit Integers */ + +typedef UINT32 ACPI_INTEGER; +#define ACPI_INTEGER_MAX ACPI_UINT32_MAX; +#define ACPI_INTEGER_BIT_SIZE 32 + +#else + +/* 64-bit Integers */ + +typedef UINT64 ACPI_INTEGER; +#define ACPI_INTEGER_MAX ACPI_UINT64_MAX; +#define ACPI_INTEGER_BIT_SIZE 64 +#endif + + +/* + * Constants with special meanings + */ + +#define ACPI_ROOT_OBJECT (ACPI_HANDLE)(-1) + +#define ACPI_FULL_INITIALIZATION 0x00 +#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 +#define ACPI_NO_HARDWARE_INIT 0x02 +#define ACPI_NO_EVENT_INIT 0x04 +#define ACPI_NO_ACPI_ENABLE 0x08 +#define ACPI_NO_DEVICE_INIT 0x10 +#define ACPI_NO_PCI_INIT 0x20 +#define ACPI_NO_OBJECT_INIT 0x40 + + +/* + * Sleep state constants + */ +#define ACPI_STATE_S0 (UINT8) 0 +#define ACPI_STATE_S1 (UINT8) 1 +#define ACPI_STATE_S2 (UINT8) 2 +#define ACPI_STATE_S3 (UINT8) 3 +#define ACPI_STATE_S4 (UINT8) 4 +#define ACPI_STATE_S4BIOS (UINT8) 5 +#define ACPI_STATE_S5 (UINT8) 6 +#define ACPI_S_STATES_MAX ACPI_STATE_S5 + + +/* + * Table types. These values are passed to the table related APIs + */ + +typedef UINT32 ACPI_TABLE_TYPE; + +#define ACPI_TABLE_RSDP (ACPI_TABLE_TYPE) 0 +#define ACPI_TABLE_APIC (ACPI_TABLE_TYPE) 1 +#define ACPI_TABLE_DSDT (ACPI_TABLE_TYPE) 2 +#define ACPI_TABLE_FACP (ACPI_TABLE_TYPE) 3 +#define ACPI_TABLE_FACS (ACPI_TABLE_TYPE) 4 +#define ACPI_TABLE_PSDT (ACPI_TABLE_TYPE) 5 +#define ACPI_TABLE_RSDT (ACPI_TABLE_TYPE) 6 +#define ACPI_TABLE_SSDT (ACPI_TABLE_TYPE) 7 +#define ACPI_TABLE_SBST (ACPI_TABLE_TYPE) 8 +#define ACPI_TABLE_SPIC (ACPI_TABLE_TYPE) 9 +#define ACPI_TABLE_BOOT (ACPI_TABLE_TYPE) 10 +#define ACPI_TABLE_MAX 10 +#define NUM_ACPI_TABLES (ACPI_TABLE_MAX+1) + + +/* + * Types associated with names. The first group of + * values correspond to the definition of the ACPI + * ObjectType operator (See the ACPI Spec). Therefore, + * only add to the first group if the spec changes! + * + * Types must be kept in sync with the AcpiNsProperties + * and AcpiNsTypeNames arrays + */ + +typedef UINT32 ACPI_OBJECT_TYPE; +typedef UINT8 OBJECT_TYPE_INTERNAL; + +#define ACPI_TYPE_ANY 0 /* 0x00 */ +#define ACPI_TYPE_NUMBER 1 /* 0x01 Byte/Word/Dword/Zero/One/Ones */ +#define ACPI_TYPE_STRING 2 /* 0x02 */ +#define ACPI_TYPE_BUFFER 3 /* 0x03 */ +#define ACPI_TYPE_PACKAGE 4 /* 0x04 ByteConst, multiple DataTerm/Constant/SuperName */ +#define ACPI_TYPE_FIELD_UNIT 5 /* 0x05 */ +#define ACPI_TYPE_DEVICE 6 /* 0x06 Name, multiple Node */ +#define ACPI_TYPE_EVENT 7 /* 0x07 */ +#define ACPI_TYPE_METHOD 8 /* 0x08 Name, ByteConst, multiple Code */ +#define ACPI_TYPE_MUTEX 9 /* 0x09 */ +#define ACPI_TYPE_REGION 10 /* 0x0A */ +#define ACPI_TYPE_POWER 11 /* 0x0B Name,ByteConst,WordConst,multi Node */ +#define ACPI_TYPE_PROCESSOR 12 /* 0x0C Name,ByteConst,DWordConst,ByteConst,multi NmO */ +#define ACPI_TYPE_THERMAL 13 /* 0x0D Name, multiple Node */ +#define ACPI_TYPE_BUFFER_FIELD 14 /* 0x0E */ +#define ACPI_TYPE_DDB_HANDLE 15 /* 0x0F */ +#define ACPI_TYPE_DEBUG_OBJECT 16 /* 0x10 */ + +#define ACPI_TYPE_MAX 16 + +/* + * This section contains object types that do not relate to the ACPI ObjectType operator. + * They are used for various internal purposes only. If new predefined ACPI_TYPEs are + * added (via the ACPI specification), these internal types must move upwards. + * Also, values exceeding the largest official ACPI ObjectType must not overlap with + * defined AML opcodes. + */ +#define INTERNAL_TYPE_BEGIN 17 + +#define INTERNAL_TYPE_DEF_FIELD 17 /* 0x11 */ +#define INTERNAL_TYPE_BANK_FIELD 18 /* 0x12 */ +#define INTERNAL_TYPE_INDEX_FIELD 19 /* 0x13 */ +#define INTERNAL_TYPE_REFERENCE 20 /* 0x14 Arg#, Local#, Name, Debug; used only in descriptors */ +#define INTERNAL_TYPE_ALIAS 21 /* 0x15 */ +#define INTERNAL_TYPE_NOTIFY 22 /* 0x16 */ +#define INTERNAL_TYPE_ADDRESS_HANDLER 23 /* 0x17 */ + +#define INTERNAL_TYPE_NODE_MAX 23 + +/* These are pseudo-types because there are never any namespace nodes with these types */ + +#define INTERNAL_TYPE_DEF_FIELD_DEFN 24 /* 0x18 Name, ByteConst, multiple FieldElement */ +#define INTERNAL_TYPE_BANK_FIELD_DEFN 25 /* 0x19 2 Name,DWordConst,ByteConst,multi FieldElement */ +#define INTERNAL_TYPE_INDEX_FIELD_DEFN 26 /* 0x1A 2 Name, ByteConst, multiple FieldElement */ +#define INTERNAL_TYPE_IF 27 /* 0x1B OpCode, multiple Code */ +#define INTERNAL_TYPE_ELSE 28 /* 0x1C multiple Code */ +#define INTERNAL_TYPE_WHILE 29 /* 0x1D OpCode, multiple Code */ +#define INTERNAL_TYPE_SCOPE 30 /* 0x1E Name, multiple Node */ +#define INTERNAL_TYPE_DEF_ANY 31 /* 0x1F type is Any, suppress search of enclosing scopes */ +#define INTERNAL_TYPE_METHOD_ARGUMENT 32 /* 0x20 */ +#define INTERNAL_TYPE_METHOD_LOCAL_VAR 33 /* 0x21 */ +#define INTERNAL_TYPE_EXTRA 34 /* 0x22 */ + +#define INTERNAL_TYPE_MAX 34 + +#define INTERNAL_TYPE_INVALID 35 +#define ACPI_TYPE_NOT_FOUND 0xFF + +/* + * AcpiEvent Types: + * ------------ + * Fixed & general purpose... + */ + +typedef UINT32 ACPI_EVENT_TYPE; + +#define ACPI_EVENT_FIXED (ACPI_EVENT_TYPE) 0 +#define ACPI_EVENT_GPE (ACPI_EVENT_TYPE) 1 + +/* + * Fixed events + */ + +#define ACPI_EVENT_PMTIMER (ACPI_EVENT_TYPE) 0 + /* + * There's no bus master event so index 1 is used for IRQ's that are not + * handled by the SCI handler + */ +#define ACPI_EVENT_NOT_USED (ACPI_EVENT_TYPE) 1 +#define ACPI_EVENT_GLOBAL (ACPI_EVENT_TYPE) 2 +#define ACPI_EVENT_POWER_BUTTON (ACPI_EVENT_TYPE) 3 +#define ACPI_EVENT_SLEEP_BUTTON (ACPI_EVENT_TYPE) 4 +#define ACPI_EVENT_RTC (ACPI_EVENT_TYPE) 5 +#define ACPI_EVENT_GENERAL (ACPI_EVENT_TYPE) 6 +#define ACPI_EVENT_MAX 6 +#define NUM_FIXED_EVENTS (ACPI_EVENT_TYPE) 7 + +#define ACPI_GPE_INVALID 0xFF +#define ACPI_GPE_MAX 0xFF +#define NUM_GPE 256 + +#define ACPI_EVENT_LEVEL_TRIGGERED (ACPI_EVENT_TYPE) 1 +#define ACPI_EVENT_EDGE_TRIGGERED (ACPI_EVENT_TYPE) 2 + +/* + * AcpiEvent Status: + * ------------- + * The encoding of ACPI_EVENT_STATUS is illustrated below. + * Note that a set bit (1) indicates the property is TRUE + * (e.g. if bit 0 is set then the event is enabled). + * +---------------+-+-+ + * | Bits 31:2 |1|0| + * +---------------+-+-+ + * | | | + * | | +- Enabled? + * | +--- Set? + * +----------- + */ +typedef UINT32 ACPI_EVENT_STATUS; + +#define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 +#define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x02 + + +/* Notify types */ + +#define ACPI_SYSTEM_NOTIFY 0 +#define ACPI_DEVICE_NOTIFY 1 +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 1 + +#define MAX_SYS_NOTIFY 0x7f + + +/* Address Space (Operation Region) Types */ + +typedef UINT32 ACPI_ADDRESS_SPACE_TYPE; + +#define ADDRESS_SPACE_SYSTEM_MEMORY (ACPI_ADDRESS_SPACE_TYPE) 0 +#define ADDRESS_SPACE_SYSTEM_IO (ACPI_ADDRESS_SPACE_TYPE) 1 +#define ADDRESS_SPACE_PCI_CONFIG (ACPI_ADDRESS_SPACE_TYPE) 2 +#define ADDRESS_SPACE_EC (ACPI_ADDRESS_SPACE_TYPE) 3 +#define ADDRESS_SPACE_SMBUS (ACPI_ADDRESS_SPACE_TYPE) 4 + + +/* + * External ACPI object definition + */ + +typedef union AcpiObj +{ + ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ + struct + { + ACPI_OBJECT_TYPE Type; + ACPI_INTEGER Value; /* The actual number */ + } Number; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Length; /* # of bytes in string, excluding trailing null */ + NATIVE_CHAR *Pointer; /* points to the string value */ + } String; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Length; /* # of bytes in buffer */ + UINT8 *Pointer; /* points to the buffer */ + } Buffer; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Fill1; + ACPI_HANDLE Handle; /* object reference */ + } Reference; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 Count; /* # of elements in package */ + union AcpiObj *Elements; /* Pointer to an array of ACPI_OBJECTs */ + } Package; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 ProcId; + UINT32 PblkAddress; + UINT32 PblkLength; + } Processor; + + struct + { + ACPI_OBJECT_TYPE Type; + UINT32 SystemLevel; + UINT32 ResourceOrder; + } PowerResource; + +} ACPI_OBJECT, *PACPI_OBJECT; + + +/* + * List of objects, used as a parameter list for control method evaluation + */ + +typedef struct AcpiObjList +{ + UINT32 Count; + ACPI_OBJECT *Pointer; + +} ACPI_OBJECT_LIST, *PACPI_OBJECT_LIST; + + +/* + * Miscellaneous common Data Structures used by the interfaces + */ + +typedef struct +{ + UINT32 Length; /* Length in bytes of the buffer */ + void *Pointer; /* pointer to buffer */ + +} ACPI_BUFFER; + + +/* + * NameType for AcpiGetName + */ + +#define ACPI_FULL_PATHNAME 0 +#define ACPI_SINGLE_NAME 1 +#define ACPI_NAME_TYPE_MAX 1 + + +/* + * Structure and flags for AcpiGetSystemInfo + */ + +#define SYS_MODE_UNKNOWN 0x0000 +#define SYS_MODE_ACPI 0x0001 +#define SYS_MODE_LEGACY 0x0002 +#define SYS_MODES_MASK 0x0003 + +/* + * ACPI CPU Cx state handler + */ +typedef +ACPI_STATUS (*ACPI_SET_C_STATE_HANDLER) ( + NATIVE_UINT PblkAddress); + +/* + * ACPI Cx State info + */ +typedef struct +{ + UINT32 StateNumber; + UINT32 Latency; +} ACPI_CX_STATE; + +/* + * ACPI CPU throttling info + */ +typedef struct +{ + UINT32 StateNumber; + UINT32 PercentOfClock; +} ACPI_CPU_THROTTLING_STATE; + +/* + * ACPI Table Info. One per ACPI table _type_ + */ +typedef struct AcpiTableInfo +{ + UINT32 Count; + +} ACPI_TABLE_INFO; + + +/* + * System info returned by AcpiGetSystemInfo() + */ + +typedef struct _AcpiSysInfo +{ + UINT32 AcpiCaVersion; + UINT32 Flags; + UINT32 TimerResolution; + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 DebugLevel; + UINT32 DebugLayer; + UINT32 NumTableTypes; + ACPI_TABLE_INFO TableInfo [NUM_ACPI_TABLES]; + +} ACPI_SYSTEM_INFO; + + +/* + * System Initiailization data. This data is passed to ACPIInitialize + * copyied to global data and retained by ACPI CA + */ + +typedef struct _AcpiInitData +{ + void *RSDP_PhysicalAddress; /* Address of RSDP, needed it it is */ + /* not found in the IA32 manner */ +} ACPI_INIT_DATA; + +/* + * Various handlers and callback procedures + */ + +typedef +UINT32 (*FIXED_EVENT_HANDLER) ( + void *Context); + +typedef +void (*GPE_HANDLER) ( + void *Context); + +typedef +void (*NOTIFY_HANDLER) ( + ACPI_HANDLE Device, + UINT32 Value, + void *Context); + +#define ADDRESS_SPACE_READ 1 +#define ADDRESS_SPACE_WRITE 2 + +typedef +ACPI_STATUS (*ADDRESS_SPACE_HANDLER) ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext); + +#define ACPI_DEFAULT_HANDLER ((ADDRESS_SPACE_HANDLER) NULL) + + +typedef +ACPI_STATUS (*ADDRESS_SPACE_SETUP) ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +#define ACPI_REGION_ACTIVATE 0 +#define ACPI_REGION_DEACTIVATE 1 + +typedef +ACPI_STATUS (*WALK_CALLBACK) ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/* Interrupt handler return values */ + +#define INTERRUPT_NOT_HANDLED 0x00 +#define INTERRUPT_HANDLED 0x01 + + +/* Structure and flags for AcpiGetDeviceInfo */ + +#define ACPI_VALID_HID 0x1 +#define ACPI_VALID_UID 0x2 +#define ACPI_VALID_ADR 0x4 +#define ACPI_VALID_STA 0x8 + + +#define ACPI_COMMON_OBJ_INFO \ + ACPI_OBJECT_TYPE Type; /* ACPI object type */ \ + ACPI_NAME Name /* ACPI object Name */ + + +typedef struct +{ + ACPI_COMMON_OBJ_INFO; +} ACPI_OBJ_INFO_HEADER; + + +typedef struct +{ + ACPI_COMMON_OBJ_INFO; + + UINT32 Valid; /* Are the next bits legit? */ + NATIVE_CHAR HardwareId [9]; /* _HID value if any */ + NATIVE_CHAR UniqueId[9]; /* _UID value if any */ + ACPI_INTEGER Address; /* _ADR value if any */ + UINT32 CurrentStatus; /* _STA value */ +} ACPI_DEVICE_INFO; + + +/* Context structs for address space handlers */ + +typedef struct +{ + UINT32 Seg; + UINT32 Bus; + UINT32 DevFunc; +} PCI_HANDLER_CONTEXT; + + +typedef struct +{ + UINT8 *MappedPhysicalAddress; + UINT8 *MappedLogicalAddress; + UINT32 MappedLength; +} MEM_HANDLER_CONTEXT; + + +/* + * C-state handler + */ + +typedef ACPI_STATUS (*ACPI_C_STATE_HANDLER) (ACPI_IO_ADDRESS, UINT32*); + + +/* + * Definitions for Resource Attributes + */ + +/* + * Memory Attributes + */ +#define READ_ONLY_MEMORY (UINT8) 0x00 +#define READ_WRITE_MEMORY (UINT8) 0x01 + +#define NON_CACHEABLE_MEMORY (UINT8) 0x00 +#define CACHABLE_MEMORY (UINT8) 0x01 +#define WRITE_COMBINING_MEMORY (UINT8) 0x02 +#define PREFETCHABLE_MEMORY (UINT8) 0x03 + +/* + * IO Attributes + * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. + * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. + */ +#define NON_ISA_ONLY_RANGES (UINT8) 0x01 +#define ISA_ONLY_RANGES (UINT8) 0x02 +#define ENTIRE_RANGE (NON_ISA_ONLY_RANGES | ISA_ONLY_RANGES) + +/* + * IO Port Descriptor Decode + */ +#define DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ +#define DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ + +/* + * IRQ Attributes + */ +#define EDGE_SENSITIVE (UINT8) 0x00 +#define LEVEL_SENSITIVE (UINT8) 0x01 + +#define ACTIVE_HIGH (UINT8) 0x00 +#define ACTIVE_LOW (UINT8) 0x01 + +#define EXCLUSIVE (UINT8) 0x00 +#define SHARED (UINT8) 0x01 + +/* + * DMA Attributes + */ +#define COMPATIBILITY (UINT8) 0x00 +#define TYPE_A (UINT8) 0x01 +#define TYPE_B (UINT8) 0x02 +#define TYPE_F (UINT8) 0x03 + +#define NOT_BUS_MASTER (UINT8) 0x00 +#define BUS_MASTER (UINT8) 0x01 + +#define TRANSFER_8 (UINT8) 0x00 +#define TRANSFER_8_16 (UINT8) 0x01 +#define TRANSFER_16 (UINT8) 0x02 + +/* + * Start Dependent Functions Priority definitions + */ +#define GOOD_CONFIGURATION (UINT8) 0x00 +#define ACCEPTABLE_CONFIGURATION (UINT8) 0x01 +#define SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 + +/* + * 16, 32 and 64-bit Address Descriptor resource types + */ +#define MEMORY_RANGE (UINT8) 0x00 +#define IO_RANGE (UINT8) 0x01 +#define BUS_NUMBER_RANGE (UINT8) 0x02 + +#define ADDRESS_NOT_FIXED (UINT8) 0x00 +#define ADDRESS_FIXED (UINT8) 0x01 + +#define POS_DECODE (UINT8) 0x00 +#define SUB_DECODE (UINT8) 0x01 + +#define PRODUCER (UINT8) 0x00 +#define CONSUMER (UINT8) 0x01 + + +/* + * Structures used to describe device resources + */ +typedef struct +{ + UINT32 EdgeLevel; + UINT32 ActiveHighLow; + UINT32 SharedExclusive; + UINT32 NumberOfInterrupts; + UINT32 Interrupts[1]; + +} IRQ_RESOURCE; + +typedef struct +{ + UINT32 Type; + UINT32 BusMaster; + UINT32 Transfer; + UINT32 NumberOfChannels; + UINT32 Channels[1]; + +} DMA_RESOURCE; + +typedef struct +{ + UINT32 CompatibilityPriority; + UINT32 PerformanceRobustness; + +} START_DEPENDENT_FUNCTIONS_RESOURCE; + +/* + * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not + * needed because it has no fields + */ + +typedef struct +{ + UINT32 IoDecode; + UINT32 MinBaseAddress; + UINT32 MaxBaseAddress; + UINT32 Alignment; + UINT32 RangeLength; + +} IO_RESOURCE; + +typedef struct +{ + UINT32 BaseAddress; + UINT32 RangeLength; + +} FIXED_IO_RESOURCE; + +typedef struct +{ + UINT32 Length; + UINT8 Reserved[1]; + +} VENDOR_RESOURCE; + +typedef struct +{ + UINT32 ReadWriteAttribute; + UINT32 MinBaseAddress; + UINT32 MaxBaseAddress; + UINT32 Alignment; + UINT32 RangeLength; + +} MEMORY24_RESOURCE; + +typedef struct +{ + UINT32 ReadWriteAttribute; + UINT32 MinBaseAddress; + UINT32 MaxBaseAddress; + UINT32 Alignment; + UINT32 RangeLength; + +} MEMORY32_RESOURCE; + +typedef struct +{ + UINT32 ReadWriteAttribute; + UINT32 RangeBaseAddress; + UINT32 RangeLength; + +} FIXED_MEMORY32_RESOURCE; + +typedef struct +{ + UINT16 CacheAttribute; + UINT16 ReadWriteAttribute; + +} MEMORY_ATTRIBUTE; + +typedef struct +{ + UINT16 RangeAttribute; + UINT16 Reserved; + +} IO_ATTRIBUTE; + +typedef struct +{ + UINT16 Reserved1; + UINT16 Reserved2; + +} BUS_ATTRIBUTE; + +typedef union +{ + MEMORY_ATTRIBUTE Memory; + IO_ATTRIBUTE Io; + BUS_ATTRIBUTE Bus; + +} ATTRIBUTE_DATA; + +typedef struct +{ + UINT32 ResourceType; + UINT32 ProducerConsumer; + UINT32 Decode; + UINT32 MinAddressFixed; + UINT32 MaxAddressFixed; + ATTRIBUTE_DATA Attribute; + UINT32 Granularity; + UINT32 MinAddressRange; + UINT32 MaxAddressRange; + UINT32 AddressTranslationOffset; + UINT32 AddressLength; + UINT32 ResourceSourceIndex; + UINT32 ResourceSourceStringLength; + NATIVE_CHAR ResourceSource[1]; + +} ADDRESS16_RESOURCE; + +typedef struct +{ + UINT32 ResourceType; + UINT32 ProducerConsumer; + UINT32 Decode; + UINT32 MinAddressFixed; + UINT32 MaxAddressFixed; + ATTRIBUTE_DATA Attribute; + UINT32 Granularity; + UINT32 MinAddressRange; + UINT32 MaxAddressRange; + UINT32 AddressTranslationOffset; + UINT32 AddressLength; + UINT32 ResourceSourceIndex; + UINT32 ResourceSourceStringLength; + NATIVE_CHAR ResourceSource[1]; + +} ADDRESS32_RESOURCE; + +typedef struct +{ + UINT32 ProducerConsumer; + UINT32 EdgeLevel; + UINT32 ActiveHighLow; + UINT32 SharedExclusive; + UINT32 NumberOfInterrupts; + UINT32 Interrupts[1]; + UINT32 ResourceSourceIndex; + UINT32 ResourceSourceStringLength; + NATIVE_CHAR ResourceSource[1]; + +} EXTENDED_IRQ_RESOURCE; + +typedef enum +{ + Irq, + Dma, + StartDependentFunctions, + EndDependentFunctions, + Io, + FixedIo, + VendorSpecific, + EndTag, + Memory24, + Memory32, + FixedMemory32, + Address16, + Address32, + ExtendedIrq +} RESOURCE_TYPE; + +typedef union +{ + IRQ_RESOURCE Irq; + DMA_RESOURCE Dma; + START_DEPENDENT_FUNCTIONS_RESOURCE StartDependentFunctions; + IO_RESOURCE Io; + FIXED_IO_RESOURCE FixedIo; + VENDOR_RESOURCE VendorSpecific; + MEMORY24_RESOURCE Memory24; + MEMORY32_RESOURCE Memory32; + FIXED_MEMORY32_RESOURCE FixedMemory32; + ADDRESS16_RESOURCE Address16; + ADDRESS32_RESOURCE Address32; + EXTENDED_IRQ_RESOURCE ExtendedIrq; +} RESOURCE_DATA; + +typedef struct _resource_tag +{ + RESOURCE_TYPE Id; + UINT32 Length; + RESOURCE_DATA Data; +} RESOURCE; + +#define RESOURCE_LENGTH 12 +#define RESOURCE_LENGTH_NO_DATA 8 + +#define NEXT_RESOURCE(Res) (RESOURCE*)((UINT8*) Res + Res->length) + +/* + * END: Definitions for Resource Attributes + */ + +/* + * Definitions for PCI Routing tables + */ +typedef struct +{ + ACPI_INTEGER Address; + UINT32 Pin; + UINT32 SourceIndex; + NATIVE_CHAR Source[1]; + +} PRT_ENTRY; + +typedef struct _prt_tag +{ + UINT32 Length; + PRT_ENTRY Data; + +} PCI_ROUTING_TABLE; + + +/* + * END: Definitions for PCI Routing tables + */ + +#endif /* __ACTYPES_H__ */ diff --git a/sys/contrib/dev/acpica/acutils.h b/sys/contrib/dev/acpica/acutils.h new file mode 100644 index 0000000..e2e1218 --- /dev/null +++ b/sys/contrib/dev/acpica/acutils.h @@ -0,0 +1,757 @@ +/****************************************************************************** + * + * Name: accommon.h -- prototypes for the common (subsystem-wide) procedures + * $Revision: 80 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACCOMMON_H +#define _ACCOMMON_H + + +#define REF_INCREMENT (UINT16) 0 +#define REF_DECREMENT (UINT16) 1 +#define REF_FORCE_DELETE (UINT16) 2 + +/* AcpiCmDumpBuffer */ + +#define DB_BYTE_DISPLAY 1 +#define DB_WORD_DISPLAY 2 +#define DB_DWORD_DISPLAY 4 +#define DB_QWORD_DISPLAY 8 + + +/* Global initialization interfaces */ + +void +AcpiCmInitGlobals ( + void); + +void +AcpiCmTerminate ( + void); + + +/* + * CmInit - miscellaneous initialization and shutdown + */ + +ACPI_STATUS +AcpiCmHardwareInitialize ( + void); + +ACPI_STATUS +AcpiCmSubsystemShutdown ( + void); + +ACPI_STATUS +AcpiCmValidateFacp ( + void); + +/* + * CmGlobal - Global data structures and procedures + */ + +NATIVE_CHAR * +AcpiCmGetMutexName ( + UINT32 MutexId); + +NATIVE_CHAR * +AcpiCmGetTypeName ( + UINT32 Type); + +BOOLEAN +AcpiCmValidObjectType ( + UINT32 Type); + +ACPI_OWNER_ID +AcpiCmAllocateOwnerId ( + UINT32 IdType); + + +/* + * CmClib - Local implementations of C library functions + */ + +NATIVE_UINT +AcpiCmStrlen ( + const NATIVE_CHAR *String); + +NATIVE_CHAR * +AcpiCmStrcpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString); + +NATIVE_CHAR * +AcpiCmStrncpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count); + +UINT32 +AcpiCmStrncmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2, + NATIVE_UINT Count); + +UINT32 +AcpiCmStrcmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2); + +NATIVE_CHAR * +AcpiCmStrcat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString); + +NATIVE_CHAR * +AcpiCmStrncat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count); + +UINT32 +AcpiCmStrtoul ( + const NATIVE_CHAR *String, + NATIVE_CHAR **Terminator, + UINT32 Base); + +NATIVE_CHAR * +AcpiCmStrstr ( + NATIVE_CHAR *String1, + NATIVE_CHAR *String2); + +NATIVE_CHAR * +AcpiCmStrupr ( + NATIVE_CHAR *SrcString); + +void * +AcpiCmMemcpy ( + void *Dest, + const void *Src, + NATIVE_UINT Count); + +void * +AcpiCmMemset ( + void *Dest, + UINT32 Value, + NATIVE_UINT Count); + +UINT32 +AcpiCmToUpper ( + UINT32 c); + +UINT32 +AcpiCmToLower ( + UINT32 c); + + +/* + * CmCopy - Object construction and conversion interfaces + */ + +ACPI_STATUS +AcpiCmBuildSimpleObject( + ACPI_OPERAND_OBJECT *Obj, + ACPI_OBJECT *UserObj, + UINT8 *DataSpace, + UINT32 *BufferSpaceUsed); + +ACPI_STATUS +AcpiCmBuildPackageObject ( + ACPI_OPERAND_OBJECT *Obj, + UINT8 *Buffer, + UINT32 *SpaceUsed); + +ACPI_STATUS +AcpiCmBuildExternalObject ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiCmBuildInternalSimpleObject( + ACPI_OBJECT *UserObj, + ACPI_OPERAND_OBJECT *Obj); + +ACPI_STATUS +AcpiCmBuildInternalObject ( + ACPI_OBJECT *Obj, + ACPI_OPERAND_OBJECT *InternalObj); + +ACPI_STATUS +AcpiCmCopyInternalSimpleObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj); + +ACPI_STATUS +AcpiCmBuildCopyInternalPackageObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj); + + +/* + * CmCreate - Object creation + */ + +ACPI_STATUS +AcpiCmUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + +ACPI_OPERAND_OBJECT * +_CmCreateInternalObject ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + OBJECT_TYPE_INTERNAL Type); + + +/* + * CmDebug - Debug interfaces + */ + +UINT32 +GetDebugLevel ( + void); + +void +SetDebugLevel ( + UINT32 level); + +void +FunctionTrace ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName); + +void +FunctionTracePtr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + void *Pointer); + +void +FunctionTraceU32 ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT32 Integer); + +void +FunctionTraceStr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_CHAR *String); + +void +FunctionExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName); + +void +FunctionStatusExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + ACPI_STATUS Status); + +void +FunctionValueExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_UINT Value); + +void +FunctionPtrExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT8 *Ptr); + +void +DebugPrintPrefix ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber); + +void +DebugPrint ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + UINT32 PrintLevel, + NATIVE_CHAR *Format, ...); + +void +DebugPrintRaw ( + NATIVE_CHAR *Format, ...); + +void +_ReportInfo ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +void +_ReportError ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +void +_ReportWarning ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +void +AcpiCmDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 componentId); + + +/* + * CmDelete - Object deletion + */ + +void +AcpiCmDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiCmDeleteInternalPackageObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiCmDeleteInternalSimpleObject ( + ACPI_OPERAND_OBJECT *Object); + +ACPI_STATUS +AcpiCmDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList); + + +/* + * CmEval - object evaluation + */ + +/* Method name strings */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" + + +ACPI_STATUS +AcpiCmEvaluateNumericObject ( + NATIVE_CHAR *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Address); + +ACPI_STATUS +AcpiCmExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Hid); + +ACPI_STATUS +AcpiCmExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *StatusFlags); + +ACPI_STATUS +AcpiCmExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Uid); + + +/* + * CmError - exception interfaces + */ + +NATIVE_CHAR * +AcpiCmFormatException ( + ACPI_STATUS Status); + + +/* + * CmMutex - mutual exclusion interfaces + */ + +ACPI_STATUS +AcpiCmMutexInitialize ( + void); + +void +AcpiCmMutexTerminate ( + void); + +ACPI_STATUS +AcpiCmCreateMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiCmDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiCmAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiCmReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/* + * CmObject - internal object create/delete/cache routines + */ + +void * +_CmAllocateObjectDesc ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +#define AcpiCmCreateInternalObject(t) _CmCreateInternalObject(_THIS_MODULE,__LINE__,_COMPONENT,t) +#define AcpiCmAllocateObjectDesc() _CmAllocateObjectDesc(_THIS_MODULE,__LINE__,_COMPONENT) + +void +AcpiCmDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object); + +BOOLEAN +AcpiCmValidInternalObject ( + void *Object); + + +/* + * CmRefCnt - Object reference count management + */ + +void +AcpiCmAddReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiCmRemoveReference ( + ACPI_OPERAND_OBJECT *Object); + +/* + * CmSize - Object size routines + */ + +ACPI_STATUS +AcpiCmGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + UINT32 *ObjLength); + +ACPI_STATUS +AcpiCmGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + UINT32 *ObjLength); + +ACPI_STATUS +AcpiCmGetObjectSize( + ACPI_OPERAND_OBJECT *Obj, + UINT32 *ObjLength); + + +/* + * CmState - Generic state creation/cache routines + */ + +void +AcpiCmPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State); + +ACPI_GENERIC_STATE * +AcpiCmPopGenericState ( + ACPI_GENERIC_STATE **ListHead); + + +ACPI_GENERIC_STATE * +AcpiCmCreateGenericState ( + void); + +ACPI_GENERIC_STATE * +AcpiCmCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + +ACPI_STATUS +AcpiCmCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList); + +ACPI_GENERIC_STATE * +AcpiCmCreateControlState ( + void); + +void +AcpiCmDeleteGenericState ( + ACPI_GENERIC_STATE *State); + +void +AcpiCmDeleteGenericStateCache ( + void); + +void +AcpiCmDeleteObjectCache ( + void); + +/* + * Cmutils + */ + +BOOLEAN +AcpiCmValidAcpiName ( + UINT32 Name); + +BOOLEAN +AcpiCmValidAcpiCharacter ( + NATIVE_CHAR Character); + +ACPI_STATUS +AcpiCmResolvePackageReferences ( + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * Memory allocation functions and related macros. + * Macros that expand to include filename and line number + */ + +void * +_CmAllocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line); + +void * +_CmCallocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line); + +void +_CmFree ( + void *Address, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line); + +void +AcpiCmInitStaticObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +#define AcpiCmAllocate(a) _CmAllocate(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define AcpiCmCallocate(a) _CmCallocate(a, _COMPONENT,_THIS_MODULE,__LINE__) +#define AcpiCmFree(a) _CmFree(a,_COMPONENT,_THIS_MODULE,__LINE__) + +#ifndef ACPI_DEBUG + +#define AcpiCmAddElementToAllocList(a,b,c,d,e,f) +#define AcpiCmDeleteElementFromAllocList(a,b,c,d) +#define AcpiCmDumpCurrentAllocations(a,b) +#define AcpiCmDumpAllocationInfo() + +#define DECREMENT_OBJECT_METRICS(a) +#define INCREMENT_OBJECT_METRICS(a) +#define INITIALIZE_ALLOCATION_METRICS() +#define DECREMENT_NAME_TABLE_METRICS(a) +#define INCREMENT_NAME_TABLE_METRICS(a) + +#else + +#define INITIALIZE_ALLOCATION_METRICS() \ + AcpiGbl_CurrentObjectCount = 0; \ + AcpiGbl_CurrentObjectSize = 0; \ + AcpiGbl_RunningObjectCount = 0; \ + AcpiGbl_RunningObjectSize = 0; \ + AcpiGbl_MaxConcurrentObjectCount = 0; \ + AcpiGbl_MaxConcurrentObjectSize = 0; \ + AcpiGbl_CurrentAllocSize = 0; \ + AcpiGbl_CurrentAllocCount = 0; \ + AcpiGbl_RunningAllocSize = 0; \ + AcpiGbl_RunningAllocCount = 0; \ + AcpiGbl_MaxConcurrentAllocSize = 0; \ + AcpiGbl_MaxConcurrentAllocCount = 0; \ + AcpiGbl_CurrentNodeCount = 0; \ + AcpiGbl_CurrentNodeSize = 0; \ + AcpiGbl_MaxConcurrentNodeCount = 0 + + +#define DECREMENT_OBJECT_METRICS(a) \ + AcpiGbl_CurrentObjectCount--; \ + AcpiGbl_CurrentObjectSize -= a + +#define INCREMENT_OBJECT_METRICS(a) \ + AcpiGbl_CurrentObjectCount++; \ + AcpiGbl_RunningObjectCount++; \ + if (AcpiGbl_MaxConcurrentObjectCount < AcpiGbl_CurrentObjectCount) \ + { \ + AcpiGbl_MaxConcurrentObjectCount = AcpiGbl_CurrentObjectCount; \ + } \ + AcpiGbl_RunningObjectSize += a; \ + AcpiGbl_CurrentObjectSize += a; \ + if (AcpiGbl_MaxConcurrentObjectSize < AcpiGbl_CurrentObjectSize) \ + { \ + AcpiGbl_MaxConcurrentObjectSize = AcpiGbl_CurrentObjectSize; \ + } + +#define DECREMENT_NAME_TABLE_METRICS(a) \ + AcpiGbl_CurrentNodeCount--; \ + AcpiGbl_CurrentNodeSize -= (a) + +#define INCREMENT_NAME_TABLE_METRICS(a) \ + AcpiGbl_CurrentNodeCount++; \ + AcpiGbl_CurrentNodeSize+= (a); \ + if (AcpiGbl_MaxConcurrentNodeCount < AcpiGbl_CurrentNodeCount) \ + { \ + AcpiGbl_MaxConcurrentNodeCount = AcpiGbl_CurrentNodeCount; \ + } \ + + +void +AcpiCmDumpAllocationInfo ( + void); + +void +AcpiCmDumpCurrentAllocations ( + UINT32 Component, + NATIVE_CHAR *Module); + +#endif + + +#endif /* _ACCOMMON_H */ diff --git a/sys/contrib/dev/acpica/amlcode.h b/sys/contrib/dev/acpica/amlcode.h new file mode 100644 index 0000000..7a3674c --- /dev/null +++ b/sys/contrib/dev/acpica/amlcode.h @@ -0,0 +1,553 @@ +/****************************************************************************** + * + * Name: amlcode.h - Definitions for AML, as included in "definition blocks" + * Declarations and definitions contained herein are derived + * directly from the ACPI specification. + * $Revision: 40 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __AMLCODE_H__ +#define __AMLCODE_H__ + + +/* primary opcodes */ + +#define AML_NULL_CHAR (UINT16) 0x00 + +#define AML_ZERO_OP (UINT16) 0x00 +#define AML_ONE_OP (UINT16) 0x01 +#define AML_UNASSIGNED (UINT16) 0x02 +#define AML_ALIAS_OP (UINT16) 0x06 +#define AML_NAME_OP (UINT16) 0x08 +#define AML_BYTE_OP (UINT16) 0x0a +#define AML_WORD_OP (UINT16) 0x0b +#define AML_DWORD_OP (UINT16) 0x0c +#define AML_STRING_OP (UINT16) 0x0d +#define AML_QWORD_OP (UINT16) 0x0e /* ACPI 2.0 */ +#define AML_SCOPE_OP (UINT16) 0x10 +#define AML_BUFFER_OP (UINT16) 0x11 +#define AML_PACKAGE_OP (UINT16) 0x12 +#define AML_VAR_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */ +#define AML_METHOD_OP (UINT16) 0x14 +#define AML_DUAL_NAME_PREFIX (UINT16) 0x2e +#define AML_MULTI_NAME_PREFIX_OP (UINT16) 0x2f +#define AML_NAME_CHAR_SUBSEQ (UINT16) 0x30 +#define AML_NAME_CHAR_FIRST (UINT16) 0x41 +#define AML_OP_PREFIX (UINT16) 0x5b +#define AML_ROOT_PREFIX (UINT16) 0x5c +#define AML_PARENT_PREFIX (UINT16) 0x5e +#define AML_LOCAL_OP (UINT16) 0x60 +#define AML_LOCAL0 (UINT16) 0x60 +#define AML_LOCAL1 (UINT16) 0x61 +#define AML_LOCAL2 (UINT16) 0x62 +#define AML_LOCAL3 (UINT16) 0x63 +#define AML_LOCAL4 (UINT16) 0x64 +#define AML_LOCAL5 (UINT16) 0x65 +#define AML_LOCAL6 (UINT16) 0x66 +#define AML_LOCAL7 (UINT16) 0x67 +#define AML_ARG_OP (UINT16) 0x68 +#define AML_ARG0 (UINT16) 0x68 +#define AML_ARG1 (UINT16) 0x69 +#define AML_ARG2 (UINT16) 0x6a +#define AML_ARG3 (UINT16) 0x6b +#define AML_ARG4 (UINT16) 0x6c +#define AML_ARG5 (UINT16) 0x6d +#define AML_ARG6 (UINT16) 0x6e +#define AML_STORE_OP (UINT16) 0x70 +#define AML_REF_OF_OP (UINT16) 0x71 +#define AML_ADD_OP (UINT16) 0x72 +#define AML_CONCAT_OP (UINT16) 0x73 +#define AML_SUBTRACT_OP (UINT16) 0x74 +#define AML_INCREMENT_OP (UINT16) 0x75 +#define AML_DECREMENT_OP (UINT16) 0x76 +#define AML_MULTIPLY_OP (UINT16) 0x77 +#define AML_DIVIDE_OP (UINT16) 0x78 +#define AML_SHIFT_LEFT_OP (UINT16) 0x79 +#define AML_SHIFT_RIGHT_OP (UINT16) 0x7a +#define AML_BIT_AND_OP (UINT16) 0x7b +#define AML_BIT_NAND_OP (UINT16) 0x7c +#define AML_BIT_OR_OP (UINT16) 0x7d +#define AML_BIT_NOR_OP (UINT16) 0x7e +#define AML_BIT_XOR_OP (UINT16) 0x7f +#define AML_BIT_NOT_OP (UINT16) 0x80 +#define AML_FIND_SET_LEFT_BIT_OP (UINT16) 0x81 +#define AML_FIND_SET_RIGHT_BIT_OP (UINT16) 0x82 +#define AML_DEREF_OF_OP (UINT16) 0x83 +#define AML_CONCAT_RES_OP (UINT16) 0x84 /* ACPI 2.0 */ +#define AML_MOD_OP (UINT16) 0x85 /* ACPI 2.0 */ +#define AML_NOTIFY_OP (UINT16) 0x86 +#define AML_SIZE_OF_OP (UINT16) 0x87 +#define AML_INDEX_OP (UINT16) 0x88 +#define AML_MATCH_OP (UINT16) 0x89 +#define AML_DWORD_FIELD_OP (UINT16) 0x8a +#define AML_WORD_FIELD_OP (UINT16) 0x8b +#define AML_BYTE_FIELD_OP (UINT16) 0x8c +#define AML_BIT_FIELD_OP (UINT16) 0x8d +#define AML_TYPE_OP (UINT16) 0x8e +#define AML_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */ +#define AML_LAND_OP (UINT16) 0x90 +#define AML_LOR_OP (UINT16) 0x91 +#define AML_LNOT_OP (UINT16) 0x92 +#define AML_LEQUAL_OP (UINT16) 0x93 +#define AML_LGREATER_OP (UINT16) 0x94 +#define AML_LLESS_OP (UINT16) 0x95 +#define AML_BUFF_OP (UINT16) 0x96 /* ACPI 2.0 */ +#define AML_DEC_STR_OP (UINT16) 0x97 /* ACPI 2.0 */ +#define AML_HEX_STR_OP (UINT16) 0x98 /* ACPI 2.0 */ +#define AML_INT_OP (UINT16) 0x99 /* ACPI 2.0 */ +#define AML_COPY_OP (UINT16) 0x9d /* ACPI 2.0 */ +#define AML_MID_OP (UINT16) 0x9e /* ACPI 2.0 */ +#define AML_CONTINUE_OP (UINT16) 0x9f /* ACPI 2.0 */ +#define AML_IF_OP (UINT16) 0xa0 +#define AML_ELSE_OP (UINT16) 0xa1 +#define AML_WHILE_OP (UINT16) 0xa2 +#define AML_NOOP_OP (UINT16) 0xa3 +#define AML_RETURN_OP (UINT16) 0xa4 +#define AML_BREAK_OP (UINT16) 0xa5 +#define AML_BREAK_POINT_OP (UINT16) 0xcc +#define AML_ONES_OP (UINT16) 0xff + +/* prefixed opcodes */ + +#define AML_EXTOP (UINT16) 0x005b + + +#define AML_MUTEX_OP (UINT16) 0x5b01 +#define AML_EVENT_OP (UINT16) 0x5b02 +#define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10 +#define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11 +#define AML_COND_REF_OF_OP (UINT16) 0x5b12 +#define AML_CREATE_FIELD_OP (UINT16) 0x5b13 +#define AML_LOAD_TABLE_OP (UINT16) 0x5b1f /* ACPI 2.0 */ +#define AML_LOAD_OP (UINT16) 0x5b20 +#define AML_STALL_OP (UINT16) 0x5b21 +#define AML_SLEEP_OP (UINT16) 0x5b22 +#define AML_ACQUIRE_OP (UINT16) 0x5b23 +#define AML_SIGNAL_OP (UINT16) 0x5b24 +#define AML_WAIT_OP (UINT16) 0x5b25 +#define AML_RESET_OP (UINT16) 0x5b26 +#define AML_RELEASE_OP (UINT16) 0x5b27 +#define AML_FROM_BCD_OP (UINT16) 0x5b28 +#define AML_TO_BCD_OP (UINT16) 0x5b29 +#define AML_UNLOAD_OP (UINT16) 0x5b2a +#define AML_REVISION_OP (UINT16) 0x5b30 +#define AML_DEBUG_OP (UINT16) 0x5b31 +#define AML_FATAL_OP (UINT16) 0x5b32 +#define AML_REGION_OP (UINT16) 0x5b80 +#define AML_DEF_FIELD_OP (UINT16) 0x5b81 +#define AML_DEVICE_OP (UINT16) 0x5b82 +#define AML_PROCESSOR_OP (UINT16) 0x5b83 +#define AML_POWER_RES_OP (UINT16) 0x5b84 +#define AML_THERMAL_ZONE_OP (UINT16) 0x5b85 +#define AML_INDEX_FIELD_OP (UINT16) 0x5b86 +#define AML_BANK_FIELD_OP (UINT16) 0x5b87 +#define AML_DATA_REGION_OP (UINT16) 0x5b88 /* ACPI 2.0 */ + + +/* Bogus opcodes (they are actually two separate opcodes) */ + +#define AML_LGREATEREQUAL_OP (UINT16) 0x9295 +#define AML_LLESSEQUAL_OP (UINT16) 0x9294 +#define AML_LNOTEQUAL_OP (UINT16) 0x9293 + + +/* + * Internal opcodes + * Use only "Unknown" AML opcodes, don't attempt to use + * any valid ACPI ASCII values (A-Z, 0-9, '-') + */ + +#define AML_NAMEPATH_OP (UINT16) 0x002d +#define AML_NAMEDFIELD_OP (UINT16) 0x0030 +#define AML_RESERVEDFIELD_OP (UINT16) 0x0031 +#define AML_ACCESSFIELD_OP (UINT16) 0x0032 +#define AML_BYTELIST_OP (UINT16) 0x0033 +#define AML_STATICSTRING_OP (UINT16) 0x0034 +#define AML_METHODCALL_OP (UINT16) 0x0035 +#define AML_RETURN_VALUE_OP (UINT16) 0x0036 + + +#define ARG_NONE 0x0 + +/* + * Argument types for the AML Parser + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + */ + +#define ARGP_BYTEDATA 0x01 +#define ARGP_BYTELIST 0x02 +#define ARGP_CHARLIST 0x03 +#define ARGP_DATAOBJ 0x04 +#define ARGP_DATAOBJLIST 0x05 +#define ARGP_DWORDDATA 0x06 +#define ARGP_FIELDLIST 0x07 +#define ARGP_NAME 0x08 +#define ARGP_NAMESTRING 0x09 +#define ARGP_OBJLIST 0x0A +#define ARGP_PKGLENGTH 0x0B +#define ARGP_SUPERNAME 0x0C +#define ARGP_TARGET 0x0D +#define ARGP_TERMARG 0x0E +#define ARGP_TERMLIST 0x0F +#define ARGP_WORDDATA 0x10 + +/* + * Resolved argument types for the AML Interpreter + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + */ + +#define ARGI_ANYTYPE 0x01 +#define ARGI_TARGETREF 0x02 +#define ARGI_REFERENCE 0x03 +#define ARGI_IF 0x04 +#define ARGI_NUMBER 0x05 +#define ARGI_STRING 0x06 +#define ARGI_BUFFER 0x07 +#define ARGI_PACKAGE 0x08 +#define ARGI_DATAOBJECT 0x09 /* Buffer, string, package or reference to a Node - Used only by SizeOf operator*/ +#define ARGI_COMPLEXOBJ 0x0A /* Buffer or package */ +#define ARGI_MUTEX 0x0B +#define ARGI_EVENT 0x0C +#define ARGI_REGION 0x0D +#define ARGI_DDBHANDLE 0x0E + +#define ARGI_INVALID_OPCODE 0xFFFFFFFF + + +/* + * hash offsets + */ +#define AML_EXTOP_HASH_OFFSET 22 +#define AML_LNOT_HASH_OFFSET 19 + + +/* + * opcode groups and types + */ + +#define OPGRP_NAMED 0x01 +#define OPGRP_FIELD 0x02 +#define OPGRP_BYTELIST 0x04 + +#define OPTYPE_UNDEFINED 0 + + +#define OPTYPE_LITERAL 1 +#define OPTYPE_CONSTANT 2 +#define OPTYPE_METHOD_ARGUMENT 3 +#define OPTYPE_LOCAL_VARIABLE 4 +#define OPTYPE_DATA_TERM 5 + +/* Type 1 opcodes */ + +#define OPTYPE_MONADIC1 6 +#define OPTYPE_DYADIC1 7 + + +/* Type 2 opcodes */ + +#define OPTYPE_MONADIC2 8 +#define OPTYPE_MONADIC2R 9 +#define OPTYPE_DYADIC2 10 +#define OPTYPE_DYADIC2R 11 +#define OPTYPE_DYADIC2S 12 +#define OPTYPE_INDEX 13 +#define OPTYPE_MATCH 14 + +/* Generic for an op that returns a value */ + +#define OPTYPE_METHOD_CALL 15 + + +/* Misc */ + +#define OPTYPE_CREATE_FIELD 16 +#define OPTYPE_FATAL 17 +#define OPTYPE_CONTROL 18 +#define OPTYPE_RECONFIGURATION 19 +#define OPTYPE_NAMED_OBJECT 20 +#define OPTYPE_RETURN 21 + +#define OPTYPE_BOGUS 22 + + +/* Predefined Operation Region SpaceIDs */ + +typedef enum +{ + REGION_MEMORY = 0, + REGION_IO, + REGION_PCI_CONFIG, + REGION_EC, + REGION_SMBUS, + REGION_CMOS, + REGION_PCI_BAR + +} AML_REGION_TYPES; + + +/* Comparison operation codes for MatchOp operator */ + +typedef enum +{ + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5 + +} AML_MATCH_OPERATOR; + +#define MAX_MATCH_OPERATOR 5 + + +/* Field Access Types */ + +#define ACCESS_TYPE_MASK 0x0f +#define ACCESS_TYPE_SHIFT 0 + +typedef enum +{ + ACCESS_ANY_ACC = 0, + ACCESS_BYTE_ACC = 1, + ACCESS_WORD_ACC = 2, + ACCESS_DWORD_ACC = 3, + ACCESS_BLOCK_ACC = 4, + ACCESS_SMBSEND_RECV_ACC = 5, + ACCESS_SMBQUICK_ACC = 6 + +} AML_ACCESS_TYPE; + + +/* Field Lock Rules */ + +#define LOCK_RULE_MASK 0x10 +#define LOCK_RULE_SHIFT 4 + +typedef enum +{ + GLOCK_NEVER_LOCK = 0, + GLOCK_ALWAYS_LOCK = 1 + +} AML_LOCK_RULE; + + +/* Field Update Rules */ + +#define UPDATE_RULE_MASK 0x060 +#define UPDATE_RULE_SHIFT 5 + +typedef enum +{ + UPDATE_PRESERVE = 0, + UPDATE_WRITE_AS_ONES = 1, + UPDATE_WRITE_AS_ZEROS = 2 + +} AML_UPDATE_RULE; + + +/* bit fields in MethodFlags byte */ + +#define METHOD_FLAGS_ARG_COUNT 0x07 +#define METHOD_FLAGS_SERIALIZED 0x08 + + +/* Array sizes. Used for range checking also */ + +#define NUM_REGION_TYPES 5 +#define NUM_ACCESS_TYPES 7 +#define NUM_UPDATE_RULES 3 +#define NUM_MATCH_OPS 7 +#define NUM_OPCODES 256 +#define NUM_FIELD_NAMES 2 + +/* External declarations of the AML tables */ + +extern UINT8 AcpiGbl_Aml [NUM_OPCODES]; +extern UINT16 AcpiGbl_Pfx [NUM_OPCODES]; +extern NATIVE_CHAR *AcpiGbl_RegionTypes [NUM_REGION_TYPES]; +extern NATIVE_CHAR *AcpiGbl_MatchOps [NUM_MATCH_OPS]; +extern NATIVE_CHAR *AcpiGbl_AccessTypes [NUM_ACCESS_TYPES]; +extern NATIVE_CHAR *AcpiGbl_UpdateRules [NUM_UPDATE_RULES]; +extern NATIVE_CHAR *AcpiGbl_FENames [NUM_FIELD_NAMES]; + + +/* + * AML tables + */ + +#ifdef DEFINE_AML_GLOBALS + +/* Data used in keeping track of fields */ + +NATIVE_CHAR *AcpiGbl_FENames[NUM_FIELD_NAMES] = +{ + "skip", + "?access?" +}; /* FE = Field Element */ + + +/* Region type decoding */ + +NATIVE_CHAR *AcpiGbl_RegionTypes[NUM_REGION_TYPES] = +{ + "SystemMemory", + "SystemIO", + "PCIConfig", + "EmbeddedControl", + "SMBus" +}; + + +NATIVE_CHAR *AcpiGbl_MatchOps[NUM_MATCH_OPS] = +{ + "Error", + "MTR", + "MEQ", + "MLE", + "MLT", + "MGE", + "MGT" +}; + + +/* Access type decoding */ + +NATIVE_CHAR *AcpiGbl_AccessTypes[NUM_ACCESS_TYPES] = +{ + "AnyAcc", + "ByteAcc", + "WordAcc", + "DWordAcc", + "BlockAcc", + "SMBSendRecvAcc", + "SMBQuickAcc" +}; + + +/* Update rule decoding */ + +NATIVE_CHAR *AcpiGbl_UpdateRules[NUM_UPDATE_RULES] = +{ + "Preserve", + "WriteAsOnes", + "WriteAsZeros" +}; + + +#endif /* DEFINE_AML_GLOBALS */ + +#endif /* __AMLCODE_H__ */ diff --git a/sys/contrib/dev/acpica/dbcmds.c b/sys/contrib/dev/acpica/dbcmds.c new file mode 100644 index 0000000..bd357df --- /dev/null +++ b/sys/contrib/dev/acpica/dbcmds.c @@ -0,0 +1,997 @@ +/******************************************************************************* + * + * Module Name: dbcmds - debug commands and output routines + * $Revision: 41 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbcmds") + + +/* + * Arguments for the Objects command + * These object types map directly to the ACPI_TYPES + */ + +ARGUMENT_INFO AcpiDbObjectTypes [] = +{ + {"ANY"}, + {"NUMBERS"}, + {"STRINGS"}, + {"BUFFERS"}, + {"PACKAGES"}, + {"FIELDS"}, + {"DEVICES"}, + {"EVENTS"}, + {"METHODS"}, + {"MUTEXES"}, + {"REGIONS"}, + {"POWERRESOURCES"}, + {"PROCESSORS"}, + {"THERMALZONES"}, + {"BUFFERFIELDS"}, + {"DDBHANDLES"}, + {NULL} /* Must be null terminated */ +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForReferences + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Check if this namespace object refers to the target object + * that is passed in as the context value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkForReferences ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + + + /* Check for match against the namespace node itself */ + + if (Node == (void *) ObjDesc) + { + AcpiOsPrintf ("Object is a Node [%4.4s]\n", &Node->Name); + } + + /* Check for match against the object attached to the node */ + + if (Node->Object == ObjDesc) + { + AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, &Node->Name); + } + + /* Check first child for a match */ + /* TBD: [Investigate] probably now obsolete with new datastructure */ + + if (Node->Child == (void *) ObjDesc) + { + AcpiOsPrintf ("Reference at Node->Child %p [%4.4s]\n", Node, &Node->Name); + } + + 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 ( + NATIVE_CHAR *ObjectArg) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + /* Convert string to object pointer */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); + + /* Search all nodes in namespace */ + + AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForReferences, (void *) ObjDesc, NULL); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *TableArg) +{ + UINT32 i; + + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + if (AcpiGbl_AcpiTables[i].Pointer) + { + AcpiOsPrintf ("%s at 0x%p length 0x%X\n", AcpiGbl_AcpiTableData[i].Name, + AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbUnloadAcpiTable + * + * PARAMETERS: TableArg - Name of the table to be unloaded + * InstanceArg - Which instance of the table to unload (if + * there are multiple tables of the same type) + * + * RETURN: Nonde + * + * DESCRIPTION: Unload an ACPI table. + * Instance is not implemented + * + ******************************************************************************/ + +void +AcpiDbUnloadAcpiTable ( + NATIVE_CHAR *TableArg, + NATIVE_CHAR *InstanceArg) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Search all tables for the target type */ + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + if (!STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature, AcpiGbl_AcpiTableData[i].SigLength)) + { + /* Found the table, unload it */ + + Status = AcpiUnloadTable (i); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); + } + else + { + AcpiOsPrintf ("%s, while unloading [%s]\n", AcpiCmFormatException (Status), TableArg); + } + + return; + } + } + + AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodBreakpoint + * + * PARAMETERS: Location - AML offset of breakpoint + * WalkState - Current walk info + * Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Set a breakpoint in a control method at the specified + * AML offset + * + ******************************************************************************/ + +void +AcpiDbSetMethodBreakpoint ( + NATIVE_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 = STRTOUL (Location, NULL, 16); + if (Address <= Op->AmlOffset) + { + AcpiOsPrintf ("Breakpoint 0x%X is beyond current address 0x%X\n", Address, Op->AmlOffset); + } + + /* Save breakpoint in current walk */ + + WalkState->MethodBreakpoint = Address; + AcpiOsPrintf ("Breakpoint set at AML offset 0x%X\n", Address); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodCallBreakpoint + * + * PARAMETERS: Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Set a breakpoint in a control method at the specified + * AML offset + * + ******************************************************************************/ + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op) +{ + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + + AcpiGbl_StepToNextCall = TRUE; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisassembleAml + * + * PARAMETERS: Statements - Number of statements to disassemble + * Op - Current Op (from parse walk) + * + * RETURN: None + * + * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number + * of statements specified. + * + ******************************************************************************/ + +void +AcpiDbDisassembleAml ( + NATIVE_CHAR *Statements, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 NumStatements = 8; + + + if (!Op) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + if (Statements) + { + NumStatements = STRTOUL (Statements, NULL, 0); + } + + + AcpiDbDisplayOp (NULL, Op, NumStatements); +} + + +/******************************************************************************* + * + * 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 ( + NATIVE_CHAR *StartArg, + NATIVE_CHAR *DepthArg) +{ + ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; + UINT32 MaxDepth = ACPI_UINT32_MAX; + + + /* No argument given, just start at the root and dump entire namespace */ + + if (StartArg) + { + /* Check if numeric argument, must be a Node */ + + if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) + { + SubtreeEntry = (ACPI_HANDLE) STRTOUL (StartArg, NULL, 16); + if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); + return; + } + + if (!VALID_DESCRIPTOR_TYPE ((SubtreeEntry), ACPI_DESC_TYPE_NAMED)) + { + AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry); + return; + } + } + + /* Alpha argument */ + + else + { + /* The parameter is a name string that must be resolved to a Named obj*/ + + SubtreeEntry = AcpiDbLocalNsLookup (StartArg); + if (!SubtreeEntry) + { + SubtreeEntry = AcpiGbl_RootNode; + } + } + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = STRTOUL (DepthArg, NULL, 0); + } + } + + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); + AcpiDbSetOutputDestination (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 ( + NATIVE_CHAR *OwnerArg, + NATIVE_CHAR *DepthArg) +{ + ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; + UINT32 MaxDepth = ACPI_UINT32_MAX; + UINT16 OwnerId; + + + OwnerId = (UINT16) STRTOUL (OwnerArg, NULL, 0); + + + /* Now we can check for the depth argument */ + + if (DepthArg) + { + MaxDepth = STRTOUL (DepthArg, NULL, 0); + } + + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("ACPI Namespace by owner 0x%X:\n", OwnerId); + + /* Display the subtree */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, OwnerId, SubtreeEntry); + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSendNotify + * + * PARAMETERS: Name - Name of ACPI object to send the notify to + * Value - Value of the notify to send. + * + * RETURN: None + * + * DESCRIPTION: Send an ACPI notification. The value specified is sent to the + * named object as an ACPI notify. + * + ******************************************************************************/ + +void +AcpiDbSendNotify ( + NATIVE_CHAR *Name, + UINT32 Value) +{ + ACPI_NAMESPACE_NODE *Node; + + + /* Translate name to an Named object */ + + Node = AcpiDbLocalNsLookup (Name); + if (!Node) + { + return; + } + + /* Decode Named object type */ + + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + /* Send the notify */ + + AcpiEvNotifyDispatch (Node, Value); + break; + + default: + AcpiOsPrintf ("Named object is not a device or a thermal object\n"); + break; + } + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetMethodData + * + * PARAMETERS: TypeArg - L for local, A for argument + * IndexArg - which one + * ValueArg - Value to set. + * + * RETURN: None + * + * DESCRIPTION: Set a local or argument for the running control method. + * NOTE: only object supported is Number. + * + ******************************************************************************/ + +void +AcpiDbSetMethodData ( + NATIVE_CHAR *TypeArg, + NATIVE_CHAR *IndexArg, + NATIVE_CHAR *ValueArg) +{ + NATIVE_CHAR Type; + UINT32 Index; + UINT32 Value; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + + + /* Validate TypeArg */ + + STRUPR (TypeArg); + Type = TypeArg[0]; + if ((Type != 'L') && + (Type != 'A')) + { + AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); + return; + } + + /* Get the index and value */ + + Index = STRTOUL (IndexArg, NULL, 16); + Value = STRTOUL (ValueArg, NULL, 16); + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + + /* Create and initialize the new object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + AcpiOsPrintf ("Could not create an internal object\n"); + return; + } + + ObjDesc->Number.Value = Value; + + + /* Store the new object into the target */ + + switch (Type) + { + case 'A': + + /* Set a method argument */ + + if (Index > MTH_NUM_ARGS) + { + AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); + return; + } + + AcpiDsMethodDataSetValue (MTH_TYPE_ARG, Index, ObjDesc, WalkState); + ObjDesc = WalkState->Arguments[Index].Object; + + AcpiOsPrintf ("Arg%d: ", Index); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + break; + + case 'L': + + /* Set a method local */ + + if (Index > MTH_NUM_LOCALS) + { + AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); + return; + } + + AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, Index, ObjDesc, WalkState); + ObjDesc = WalkState->LocalVariables[Index].Object; + + AcpiOsPrintf ("Local%d: ", Index); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + break; + + default: + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkForSpecificObjects + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display short info about objects in the namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkForSpecificObjects ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + UINT32 BufSize; + NATIVE_CHAR buffer[64]; + + + ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; + + /* Get and display the full pathname to this object */ + + Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, buffer); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + return (AE_OK); + } + + AcpiOsPrintf ("%32s", buffer); + + + /* Display short information about the object */ + + if (ObjDesc) + { + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_METHOD: + AcpiOsPrintf (" #Args %d Concurrency %d", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); + break; + + case ACPI_TYPE_NUMBER: + AcpiOsPrintf (" Value 0x%X", ObjDesc->Number.Value); + break; + + case ACPI_TYPE_STRING: + AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); + break; + + case ACPI_TYPE_REGION: + AcpiOsPrintf (" SpaceId %d Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length); + break; + + case ACPI_TYPE_PACKAGE: + AcpiOsPrintf (" #Elements %d", ObjDesc->Package.Count); + break; + + case ACPI_TYPE_BUFFER: + AcpiOsPrintf (" Length %d", ObjDesc->Buffer.Length); + break; + } + } + + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayObjects + * + * PARAMETERS: ObjTypeArg - Type of object to display + * DisplayCountArg - Max depth to display + * + * RETURN: None + * + * DESCRIPTION: Display objects in the namespace of the requested type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisplayObjects ( + NATIVE_CHAR *ObjTypeArg, + NATIVE_CHAR *DisplayCountArg) +{ + UINT32 DisplayCount; + OBJECT_TYPE_INTERNAL Type; + + + /* Get the object type */ + + STRUPR (ObjTypeArg); + Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); + if (Type == ACPI_TYPE_NOT_FOUND) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return (AE_OK); + } + + /* Get the display depth */ + + if (DisplayCountArg) + { + DisplayCount = STRTOUL (DisplayCountArg, NULL, 0); + } + + else + { + DisplayCount = ACPI_UINT32_MAX; + } + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiCmGetTypeName (Type)); + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + + /* Walk the namespace from the root */ + + AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbWalkAndMatchName + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Find a particular name/names within the namespace. Wildcards + * are supported -- '?' matches any character. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbWalkAndMatchName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + NATIVE_CHAR *RequestedName = (NATIVE_CHAR *) Context; + UINT32 i; + UINT32 BufSize; + NATIVE_CHAR Buffer[96]; + + + ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; + + + /* Check for a name match */ + + for (i = 0; i < 4; i++) + { + /* Wildcard support */ + + if ((RequestedName[i] != '?') && + (RequestedName[i] != ((NATIVE_CHAR *) (&((ACPI_NAMESPACE_NODE *) ObjHandle)->Name))[i])) + { + /* No match, just exit */ + + return (AE_OK); + } + } + + + /* Get the full pathname to this object */ + + BufSize = sizeof (Buffer); + + Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + } + + else + { + AcpiOsPrintf ("%32s (0x%p) - %s\n", Buffer, ObjHandle, + AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); + } + + 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 ( + NATIVE_CHAR *NameArg) +{ + + if (STRLEN (NameArg) > 4) + { + AcpiOsPrintf ("Name must be no longer than 4 characters\n"); + return (AE_OK); + } + + /* Walk the namespace from the root */ + + AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbWalkAndMatchName, NameArg, NULL); + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetScope + * + * PARAMETERS: Name - New scope path + * + * RETURN: Status + * + * DESCRIPTION: Set the "current scope" as maintained by this utility. + * The scope is used as a prefix to ACPI paths. + * + ******************************************************************************/ + +void +AcpiDbSetScope ( + NATIVE_CHAR *Name) +{ + + if (!Name || Name[0] == 0) + { + AcpiOsPrintf ("Current scope: %s\n", ScopeBuf); + return; + } + + AcpiDbPrepNamestring (Name); + + /* TBD: [Future] Validate scope here */ + + if (Name[0] == '\\') + { + STRCPY (ScopeBuf, Name); + STRCAT (ScopeBuf, "\\"); + } + + else + { + STRCAT (ScopeBuf, Name); + STRCAT (ScopeBuf, "\\"); + } + + AcpiOsPrintf ("New scope: %s\n", ScopeBuf); +} + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbdisasm.c b/sys/contrib/dev/acpica/dbdisasm.c new file mode 100644 index 0000000..4a7b32d --- /dev/null +++ b/sys/contrib/dev/acpica/dbdisasm.c @@ -0,0 +1,822 @@ +/******************************************************************************* + * + * Module Name: dbdisasm - parser op tree display routines + * $Revision: 33 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbdisasm") + + +#define MAX_SHOW_ENTRY 128 +#define BLOCK_PAREN 1 +#define BLOCK_BRACE 2 +#define DB_NO_OP_INFO " [%2.2d] " +#define DB_FULL_OP_INFO "%5.5X #%4.4X [%2.2d] " + + +NATIVE_CHAR *INDENT_STRING = "...."; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbBlockType + * + * PARAMETERS: Op - Object to be examined + * + * RETURN: Status + * + * DESCRIPTION: Type of block for this op (parens or braces) + * + ******************************************************************************/ + +UINT32 +AcpiDbBlockType ( + ACPI_PARSE_OBJECT *Op) +{ + + switch (Op->Opcode) + { + case AML_METHOD_OP: + return (BLOCK_BRACE); + break; + + default: + break; + } + + return (BLOCK_PAREN); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDisplayObjectPathname + * + * PARAMETERS: 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) + * + ******************************************************************************/ + +#ifdef PARSER_ONLY + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *TargetOp; + + + /* Search parent tree up to the root if necessary */ + + TargetOp = AcpiPsFind (Op, Op->Value.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 (" **** Path not found in parse tree"); + } + + else + { + /* The target was found, print the name and complete path */ + + AcpiOsPrintf (" (Path "); + AcpiDbDisplayPath (TargetOp); + AcpiOsPrintf (")"); + } + + return (AE_OK); +} + +#else + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + NATIVE_CHAR Buffer[MAX_SHOW_ENTRY]; + UINT32 BufferSize = MAX_SHOW_ENTRY; + + + AcpiOsPrintf (" (Path "); + + /* Just get the Node out of the Op object */ + + Node = Op->Node; + if (!Node) + { + /* + * No Named obj, so 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. + */ + return (AE_OK); + } + + /* Convert NamedDesc/handle to a full pathname */ + + Status = AcpiNsHandleToPathname (Node, &BufferSize, Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("****Could not get pathname****)"); + return (Status); + } + + AcpiOsPrintf ("%s)", Buffer); + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayOp + * + * PARAMETERS: Origin - Starting object + * NumOpcodes - Max number of opcodes to be displayed + * + * RETURN: None + * + * DESCRIPTION: Display parser object and its children + * + ******************************************************************************/ + +void +AcpiDbDisplayOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes) +{ + ACPI_PARSE_OBJECT *Op = Origin; + ACPI_PARSE_OBJECT *arg; + ACPI_PARSE_OBJECT *depth; + UINT32 DepthCount = 0; + UINT32 LastDepth = 0; + UINT32 i; + UINT32 j; + + + if (Op) + { + while (Op) + { + /* indentation */ + + DepthCount = 0; + if (!opt_verbose) + { + DepthCount++; + } + + /* Determine the nesting depth of this argument */ + + for (depth = Op->Parent; depth; depth = depth->Parent) + { + arg = AcpiPsGetArg (depth, 0); + while (arg && arg != Origin) + { + arg = arg->Next; + } + + if (arg) + { + break; + } + + DepthCount++; + } + + + /* Open a new block if we are nested further than last time */ + + if (DepthCount > LastDepth) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth)); + for (i = 0; i < LastDepth; i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + if (AcpiDbBlockType (Op) == BLOCK_PAREN) + AcpiOsPrintf ("(\n"); + else + AcpiOsPrintf ("{\n"); + } + + /* Close a block if we are nested less than last time */ + + else if (DepthCount < LastDepth) + { + for (j = 0; j < (LastDepth - DepthCount); j++) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth - j)); + for (i = 0; i < (LastDepth - j - 1); i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + if (AcpiDbBlockType (Op) == BLOCK_PAREN) + AcpiOsPrintf (")\n"); + else + AcpiOsPrintf ("}\n"); + } + } + + /* In verbose mode, print the AML offset, opcode and depth count */ + + VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) Op->AmlOffset, Op->Opcode, DepthCount)); + + + /* Indent the output according to the depth count */ + + for (i = 0; i < DepthCount; i++) + { + AcpiOsPrintf (INDENT_STRING); + } + + + /* Now print the opcode */ + + AcpiDbDisplayOpcode (WalkState, Op); + + /* Resolve a name reference */ + + if ((Op->Opcode == AML_NAMEPATH_OP && Op->Value.Name) && + (Op->Parent) && + (opt_verbose)) + { + AcpiPsDisplayObjectPathname (Op); + } + + AcpiOsPrintf ("\n"); + + /* Get the next node in the tree */ + + Op = AcpiPsGetDepthNext (Origin, Op); + LastDepth = DepthCount; + + NumOpcodes--; + if (!NumOpcodes) + { + Op = NULL; + } + } + + /* Close the last block(s) */ + + DepthCount = LastDepth -1; + for (i = 0; i < LastDepth; i++) + { + VERBOSE_PRINT ((DB_NO_OP_INFO, LastDepth - i)); + for (j = 0; j < DepthCount; j++) + { + AcpiOsPrintf (INDENT_STRING); + } + AcpiOsPrintf ("}\n"); + DepthCount--; + } + + } + + else + { + AcpiDbDisplayOpcode (WalkState, Op); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayNamestring + * + * PARAMETERS: Name - ACPI Name string to store + * + * RETURN: None + * + * DESCRIPTION: Display namestring. Handles prefix characters + * + ******************************************************************************/ + +void +AcpiDbDisplayNamestring ( + NATIVE_CHAR *Name) +{ + UINT32 SegCount; + BOOLEAN DoDot = FALSE; + + + if (!Name) + { + AcpiOsPrintf (""); + return; + } + + if (AcpiPsIsPrefixChar (GET8 (Name))) + { + /* append prefix character */ + + AcpiOsPrintf ("%1c", GET8 (Name)); + Name++; + } + + switch (GET8 (Name)) + { + case AML_DUAL_NAME_PREFIX: + SegCount = 2; + Name++; + break; + + case AML_MULTI_NAME_PREFIX_OP: + SegCount = (UINT32) GET8 (Name + 1); + Name += 2; + break; + + default: + SegCount = 1; + break; + } + + while (SegCount--) + { + /* append Name segment */ + + if (DoDot) + { + /* append dot */ + + AcpiOsPrintf ("."); + } + + AcpiOsPrintf ("%4.4s", Name); + DoDot = TRUE; + + Name += 4; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayPath + * + * 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 +AcpiDbDisplayPath ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Search; + UINT32 Name; + BOOLEAN DoDot = FALSE; + ACPI_PARSE_OBJECT *NamePath; + + + /* We are only interested in named objects */ + + if (!AcpiPsIsNodeOp (Op->Opcode)) + { + return; + } + + + if (AcpiPsIsCreateFieldOp (Op->Opcode)) + { + /* Field creation - check for a fully qualified namepath */ + + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + NamePath = AcpiPsGetArg (Op, 3); + } + else + { + NamePath = AcpiPsGetArg (Op, 2); + } + + if ((NamePath) && + (NamePath->Value.String) && + (NamePath->Value.String[0] == '\\')) + { + AcpiDbDisplayNamestring (NamePath->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->Parent == Prev) + { + break; + } + + /* Go up one level */ + + Search = Search->Parent; + } + + if (Prev && !AcpiPsIsFieldOp (Search->Opcode)) + { + /* below root scope, append scope name */ + + if (DoDot) + { + /* append dot */ + + AcpiOsPrintf ("."); + } + + if (AcpiPsIsCreateFieldOp (Search->Opcode)) + { + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + NamePath = AcpiPsGetArg (Op, 3); + } + else + { + NamePath = AcpiPsGetArg (Op, 2); + } + + if ((NamePath) && + (NamePath->Value.String)) + { + AcpiOsPrintf ("%4.4s", NamePath->Value.String); + } + } + + else + { + Name = AcpiPsGetName (Search); + AcpiOsPrintf ("%4.4s", &Name); + } + + DoDot = TRUE; + } + + Prev = Search; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayOpcode + * + * PARAMETERS: Op - Op that is to be printed + * + * RETURN: Status + * + * DESCRIPTION: Store printed op in a Buffer and return its length + * (or -1 if out of space) + * + * NOTE: Terse mode prints out ASL-like code. Verbose mode adds more info. + * + ******************************************************************************/ + +void +AcpiDbDisplayOpcode ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + UINT8 *ByteData; + UINT32 ByteCount; + UINT32 i; + ACPI_OPCODE_INFO *Opc = NULL; + UINT32 Name; + + + if (!Op) + { + AcpiOsPrintf (""); + } + + + /* op and arguments */ + + switch (Op->Opcode) + { + + case AML_BYTE_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT8) 0x%2.2X", Op->Value.Integer & ACPI_UINT8_MAX); + } + + else + { + AcpiOsPrintf ("0x%2.2X", Op->Value.Integer & ACPI_UINT8_MAX); + } + + break; + + + case AML_WORD_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT16) 0x%4.4X", Op->Value.Integer & ACPI_UINT16_MAX); + } + + else + { + AcpiOsPrintf ("0x%4.4X", Op->Value.Integer & ACPI_UINT16_MAX); + } + + break; + + + case AML_DWORD_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("(UINT32) 0x%8.8X", Op->Value.Integer); + } + + else + { + AcpiOsPrintf ("0x%8.8X", Op->Value.Integer); + } + + break; + + + case AML_STRING_OP: + + if (Op->Value.String) + { + AcpiOsPrintf ("\"%s\"", Op->Value.String); + } + + else + { + AcpiOsPrintf ("<\"NULL STRING PTR\">"); + } + + break; + + + case AML_STATICSTRING_OP: + + if (Op->Value.String) + { + AcpiOsPrintf ("\"%s\"", Op->Value.String); + } + + else + { + AcpiOsPrintf ("\"\""); + } + + break; + + + case AML_NAMEPATH_OP: + + AcpiDbDisplayNamestring (Op->Value.Name); + break; + + + case AML_NAMEDFIELD_OP: + + AcpiOsPrintf ("NamedField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_RESERVEDFIELD_OP: + + AcpiOsPrintf ("ReservedField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_ACCESSFIELD_OP: + + AcpiOsPrintf ("AccessField (Length 0x%8.8X) ", Op->Value.Integer); + break; + + + case AML_BYTELIST_OP: + + if (opt_verbose) + { + AcpiOsPrintf ("ByteList (Length 0x%8.8X) ", Op->Value.Integer); + } + + else + { + AcpiOsPrintf ("0x%2.2X", Op->Value.Integer); + + ByteCount = Op->Value.Integer; + ByteData = ((ACPI_PARSE2_OBJECT *) Op)->Data; + + for (i = 0; i < ByteCount; i++) + { + AcpiOsPrintf (", 0x%2.2X", ByteData[i]); + } + } + + break; + + + default: + + /* Just get the opcode name and print it */ + + Opc = AcpiPsGetOpcodeInfo (Op->Opcode); + DEBUG_ONLY_MEMBERS ((AcpiOsPrintf ("%s", Opc->Name))); + + +#ifndef PARSER_ONLY + if ((Op->Opcode == AML_RETURN_VALUE_OP) && + (WalkState->NumResults)) + { + AcpiDbDecodeInternalObject (WalkState->Results [WalkState->NumResults-1]); + } +#endif + + break; + } + + + if (!Opc) + { + /* If there is another element in the list, add a comma */ + + if (Op->Next) + { + AcpiOsPrintf (","); + } + } + + + /* + * If this is a named opcode, print the associated name value + */ + + if (Op && AcpiPsIsNamedOp (Op->Opcode)) + { + Name = AcpiPsGetName (Op); + AcpiOsPrintf (" %4.4s", &Name); + + if (opt_verbose) + { + AcpiOsPrintf (" (Path \\"); + AcpiDbDisplayPath (Op); + AcpiOsPrintf (")"); + } + } +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/dbdisply.c b/sys/contrib/dev/acpica/dbdisply.c new file mode 100644 index 0000000..1128e57 --- /dev/null +++ b/sys/contrib/dev/acpica/dbdisply.c @@ -0,0 +1,904 @@ +/******************************************************************************* + * + * Module Name: dbdisply - debug display commands + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbdisply") + + +/****************************************************************************** + * + * FUNCTION: AcpiDbGetPointer + * + * PARAMETERS: Target - Pointer to string to be converted + * + * RETURN: Converted pointer + * + * DESCRIPTION: Convert an ascii pointer value to a real value + * + *****************************************************************************/ + +void * +AcpiDbGetPointer ( + void *Target) +{ + void *ObjPtr; + + +#ifdef _IA16 +#include + + /* Have to handle 16-bit pointers of the form segment:offset */ + + if (!sscanf (Target, "%p", &ObjPtr)) + { + AcpiOsPrintf ("Invalid pointer: %s\n", Target); + return (NULL); + } + +#else + + /* Simple flat pointer */ + + ObjPtr = (void *) STRTOUL (Target, NULL, 16); + +#endif + + return (ObjPtr); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpParserDescriptor + * + * PARAMETERS: Op - A parser Op descriptor + * + * RETURN: None + * + * DESCRIPTION: Display a formatted parser object + * + ******************************************************************************/ + +void +AcpiDbDumpParserDescriptor ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_OPCODE_INFO *Info; + + + Info = AcpiPsGetOpcodeInfo (Op->Opcode); + + AcpiOsPrintf ("Parser Op Descriptor:\n"); + AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Opcode); + + DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name)); + + AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Value); + AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Parent); + AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Next); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeAndDisplayObject + * + * PARAMETERS: Target - String with object to be displayed. Names + * and hex pointers are supported. + * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q) + * + * RETURN: None + * + * DESCRIPTION: Display a formatted ACPI object + * + ******************************************************************************/ + +void +AcpiDbDecodeAndDisplayObject ( + NATIVE_CHAR *Target, + NATIVE_CHAR *OutputType) +{ + void *ObjPtr; + ACPI_NAMESPACE_NODE *Node; + UINT32 Display = DB_BYTE_DISPLAY; + NATIVE_CHAR Buffer[80]; + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + UINT32 Size; + + + if (!Target) + { + return; + } + + /* Decode the output type */ + + if (OutputType) + { + STRUPR (OutputType); + if (OutputType[0] == 'W') + { + Display = DB_WORD_DISPLAY; + } + else if (OutputType[0] == 'D') + { + Display = DB_DWORD_DISPLAY; + } + else if (OutputType[0] == 'Q') + { + Display = DB_QWORD_DISPLAY; + } + } + + + RetBuf.Length = sizeof (Buffer); + RetBuf.Pointer = Buffer; + + /* Differentiate between a number and a name */ + + if ((Target[0] >= 0x30) && (Target[0] <= 0x39)) + { + ObjPtr = AcpiDbGetPointer (Target); + if (!AcpiOsReadable (ObjPtr, 16)) + { + AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr); + return; + } + + /* Decode the object type */ + + if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_NAMED)) + { + /* This is a Node */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr); + return; + } + + Node = ObjPtr; + goto DumpNte; + } + + else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_INTERNAL)) + { + /* This is an ACPI OBJECT */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) + { + AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr); + return; + } + + AcpiCmDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiAmlDumpObjectDescriptor (ObjPtr, 1); + } + + else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_PARSER)) + { + /* This is an Parser Op object */ + + if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) + { + AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr); + return; + } + + + AcpiCmDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX); + AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); + } + + else + { + Size = 16; + if (AcpiOsReadable (ObjPtr, 64)) + { + Size = 64; + } + + /* Just dump some memory */ + + AcpiCmDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); + } + + return; + } + + + /* The parameter is a name string that must be resolved to a Named obj */ + + Node = AcpiDbLocalNsLookup (Target); + if (!Node) + { + return; + } + + +DumpNte: + /* Now dump the Named obj */ + + Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not convert name to pathname\n"); + return; + } + + AcpiOsPrintf ("Object Pathname: %s\n", RetBuf.Pointer); + if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Invalid Named object at address %p\n", Node); + return; + } + + AcpiCmDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX); + AcpiAmlDumpNode (Node, 1); + + if (Node->Object) + { + AcpiOsPrintf ("\nAttached Object (0x%p):\n", Node->Object); + if (!AcpiOsReadable (Node->Object, sizeof (ACPI_OPERAND_OBJECT))) + { + AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", Node->Object); + return; + } + + AcpiCmDumpBuffer (Node->Object, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiAmlDumpObjectDescriptor (Node->Object, 1); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDecodeInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object. Numbers and Strings. + * + ******************************************************************************/ + +void +AcpiDbDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + if (!ObjDesc) + { + return; + } + + AcpiOsPrintf (" %9.9s ", AcpiCmGetTypeName (ObjDesc->Common.Type)); + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + AcpiOsPrintf ("0x%.8X", ObjDesc->Number.Value); + break; + + case ACPI_TYPE_STRING: + AcpiOsPrintf ("\"%.16s\"...", ObjDesc->String.Pointer); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayInternalObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Short display of an internal object + * + ******************************************************************************/ + +void +AcpiDbDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + UINT8 Type; + + + AcpiOsPrintf ("%p ", ObjDesc); + + if (!ObjDesc) + { + AcpiOsPrintf ("\n"); + return; + } + + + /* Decode the object type */ + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_PARSER)) + { + AcpiOsPrintf (" "); + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + AcpiOsPrintf (" Name %4.4s Type %s", &((ACPI_NAMESPACE_NODE *)ObjDesc)->Name, + AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjDesc)->Type)); + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) + { + AcpiOsPrintf (" "); + Type = ObjDesc->Common.Type; + if (Type > INTERNAL_TYPE_MAX) + { + AcpiOsPrintf (" Type %x [Invalid Type]", Type); + return; + } + + /* Decode the ACPI object type */ + + switch (ObjDesc->Common.Type) + { + case INTERNAL_TYPE_REFERENCE: + switch (ObjDesc->Reference.OpCode) + { + case AML_ZERO_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", 0); + break; + + case AML_ONES_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", ACPI_UINT32_MAX); + break; + + case AML_ONE_OP: + AcpiOsPrintf ("[Const] Number 0x%.8X", 1); + break; + + case AML_LOCAL_OP: + AcpiOsPrintf ("[Local%d]", ObjDesc->Reference.Offset); + if (WalkState) + { + ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object; + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case AML_ARG_OP: + AcpiOsPrintf ("[Arg%d] ", ObjDesc->Reference.Offset); + if (WalkState) + { + ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object; + AcpiDbDecodeInternalObject (ObjDesc); + } + break; + + case AML_DEBUG_OP: + AcpiOsPrintf ("[Debug] "); + break; + + case AML_INDEX_OP: + AcpiOsPrintf ("[Index] "); + AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); + break; + + default: + break; + + } + break; + + default: + AcpiOsPrintf (" "); + AcpiDbDecodeInternalObject (ObjDesc); + break; + } + } + + else + { + AcpiOsPrintf (" "); + } + + AcpiOsPrintf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayMethodInfo + * + * PARAMETERS: StartOp - Root of the control method parse tree + * + * RETURN: None + * + * DESCRIPTION: Display information about the current method + * + ******************************************************************************/ + +void +AcpiDbDisplayMethodInfo ( + ACPI_PARSE_OBJECT *StartOp) +{ + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *RootOp; + ACPI_PARSE_OBJECT *Op; + ACPI_OPCODE_INFO *OpInfo; + UINT32 NumOps = 0; + UINT32 NumOperands = 0; + UINT32 NumOperators = 0; + UINT32 NumRemainingOps = 0; + UINT32 NumRemainingOperands = 0; + UINT32 NumRemainingOperators = 0; + UINT32 NumArgs; + UINT32 Concurrency; + BOOLEAN CountRemaining = FALSE; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + NumArgs = ObjDesc->Method.ParamCount; + Concurrency = ObjDesc->Method.Concurrency; + + AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", &Node->Name); + AcpiOsPrintf ("%d arguments, max concurrency = %d\n", NumArgs, Concurrency); + + + RootOp = StartOp; + while (RootOp->Parent) + { + RootOp = RootOp->Parent; + } + + Op = RootOp; + + while (Op) + { + if (Op == StartOp) + { + CountRemaining = TRUE; + } + + NumOps++; + if (CountRemaining) + { + NumRemainingOps++; + } + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Bad opcode or ASCII character */ + + continue; + } + + + /* Decode the opcode */ + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + if (CountRemaining) + { + NumRemainingOperands++; + } + + NumOperands++; + break; + + default: + if (CountRemaining) + { + NumRemainingOperators++; + } + + NumOperators++; + break; + } + + + Op = AcpiPsGetDepthNext (StartOp, Op); + } + + AcpiOsPrintf ("Method contains: %d AML Opcodes - %d Operators, %d Operands\n", + NumOps, NumOperators, NumOperands); + + AcpiOsPrintf ("Remaining to execute: %d AML Opcodes - %d Operators, %d Operands\n", + NumRemainingOps, NumRemainingOperators, NumRemainingOperands); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayLocals + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all locals for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDisplayLocals (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + + AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", &Node->Name); + + for (i = 0; i < MTH_NUM_LOCALS; i++) + { + ObjDesc = WalkState->LocalVariables[i].Object; + AcpiOsPrintf ("Local%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayArguments + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display all arguments for the currently running control method + * + ******************************************************************************/ + +void +AcpiDbDisplayArguments (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 NumArgs; + UINT32 Concurrency; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->MethodNode; + + NumArgs = ObjDesc->Method.ParamCount; + Concurrency = ObjDesc->Method.Concurrency; + + AcpiOsPrintf ("Method [%4.4s] has %d arguments, max concurrency = %d\n", &Node->Name, NumArgs, Concurrency); + + for (i = 0; i < NumArgs; i++) + { + ObjDesc = WalkState->Arguments[i].Object; + AcpiOsPrintf ("Arg%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResults + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display current contents of a method result stack + * + ******************************************************************************/ + +void +AcpiDbDisplayResults (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 NumResults; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->MethodNode; + NumResults = WalkState->NumResults - WalkState->CurrentResult; + + AcpiOsPrintf ("Method [%4.4s] has %d stacked result objects\n", &Node->Name, NumResults); + + for (i = WalkState->CurrentResult; i < WalkState->NumResults; i++) + { + ObjDesc = WalkState->Results[i]; + AcpiOsPrintf ("Result%d: ", i); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayCallingTree + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display current calling tree of nested control methods + * + ******************************************************************************/ + +void +AcpiDbDisplayCallingTree (void) +{ + UINT32 i; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); + if (!WalkState) + { + AcpiOsPrintf ("There is no method currently executing\n"); + return; + } + + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + AcpiOsPrintf ("Current Control Method Call Tree\n"); + + for (i = 0; WalkState; i++) + { + ObjDesc = WalkState->MethodDesc; + Node = WalkState->Origin->Node; + + AcpiOsPrintf (" [%4.4s]\n", &Node->Name); + + WalkState = WalkState->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayResultObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Display the result of an AML opcode + * + ******************************************************************************/ + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + + /* TBD: [Future] We don't always want to display the result. + * For now, only display if single stepping + * however, this output is very useful in other contexts also + */ + + if (!AcpiGbl_CmSingleStep) + { + return; + } + + AcpiOsPrintf ("ResultObj: "); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); + AcpiOsPrintf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayArgumentObject + * + * PARAMETERS: ObjDesc - Object to be displayed + * WalkState - Current walk state + * + * RETURN: None + * + * DESCRIPTION: Display the result of an AML opcode + * + ******************************************************************************/ + +void +AcpiDbDisplayArgumentObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + + + if (!AcpiGbl_CmSingleStep) + { + return; + } + + AcpiOsPrintf ("ArgObj: "); + AcpiDbDisplayInternalObject (ObjDesc, WalkState); +} + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/dbexec.c b/sys/contrib/dev/acpica/dbexec.c new file mode 100644 index 0000000..af1d884 --- /dev/null +++ b/sys/contrib/dev/acpica/dbexec.c @@ -0,0 +1,482 @@ +/******************************************************************************* + * + * Module Name: dbexec - debugger control method execution + * $Revision: 16 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbexec") + + +typedef struct dbmethodinfo +{ + ACPI_HANDLE ThreadGate; + NATIVE_CHAR *Name; + NATIVE_CHAR **Args; + UINT32 Flags; + UINT32 NumLoops; + NATIVE_CHAR Pathname[128]; + +} DB_METHOD_INFO; + + +DB_METHOD_INFO Info; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteMethod + * + * PARAMETERS: Info - Valid info segment + * ReturnObj - Where to put return object + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbExecuteMethod ( + DB_METHOD_INFO *Info, + ACPI_BUFFER *ReturnObj) +{ + ACPI_STATUS Status; + ACPI_OBJECT_LIST ParamObjects; + ACPI_OBJECT Params[MTH_NUM_ARGS]; + UINT32 i; + + + if (OutputToFile && !AcpiDbgLevel) + { + AcpiOsPrintf ("Warning: debug output is not enabled!\n"); + } + + /* Are there arguments to the method? */ + + if (Info->Args && Info->Args[0]) + { + for (i = 0; Info->Args[i] && i < MTH_NUM_ARGS; i++) + { + Params[i].Type = ACPI_TYPE_NUMBER; + Params[i].Number.Value = STRTOUL (Info->Args[i], NULL, 16); + } + + ParamObjects.Pointer = Params; + ParamObjects.Count = i; + } + + else + { + /* Setup default parameters */ + + Params[0].Type = ACPI_TYPE_NUMBER; + Params[0].Number.Value = 0x01020304; + + Params[1].Type = ACPI_TYPE_STRING; + Params[1].String.Length = 12; + Params[1].String.Pointer = "AML Debugger"; + + ParamObjects.Pointer = Params; + ParamObjects.Count = 2; + } + + /* Prepare for a return object of arbitrary size */ + + ReturnObj->Pointer = Buffer; + ReturnObj->Length = BUFFER_SIZE; + + + /* Do the actual method execution */ + + Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj); + + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_MethodExecuting = FALSE; + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteSetup + * + * PARAMETERS: Info - Valid method info + * + * RETURN: Status + * + * DESCRIPTION: Setup info segment prior to method execution + * + ******************************************************************************/ + +void +AcpiDbExecuteSetup ( + DB_METHOD_INFO *Info) +{ + + /* Catenate the current scope to the supplied name */ + + Info->Pathname[0] = 0; + if ((Info->Name[0] != '\\') && + (Info->Name[0] != '/')) + { + STRCAT (Info->Pathname, ScopeBuf); + } + + STRCAT (Info->Pathname, Info->Name); + AcpiDbPrepNamestring (Info->Pathname); + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("Executing %s\n", Info->Pathname); + + if (Info->Flags & EX_SINGLE_STEP) + { + AcpiGbl_CmSingleStep = TRUE; + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + } + + else + { + /* No single step, allow redirection to a file */ + + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecute + * + * PARAMETERS: Name - Name of method to execute + * Args - Parameters to the method + * Flags - single step/no single step + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method. Name is relative to the current + * scope. + * + ******************************************************************************/ + +void +AcpiDbExecute ( + NATIVE_CHAR *Name, + NATIVE_CHAR **Args, + UINT32 Flags) +{ + ACPI_STATUS Status; + UINT32 PreviousAllocations; + UINT32 PreviousSize; + UINT32 Allocations; + UINT32 Size; + ACPI_BUFFER ReturnObj; + + + /* Memory allocation tracking */ + + PreviousAllocations = AcpiGbl_CurrentAllocCount; + PreviousSize = AcpiGbl_CurrentAllocSize; + + + Info.Name = Name; + Info.Args = Args; + Info.Flags = Flags; + + AcpiDbExecuteSetup (&Info); + Status = AcpiDbExecuteMethod (&Info, &ReturnObj); + + + /* Memory allocation tracking */ + + Allocations = AcpiGbl_CurrentAllocCount - PreviousAllocations; + Size = AcpiGbl_CurrentAllocSize - PreviousSize; + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + + if (Allocations > 0) + { + AcpiOsPrintf ("Outstanding: %ld allocations of total size %ld after execution\n", + Allocations, Size); + } + + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Execution of %s failed with status %s\n", Info.Pathname, AcpiCmFormatException (Status)); + } + + else + { + /* Display a return object, if any */ + + if (ReturnObj.Length) + { + AcpiOsPrintf ("Execution of %s returned object %p\n", Info.Pathname, ReturnObj.Pointer); + AcpiDbDumpObject (ReturnObj.Pointer, 1); + } + } + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbMethodThread + * + * PARAMETERS: Context - Execution info segment + * + * RETURN: None + * + * DESCRIPTION: Debugger execute thread. Waits for a command line, then + * simply dispatches it. + * + ******************************************************************************/ + +void +AcpiDbMethodThread ( + void *Context) +{ + ACPI_STATUS Status; + DB_METHOD_INFO *Info = Context; + UINT32 i; + ACPI_BUFFER ReturnObj; + + + for (i = 0; i < Info->NumLoops; i++) + { + Status = AcpiDbExecuteMethod (Info, &ReturnObj); + if (ACPI_SUCCESS (Status)) + { + if (ReturnObj.Length) + { + AcpiOsPrintf ("Execution of %s returned object %p\n", Info->Pathname, ReturnObj.Pointer); + AcpiDbDumpObject (ReturnObj.Pointer, 1); + } + } + } + + + /* Signal our completion */ + + AcpiOsSignalSemaphore (Info->ThreadGate, 1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCreateExecutionThreads + * + * PARAMETERS: NumThreadsArg - Number of threads to create + * NumLoopsArg - Loop count for the thread(s) + * MethodNameArg - Control method to execute + * + * RETURN: None + * + * DESCRIPTION: Create threads to execute method(s) + * + ******************************************************************************/ + +void +AcpiDbCreateExecutionThreads ( + NATIVE_CHAR *NumThreadsArg, + NATIVE_CHAR *NumLoopsArg, + NATIVE_CHAR *MethodNameArg) +{ + ACPI_STATUS Status; + UINT32 NumThreads; + UINT32 NumLoops; + UINT32 i; + ACPI_HANDLE ThreadGate; + + + /* Get the arguments */ + + NumThreads = STRTOUL (NumThreadsArg, NULL, 0); + NumLoops = STRTOUL (NumLoopsArg, NULL, 0); + + if (!NumThreads || !NumLoops) + { + AcpiOsPrintf ("Bad argument: Threads %d, Loops %d\n", NumThreads, NumLoops); + return; + } + + + /* Create the synchronization semaphore */ + + Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiCmFormatException (Status)); + return; + } + + /* Setup the context to be passed to each thread */ + + Info.Name = MethodNameArg; + Info.Args = NULL; + Info.Flags = 0; + Info.NumLoops = NumLoops; + Info.ThreadGate = ThreadGate; + + AcpiDbExecuteSetup (&Info); + + + /* Create the threads */ + + AcpiOsPrintf ("Creating %d threads to execute %d times each\n", NumThreads, NumLoops); + + for (i = 0; i < (NumThreads); i++) + { + AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &Info); + } + + + /* Wait for all threads to complete */ + + i = NumThreads; + while (i) /* Brain damage for OSD implementations that only support wait of 1 unit */ + { + Status = AcpiOsWaitSemaphore (ThreadGate, 1, WAIT_FOREVER); + i--; + } + + /* Cleanup and exit */ + + AcpiOsDeleteSemaphore (ThreadGate); + + AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); + AcpiOsPrintf ("All threads (%d) have completed\n", NumThreads); + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); +} + + +#endif /* ENABLE_DEBUGGER */ + + diff --git a/sys/contrib/dev/acpica/dbfileio.c b/sys/contrib/dev/acpica/dbfileio.c new file mode 100644 index 0000000..c7fe4fe --- /dev/null +++ b/sys/contrib/dev/acpica/dbfileio.c @@ -0,0 +1,472 @@ +/******************************************************************************* + * + * Module Name: dbfileio - Debugger file I/O commands. These can't usually + * be used when running the debugger in Ring 0 (Kernel mode) + * $Revision: 30 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acdebug.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbfileio") + + +ACPI_PARSE_OBJECT *root; + +#ifdef ACPI_APPLICATION +#include +FILE *DebugFile = NULL; +#endif + + +/* + * NOTE: this is here for lack of a better place. It is used in all + * flavors of the debugger, need LCD file + */ + +/******************************************************************************* + * + * 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 + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDbMatchArgument ( + NATIVE_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 (STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name) + { + return ((OBJECT_TYPE_INTERNAL) i); + } + } + + /* Argument not recognized */ + + return (ACPI_TYPE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCloseDebugFile + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: If open, close the current debug output file + * + ******************************************************************************/ + +void +AcpiDbCloseDebugFile ( + void) +{ + +#ifdef ACPI_APPLICATION + + if (DebugFile) + { + fclose (DebugFile); + DebugFile = NULL; + OutputToFile = FALSE; + AcpiOsPrintf ("Debug output file %s closed\n", DebugFilename); + } +#endif + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbOpenDebugFile + * + * PARAMETERS: Name - Filename to open + * + * RETURN: Status + * + * DESCRIPTION: Open a file where debug output will be directed. + * + ******************************************************************************/ + +void +AcpiDbOpenDebugFile ( + NATIVE_CHAR *Name) +{ + +#ifdef ACPI_APPLICATION + + AcpiDbCloseDebugFile (); + DebugFile = fopen (Name, "w+"); + if (DebugFile) + { + AcpiOsPrintf ("Debug output file %s opened\n", Name); + STRCPY (DebugFilename, Name); + OutputToFile = TRUE; + } + +#endif +} + + +#ifdef ACPI_APPLICATION +/******************************************************************************* + * + * FUNCTION: AcpiDbLoadTable + * + * PARAMETERS: fp - File that contains table + * TablePtr - Return value, buffer with table + * TableLenght - Return value, length of table + * + * RETURN: Status + * + * DESCRIPTION: Load the DSDT from the file pointer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbLoadTable( + FILE *fp, + ACPI_TABLE_HEADER **TablePtr, + UINT32 *TableLength) +{ + ACPI_TABLE_HEADER TableHeader; + UINT8 *AmlPtr; + UINT32 AmlLength; + UINT32 Actual; + + + /* Read the table header */ + + if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (TableHeader)) + { + AcpiOsPrintf ("Couldn't read the table header\n"); + return (AE_BAD_SIGNATURE); + } + + /* Get and validate the table length */ + + *TableLength = TableHeader.Length; + if (!*TableLength) + { + AcpiOsPrintf ("Found a table length of zero!\n"); + return (AE_ERROR); + } + + /* Allocate a buffer for the table */ + + *TablePtr = (ACPI_TABLE_HEADER *) malloc ((size_t) *TableLength); + if (!*TablePtr) + { + AcpiOsPrintf ("Could not allocate memory for the table (size=0x%X)\n", TableHeader.Length); + return (AE_NO_MEMORY); + } + + + AmlPtr = (UINT8 *) *TablePtr + sizeof (TableHeader); + AmlLength = *TableLength - sizeof (TableHeader); + + /* Copy the header to the buffer */ + + MEMCPY (*TablePtr, &TableHeader, sizeof (TableHeader)); + + /* Get the rest of the table */ + + Actual = fread (AmlPtr, 1, (size_t) AmlLength, fp); + if (Actual == AmlLength) + { + return (AE_OK); + } + + if (Actual > 0) + { + AcpiOsPrintf ("Warning - reading table, asked for %d got %d\n", AmlLength, Actual); + return (AE_OK); + } + + + AcpiOsPrintf ("Error - could not read the table file\n"); + free (*TablePtr); + *TablePtr = NULL; + *TableLength = 0; + + return (AE_ERROR); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AeLocalLoadTable + * + * PARAMETERS: TablePtr - pointer to a buffer containing the entire + * table to be loaded + * + * RETURN: Status + * + * DESCRIPTION: This function is called to load a table from the caller's + * buffer. The buffer must contain an entire ACPI Table including + * a valid header. The header fields will be verified, and if it + * is determined that the table is invalid, the call will fail. + * + * If the call fails an appropriate status will be returned. + * + ******************************************************************************/ + +ACPI_STATUS +AeLocalLoadTable ( + ACPI_TABLE_HEADER *TablePtr) +{ + ACPI_STATUS Status; + ACPI_TABLE_DESC TableInfo; + + + FUNCTION_TRACE ("AeLocalLoadTable"); + + if (!TablePtr) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Install the new table into the local data structures */ + + TableInfo.Pointer = TablePtr; + + Status = AcpiTbInstallTable (NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + /* Free table allocated by AcpiTbGetTable */ + + AcpiTbDeleteSingleTable (&TableInfo); + return_ACPI_STATUS (Status); + } + + +#ifndef PARSER_ONLY + Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + /* Uninstall table and free the buffer */ + + AcpiTbUninstallTable (TableInfo.InstalledDesc); + return_ACPI_STATUS (Status); + } +#endif + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbLoadAcpiTable + * + * PARAMETERS: Filname - File where table is located + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from a file + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + NATIVE_CHAR *Filename) +{ +#ifdef ACPI_APPLICATION + FILE *fp; + ACPI_STATUS Status; + ACPI_TABLE_HEADER *TablePtr; + UINT32 TableLength; + + + /* Open the file */ + + fp = fopen (Filename, "rb"); + if (!fp) + { + AcpiOsPrintf ("Could not open file %s\n", Filename); + return (AE_ERROR); + } + + + /* Get the entire file */ + + AcpiOsPrintf ("Loading Acpi table from file %s\n", Filename); + Status = AcpiDbLoadTable (fp, &TablePtr, &TableLength); + fclose(fp); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Couldn't get table from the file\n"); + return (Status); + } + + + /* Attempt to recognize and install the table */ + Status = AeLocalLoadTable (TablePtr); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_EXIST) + { + AcpiOsPrintf ("Table %4.4s is already installed\n", + &TablePtr->Signature); + } + else + { + AcpiOsPrintf ("Could not install table, %s\n", + AcpiCmFormatException (Status)); + } + free (TablePtr); + return (Status); + } + + AcpiOsPrintf ("%4.4s at %p successfully installed and loaded\n", + &TablePtr->Signature, TablePtr); + + AcpiGbl_AcpiHardwarePresent = FALSE; + +#endif /* ACPI_APPLICATION */ + return (AE_OK); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/dbhistry.c b/sys/contrib/dev/acpica/dbhistry.c new file mode 100644 index 0000000..bcc18a8 --- /dev/null +++ b/sys/contrib/dev/acpica/dbhistry.c @@ -0,0 +1,301 @@ +/****************************************************************************** + * + * Module Name: dbhistry - debugger HISTORY command + * $Revision: 15 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "actables.h" + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbhistry") + + +#define HI_NO_HISTORY 0 +#define HI_RECORD_HISTORY 1 +#define HISTORY_SIZE 20 + + +typedef struct HistoryInfo +{ + NATIVE_CHAR Command[80]; + UINT32 CmdNum; + +} HISTORY_INFO; + + +HISTORY_INFO HistoryBuffer[HISTORY_SIZE]; +UINT16 LoHistory = 0; +UINT16 NumHistory = 0; +UINT16 NextHistoryIndex = 0; +UINT32 NextCmdNum = 1; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbAddToHistory + * + * PARAMETERS: CommandLine - Command to add + * + * RETURN: None + * + * DESCRIPTION: Add a command line to the history buffer. + * + ******************************************************************************/ + +void +AcpiDbAddToHistory ( + NATIVE_CHAR *CommandLine) +{ + + + /* Put command into the next available slot */ + + STRCPY (HistoryBuffer[NextHistoryIndex].Command, CommandLine); + HistoryBuffer[NextHistoryIndex].CmdNum = NextCmdNum; + + /* Adjust indexes */ + + if ((NumHistory == HISTORY_SIZE) && + (NextHistoryIndex == LoHistory)) + { + LoHistory++; + if (LoHistory >= HISTORY_SIZE) + { + LoHistory = 0; + } + } + + NextHistoryIndex++; + if (NextHistoryIndex >= HISTORY_SIZE) + { + NextHistoryIndex = 0; + } + + + NextCmdNum++; + if (NumHistory < HISTORY_SIZE) + { + NumHistory++; + } + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayHistory + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display the contents of the history buffer + * + ******************************************************************************/ + +void +AcpiDbDisplayHistory (void) +{ + NATIVE_UINT i; + UINT16 HistoryIndex; + + + HistoryIndex = LoHistory; + + /* Dump entire history buffer */ + + for (i = 0; i < NumHistory; i++) + { + AcpiOsPrintf ("%ld %s\n", HistoryBuffer[HistoryIndex].CmdNum, HistoryBuffer[HistoryIndex].Command); + + HistoryIndex++; + if (HistoryIndex >= HISTORY_SIZE) + { + HistoryIndex = 0; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetFromHistory + * + * PARAMETERS: CommandNumArg - String containing the number of the + * command to be retrieved + * + * RETURN: None + * + * DESCRIPTION: Get a command from the history buffer + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiDbGetFromHistory ( + NATIVE_CHAR *CommandNumArg) +{ + NATIVE_UINT i; + UINT16 HistoryIndex; + UINT32 CmdNum; + + + if (CommandNumArg == NULL) + { + CmdNum = NextCmdNum - 1; + } + + else + { + CmdNum = STRTOUL (CommandNumArg, NULL, 0); + } + + + /* Search history buffer */ + + HistoryIndex = LoHistory; + for (i = 0; i < NumHistory; i++) + { + if (HistoryBuffer[HistoryIndex].CmdNum == CmdNum) + { + /* Found the commnad, return it */ + + return (HistoryBuffer[HistoryIndex].Command); + } + + + HistoryIndex++; + if (HistoryIndex >= HISTORY_SIZE) + { + HistoryIndex = 0; + } + } + + AcpiOsPrintf ("Invalid history number: %d\n", HistoryIndex); + return (NULL); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/dbinput.c b/sys/contrib/dev/acpica/dbinput.c new file mode 100644 index 0000000..d81e1ad --- /dev/null +++ b/sys/contrib/dev/acpica/dbinput.c @@ -0,0 +1,981 @@ +/******************************************************************************* + * + * Module Name: dbinput - user front-end to the AML debugger + * $Revision: 51 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "actables.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbinput") + + +/* + * Globals that are specific to the debugger + */ + +NATIVE_CHAR LineBuf[80]; +NATIVE_CHAR ParsedBuf[80]; +NATIVE_CHAR ScopeBuf[40]; +NATIVE_CHAR DebugFilename[40]; +NATIVE_CHAR *Args[DB_MAX_ARGS]; +NATIVE_CHAR *Buffer; +NATIVE_CHAR *Filename = NULL; +BOOLEAN OutputToFile = FALSE; + + +UINT32 AcpiGbl_DbDebugLevel = 0x0FFFFFFF; +UINT32 AcpiGbl_DbConsoleDebugLevel = NORMAL_DEFAULT | TRACE_TABLES; +UINT8 AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT; + + +BOOLEAN opt_tables = FALSE; +BOOLEAN opt_disasm = FALSE; +BOOLEAN opt_stats = FALSE; +BOOLEAN opt_parse_jit = FALSE; +BOOLEAN opt_verbose = TRUE; + + +/* + * Top-level debugger commands. + * + * This list of commands must match the string table below it + */ + +enum AcpiAmlDebuggerCommands +{ + CMD_NOT_FOUND = 0, + CMD_NULL, + CMD_ALLOCATIONS, + CMD_ARGS, + CMD_ARGUMENTS, + CMD_BREAKPOINT, + CMD_CALL, + CMD_CLOSE, + CMD_DEBUG, + CMD_DUMP, + CMD_ENABLEACPI, + CMD_EVENT, + CMD_EXECUTE, + CMD_EXIT, + CMD_FIND, + CMD_GO, + CMD_HELP, + CMD_HELP2, + CMD_HISTORY, + CMD_HISTORY_EXE, + CMD_HISTORY_LAST, + CMD_INFORMATION, + CMD_INTO, + CMD_LEVEL, + CMD_LIST, + CMD_LOAD, + CMD_LOCALS, + CMD_METHODS, + CMD_NAMESPACE, + CMD_NOTIFY, + CMD_OBJECT, + CMD_OPEN, + CMD_OWNER, + CMD_PREFIX, + CMD_QUIT, + CMD_REFERENCES, + CMD_RESULTS, + CMD_SET, + CMD_STATS, + CMD_STOP, + CMD_TABLES, + CMD_TERMINATE, + CMD_THREADS, + CMD_TREE, + CMD_UNLOAD +}; + +#define CMD_FIRST_VALID 2 + + +COMMAND_INFO Commands[] = +{ + {"", 0}, + {"", 0}, + {"ALLOCATIONS", 0}, + {"ARGS", 0}, + {"ARGUMENTS", 0}, + {"BREAKPOINT", 1}, + {"CALL", 0}, + {"CLOSE", 0}, + {"DEBUG", 1}, + {"DUMP", 1}, + {"ENABLEACPI", 0}, + {"EVENT", 1}, + {"EXECUTE", 1}, + {"EXIT", 0}, + {"FIND", 1}, + {"GO", 0}, + {"HELP", 0}, + {"?", 0}, + {"HISTORY", 0}, + {"!", 1}, + {"!!", 0}, + {"INFORMATION", 0}, + {"INTO", 0}, + {"LEVEL", 0}, + {"LIST", 0}, + {"LOAD", 1}, + {"LOCALS", 0}, + {"METHODS", 0}, + {"NAMESPACE", 0}, + {"NOTIFY", 2}, + {"OBJECT", 1}, + {"OPEN", 1}, + {"OWNER", 1}, + {"PREFIX", 0}, + {"QUIT", 0}, + {"REFERENCES", 1}, + {"RESULTS", 0}, + {"SET", 3}, + {"STATS", 0}, + {"STOP", 0}, + {"TABLES", 0}, + {"TERMINATE", 0}, + {"THREADS", 3}, + {"TREE", 0}, + {"UNLOAD", 0}, + {NULL, 0} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayHelp + * + * PARAMETERS: HelpType - Subcommand (optional) + * + * RETURN: None + * + * DESCRIPTION: Print a usage message. + * + ******************************************************************************/ + +void +AcpiDbDisplayHelp ( + NATIVE_CHAR *HelpType) +{ + + + /* No parameter, just give the overview */ + + if (!HelpType) + { + AcpiOsPrintf ("ACPI CA Debugger Commands\n\n"); + AcpiOsPrintf ("The following classes of commands are available. Help is available for\n"); + AcpiOsPrintf ("each class by entering \"Help \"\n\n"); + AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n"); + AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n"); + AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n"); + AcpiOsPrintf (" [FILE] File I/O Commands\n"); + return; + + } + + + /* + * Parameter is the command class + * + * The idea here is to keep each class of commands smaller than a screenful + */ + + switch (HelpType[0]) + { + case 'G': + AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n"); + AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); + AcpiOsPrintf ("Dump
|\n"); + AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n"); + AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n"); + AcpiOsPrintf ("Help This help screen\n"); + AcpiOsPrintf ("History Display command history buffer\n"); + AcpiOsPrintf ("Level [] [console] Get/Set debug level for file or console\n"); + AcpiOsPrintf ("Quit or Exit Exit this command\n"); + AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); + AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n"); + AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); + AcpiOsPrintf ("Unload Unload an ACPI table\n"); + AcpiOsPrintf ("! Execute command from history buffer\n"); + AcpiOsPrintf ("!! Execute last command again\n"); + return; + + case 'N': + AcpiOsPrintf ("\nNamespace Access Commands\n\n"); + AcpiOsPrintf ("Debug [Arguments] Single Step a control method\n"); + AcpiOsPrintf ("Event Generate AcpiEvent (Fixed/GPE)\n"); + AcpiOsPrintf ("Execute [Arguments] Execute control method\n"); + AcpiOsPrintf ("Find (? is wildcard) Find ACPI name(s) with wildcards\n"); + AcpiOsPrintf ("Method Display list of loaded control methods\n"); + AcpiOsPrintf ("Namespace [|] [Depth] Display loaded namespace tree/subtree\n"); + AcpiOsPrintf ("Notify Send a notification\n"); + AcpiOsPrintf ("Objects Display all objects of the given type\n"); + AcpiOsPrintf ("Owner [Depth] Display loaded namespace by object owner\n"); + AcpiOsPrintf ("Prefix [] Set or Get current execution prefix\n"); + AcpiOsPrintf ("References Find all references to object at addr\n"); + AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); + AcpiOsPrintf ("Thread Spawn threads to execute method(s)\n"); + return; + + case 'M': + AcpiOsPrintf ("\nControl Method Execution Commands\n\n"); + AcpiOsPrintf ("Arguments (or Args) Display method arguments\n"); + AcpiOsPrintf ("Breakpoint Set an AML execution breakpoint\n"); + AcpiOsPrintf ("Call Run to next control method invocation\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 AcpiAml Opcodes] Display method ASL statements\n"); + AcpiOsPrintf ("Locals Display method local variables\n"); + AcpiOsPrintf ("Results Display method result stack\n"); + AcpiOsPrintf ("Set <#> Set method data (Arguments/Locals)\n"); + AcpiOsPrintf ("Stop Terminate control method\n"); + AcpiOsPrintf ("Tree Display control method calling tree\n"); + AcpiOsPrintf (" Single step next AML opcode (over calls)\n"); + return; + + case 'F': + AcpiOsPrintf ("\nFile I/O Commands\n\n"); + AcpiOsPrintf ("Close Close debug output file\n"); + AcpiOsPrintf ("Open Open a file for debug output\n"); + AcpiOsPrintf ("Load Load ACPI table from a file\n"); + return; + + default: + AcpiOsPrintf ("Unrecognized Command Class: %x\n", HelpType); + return; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetNextToken + * + * PARAMETERS: String - Command buffer + * Next - Return value, end of next token + * + * RETURN: Pointer to the start of the next token. + * + * DESCRIPTION: Command line parsing. Get the next token on the command line + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiDbGetNextToken ( + NATIVE_CHAR *String, + NATIVE_CHAR **Next) +{ + NATIVE_CHAR *Start; + + /* At end of buffer? */ + + if (!String || !(*String)) + { + return (NULL); + } + + + /* Get rid of any spaces at the beginning */ + + if (*String == ' ') + { + while (*String && (*String == ' ')) + { + String++; + } + + if (!(*String)) + { + return (NULL); + } + } + + Start = String; + + /* Find end of token */ + + while (*String && (*String != ' ')) + { + String++; + } + + + if (!(*String)) + { + *Next = NULL; + } + + else + { + *String = 0; + *Next = String + 1; + } + + return (Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetLine + * + * PARAMETERS: InputBuffer - Command line buffer + * + * RETURN: None + * + * DESCRIPTION: Get the next command line from the user. Gets entire line + * up to the next newline + * + ******************************************************************************/ + +UINT32 +AcpiDbGetLine ( + NATIVE_CHAR *InputBuffer) +{ + UINT32 i; + UINT32 Count; + NATIVE_CHAR *Next; + NATIVE_CHAR *This; + + + STRCPY (ParsedBuf, InputBuffer); + STRUPR (ParsedBuf); + + This = ParsedBuf; + for (i = 0; i < DB_MAX_ARGS; i++) + { + Args[i] = AcpiDbGetNextToken (This, &Next); + if (!Args[i]) + { + break; + } + + This = Next; + } + + + /* Uppercase the actual command */ + + if (Args[0]) + { + STRUPR (Args[0]); + } + + Count = i; + if (Count) + { + Count--; /* Number of args only */ + } + + return (Count); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbMatchCommand + * + * PARAMETERS: UserCommand - User command line + * + * RETURN: Index into command array, -1 if not found + * + * DESCRIPTION: Search command array for a command match + * + ******************************************************************************/ + +UINT32 +AcpiDbMatchCommand ( + NATIVE_CHAR *UserCommand) +{ + UINT32 i; + + + if (!UserCommand || UserCommand[0] == 0) + { + return (CMD_NULL); + } + + for (i = CMD_FIRST_VALID; Commands[i].Name; i++) + { + if (STRSTR (Commands[i].Name, UserCommand) == Commands[i].Name) + { + return (i); + } + } + + /* Command not recognized */ + + return (CMD_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCommandDispatch + * + * PARAMETERS: InputBuffer - Command line buffer + * WalkState - Current walk + * Op - Current (executing) parse op + * + * RETURN: Status + * + * DESCRIPTION: Command dispatcher. Called from two places: + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbCommandDispatch ( + NATIVE_CHAR *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + UINT32 Temp; + UINT32 CommandIndex; + UINT32 ParamCount; + NATIVE_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 (Args[0]); + Temp = 0; + + /* Verify that we have the minimum number of params */ + + if (ParamCount < Commands[CommandIndex].MinArgs) + { + AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", + ParamCount, Commands[CommandIndex].Name, Commands[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: + AcpiCmDumpCurrentAllocations ((UINT32) -1, NULL); + break; + + case CMD_ARGS: + case CMD_ARGUMENTS: + AcpiDbDisplayArguments (); + break; + + case CMD_BREAKPOINT: + AcpiDbSetMethodBreakpoint (Args[1], WalkState, Op); + break; + + case CMD_CALL: + AcpiDbSetMethodCallBreakpoint (Op); + Status = AE_OK; + break; + + case CMD_CLOSE: + AcpiDbCloseDebugFile (); + break; + + case CMD_DEBUG: + AcpiDbExecute (Args[1], &Args[2], EX_SINGLE_STEP); + break; + + case CMD_DUMP: + AcpiDbDecodeAndDisplayObject (Args[1], Args[2]); + break; + + case CMD_ENABLEACPI: + Status = AcpiEnable(); + if (ACPI_FAILURE(Status)) + { + AcpiOsPrintf("AcpiEnable failed (0x%x)\n", Status); + return (Status); + } + break; + + case CMD_EVENT: + AcpiOsPrintf ("Event command not implemented\n"); + break; + + case CMD_EXECUTE: + AcpiDbExecute (Args[1], &Args[2], EX_NO_SINGLE_STEP); + break; + + case CMD_FIND: + AcpiDbFindNameInNamespace (Args[1]); + break; + + case CMD_GO: + AcpiGbl_CmSingleStep = FALSE; + return (AE_OK); + + case CMD_HELP: + case CMD_HELP2: + AcpiDbDisplayHelp (Args[1]); + break; + + case CMD_HISTORY: + AcpiDbDisplayHistory (); + break; + + case CMD_HISTORY_EXE: + CommandLine = AcpiDbGetFromHistory (Args[1]); + if (!CommandLine) + { + return (AE_CTRL_TRUE); + } + + Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); + if (ACPI_SUCCESS (Status)) + Status = AE_CTRL_TRUE; + return (Status); + break; + + case CMD_HISTORY_LAST: + CommandLine = AcpiDbGetFromHistory (NULL); + if (!CommandLine) + { + return (AE_CTRL_TRUE); + } + + Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); + if (ACPI_SUCCESS (Status)) + Status = AE_CTRL_TRUE; + return (Status); + + case CMD_INFORMATION: + AcpiDbDisplayMethodInfo (Op); + break; + + case CMD_INTO: + if (Op) + { + AcpiGbl_CmSingleStep = TRUE; + +/* TBD: Must get current walk state */ + /* AcpiGbl_MethodBreakpoint = 0; */ + 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 = STRTOUL (Args[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 = STRTOUL (Args[1], NULL, 16); + AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); + } + break; + + case CMD_LIST: + AcpiDbDisassembleAml (Args[1], Op); + break; + + case CMD_LOAD: + Status = AcpiDbLoadAcpiTable (Args[1]); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case CMD_LOCALS: + AcpiDbDisplayLocals (); + break; + + case CMD_METHODS: + AcpiDbDisplayObjects ("METHOD", Args[1]); + break; + + case CMD_NAMESPACE: + AcpiDbDumpNamespace (Args[1], Args[2]); + break; + + case CMD_NOTIFY: + Temp = STRTOUL (Args[2], NULL, 0); + AcpiDbSendNotify (Args[1], Temp); + break; + + case CMD_OBJECT: + AcpiDbDisplayObjects (Args[1], Args[2]); + break; + + case CMD_OPEN: + AcpiDbOpenDebugFile (Args[1]); + break; + + case CMD_OWNER: + AcpiDbDumpNamespaceByOwner (Args[1], Args[2]); + break; + + case CMD_PREFIX: + AcpiDbSetScope (Args[1]); + break; + + case CMD_REFERENCES: + AcpiDbFindReferences (Args[1]); + break; + + case CMD_RESULTS: + AcpiDbDisplayResults (); + break; + + case CMD_SET: + AcpiDbSetMethodData (Args[1], Args[2], Args[3]); + break; + + case CMD_STATS: + AcpiDbDisplayStatistics (Args[1]); + break; + + case CMD_STOP: + return (AE_AML_ERROR); + break; + + case CMD_TABLES: + AcpiDbDisplayTableInfo (Args[1]); + break; + + case CMD_TERMINATE: + AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); + AcpiCmSubsystemShutdown (); + + /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */ + + /* AcpiInitialize (NULL); */ + break; + + case CMD_THREADS: + AcpiDbCreateExecutionThreads (Args[1], Args[2], Args[3]); + break; + + case CMD_TREE: + AcpiDbDisplayCallingTree (); + break; + + case CMD_UNLOAD: + AcpiDbUnloadAcpiTable (Args[1], Args[2]); + break; + + case CMD_EXIT: + case CMD_QUIT: + if (Op) + { + return (AE_AML_ERROR); + } + + if (!OutputToFile) + { + AcpiDbgLevel = DEBUG_DEFAULT; + } + + /* Shutdown */ + + /* AcpiCmSubsystemShutdown (); */ + AcpiDbCloseDebugFile (); + + AcpiGbl_DbTerminateThreads = TRUE; + + return (AE_CTRL_TERMINATE); + + case CMD_NOT_FOUND: + AcpiOsPrintf ("Unknown Command\n"); + return (AE_CTRL_TRUE); + } + + + /* Add all commands that come here to the history buffer */ + + AcpiDbAddToHistory (InputBuffer); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbExecuteThread + * + * PARAMETERS: Context - Not used + * + * RETURN: None + * + * DESCRIPTION: Debugger execute thread. Waits for a command line, then + * simply dispatches it. + * + ******************************************************************************/ + +void +AcpiDbExecuteThread ( + void *Context) +{ + ACPI_STATUS Status = AE_OK; + + + while (Status != AE_CTRL_TERMINATE) + { + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; + + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + Status = AcpiDbCommandDispatch (LineBuf, NULL, NULL); + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSingleThread + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Debugger execute thread. Waits for a command line, then + * simply dispatches it. + * + ******************************************************************************/ + +void +AcpiDbSingleThread ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; + + Status = AcpiDbCommandDispatch (LineBuf, 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 ( + NATIVE_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 (DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + AcpiOsGetLine (LineBuf); + + + /* 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. + */ + + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + } + + 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 + */ + AcpiTerminate (); + + return (Status); +} + + +#endif /* ENABLE_DEBUGGER */ + diff --git a/sys/contrib/dev/acpica/dbstats.c b/sys/contrib/dev/acpica/dbstats.c new file mode 100644 index 0000000..afb8b44 --- /dev/null +++ b/sys/contrib/dev/acpica/dbstats.c @@ -0,0 +1,548 @@ +/******************************************************************************* + * + * Module Name: dbstats - Generation and display of ACPI table statistics + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include +#include +#include +#include + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbstats") + +/* + * Statistics subcommands + */ +ARGUMENT_INFO AcpiDbStatTypes [] = +{ + {"ALLOCATIONS"}, + {"OBJECTS"}, + {"MEMORY"}, + {"MISC"}, + {"TABLES"}, + {"SIZES"}, + {NULL} /* Must be null terminated */ +}; + +#define CMD_ALLOCATIONS 0 +#define CMD_OBJECTS 1 +#define CMD_MEMORY 2 +#define CMD_MISC 3 +#define CMD_TABLES 4 +#define CMD_SIZES 5 + + +/* + * Statistic globals + */ +UINT16 AcpiGbl_ObjTypeCount[INTERNAL_TYPE_NODE_MAX+1]; +UINT16 AcpiGbl_NodeTypeCount[INTERNAL_TYPE_NODE_MAX+1]; +UINT16 AcpiGbl_ObjTypeCountMisc; +UINT16 AcpiGbl_NodeTypeCountMisc; +UINT32 NumNodes; +UINT32 NumObjects; + + +UINT32 SizeOfParseTree; +UINT32 SizeOfMethodTrees; +UINT32 SizeOfNodeEntries; +UINT32 SizeOfAcpiObjects; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbEnumerateObject + * + * PARAMETERS: ObjDesc - Object to be counted + * + * RETURN: None + * + * DESCRIPTION: Add this object to the global counts, by object type. + * Recursively handles subobjects and packages. + * + * [TBD] Restructure - remove recursion. + * + ******************************************************************************/ + +void +AcpiDbEnumerateObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + UINT32 Type; + UINT32 i; + + + if (!ObjDesc) + { + return; + } + + + /* Enumerate this object first */ + + NumObjects++; + + Type = ObjDesc->Common.Type; + if (Type > INTERNAL_TYPE_NODE_MAX) + { + AcpiGbl_ObjTypeCountMisc++; + } + else + { + AcpiGbl_ObjTypeCount [Type]++; + } + + /* Count the sub-objects */ + + switch (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.SysHandler); + AcpiDbEnumerateObject (ObjDesc->Device.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->Device.AddrHandler); + break; + + case ACPI_TYPE_REGION: + AcpiDbEnumerateObject (ObjDesc->Region.AddrHandler); + break; + + case ACPI_TYPE_POWER: + AcpiDbEnumerateObject (ObjDesc->PowerResource.SysHandler); + AcpiDbEnumerateObject (ObjDesc->PowerResource.DrvHandler); + break; + + case ACPI_TYPE_PROCESSOR: + AcpiDbEnumerateObject (ObjDesc->Processor.SysHandler); + AcpiDbEnumerateObject (ObjDesc->Processor.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->Processor.AddrHandler); + break; + + case ACPI_TYPE_THERMAL: + AcpiDbEnumerateObject (ObjDesc->ThermalZone.SysHandler); + AcpiDbEnumerateObject (ObjDesc->ThermalZone.DrvHandler); + AcpiDbEnumerateObject (ObjDesc->ThermalZone.AddrHandler); + break; + } +} + + +#ifndef PARSER_ONLY + +/******************************************************************************* + * + * FUNCTION: AcpiDbClassifyOneObject + * + * PARAMETERS: Callback for WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and + * the parent namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbClassifyOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Type; + + + NumNodes++; + + Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ObjDesc = ((ACPI_NAMESPACE_NODE *) ObjHandle)->Object; + + AcpiDbEnumerateObject (ObjDesc); + + Type = Node->Type; + if (Type > INTERNAL_TYPE_INVALID) + { + AcpiGbl_NodeTypeCountMisc++; + } + + else + { + AcpiGbl_NodeTypeCount [Type]++; + } + + return AE_OK; + + + /* TBD: These need to be counted during the initial parsing phase */ + /* + if (AcpiPsIsNamedOp (Op->Opcode)) + { + NumNodes++; + } + + if (IsMethod) + { + NumMethodElements++; + } + + NumGrammarElements++; + Op = AcpiPsGetDepthNext (Root, Op); + + SizeOfParseTree = (NumGrammarElements - NumMethodElements) * (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); + SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); + + */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbCountNamespaceObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Count and classify the entire namespace, including all + * namespace nodes and attached objects. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbCountNamespaceObjects ( + void) +{ + UINT32 i; + + + NumNodes = 0; + NumObjects = 0; + + AcpiGbl_ObjTypeCountMisc = 0; + for (i = 0; i < INTERNAL_TYPE_INVALID; i++) + { + AcpiGbl_ObjTypeCount [i] = 0; + AcpiGbl_NodeTypeCount [i] = 0; + } + + AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + FALSE, AcpiDbClassifyOneObject, NULL, NULL); + + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayStatistics + * + * PARAMETERS: TypeArg - Subcommand + * + * RETURN: Status + * + * DESCRIPTION: Display various statistics + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisplayStatistics ( + NATIVE_CHAR *TypeArg) +{ + UINT32 i; + UINT32 Type; + + + if (!AcpiGbl_DSDT) + { + AcpiOsPrintf ("*** Warning: There is no DSDT loaded\n"); + } + + if (!TypeArg) + { + AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); + return (AE_OK); + } + + STRUPR (TypeArg); + Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); + if (Type == (UINT32) -1) + { + AcpiOsPrintf ("Invalid or unsupported argument\n"); + return (AE_OK); + } + +#ifndef PARSER_ONLY + + AcpiDbCountNamespaceObjects (); +#endif + + + switch (Type) + { +#ifndef PARSER_ONLY + case CMD_ALLOCATIONS: + AcpiCmDumpAllocationInfo (); + break; +#endif + + case CMD_TABLES: + + AcpiOsPrintf ("ACPI Table Information:\n\n"); + if (AcpiGbl_DSDT) + { + AcpiOsPrintf ("DSDT Length:................% 7ld (0x%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); + } + break; + + case CMD_OBJECTS: + + AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n"); + + AcpiOsPrintf ("%16.16s % 10.10s % 10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS"); + + for (i = 0; i < INTERNAL_TYPE_NODE_MAX; i++) + { + AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiCmGetTypeName (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:", + NumNodes, NumObjects); + + +/* + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("ASL/AML Grammar Usage:\n\n"); + AcpiOsPrintf ("Elements Inside Methods:....% 7ld\n", NumMethodElements); + AcpiOsPrintf ("Elements Outside Methods:...% 7ld\n", NumGrammarElements - NumMethodElements); + AcpiOsPrintf ("Total Grammar Elements:.....% 7ld\n", NumGrammarElements); +*/ + break; + + case CMD_MEMORY: + + AcpiOsPrintf ("\nDynamic Memory Estimates:\n\n"); + AcpiOsPrintf ("Parse Tree without Methods:.% 7ld\n", SizeOfParseTree); + AcpiOsPrintf ("Control Method Parse Trees:.% 7ld (If parsed simultaneously)\n", SizeOfMethodTrees); + AcpiOsPrintf ("Namespace Nodes:............% 7ld (%d nodes)\n", sizeof (ACPI_NAMESPACE_NODE) * NumNodes, NumNodes); + AcpiOsPrintf ("Named Internal Objects......% 7ld\n", SizeOfAcpiObjects); + AcpiOsPrintf ("State Cache size............% 7ld\n", AcpiGbl_GenericStateCacheDepth * sizeof (ACPI_GENERIC_STATE)); + AcpiOsPrintf ("Parse Cache size............% 7ld\n", AcpiGbl_ParseCacheDepth * sizeof (ACPI_PARSE_OBJECT)); + AcpiOsPrintf ("Object Cache size...........% 7ld\n", AcpiGbl_ObjectCacheDepth * sizeof (ACPI_OPERAND_OBJECT)); + AcpiOsPrintf ("WalkState Cache size........% 7ld\n", AcpiGbl_WalkStateCacheDepth * sizeof (ACPI_WALK_STATE)); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("Cache Statistics:\n\n"); + AcpiOsPrintf ("State Cache requests........% 7ld\n", AcpiGbl_StateCacheRequests); + AcpiOsPrintf ("State Cache hits............% 7ld\n", AcpiGbl_StateCacheHits); + AcpiOsPrintf ("State Cache depth...........% 7ld (%d remaining entries)\n", AcpiGbl_GenericStateCacheDepth, + MAX_STATE_CACHE_DEPTH - AcpiGbl_GenericStateCacheDepth); + AcpiOsPrintf ("Parse Cache requests........% 7ld\n", AcpiGbl_ParseCacheRequests); + AcpiOsPrintf ("Parse Cache hits............% 7ld\n", AcpiGbl_ParseCacheHits); + AcpiOsPrintf ("Parse Cache depth...........% 7ld (%d remaining entries)\n", AcpiGbl_ParseCacheDepth, + MAX_PARSE_CACHE_DEPTH - AcpiGbl_ParseCacheDepth); + AcpiOsPrintf ("Ext Parse Cache requests....% 7ld\n", AcpiGbl_ExtParseCacheRequests); + AcpiOsPrintf ("Ext Parse Cache hits........% 7ld\n", AcpiGbl_ExtParseCacheHits); + AcpiOsPrintf ("Ext Parse Cache depth.......% 7ld (%d remaining entries)\n", AcpiGbl_ExtParseCacheDepth, + MAX_EXTPARSE_CACHE_DEPTH - AcpiGbl_ExtParseCacheDepth); + AcpiOsPrintf ("Object Cache requests.......% 7ld\n", AcpiGbl_ObjectCacheRequests); + AcpiOsPrintf ("Object Cache hits...........% 7ld\n", AcpiGbl_ObjectCacheHits); + AcpiOsPrintf ("Object Cache depth..........% 7ld (%d remaining entries)\n", AcpiGbl_ObjectCacheDepth, + MAX_OBJECT_CACHE_DEPTH - AcpiGbl_ObjectCacheDepth); + AcpiOsPrintf ("WalkState Cache requests....% 7ld\n", AcpiGbl_WalkStateCacheRequests); + AcpiOsPrintf ("WalkState Cache hits........% 7ld\n", AcpiGbl_WalkStateCacheHits); + AcpiOsPrintf ("WalkState Cache depth.......% 7ld (%d remaining entries)\n", AcpiGbl_WalkStateCacheDepth, + MAX_WALK_CACHE_DEPTH - AcpiGbl_WalkStateCacheDepth); + break; + + case CMD_MISC: + + AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n"); + AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", AcpiGbl_PsFindCount); + AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", AcpiGbl_NsLookupCount); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("Mutex usage:\n\n"); + for (i = 0; i < NUM_MTX; i++) + { + AcpiOsPrintf ("%-20s: % 7ld\n", AcpiCmGetMutexName (i), AcpiGbl_AcpiMutexInfo[i].UseCount); + } + break; + + + case CMD_SIZES: + + AcpiOsPrintf ("\nInternal object sizes:\n\n"); + + AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON)); + AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_NUMBER)); + 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 ("FieldUnit %3d\n", sizeof (ACPI_OBJECT_FIELD_UNIT)); + 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 ("Field %3d\n", sizeof (ACPI_OBJECT_FIELD)); + AcpiOsPrintf ("BankField %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD)); + AcpiOsPrintf ("IndexField %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD)); + AcpiOsPrintf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE)); + AcpiOsPrintf ("NotifyHandler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER)); + AcpiOsPrintf ("AddrHandler %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER)); + AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA)); + + AcpiOsPrintf ("\n"); + + AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJECT)); + AcpiOsPrintf ("Parse2Object %3d\n", sizeof (ACPI_PARSE2_OBJECT)); + AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT)); + AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE)); + + break; + + } + + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbutils.c b/sys/contrib/dev/acpica/dbutils.c new file mode 100644 index 0000000..a520221 --- /dev/null +++ b/sys/contrib/dev/acpica/dbutils.c @@ -0,0 +1,465 @@ +/******************************************************************************* + * + * Module Name: dbutils - AML debugger utilities + * $Revision: 32 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" +#include "acdispat.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSetOutputDestination + * + * PARAMETERS: OutputFlags - Current flags word + * + * RETURN: None + * + * DESCRIPTION: Set the current destination for debugger output. Alos sets + * the debug output level accordingly. + * + ******************************************************************************/ + +void +AcpiDbSetOutputDestination ( + UINT32 OutputFlags) +{ + + AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; + + if (OutputFlags & DB_REDIRECTABLE_OUTPUT) + { + if (OutputToFile) + { + AcpiDbgLevel = AcpiGbl_DbDebugLevel; + } + } + else + { + AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpBuffer + * + * PARAMETERS: Address - Pointer to the buffer + * + * RETURN: None + * + * DESCRIPTION: Print a portion of a buffer + * + ******************************************************************************/ + +void +AcpiDbDumpBuffer ( + UINT32 Address) +{ + + AcpiOsPrintf ("\nLocation 0x%X:\n", Address); + + AcpiDbgLevel |= TRACE_TABLES; + AcpiCmDumpBuffer ((UINT8 *) Address, 64, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDumpObject + * + * PARAMETERS: ObjDesc - External ACPI object to dump + * Level - Nesting level. + * + * RETURN: None + * + * DESCRIPTION: Dump the contents of an ACPI external object + * + ******************************************************************************/ + +void +AcpiDbDumpObject ( + ACPI_OBJECT *ObjDesc, + UINT32 Level) +{ + UINT32 i; + + + if (!ObjDesc) + { + AcpiOsPrintf ("[Null Object]\n"); + return; + } + + for (i = 0; i < Level; i++) + { + AcpiOsPrintf (" "); + } + + switch (ObjDesc->Type) + { + case ACPI_TYPE_ANY: + + AcpiOsPrintf ("[Object Reference] Value: %p\n", ObjDesc->Reference.Handle); + break; + + + case ACPI_TYPE_NUMBER: + AcpiOsPrintf ("[Number] Value: %ld (0x%lX)\n", ObjDesc->Number.Value, ObjDesc->Number.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] Value: "); + AcpiCmDumpBuffer ((UINT8 *) ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("[Package] Contains %d Elements: \n", ObjDesc->Package.Count); + + for (i = 0; i < ObjDesc->Package.Count; i++) + { + AcpiDbDumpObject (&ObjDesc->Package.Elements[i], Level+1); + } + break; + + + case INTERNAL_TYPE_REFERENCE: + AcpiOsPrintf ("[Object Reference] Value: %p\n", ObjDesc->Reference.Handle); + break; + + case ACPI_TYPE_PROCESSOR: + AcpiOsPrintf ("[Processor]\n"); + break; + + case ACPI_TYPE_POWER: + AcpiOsPrintf ("[Power Resource]\n"); + break; + + default: + + AcpiOsPrintf ("[Unknown Type] 0x%X \n", ObjDesc->Type); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbPrepNamestring + * + * PARAMETERS: Name - String to prepare + * + * RETURN: None + * + * DESCRIPTION: Translate all forward slashes and dots to backslashes. + * + ******************************************************************************/ + +void +AcpiDbPrepNamestring ( + NATIVE_CHAR *Name) +{ + + + if (!Name) + { + return; + } + + STRUPR (Name); + + /* Convert a leading forward slash to a backslash */ + + if (*Name == '/') + { + *Name = '\\'; + } + + /* Ignore a leading backslash, this is the root prefix */ + + if (*Name == '\\') + { + Name++; + } + + /* Convert all slash path separators to dots */ + + while (*Name) + { + if ((*Name == '/') || + (*Name == '\\')) + { + *Name = '.'; + } + + Name++; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSecondPassParse + * + * PARAMETERS: Root - Root of the parse tree + * + * RETURN: Status + * + * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until + * second pass to parse the control methods + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbSecondPassParse ( + ACPI_PARSE_OBJECT *Root) +{ + ACPI_PARSE_OBJECT *Op = Root; + ACPI_PARSE2_OBJECT *Method; + ACPI_PARSE_OBJECT *SearchOp; + ACPI_PARSE_OBJECT *StartOp; + ACPI_STATUS Status = AE_OK; + UINT32 BaseAmlOffset; + + + AcpiOsPrintf ("Pass two parse ....\n"); + + while (Op) + { + if (Op->Opcode == AML_METHOD_OP) + { + Method = (ACPI_PARSE2_OBJECT *) Op; + Status = AcpiPsParseAml (Op, Method->Data, Method->Length, 0, + NULL, NULL, NULL, AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + + + BaseAmlOffset = (Method->Value.Arg)->AmlOffset + 1; + StartOp = (Method->Value.Arg)->Next; + SearchOp = StartOp; + + while (SearchOp) + { + SearchOp->AmlOffset += BaseAmlOffset; + SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp); + } + + } + + if (Op->Opcode == 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)) + { + return (Status); + } + + Op = AcpiPsGetDepthNext (Root, Op); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbLocalNsLookup + * + * PARAMETERS: Name - Name to lookup + * + * RETURN: Pointer to a namespace node + * + * DESCRIPTION: Lookup a name in the ACPI namespace + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + NATIVE_CHAR *Name) +{ + NATIVE_CHAR *InternalPath; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + + + AcpiDbPrepNamestring (Name); + + /* Build an internal namestring */ + + Status = AcpiNsInternalizeName (Name, &InternalPath); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Invalid namestring: %s\n", Name); + return (NULL); + } + + /* Lookup the name */ + + /* TBD: [Investigate] what scope do we use? */ + /* Use the root scope for the start of the search */ + + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not locate name: %s %s\n", Name, AcpiCmFormatException (Status)); + } + + + AcpiCmFree (InternalPath); + + return (Node); +} + + +#endif /* ENABLE_DEBUGGER */ + + diff --git a/sys/contrib/dev/acpica/dbxface.c b/sys/contrib/dev/acpica/dbxface.c new file mode 100644 index 0000000..19cfafb --- /dev/null +++ b/sys/contrib/dev/acpica/dbxface.c @@ -0,0 +1,432 @@ +/******************************************************************************* + * + * Module Name: dbxface - AML Debugger external interfaces + * $Revision: 31 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acevents.h" +#include "acinterp.h" +#include "acdebug.h" + + +#ifdef ENABLE_DEBUGGER + +#define _COMPONENT DEBUGGER + MODULE_NAME ("dbxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiDbSingleStep + * + * PARAMETERS: WalkState - Current walk + * Op - Current executing op + * OpType - Type 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, + UINT8 OpType) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_STATUS Status = AE_OK; + UINT32 OriginalDebugLevel; + ACPI_PARSE_OBJECT *DisplayOp; + + + /* Is there a breakpoint set? */ + + if (WalkState->MethodBreakpoint) + { + /* Check if the breakpoint has been reached or passed */ + + if (WalkState->MethodBreakpoint <= Op->AmlOffset) + { + /* Hit the breakpoint, resume single step, reset breakpoint */ + + AcpiOsPrintf ("***Break*** at AML offset 0x%X\n", Op->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->Opcode == AML_NAMEDFIELD_OP) + { + return (AE_OK); + } + + switch (OpType) + { + case OPTYPE_UNDEFINED: + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + return (AE_OK); + break; + + case OPTYPE_NAMED_OBJECT: + switch (Op->Opcode) + { + case AML_NAMEPATH_OP: + return (AE_OK); + break; + } + } + + + /* + * Under certain debug conditions, display this opcode and its operands + */ + + if ((OutputToFile) || + (AcpiGbl_CmSingleStep) || + (AcpiDbgLevel & TRACE_PARSE)) + { + if ((OutputToFile) || + (AcpiDbgLevel & TRACE_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 &= ~(TRACE_PARSE | TRACE_FUNCTIONS); + Next = Op->Next; + Op->Next = NULL; + + + DisplayOp = Op; + if (Op->Parent) + { + if ((Op->Parent->Opcode == AML_IF_OP) || + (Op->Parent->Opcode == AML_WHILE_OP)) + { + DisplayOp = Op->Parent; + } + } + + /* Now we can display it */ + + AcpiDbDisplayOp (WalkState, DisplayOp, ACPI_UINT32_MAX); + + if ((Op->Opcode == AML_IF_OP) || + (Op->Opcode == AML_WHILE_OP)) + { + if (WalkState->ControlState->Common.Value) + { + AcpiOsPrintf ("Predicate was TRUE, executed block\n"); + } + else + { + AcpiOsPrintf ("Predicate is FALSE, skipping block\n"); + } + } + + else if (Op->Opcode == AML_ELSE_OP) + { + /* TBD */ + } + + + /* Restore everything */ + + Op->Next = Next; + 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->Opcode != AML_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->Opcode == AML_METHODCALL_OP) + { + AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */ + + /* Set the breakpoint on the call, it will stop execution as soon as we return */ + + /* TBD: [Future] don't kill the user breakpoint! */ + + WalkState->MethodBreakpoint = /* Op->AmlOffset + */ 1; /* Must be non-zero! */ + } + + + /* TBD: [Investigate] what are the namespace locking issues here */ + + /* AcpiCmReleaseMutex (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 */ + + AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + } + + else + { + /* Single threaded, we must get a command line ourselves */ + + /* Force output to console until a command is entered */ + + AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", DB_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", DB_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + AcpiOsGetLine (LineBuf); + } + + Status = AcpiDbCommandDispatch (LineBuf, WalkState, Op); + } + + /* AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); */ + + + /* User commands complete, continue execution of the interrupted method */ + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Init and start debugger + * + ******************************************************************************/ + +int +AcpiDbInitialize (void) +{ + + + /* Init globals */ + + Buffer = AcpiOsAllocate (BUFFER_SIZE); + + /* Initial scope is the root */ + + ScopeBuf [0] = '\\'; + ScopeBuf [1] = 0; + + + /* + * 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 */ + + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE); + AcpiCmAcquireMutex (ACPI_MTX_DEBUG_CMD_READY); + + /* Create the debug execution thread to execute commands */ + + AcpiOsQueueForExecution (0, AcpiDbExecuteThread, NULL); + } + + if (!opt_verbose) + { + INDENT_STRING = " "; + opt_disasm = TRUE; + opt_stats = FALSE; + } + + + return (0); +} + + +#endif /* ENABLE_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dsfield.c b/sys/contrib/dev/acpica/dsfield.c new file mode 100644 index 0000000..60e31df --- /dev/null +++ b/sys/contrib/dev/acpica/dsfield.c @@ -0,0 +1,546 @@ +/****************************************************************************** + * + * Module Name: dsfield - Dispatcher field routines + * $Revision: 29 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSFIELD_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsfield") + + +/* + * Field flags: Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.) + * 04 : LockRule (1 == Lock) + * 05 - 06 : UpdateRule + */ + +#define FIELD_ACCESS_TYPE_MASK 0x0F +#define FIELD_LOCK_RULE_MASK 0x10 +#define FIELD_UPDATE_RULE_MASK 0x60 + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * + * 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 = AE_AML_ERROR; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *Node; + UINT8 FieldFlags; + UINT8 AccessAttribute = 0; + UINT32 FieldBitPosition = 0; + + + FUNCTION_TRACE_PTR ("DsCreateField", Op); + + + /* First arg is the name of the parent OpRegion */ + + Arg = Op->Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name, + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, WalkState, + &RegionNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the field flags */ + + Arg = Arg->Next; + FieldFlags = (UINT8) Arg->Value.Integer; + + /* Each remaining arg is a Named Field */ + + Arg = Arg->Next; + while (Arg) + { + switch (Arg->Opcode) + { + case AML_RESERVEDFIELD_OP: + + FieldBitPosition += Arg->Value.Size; + break; + + + case AML_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute for all + * entries (until end or another AccessAs keyword) + */ + + AccessAttribute = (UINT8) Arg->Value.Integer; + FieldFlags = (UINT8) + ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || + ((UINT8) (Arg->Value.Integer >> 8))); + break; + + + case AML_NAMEDFIELD_OP: + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, + INTERNAL_TYPE_DEF_FIELD, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize an object for the new Node that is on + * the object stack + */ + + Status = AcpiAmlPrepDefFieldValue (Node, RegionNode, FieldFlags, + AccessAttribute, FieldBitPosition, Arg->Value.Size); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Keep track of bit position for *next* field */ + + FieldBitPosition += Arg->Value.Size; + break; + } + + Arg = Arg->Next; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBankField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * + * 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 = AE_AML_ERROR; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *RegisterNode; + ACPI_NAMESPACE_NODE *Node; + UINT32 BankValue; + UINT8 FieldFlags; + UINT8 AccessAttribute = 0; + UINT32 FieldBitPosition = 0; + + + FUNCTION_TRACE_PTR ("DsCreateBankField", Op); + + + /* First arg is the name of the parent OpRegion */ + + Arg = Op->Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name, + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, WalkState, + &RegionNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the Bank Register */ + + Arg = Arg->Next; + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, + INTERNAL_TYPE_BANK_FIELD_DEFN, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &RegisterNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Third arg is the BankValue */ + + Arg = Arg->Next; + BankValue = Arg->Value.Integer; + + + /* Next arg is the field flags */ + + Arg = Arg->Next; + FieldFlags = (UINT8) Arg->Value.Integer; + + /* Each remaining arg is a Named Field */ + + Arg = Arg->Next; + while (Arg) + { + switch (Arg->Opcode) + { + case AML_RESERVEDFIELD_OP: + + FieldBitPosition += Arg->Value.Size; + break; + + + case AML_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute for + * all entries (until end or another AccessAs keyword) + */ + + AccessAttribute = (UINT8) Arg->Value.Integer; + FieldFlags = (UINT8) + ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || + ((UINT8) (Arg->Value.Integer >> 8))); + break; + + + case AML_NAMEDFIELD_OP: + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, + INTERNAL_TYPE_DEF_FIELD, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize an object for the new Node that is on + * the object stack + */ + + Status = AcpiAmlPrepBankFieldValue (Node, RegionNode, RegisterNode, + BankValue, FieldFlags, AccessAttribute, + FieldBitPosition, Arg->Value.Size); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Keep track of bit position for the *next* field */ + + FieldBitPosition += Arg->Value.Size; + break; + + } + + Arg = Arg->Next; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateIndexField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * + * RETURN: Status + * + * DESCRIPTION: Create a new index field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *IndexRegisterNode; + ACPI_NAMESPACE_NODE *DataRegisterNode; + UINT8 FieldFlags; + UINT8 AccessAttribute = 0; + UINT32 FieldBitPosition = 0; + + + FUNCTION_TRACE_PTR ("DsCreateIndexField", Op); + + + Arg = Op->Value.Arg; + + /* First arg is the name of the Index register */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, + ACPI_TYPE_ANY, IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &IndexRegisterNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Second arg is the data register */ + + Arg = Arg->Next; + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, + INTERNAL_TYPE_INDEX_FIELD_DEFN, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &DataRegisterNode); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Next arg is the field flags */ + + Arg = Arg->Next; + FieldFlags = (UINT8) Arg->Value.Integer; + + + /* Each remaining arg is a Named Field */ + + Arg = Arg->Next; + while (Arg) + { + switch (Arg->Opcode) + { + case AML_RESERVEDFIELD_OP: + + FieldBitPosition += Arg->Value.Size; + break; + + + case AML_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute for all + * entries (until end or another AccessAs keyword) + */ + + AccessAttribute = (UINT8) Arg->Value.Integer; + FieldFlags = (UINT8) + ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || + ((UINT8) (Arg->Value.Integer >> 8))); + break; + + + case AML_NAMEDFIELD_OP: + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, + INTERNAL_TYPE_INDEX_FIELD, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, &Node); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Initialize an object for the new Node that is on + * the object stack + */ + + Status = AcpiAmlPrepIndexFieldValue (Node, IndexRegisterNode, DataRegisterNode, + FieldFlags, AccessAttribute, + FieldBitPosition, Arg->Value.Size); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Keep track of bit position for the *next* field */ + + FieldBitPosition += Arg->Value.Size; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("DsEnterIndexField: Invalid opcode in field list: %X\n", + Arg->Opcode)); + Status = AE_AML_ERROR; + break; + } + + Arg = Arg->Next; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/dsmethod.c b/sys/contrib/dev/acpica/dsmethod.c new file mode 100644 index 0000000..98a4ed5 --- /dev/null +++ b/sys/contrib/dev/acpica/dsmethod.c @@ -0,0 +1,644 @@ +/****************************************************************************** + * + * Module Name: dsmethod - Parser/Interpreter interface - control method parsing + * $Revision: 52 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMETHOD_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acdebug.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsmethod") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsParseMethod + * + * PARAMETERS: ObjHandle - Node of the method + * Level - Current nesting level + * Context - Points to a method counter + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Call the parser and parse the AML that is + * associated with the method. + * + * MUTEX: Assumes parser is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsParseMethod ( + ACPI_HANDLE ObjHandle) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *Op; + ACPI_NAMESPACE_NODE *Node; + ACPI_OWNER_ID OwnerId; + + + FUNCTION_TRACE_PTR ("DsParseMethod", ObjHandle); + + + /* Parameter Validation */ + + if (!ObjHandle) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + DEBUG_PRINT (ACPI_INFO, + ("DsParseMethod: **** Parsing [%4.4s] **** NamedObj=%p\n", + &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name, ObjHandle)); + + + /* Extract the method object from the method Node */ + + Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ObjDesc = Node->Object; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Create a mutex for the method if there is a concurrency limit */ + + if ((ObjDesc->Method.Concurrency != INFINITE_CONCURRENCY) && + (!ObjDesc->Method.Semaphore)) + { + Status = AcpiOsCreateSemaphore (1,ObjDesc->Method.Concurrency, + &ObjDesc->Method.Semaphore); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Allocate a new parser op to be the root of the parsed + * method tree + */ + + Op = AcpiPsAllocOp (AML_METHOD_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init new op with the method name and pointer back to the Node */ + + AcpiPsSetName (Op, Node->Name); + Op->Node = Node; + + + /* + * Parse the method, first pass + * + * The first pass load is + * where newly declared named objects are + * added into the namespace. Actual evaluation of + * the named objects (what would be called a "second + * pass") happens during the actual execution of the + * method so that operands to the named objects can + * take on dynamic run-time values. + */ + + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + Node, NULL, NULL, + AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get a new OwnerId for objects created by this method */ + + OwnerId = AcpiCmAllocateOwnerId (OWNER_TYPE_METHOD); + ObjDesc->Method.OwningId = OwnerId; + + DEBUG_PRINT (ACPI_INFO, + ("DsParseMethod: **** [%4.4s] Parsed **** NamedObj=%p Op=%p\n", + &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name, ObjHandle, Op)); + + /* Install the parsed tree in the method object */ + /* TBD: [Restructure] Obsolete field? */ + + AcpiPsDeleteParseTree (Op); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBeginMethodExecution + * + * PARAMETERS: MethodNode - Node of the method + * ObjDesc - The method object + * + * RETURN: Status + * + * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, + * increments the thread count, and waits at the method semaphore + * for clearance to execute. + * + * MUTEX: Locks/unlocks parser. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("DsBeginMethodExecution", MethodNode); + + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + + /* + * If there is a concurrency limit on this method, we need to + * obtain a unit from the method semaphore. This releases the + * interpreter if we block + */ + + if (ObjDesc->Method.Semaphore) + { + Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Method.Semaphore, + WAIT_FOREVER); + } + + + /* + * Increment the method parse tree thread count since there + * is one additional thread executing in it. If configured + * for deletion-on-exit, the parse tree will be deleted when + * the last thread completes execution of the method + */ + + ObjDesc->Method.ThreadCount++; + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCallControlMethod + * + * PARAMETERS: WalkState - Current state of the walk + * Op - Current Op to be walked + * + * RETURN: Status + * + * DESCRIPTION: Transfer execution to a called control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_WALK_LIST *WalkList, + ACPI_WALK_STATE *ThisWalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_WALK_STATE *NextWalkState; + ACPI_PARSE_STATE *ParserState; + UINT32 i; + + + FUNCTION_TRACE_PTR ("DsCallControlMethod", ThisWalkState); + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCall, execute method %p, currentstate=%p\n", + ThisWalkState->PrevOp, ThisWalkState)); + + /* + * Get the namespace entry for the control method we are about to call + */ + + MethodNode = ThisWalkState->MethodCallNode; + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Create and initialize a new parser state */ + + ParserState = AcpiPsCreateState (ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength); + if (!ParserState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiPsInitScope (ParserState, NULL); + ParserState->StartNode = MethodNode; + + + /* Create a new state for the preempting walk */ + + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, + NULL, ObjDesc, WalkList); + if (!NextWalkState) + { + /* TBD: delete parser state */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NextWalkState->WalkType = WALK_METHOD; + NextWalkState->MethodNode = MethodNode; + NextWalkState->ParserState = ParserState; + NextWalkState->ParseFlags = ThisWalkState->ParseFlags; + NextWalkState->DescendingCallback = ThisWalkState->DescendingCallback; + NextWalkState->AscendingCallback = ThisWalkState->AscendingCallback; + + /* The NextOp of the NextWalk will be the beginning of the method */ + /* TBD: [Restructure] -- obsolete? */ + + NextWalkState->NextOp = NULL; + + /* Open a new scope */ + + Status = AcpiDsScopeStackPush (MethodNode, + ACPI_TYPE_METHOD, NextWalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* + * Initialize the arguments for the method. 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. + */ + + Status = AcpiDsMethodDataInitArgs (&ThisWalkState->Operands[0], + ThisWalkState->NumOperands, + NextWalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + MethodNode, NULL, NULL, + AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + AcpiPsDeleteParseTree (Op); + + + /* + * Delete the operands on the previous walkstate operand stack + * (they were copied to new objects) + */ + + for (i = 0; i < ObjDesc->Method.ParamCount; i++) + { + AcpiCmRemoveReference (ThisWalkState->Operands [i]); + ThisWalkState->Operands [i] = NULL; + } + + /* Clear the operand stack */ + + ThisWalkState->NumOperands = 0; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCall, starting nested execution, newstate=%p\n", NextWalkState)); + + return_ACPI_STATUS (AE_OK); + + + /* On error, we must delete the new walk state */ + +Cleanup: + AcpiDsTerminateControlMethod (NextWalkState); + AcpiDsDeleteWalkState (NextWalkState); + return_ACPI_STATUS (Status); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsRestartControlMethod + * + * PARAMETERS: WalkState - State of the method when it was preempted + * Op - Pointer to new current op + * + * RETURN: Status + * + * DESCRIPTION: Restart a method that was preempted + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("DsRestartControlMethod", WalkState); + + + if (ReturnDesc) + { + if (WalkState->ReturnUsed) + { + /* + * Get the return value (if any) from the previous method. + * NULL if no return value + */ + + Status = AcpiDsResultStackPush (ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ReturnDesc); + return_ACPI_STATUS (Status); + } + } + + else + { + /* + * Delete the return value if it will not be used by the + * calling method + */ + AcpiCmRemoveReference (ReturnDesc); + } + + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsRestart: Method=%p Return=%p State=%p\n", + WalkState->MethodCallOp, ReturnDesc, WalkState)); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsTerminateControlMethod + * + * PARAMETERS: WalkState - State of the method + * + * RETURN: Status + * + * DESCRIPTION: Terminate a control method. Delete everything that the method + * created, delete all locals and arguments, and delete the parse + * tree if requested. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsTerminateControlMethod ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *MethodNode; + + + FUNCTION_TRACE_PTR ("DsTerminateControlMethod", WalkState); + + + /* The method object should be stored in the walk state */ + + ObjDesc = WalkState->MethodDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* Delete all arguments and locals */ + + AcpiDsMethodDataDeleteAll (WalkState); + + /* + * Lock the parser while we terminate this method. + * If this is the last thread executing the method, + * we have additional cleanup to perform + */ + + AcpiCmAcquireMutex (ACPI_MTX_PARSER); + + + /* Signal completion of the execution of this method if necessary */ + + if (WalkState->MethodDesc->Method.Semaphore) + { + Status = AcpiOsSignalSemaphore ( + WalkState->MethodDesc->Method.Semaphore, 1); + } + + /* Decrement the thread count on the method parse tree */ + + WalkState->MethodDesc->Method.ThreadCount--; + if (!WalkState->MethodDesc->Method.ThreadCount) + { + /* + * There are no more threads executing this method. Perform + * additional cleanup. + * + * The method Node is stored in the walk state + */ + MethodNode = WalkState->MethodNode; + /* + * Delete any namespace entries created immediately underneath + * the method + */ + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + if (MethodNode->Child) + { + AcpiNsDeleteNamespaceSubtree (MethodNode); + } + + /* + * Delete any namespace entries created anywhere else within + * the namespace + */ + AcpiNsDeleteNamespaceByOwner (WalkState->MethodDesc->Method.OwningId); + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + AcpiCmReleaseMutex (ACPI_MTX_PARSER); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/dsmthdat.c b/sys/contrib/dev/acpica/dsmthdat.c new file mode 100644 index 0000000..e6b5cec --- /dev/null +++ b/sys/contrib/dev/acpica/dsmthdat.c @@ -0,0 +1,882 @@ +/******************************************************************************* + * + * Module Name: dsmthdat - control method arguments and local variables + * $Revision: 34 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSMTHDAT_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsmthdat") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInit + * + * PARAMETERS: *ObjDesc + * + * RETURN: Status + * + * DESCRIPTION: Initialize the data structures that hold the method's arguments + * and locals. The data struct is an array of NTEs for each. + * This allows RefOf and DeRefOf to work properly for these + * special data types. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + FUNCTION_TRACE ("DsMethodDataInit"); + + /* + * WalkState fields are initialized to zero by the + * AcpiCmCallocate(). + * + * An Node is assigned to each argument and local so + * that RefOf() can return a pointer to the Node. + */ + + /* Init the method arguments */ + + for (i = 0; i < MTH_NUM_ARGS; i++) + { + MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, + NAMEOF_ARG_NTE); + + WalkState->Arguments[i].Name |= (i << 24); + WalkState->Arguments[i].DataType = ACPI_DESC_TYPE_NAMED; + WalkState->Arguments[i].Type = INTERNAL_TYPE_METHOD_ARGUMENT; + } + + /* Init the method locals */ + + for (i = 0; i < MTH_NUM_LOCALS; i++) + { + MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name, + NAMEOF_LOCAL_NTE); + + WalkState->LocalVariables[i].Name |= (i << 24); + WalkState->LocalVariables[i].DataType = ACPI_DESC_TYPE_NAMED; + WalkState->LocalVariables[i].Type = INTERNAL_TYPE_METHOD_LOCAL_VAR; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteAll + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Delete method locals and arguments. Arguments are only + * deleted if this method was called from another method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataDeleteAll"); + + + /* Delete the locals */ + + DEBUG_PRINT (ACPI_INFO, + ("MethodDeleteAll: Deleting local variables in %p\n", WalkState)); + + for (Index = 0; Index < MTH_NUM_LOCALS; Index++) + { + Object = WalkState->LocalVariables[Index].Object; + if (Object) + { + DEBUG_PRINT (TRACE_EXEC, + ("MethodDeleteAll: Deleting Local%d=%p\n", Index, Object)); + + /* Remove first */ + + WalkState->LocalVariables[Index].Object = NULL; + + /* Was given a ref when stored */ + + AcpiCmRemoveReference (Object); + } + } + + + /* Delete the arguments */ + + DEBUG_PRINT (ACPI_INFO, + ("MethodDeleteAll: Deleting arguments in %p\n", WalkState)); + + for (Index = 0; Index < MTH_NUM_ARGS; Index++) + { + Object = WalkState->Arguments[Index].Object; + if (Object) + { + DEBUG_PRINT (TRACE_EXEC, + ("MethodDeleteAll: Deleting Arg%d=%p\n", Index, Object)); + + /* Remove first */ + + WalkState->Arguments[Index].Object = NULL; + + /* Was given a ref when stored */ + + AcpiCmRemoveReference (Object); + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInitArgs + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize arguments for a method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + UINT32 Mindex; + UINT32 Pindex; + + + FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); + + + if (!Params) + { + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataInitArgs: No param list passed to method\n")); + return_ACPI_STATUS (AE_OK); + } + + /* Copy passed parameters into the new method stack frame */ + + for (Pindex = Mindex = 0; + (Mindex < MTH_NUM_ARGS) && (Pindex < MaxParamCount); + Mindex++) + { + if (Params[Pindex]) + { + /* + * A valid parameter. + * Set the current method argument to the + * Params[Pindex++] argument object descriptor + */ + Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG, Mindex, + Params[Pindex], WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + Pindex++; + } + + else + { + break; + } + } + + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataInitArgs: %d args passed to method\n", Pindex)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetEntry + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to get + * Entry - Pointer to where a pointer to the stack + * entry is returned. + * + * RETURN: Status + * + * DESCRIPTION: Get the address of the stack entry given by Type:Index + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT ***Entry) +{ + + FUNCTION_TRACE_U32 ("DsMethodDataGetEntry", Index); + + + /* + * Get the requested object. + * The stack "Type" is either a LocalVariable or an Argument + */ + + switch (Type) + { + + case MTH_TYPE_LOCAL: + + if (Index > MTH_MAX_LOCAL) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: LocalVar index %d is invalid (max %d)\n", + Index, MTH_MAX_LOCAL)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + *Entry = + (ACPI_OPERAND_OBJECT **) &WalkState->LocalVariables[Index].Object; + break; + + + case MTH_TYPE_ARG: + + if (Index > MTH_MAX_ARG) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Argument index %d is invalid (max %d)\n", + Index, MTH_MAX_ARG)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + *Entry = + (ACPI_OPERAND_OBJECT **) &WalkState->Arguments[Index].Object; + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Stack type %d is invalid\n", + Type)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataSetEntry + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to get + * Object - Object to be inserted into the stack entry + * + * RETURN: Status + * + * DESCRIPTION: Insert an object onto the method stack at entry Type:Index. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataSetEntry ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + + + FUNCTION_TRACE ("DsMethodDataSetEntry"); + + /* Get a pointer to the stack entry to set */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Increment ref count so object can't be deleted while installed */ + + AcpiCmAddReference (Object); + + /* Install the object into the stack entry */ + + *Entry = Object; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetType + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument whose type + * to get + * + * RETURN: Data type of selected Arg or Local + * Used only in ExecMonadic2()/TypeOp. + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDsMethodDataGetType ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataGetType"); + + + /* Get a pointer to the requested stack entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_VALUE ((ACPI_TYPE_NOT_FOUND)); + } + + /* Get the object from the method stack */ + + Object = *Entry; + + /* Get the object type */ + + if (!Object) + { + /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */ + return_VALUE (ACPI_TYPE_ANY); + } + + return_VALUE (Object->Common.Type); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetNte + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument whose type + * to get + * + * RETURN: Get the Node associated with a local or arg. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiDsMethodDataGetNte ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_NAMESPACE_NODE *Node = NULL; + + + FUNCTION_TRACE ("DsMethodDataGetNte"); + + + switch (Type) + { + + case MTH_TYPE_LOCAL: + + if (Index > MTH_MAX_LOCAL) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: LocalVar index %d is invalid (max %d)\n", + Index, MTH_MAX_LOCAL)); + return_PTR (Node); + } + + Node = &WalkState->LocalVariables[Index]; + break; + + + case MTH_TYPE_ARG: + + if (Index > MTH_MAX_ARG) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Argument index %d is invalid (max %d)\n", + Index, MTH_MAX_ARG)); + return_PTR (Node); + } + + Node = &WalkState->Arguments[Index]; + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetEntry: Stack type %d is invalid\n", + Type)); + break; + } + + + return_PTR (Node); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetValue + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to get + * *DestDesc - Descriptor into which selected Arg + * or Local value should be copied + * + * RETURN: Status + * + * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame + * at the current top of the method stack. + * Used only in AcpiAmlResolveToValue(). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataGetValue"); + + + /* Validate the object descriptor */ + + if (!DestDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetValue: NULL object descriptor pointer\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the requested method stack entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the object from the method stack */ + + Object = *Entry; + + + /* Examine the returned object, it must be valid. */ + + if (!Object) + { + /* + * Index points to uninitialized object stack value. + * This means that either 1) The expected argument was + * not passed to the method, or 2) A local variable + * was referenced by the method (via the ASL) + * before it was initialized. Either case is an error. + */ + + switch (Type) + { + case MTH_TYPE_ARG: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetValue: Uninitialized Arg[%d] at entry %X\n", + Index, Entry)); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); + break; + + case MTH_TYPE_LOCAL: + DEBUG_PRINT (ACPI_ERROR, + ("DsMethodDataGetValue: Uninitialized Local[%d] at entry %X\n", + Index, Entry)); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); + break; + } + } + + + /* + * Index points to initialized and valid object stack value. + * Return an additional reference to the object + */ + + *DestDesc = Object; + AcpiCmAddReference (Object); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteValue + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to delete + * + * RETURN: Status + * + * DESCRIPTION: Delete the entry at Type:Index on the method stack. Inserts + * a null into the stack slot after the object is deleted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataDeleteValue ( + UINT32 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("DsMethodDataDeleteValue"); + + + /* Get a pointer to the requested entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the current entry in this slot k */ + + Object = *Entry; + + /* + * Undefine the Arg or Local by setting its descriptor + * pointer to NULL. Locals/Args can contain both + * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs + */ + *Entry = NULL; + + + if ((Object) && + (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL))) + { + /* + * There is a valid object in this slot + * Decrement the reference count by one to balance the + * increment when the object was stored in the slot. + */ + + AcpiCmRemoveReference (Object); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataSetValue + * + * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * Index - Which localVar or argument to set + * *SrcDesc - Value to be stored + * *DestDesc - Descriptor into which *SrcDesc + * can be copied, or NULL if one must + * be allocated for the purpose. If + * provided, this descriptor will be + * used for the new value. + * + * RETURN: Status + * + * DESCRIPTION: Store a value in an Arg or Local. The SrcDesc is installed + * as the new value for the Arg or Local and the reference count + * is incremented. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT32 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Entry; + + + FUNCTION_TRACE ("DsMethodDataSetValue"); + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataSetValue: Type=%d Idx=%d Obj=%p\n", + Type, Index, SrcDesc)); + + + /* Parameter validation */ + + if (!SrcDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the requested method stack entry */ + + Status = AcpiDsMethodDataGetEntry (Type, Index, WalkState, &Entry); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (*Entry == SrcDesc) + { + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataSetValue: Obj=%p already installed!\n", + SrcDesc)); + goto Cleanup; + } + + + /* + * 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 (*Entry) + { + /* + * 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 == MTH_TYPE_ARG) && + (VALID_DESCRIPTOR_TYPE (*Entry, ACPI_DESC_TYPE_NAMED))) + { + DEBUG_PRINT (TRACE_EXEC, + ("DsMethodDataSetValue: Arg (%p) is an ObjRef(Node), storing in %p\n", + SrcDesc, *Entry)); + + /* Detach an existing object from the Node */ + + AcpiNsDetachObject ((ACPI_NAMESPACE_NODE *) *Entry); + + /* + * Store this object into the Node + * (do the indirect store) + */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) *Entry, SrcDesc, + SrcDesc->Common.Type); + return_ACPI_STATUS (Status); + } + + + /* + * Otherwise, just delete the existing object + * before storing the new one + */ + + AcpiDsMethodDataDeleteValue (Type, Index, WalkState); + } + + + /* + * Install the ObjStack descriptor (*SrcDesc) into + * the descriptor for the Arg or Local. + * Install the new object in the stack entry + * (increments the object reference count by one) + */ + + Status = AcpiDsMethodDataSetEntry (Type, Index, SrcDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + + + /* Error exit */ + +Cleanup: + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/dsobject.c b/sys/contrib/dev/acpica/dsobject.c new file mode 100644 index 0000000..71cb151 --- /dev/null +++ b/sys/contrib/dev/acpica/dsobject.c @@ -0,0 +1,805 @@ +/****************************************************************************** + * + * Module Name: dsobject - Dispatcher object management routines + * $Revision: 48 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOBJECT_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsobject") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitOneObject + * + * PARAMETERS: ObjHandle - Node + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Op Regions + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + OBJECT_TYPE_INTERNAL Type; + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + + + Info->ObjectCount++; + + /* + * We are only interested in objects owned by the table that + * was just loaded + */ + + if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId != + Info->TableDesc->TableId) + { + return (AE_OK); + } + + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + + switch (Type) + { + + case ACPI_TYPE_REGION: + + AcpiDsInitializeRegion (ObjHandle); + + Info->OpRegionCount++; + break; + + + case ACPI_TYPE_METHOD: + + Info->MethodCount++; + + DEBUG_PRINT_RAW (ACPI_OK, (".")); + + + /* + * Always parse methods to detect errors, we may delete + * the parse tree below + */ + + Status = AcpiDsParseMethod (ObjHandle); + + /* TBD: [Errors] what do we do with an error? */ + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsInitOneObject: Method %p [%4.4s] parse failed! %s\n", + ObjHandle, &((ACPI_NAMESPACE_NODE *)ObjHandle)->Name, + AcpiCmFormatException (Status))); + break; + } + + /* + * Keep the parse tree only if we are parsing all methods + * at init time (versus just-in-time) + */ + + if (AcpiGbl_WhenToParseMethods != METHOD_PARSE_AT_INIT) + { + AcpiNsDeleteNamespaceSubtree (ObjHandle); + } + + 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: None + * + * RETURN: Status + * + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeObjects ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + + + FUNCTION_TRACE ("DsInitializeObjects"); + + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsInitializeObjects: **** Starting initialization of namespace objects ****\n")); + DEBUG_PRINT_RAW (ACPI_OK, ("Parsing Methods:")); + + + Info.MethodCount = 0; + Info.OpRegionCount = 0; + Info.ObjectCount = 0; + Info.TableDesc = TableDesc; + + + /* Walk entire namespace from the supplied root */ + + Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, + ACPI_UINT32_MAX, AcpiDsInitOneObject, + &Info, NULL); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsInitializeObjects: WalkNamespace failed! %x\n", Status)); + } + + DEBUG_PRINT_RAW (ACPI_OK, + ("\n%d Control Methods found and parsed (%d nodes total)\n", + Info.MethodCount, Info.ObjectCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("DsInitializeObjects: %d Control Methods found\n", Info.MethodCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("DsInitializeObjects: %d Op Regions found\n", Info.OpRegionCount)); + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsInitObjectFromOp + * + * PARAMETERS: Op - Parser op used to init the internal object + * Opcode - AML opcode associated with the object + * ObjDesc - 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 **ObjDesc) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE2_OBJECT *ByteList; + ACPI_OPERAND_OBJECT *ArgDesc; + ACPI_OPCODE_INFO *OpInfo; + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Unknown opcode */ + + return (AE_TYPE); + } + + + /* Get and prepare the first argument */ + + switch ((*ObjDesc)->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* First arg is a number */ + + AcpiDsCreateOperand (WalkState, Op->Value.Arg); + ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; + AcpiDsObjStackPop (1, WalkState); + + /* Resolve the object (could be an arg or local) */ + + Status = AcpiAmlResolveToValue (&ArgDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ArgDesc); + return (Status); + } + + /* We are expecting a number */ + + if (ArgDesc->Common.Type != ACPI_TYPE_NUMBER) + { + DEBUG_PRINT (ACPI_ERROR, + ("InitObject: Expecting number, got obj: %p type %X\n", + ArgDesc, ArgDesc->Common.Type)); + AcpiCmRemoveReference (ArgDesc); + return (AE_TYPE); + } + + /* Get the value, delete the internal object */ + + (*ObjDesc)->Buffer.Length = (UINT32) ArgDesc->Number.Value; + AcpiCmRemoveReference (ArgDesc); + + /* Allocate the buffer */ + + if ((*ObjDesc)->Buffer.Length == 0) + { + (*ObjDesc)->Buffer.Pointer = NULL; + REPORT_WARNING (("Buffer created with zero length in AML\n")); + break; + } + + else + { + (*ObjDesc)->Buffer.Pointer = + AcpiCmCallocate ((*ObjDesc)->Buffer.Length); + + if (!(*ObjDesc)->Buffer.Pointer) + { + return (AE_NO_MEMORY); + } + } + + /* + * Second arg is the buffer data (optional) + * ByteList can be either individual bytes or a + * string initializer! + */ + + /* skip first arg */ + Arg = Op->Value.Arg; + ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next; + if (ByteList) + { + if (ByteList->Opcode != AML_BYTELIST_OP) + { + DEBUG_PRINT (ACPI_ERROR, + ("InitObject: Expecting bytelist, got: %x\n", + ByteList)); + return (AE_TYPE); + } + + MEMCPY ((*ObjDesc)->Buffer.Pointer, ByteList->Data, + (*ObjDesc)->Buffer.Length); + } + + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * When called, an internal package object has already + * been built and is pointed to by *ObjDesc. + * AcpiDsBuildInternalObject build another internal + * package object, so remove reference to the original + * so that it is deleted. Error checking is done + * within the remove reference function. + */ + AcpiCmRemoveReference(*ObjDesc); + + Status = AcpiDsBuildInternalObject (WalkState, Op, ObjDesc); + break; + + case ACPI_TYPE_NUMBER: + (*ObjDesc)->Number.Value = Op->Value.Integer; + break; + + + case ACPI_TYPE_STRING: + (*ObjDesc)->String.Pointer = Op->Value.String; + (*ObjDesc)->String.Length = STRLEN (Op->Value.String); + break; + + + case ACPI_TYPE_METHOD: + break; + + + case INTERNAL_TYPE_REFERENCE: + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + case OPTYPE_LOCAL_VARIABLE: + + /* Split the opcode into a base opcode + offset */ + + (*ObjDesc)->Reference.OpCode = AML_LOCAL_OP; + (*ObjDesc)->Reference.Offset = Opcode - AML_LOCAL_OP; + break; + + case OPTYPE_METHOD_ARGUMENT: + + /* Split the opcode into a base opcode + offset */ + + (*ObjDesc)->Reference.OpCode = AML_ARG_OP; + (*ObjDesc)->Reference.Offset = Opcode - AML_ARG_OP; + break; + + default: /* Constants, Literals, etc.. */ + + if (Op->Opcode == AML_NAMEPATH_OP) + { + /* Node was saved in Op */ + + (*ObjDesc)->Reference.Node = Op->Node; + } + + (*ObjDesc)->Reference.OpCode = Opcode; + break; + } + + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("InitObject: Unimplemented data type: %x\n", + (*ObjDesc)->Common.Type)); + + break; + } + + return (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsBuildInternalSimpleObj + * + * PARAMETERS: Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op object to the equivalent namespace object + * Simple objects are any objects other than a package object! + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalSimpleObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + OBJECT_TYPE_INTERNAL Type; + ACPI_STATUS Status; + UINT32 Length; + char *Name; + + + FUNCTION_TRACE ("DsBuildInternalSimpleObj"); + + + if (Op->Opcode == AML_NAMEPATH_OP) + { + /* + * This is an object reference. If The name was + * previously looked up in the NS, it is stored in this op. + * Otherwise, go ahead and look it up now + */ + + if (!Op->Node) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + Op->Value.String, ACPI_TYPE_ANY, + IMODE_EXECUTE, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, + NULL, + (ACPI_NAMESPACE_NODE **)&(Op->Node)); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + Name = NULL; + AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Value.String, &Length, &Name); + + if (Name) + { + REPORT_WARNING (("Reference %s AML 0x%X not found\n", + Name, Op->AmlOffset)); + AcpiCmFree (Name); + } + else + { + REPORT_WARNING (("Reference %s AML 0x%X not found\n", + Op->Value.String, Op->AmlOffset)); + } + *ObjDescPtr = NULL; + return_ACPI_STATUS (AE_OK); + } + + return_ACPI_STATUS (Status); + } + } + + /* + * The reference will be a Reference + * TBD: [Restructure] unless we really need a separate + * type of INTERNAL_TYPE_REFERENCE change + * AcpiDsMapOpcodeToDataType to handle this case + */ + Type = INTERNAL_TYPE_REFERENCE; + } + else + { + Type = AcpiDsMapOpcodeToDataType (Op->Opcode, NULL); + } + + + /* Create and init the internal ACPI object */ + + ObjDesc = AcpiCmCreateInternalObject (Type); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiDsInitObjectFromOp (WalkState, Op, + Op->Opcode, &ObjDesc); + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); + } + + *ObjDescPtr = ObjDesc; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsBuildInternalPackageObj + * + * PARAMETERS: Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("DsBuildInternalPackageObj"); + + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* The first argument must be the package length */ + + Arg = Op->Value.Arg; + ObjDesc->Package.Count = Arg->Value.Integer; + + /* + * Allocate the array of pointers (ptrs to the + * individual objects) Add an extra pointer slot so + * that the list is always null terminated. + */ + + ObjDesc->Package.Elements = + AcpiCmCallocate ((ObjDesc->Package.Count + 1) * + sizeof (void *)); + + if (!ObjDesc->Package.Elements) + { + /* Package vector allocation failure */ + + REPORT_ERROR (("DsBuildInternalPackageObj: Package vector allocation failure\n")); + + AcpiCmDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.NextElement = ObjDesc->Package.Elements; + + /* + * Now init the elements of the package + */ + + Arg = Arg->Next; + while (Arg) + { + if (Arg->Opcode == AML_PACKAGE_OP) + { + Status = AcpiDsBuildInternalPackageObj (WalkState, Arg, + ObjDesc->Package.NextElement); + } + + else + { + Status = AcpiDsBuildInternalSimpleObj (WalkState, Arg, + ObjDesc->Package.NextElement); + } + + ObjDesc->Package.NextElement++; + Arg = Arg->Next; + } + + *ObjDescPtr = ObjDesc; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsBuildInternalObject + * + * PARAMETERS: 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 + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_STATUS Status; + + + if (Op->Opcode == AML_PACKAGE_OP) + { + Status = AcpiDsBuildInternalPackageObj (WalkState, Op, + ObjDescPtr); + } + + else + { + Status = AcpiDsBuildInternalSimpleObj (WalkState, Op, + ObjDescPtr); + } + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsCreateNode + * + * PARAMETERS: Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("DsCreateNode", Op); + + + if (!Op->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->Value.Arg, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Re-type the object according to it's argument */ + + Node->Type = ObjDesc->Common.Type; + + /* Init obj */ + + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) Node->Type); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + return_ACPI_STATUS (Status); + + +Cleanup: + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/dsopcode.c b/sys/contrib/dev/acpica/dsopcode.c new file mode 100644 index 0000000..b3d63c1 --- /dev/null +++ b/sys/contrib/dev/acpica/dsopcode.c @@ -0,0 +1,1070 @@ +/****************************************************************************** + * + * Module Name: dsopcode - Dispatcher Op Region support and handling of + * "control" opcodes + * $Revision: 21 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSOPCODE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dsopcode") + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetFieldUnitArguments + * + * PARAMETERS: ObjDesc - A valid FieldUnit object + * + * RETURN: Status. + * + * DESCRIPTION: Get FieldUnit Buffer and Index. This implements the late + * evaluation of these field attributes. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetFieldUnitArguments ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_OPERAND_OBJECT *ExtraDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *FieldOp; + ACPI_STATUS Status; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE_PTR ("DsGetFieldUnitArguments", ObjDesc); + + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + + /* Get the AML pointer (method object) and FieldUnit node */ + + ExtraDesc = ObjDesc->FieldUnit.Extra; + Node = ObjDesc->FieldUnit.Node; + + DEBUG_PRINT (TRACE_EXEC, + ("DsGetFieldUnitArguments: [%4.4s] FieldUnit JIT Init\n", + &Node->Name)); + + + /* + * Allocate a new parser op to be the root of the parsed + * OpRegion tree + */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Save the Node for use in AcpiPsParseAml */ + + Op->Node = AcpiNsGetParentObject (Node); + + /* Get a handle to the parent ACPI table */ + + Status = AcpiTbHandleToObject (Node->OwnerId, &TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Pass1: Parse the entire FieldUnit declaration */ + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, 0, + NULL, NULL, NULL, AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + if (ACPI_FAILURE (Status)) + { + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); + } + + + /* Get and init the actual FielUnitOp created above */ + + FieldOp = Op->Value.Arg; + Op->Node = Node; + + + FieldOp = Op->Value.Arg; + FieldOp->Node = Node; + AcpiPsDeleteParseTree (Op); + + /* AcpiEvaluate the address and length arguments for the OpRegion */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + Op->Node = AcpiNsGetParentObject (Node); + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + NULL /*MethodDesc*/, NULL, NULL, + AcpiDsExecBeginOp, AcpiDsExecEndOp); + /* All done with the parse tree, delete it */ + + AcpiPsDeleteParseTree (Op); + + + /* + * The pseudo-method object is no longer needed since the region is + * now initialized + */ + AcpiCmRemoveReference (ObjDesc->FieldUnit.Extra); + ObjDesc->FieldUnit.Extra = NULL; + + 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_OPERAND_OBJECT *ExtraDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *RegionOp; + ACPI_STATUS Status; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); + + + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + return_ACPI_STATUS (AE_OK); + } + + + /* Get the AML pointer (method object) and region node */ + + ExtraDesc = ObjDesc->Region.Extra; + Node = ObjDesc->Region.Node; + + DEBUG_PRINT (TRACE_EXEC, + ("DsGetRegionArguments: [%4.4s] OpRegion JIT Init\n", + &Node->Name)); + + /* + * Allocate a new parser op to be the root of the parsed + * OpRegion tree + */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Save the Node for use in AcpiPsParseAml */ + + Op->Node = AcpiNsGetParentObject (Node); + + /* Get a handle to the parent ACPI table */ + + Status = AcpiTbHandleToObject (Node->OwnerId, &TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Parse the entire OpRegion declaration, creating a parse tree */ + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, 0, + NULL, NULL, NULL, AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + + if (ACPI_FAILURE (Status)) + { + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); + } + + + /* Get and init the actual RegionOp created above */ + + RegionOp = Op->Value.Arg; + Op->Node = Node; + + + RegionOp = Op->Value.Arg; + RegionOp->Node = Node; + AcpiPsDeleteParseTree (Op); + + /* AcpiEvaluate the address and length arguments for the OpRegion */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return (AE_NO_MEMORY); + } + + Op->Node = AcpiNsGetParentObject (Node); + + Status = AcpiPsParseAml (Op, ExtraDesc->Extra.Pcode, + ExtraDesc->Extra.PcodeLength, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + NULL /*MethodDesc*/, NULL, NULL, + AcpiDsExecBeginOp, AcpiDsExecEndOp); + + /* All done with the parse tree, delete it */ + + AcpiPsDeleteParseTree (Op); + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsInitializeRegion + * + * PARAMETERS: Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: + * + ****************************************************************************/ + +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: AcpiDsEvalFieldUnitOperands + * + * PARAMETERS: Op - A valid FieldUnit Op object + * + * RETURN: Status + * + * DESCRIPTION: Get FieldUnit Buffer and Index + * Called from AcpiDsExecEndOp during FieldUnit parse tree walk + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsEvalFieldUnitOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *FieldDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + UINT32 Offset; + UINT32 BitOffset; + UINT16 BitCount; + + + ACPI_OPERAND_OBJECT *ResDesc = NULL; + ACPI_OPERAND_OBJECT *CntDesc = NULL; + ACPI_OPERAND_OBJECT *OffDesc = NULL; + ACPI_OPERAND_OBJECT *SrcDesc = NULL; + UINT32 NumOperands = 3; + + + FUNCTION_TRACE_PTR ("DsEvalFieldUnitOperands", Op); + + + /* + * This is where we evaluate the address and length fields of the OpFieldUnit declaration + */ + + Node = Op->Node; + + /* NextOp points to the op that holds the Buffer */ + NextOp = Op->Value.Arg; + + /* AcpiEvaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + FieldDesc = AcpiNsGetAttachedObject (Node); + if (!FieldDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Op->Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Op->Opcode), + NumOperands, "after AcpiAmlResolveOperands"); + + + /* Get the operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + if (AML_CREATE_FIELD_OP == Op->Opcode) + { + NumOperands = 4; + Status |= AcpiDsObjStackPopObject (&CntDesc, WalkState); + } + + Status |= AcpiDsObjStackPopObject (&OffDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&SrcDesc, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecCreateField/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Op->Opcode), Status)); + + goto Cleanup; + } + + + Offset = (UINT32) OffDesc->Number.Value; + + + /* + * If ResDesc is a Name, it will be a direct name pointer after + * AcpiAmlResolveOperands() + */ + + if (!VALID_DESCRIPTOR_TYPE (ResDesc, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField (%s): destination must be a Node\n", + AcpiPsGetOpcodeName (Op->Opcode))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + + switch (Op->Opcode) + { + + /* DefCreateBitField */ + + case AML_BIT_FIELD_OP: + + /* Offset is in bits, Field is a bit */ + + BitOffset = Offset; + BitCount = 1; + break; + + + /* DefCreateByteField */ + + case AML_BYTE_FIELD_OP: + + /* Offset is in bytes, field is a byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + break; + + + /* DefCreateWordField */ + + case AML_WORD_FIELD_OP: + + /* Offset is in bytes, field is a word */ + + BitOffset = 8 * Offset; + BitCount = 16; + break; + + + /* DefCreateDWordField */ + + case AML_DWORD_FIELD_OP: + + /* Offset is in bytes, field is a dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + break; + + + /* DefCreateField */ + + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + BitOffset = Offset; + BitCount = (UINT16) CntDesc->Number.Value; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Internal error - unknown field creation opcode %02x\n", + Op->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Setup field according to the object type + */ + + switch (SrcDesc->Common.Type) + { + + /* SourceBuff := TermArg=>Buffer */ + + case ACPI_TYPE_BUFFER: + + if (BitOffset + (UINT32) BitCount > + (8 * (UINT32) SrcDesc->Buffer.Length)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Field exceeds Buffer %d > %d\n", + BitOffset + (UINT32) BitCount, + 8 * (UINT32) SrcDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + + /* Construct the remainder of the field object */ + + FieldDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC; + FieldDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK; + FieldDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE; + FieldDesc->FieldUnit.Length = BitCount; + FieldDesc->FieldUnit.BitOffset = (UINT8) (BitOffset % 8); + FieldDesc->FieldUnit.Offset = DIV_8 (BitOffset); + FieldDesc->FieldUnit.Container = SrcDesc; + + /* Reference count for SrcDesc inherits FieldDesc count */ + + SrcDesc->Common.ReferenceCount = (UINT16) (SrcDesc->Common.ReferenceCount + + FieldDesc->Common.ReferenceCount); + + break; + + + /* Improper object type */ + + default: + + if ((SrcDesc->Common.Type > (UINT8) INTERNAL_TYPE_REFERENCE) || + !AcpiCmValidObjectType (SrcDesc->Common.Type)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in invalid object type - 0x%X\n", + SrcDesc->Common.Type)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in improper object type - %s\n", + AcpiCmGetTypeName (SrcDesc->Common.Type))); + } + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + if (AML_CREATE_FIELD_OP == Op->Opcode) + { + /* Delete object descriptor unique to CreateField */ + + AcpiCmRemoveReference (CntDesc); + CntDesc = NULL; + } + + +Cleanup: + + /* Always delete the operands */ + + AcpiCmRemoveReference (OffDesc); + AcpiCmRemoveReference (SrcDesc); + + if (AML_CREATE_FIELD_OP == Op->Opcode) + { + AcpiCmRemoveReference (CntDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); /* Result descriptor */ + } + + else + { + /* Now the address and length are valid for this opFieldUnit */ + + FieldDesc->FieldUnit.Flags |= AOPOBJ_DATA_VALID; + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsEvalRegionOperands + * + * PARAMETERS: 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; + + + FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); + + + /* + * This is where we evaluate the address and length fields of the OpRegion declaration + */ + + Node = Op->Node; + + /* NextOp points to the op that holds the SpaceID */ + NextOp = Op->Value.Arg; + + /* NextOp points to address op */ + NextOp = NextOp->Next; + + /* AcpiEvaluate/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); + } + + /* Get the length and save it */ + + /* Top of stack */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; + + ObjDesc->Region.Length = (UINT32) OperandDesc->Number.Value; + AcpiCmRemoveReference (OperandDesc); + + /* Get the address and save it */ + + /* Top of stack - 1 */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; + + ObjDesc->Region.Address = OperandDesc->Number.Value; + AcpiCmRemoveReference (OperandDesc); + + + DEBUG_PRINT (TRACE_EXEC, + ("DsEvalRegionOperands: RgnObj %p Addr %X Len %X\n", + ObjDesc, 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: 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; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("BeginControlOp: Op=%p Opcode=%2.2X State=%p\n", Op, + Op->Opcode, WalkState)); + + switch (Op->Opcode) + { + case AML_IF_OP: + case AML_WHILE_OP: + + /* + * IF/WHILE: Create a new control state to manage these + * constructs. We need to manage these as a stack, in order + * to handle nesting. + */ + + ControlState = AcpiCmCreateControlState (); + if (!ControlState) + { + Status = AE_NO_MEMORY; + break; + } + + AcpiCmPushGenericState (&WalkState->ControlState, ControlState); + + /* + * Save a pointer to the predicate for multiple executions + * of a loop + */ + WalkState->ControlState->Control.AmlPredicateStart = + WalkState->ParserState->Aml - 1; + /* TBD: can this be removed? */ + /*AcpiPsPkgLengthEncodingSize (GET8 (WalkState->ParserState->Aml));*/ + 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; + + + switch (Op->Opcode) + { + case AML_IF_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [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 = + AcpiCmPopGenericState (&WalkState->ControlState); + + AcpiCmDeleteGenericState (ControlState); + + break; + + + case AML_ELSE_OP: + + break; + + + case AML_WHILE_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [WHILE_OP] Op=%p\n", Op)); + + if (WalkState->ControlState->Common.Value) + { + /* Predicate was true, go back and evaluate it again! */ + + Status = AE_CTRL_PENDING; + } + + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [WHILE_OP] termination! Op=%p\n", Op)); + + /* Pop this control state and free it */ + + ControlState = + AcpiCmPopGenericState (&WalkState->ControlState); + + WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; + AcpiCmDeleteGenericState (ControlState); + + break; + + + case AML_RETURN_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: [RETURN_OP] Op=%p Arg=%p\n",Op, Op->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->Value.Arg) + { + /* Return statement has an immediate operand */ + + Status = AcpiDsCreateOperands (WalkState, Op->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 = AcpiAmlResolveToValue (&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->NumResults > 0) + { + /* + * The return value has come from a previous calculation. + * + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + */ + + Status = AcpiAmlResolveToValue (&WalkState->Results [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + WalkState->ReturnDesc = WalkState->Results [0]; + } + + else + { + /* No return operand */ + + if (WalkState->NumOperands) + { + AcpiCmRemoveReference (WalkState->Operands [0]); + } + + WalkState->Operands [0] = NULL; + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; + } + + + DEBUG_PRINT (TRACE_DISPATCH, + ("EndControlOp: Completed RETURN_OP State=%p, RetVal=%p\n", + WalkState, WalkState->ReturnDesc)); + + /* End the control method execution right now */ + Status = AE_CTRL_TERMINATE; + break; + + + case AML_NOOP_OP: + + /* Just do nothing! */ + break; + + + case AML_BREAK_POINT_OP: + + /* Call up to the OS dependent layer to handle this */ + + AcpiOsBreakpoint (NULL); + + /* If it returns, we are done! */ + + break; + + + case AML_BREAK_OP: + + DEBUG_PRINT (ACPI_INFO, + ("EndControlOp: Break to end of current package, Op=%p\n", Op)); + + /* + * As per the ACPI specification: + * "The break operation causes the current package + * execution to complete" + * "Break -- Stop executing the current code package + * at this point" + * + * Returning AE_FALSE here will cause termination of + * the current package, and execution will continue one + * level up, starting with the completion of the parent Op. + */ + + Status = AE_CTRL_FALSE; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("EndControlOp: Unknown control opcode=%X Op=%p\n", + Op->Opcode, Op)); + + Status = AE_AML_BAD_OPCODE; + break; + } + + + return (Status); +} + diff --git a/sys/contrib/dev/acpica/dsutils.c b/sys/contrib/dev/acpica/dsutils.c new file mode 100644 index 0000000..28e01c5 --- /dev/null +++ b/sys/contrib/dev/acpica/dsutils.c @@ -0,0 +1,932 @@ +/******************************************************************************* + * + * Module Name: dsutils - Dispatcher utilities + * $Revision: 45 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSUTILS_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT PARSER + MODULE_NAME ("dsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsIsResultUsed + * + * PARAMETERS: Op + * ResultObj + * WalkState + * + * RETURN: Status + * + * DESCRIPTION: Check if a result object will be used by the parent + * + ******************************************************************************/ + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPCODE_INFO *ParentInfo; + + + FUNCTION_TRACE_PTR ("DsIsResultUsed", Op); + + + /* Must have both an Op and a Result Object */ + + if (!Op) + { + DEBUG_PRINT (ACPI_ERROR, ("DsIsResultUsed: Null Op\n")); + return_VALUE (TRUE); + } + + + /* + * If there is no parent, the result can't possibly be used! + * (An executing method typically has no parent, since each + * method is parsed separately) However, a method that is + * invoked from another method has a parent. + */ + if (!Op->Parent) + { + return_VALUE (FALSE); + } + + + /* + * Get info on the parent. The root Op is AML_SCOPE + */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode); + if (ACPI_GET_OP_TYPE (ParentInfo) != ACPI_OP_TYPE_OPCODE) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsIsResultUsed: Unknown parent opcode. Op=%X\n", + Op)); + + return_VALUE (FALSE); + } + + + /* + * Decide what to do with the result based on the parent. If + * the parent opcode will not use the result, delete the object. + * Otherwise leave it as is, it will be deleted when it is used + * as an operand later. + */ + + switch (ACPI_GET_OP_CLASS (ParentInfo)) + { + /* + * In these cases, the parent will never use the return object + */ + case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ + + switch (Op->Parent->Opcode) + { + case AML_RETURN_OP: + + /* Never delete the return value associated with a return opcode */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsIsResultUsed: Result used, [RETURN] opcode=%X Op=%X\n", + Op->Opcode, Op)); + return_VALUE (TRUE); + break; + + 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 == CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("DsIsResultUsed: Result used as a predicate, [IF/WHILE] opcode=%X Op=%X\n", + Op->Opcode, Op)); + return_VALUE (TRUE); + } + + break; + } + + + /* Fall through to not used case below */ + + + + case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsIsResultUsed: Result not used, Parent opcode=%X Op=%X\n", + Op->Opcode, Op)); + + return_VALUE (FALSE); + break; + + /* + * In all other cases. the parent will actually use the return + * object, so keep it. + */ + default: + break; + } + + return_VALUE (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteResultIfNotUsed + * + * PARAMETERS: Op + * ResultObj + * WalkState + * + * RETURN: Status + * + * DESCRIPTION: Used after interpretation of an opcode. If there is an internal + * result descriptor, check if the parent opcode will actually use + * this result. If not, delete the result now so that it will + * not become orphaned. + * + ******************************************************************************/ + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj); + + + if (!Op) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsDeleteResultIfNotUsed: Null Op=%X\n", + Op)); + return_VOID; + } + + if (!ResultObj) + { + return_VOID; + } + + + if (!AcpiDsIsResultUsed (Op, WalkState)) + { + /* + * Must pop the result stack (ObjDesc should be equal + * to ResultObj) + */ + + Status = AcpiDsResultStackPop (&ObjDesc, WalkState); + if (ACPI_SUCCESS (Status)) + { + AcpiCmRemoveReference (ResultObj); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperand + * + * PARAMETERS: WalkState + * Arg + * + * RETURN: Status + * + * DESCRIPTION: Translate a parse tree object that is an argument to an AML + * opcode to the equivalent interpreter object. This may include + * looking up a name or entering a new name into the internal + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_STATUS Status = AE_OK; + NATIVE_CHAR *NameString; + UINT32 NameLength; + OBJECT_TYPE_INTERNAL DataType; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ParentOp; + UINT16 Opcode; + UINT32 Flags; + OPERATING_MODE InterpreterMode; + + + FUNCTION_TRACE_PTR ("DsCreateOperand", Arg); + + + /* A valid name must be looked up in the namespace */ + + if ((Arg->Opcode == AML_NAMEPATH_OP) && + (Arg->Value.String)) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperand: Getting a name: Arg=%p\n", Arg)); + + /* Get the entire name string from the AML stream */ + + Status = AcpiAmlGetNameString (ACPI_TYPE_ANY, + Arg->Value.Buffer, + &NameString, + &NameLength); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * All prefixes have been handled, and the name is + * in NameString + */ + + /* + * Differentiate between a namespace "create" operation + * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. + * IMODE_EXECUTE) in order to support the creation of + * namespace objects during the execution of control methods. + */ + + ParentOp = Arg->Parent; + if ((AcpiPsIsNodeOp (ParentOp->Opcode)) && + (ParentOp->Opcode != AML_METHODCALL_OP) && + (ParentOp->Opcode != AML_NAMEPATH_OP)) + { + /* Enter name into namespace if not found */ + + InterpreterMode = IMODE_LOAD_PASS2; + } + + else + { + /* Return a failure if name not found */ + + InterpreterMode = IMODE_EXECUTE; + } + + Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, + ACPI_TYPE_ANY, InterpreterMode, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, + WalkState, + (ACPI_NAMESPACE_NODE **) &ObjDesc); + + /* Free the namestring created above */ + + AcpiCmFree (NameString); + + /* + * The only case where we pass through (ignore) a NOT_FOUND + * error is for the CondRefOf opcode. + */ + + if (Status == AE_NOT_FOUND) + { + if (ParentOp->Opcode == 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_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; + } + } + + /* 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); + } + DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + + + else + { + /* Check for null name case */ + + if (Arg->Opcode == AML_NAMEPATH_OP) + { + /* + * If the name is null, this means that this is an + * optional result parameter that was not specified + * in the original ASL. Create an Reference for a + * placeholder + */ + Opcode = AML_ZERO_OP; /* Has no arguments! */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperand: Null namepath: Arg=%p\n", Arg)); + + /* + * TBD: [Investigate] anything else needed for the + * zero op lvalue? + */ + } + + else + { + Opcode = Arg->Opcode; + } + + + /* Get the data type of the argument */ + + DataType = AcpiDsMapOpcodeToDataType (Opcode, &Flags); + if (DataType == INTERNAL_TYPE_INVALID) + { + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + if (Flags & OP_HAS_RETURN_VALUE) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperand: Argument previously created, already stacked \n")); + + DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (WalkState->Operands [WalkState->NumOperands - 1], WalkState)); + + /* + * Use value that was already previously returned + * by the evaluation of this argument + */ + + Status = AcpiDsResultStackPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* + * Only error is underflow, and this indicates + * a missing or null operand! + */ + DEBUG_PRINT (ACPI_ERROR, + ("DsCreateOperand: Could not pop result\n")); + return_ACPI_STATUS (Status); + } + + } + + else + { + /* Create an ACPI_INTERNAL_OBJECT for the argument */ + + ObjDesc = AcpiCmCreateInternalObject (DataType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new object */ + + Status = AcpiDsInitObjectFromOp (WalkState, Arg, + Opcode, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmDeleteObjectDesc (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); + } + + DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperands + * + * PARAMETERS: FirstArg - First argument of a parser argument tree + * + * RETURN: Status + * + * DESCRIPTION: Convert an operator's arguments from a parse tree format to + * namespace objects and place those argument object on the object + * stack in preparation for evaluation by the interpreter. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg; + UINT32 ArgsPushed = 0; + + + FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg); + + Arg = FirstArg; + + + /* For all arguments in the list... */ + + while (Arg) + { + + Status = AcpiDsCreateOperand (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("DsCreateOperands: Arg #%d (%p) done, Arg1=%p\n", + ArgsPushed, Arg, FirstArg)); + + /* Move on to next argument, if any */ + + Arg = Arg->Next; + ArgsPushed++; + } + + 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 (ArgsPushed, WalkState); + + DEBUG_PRINT (ACPI_ERROR, + ("DsCreateOperands: Error while creating Arg %d - %s\n", + (ArgsPushed+1), AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * 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; + + + FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState); + + + /* + * Attempt to resolve each of the valid operands + * Method arguments are passed by value, not by reference + */ + + /* + * TBD: [Investigate] Note from previous parser: + * RefOf problem with AcpiAmlResolveToValue() conversion. + */ + + for (i = 0; i < WalkState->NumOperands; i++) + { + Status = AcpiAmlResolveToValue (&WalkState->Operands[i], WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMapOpcodeToDataType + * + * PARAMETERS: Opcode - AML opcode to map + * OutFlags - Additional info about the opcode + * + * RETURN: The ACPI type associated with the opcode + * + * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type, + * if any. If the opcode returns a value as part of the + * intepreter execution, a flag is returned in OutFlags. + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDsMapOpcodeToDataType ( + UINT16 Opcode, + UINT32 *OutFlags) +{ + OBJECT_TYPE_INTERNAL DataType = INTERNAL_TYPE_INVALID; + ACPI_OPCODE_INFO *OpInfo; + UINT32 Flags = 0; + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Unknown opcode */ + + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unknown AML opcode: %x\n", + Opcode)); + + return (DataType); + } + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + + case OPTYPE_LITERAL: + + switch (Opcode) + { + case AML_BYTE_OP: + case AML_WORD_OP: + case AML_DWORD_OP: + + DataType = ACPI_TYPE_NUMBER; + break; + + + case AML_STRING_OP: + + DataType = ACPI_TYPE_STRING; + break; + + case AML_NAMEPATH_OP: + DataType = INTERNAL_TYPE_REFERENCE; + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unknown (type LITERAL) AML opcode: %x\n", + Opcode)); + break; + } + break; + + + case OPTYPE_DATA_TERM: + + switch (Opcode) + { + case AML_BUFFER_OP: + + DataType = ACPI_TYPE_BUFFER; + break; + + case AML_PACKAGE_OP: + + DataType = ACPI_TYPE_PACKAGE; + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unknown (type DATA_TERM) AML opcode: %x\n", + Opcode)); + break; + } + break; + + + case OPTYPE_CONSTANT: + case OPTYPE_METHOD_ARGUMENT: + case OPTYPE_LOCAL_VARIABLE: + + DataType = INTERNAL_TYPE_REFERENCE; + break; + + + case OPTYPE_MONADIC2: + case OPTYPE_MONADIC2R: + case OPTYPE_DYADIC2: + case OPTYPE_DYADIC2R: + case OPTYPE_DYADIC2S: + case OPTYPE_INDEX: + case OPTYPE_MATCH: + case OPTYPE_RETURN: + + Flags = OP_HAS_RETURN_VALUE; + DataType = ACPI_TYPE_ANY; + break; + + case OPTYPE_METHOD_CALL: + + Flags = OP_HAS_RETURN_VALUE; + DataType = ACPI_TYPE_METHOD; + break; + + + case OPTYPE_NAMED_OBJECT: + + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); + break; + + + case OPTYPE_DYADIC1: + case OPTYPE_CONTROL: + + /* No mapping needed at this time */ + + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("MapOpcode: Unimplemented data type opcode: %x\n", + Opcode)); + break; + } + + /* Return flags to caller if requested */ + + if (OutFlags) + { + *OutFlags = Flags; + } + + return (DataType); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMapNamedOpcodeToDataType + * + * PARAMETERS: Opcode - The Named AML opcode to map + * + * RETURN: The ACPI type associated with the named opcode + * + * DESCRIPTION: Convert a raw Named AML opcode to the associated data type. + * Named opcodes are a subsystem of the AML opcodes. + * + ******************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiDsMapNamedOpcodeToDataType ( + UINT16 Opcode) +{ + OBJECT_TYPE_INTERNAL DataType; + + + /* Decode Opcode */ + + switch (Opcode) + { + case AML_SCOPE_OP: + DataType = INTERNAL_TYPE_SCOPE; + break; + + case AML_DEVICE_OP: + DataType = ACPI_TYPE_DEVICE; + break; + + case AML_THERMAL_ZONE_OP: + DataType = ACPI_TYPE_THERMAL; + break; + + case AML_METHOD_OP: + DataType = ACPI_TYPE_METHOD; + break; + + case AML_POWER_RES_OP: + DataType = ACPI_TYPE_POWER; + break; + + case AML_PROCESSOR_OP: + DataType = ACPI_TYPE_PROCESSOR; + break; + + case AML_DEF_FIELD_OP: /* DefFieldOp */ + DataType = INTERNAL_TYPE_DEF_FIELD_DEFN; + break; + + case AML_INDEX_FIELD_OP: /* IndexFieldOp */ + DataType = INTERNAL_TYPE_INDEX_FIELD_DEFN; + break; + + case AML_BANK_FIELD_OP: /* BankFieldOp */ + DataType = INTERNAL_TYPE_BANK_FIELD_DEFN; + break; + + case AML_NAMEDFIELD_OP: /* NO CASE IN ORIGINAL */ + DataType = ACPI_TYPE_ANY; + break; + + case AML_NAME_OP: /* NameOp - special code in original */ + case AML_NAMEPATH_OP: + DataType = ACPI_TYPE_ANY; + break; + + case AML_ALIAS_OP: + DataType = INTERNAL_TYPE_ALIAS; + break; + + case AML_MUTEX_OP: + DataType = ACPI_TYPE_MUTEX; + break; + + case AML_EVENT_OP: + DataType = ACPI_TYPE_EVENT; + break; + + case AML_REGION_OP: + DataType = ACPI_TYPE_REGION; + break; + + + default: + DataType = ACPI_TYPE_ANY; + break; + + } + + return (DataType); +} + + diff --git a/sys/contrib/dev/acpica/dswexec.c b/sys/contrib/dev/acpica/dswexec.c new file mode 100644 index 0000000..7e3d58b --- /dev/null +++ b/sys/contrib/dev/acpica/dswexec.c @@ -0,0 +1,800 @@ +/****************************************************************************** + * + * Module Name: dswexec - Dispatcher method execution callbacks; + * dispatch to interpreter. + * $Revision: 45 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWEXEC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswexec") + + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetPredicateValue + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 HasResultObj) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState); + + + WalkState->ControlState->Common.State = 0; + + if (HasResultObj) + { + Status = AcpiDsResultStackPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + else + { + Status = AcpiDsCreateOperand (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = WalkState->Operands [0]; + } + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecEndOp: No predicate ObjDesc=%X State=%X\n", + ObjDesc, WalkState)); + + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + + /* + * Result of predicate evaluation currently must + * be a number + */ + + if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecEndOp: Bad predicate (not a number) ObjDesc=%X State=%X Type=%X\n", + ObjDesc, WalkState, ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Save the result of the predicate evaluation on + * the control stack + */ + + if (ObjDesc->Number.Value) + { + WalkState->ControlState->Common.Value = TRUE; + } + + else + { + /* + * Predicate is FALSE, we will just toss the + * rest of the package + */ + + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_FALSE; + } + + + +Cleanup: + + DEBUG_PRINT (TRACE_EXEC, + ("ExecEndOp: Completed a predicate eval=%X Op=%X\n", + WalkState->ControlState->Common.Value, Op)); + + /* Break to debugger to display result */ + + DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState)); + + /* + * Delete the predicate result object (we know that + * we don't need it anymore) + */ + + AcpiCmRemoveReference (ObjDesc); + + WalkState->ControlState->Common.State = CONTROL_NORMAL; + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecBeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been reached in the + * walk; Arguments have not been evaluated yet. + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the execution of control + * methods. This is where most operators and operands are + * dispatched to the interpreter. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_OPCODE_INFO *OpInfo; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("DsExecBeginOp", Op); + + + if (!Op) + { + Status = AcpiDsLoad2BeginOp (Opcode, NULL, WalkState, OutOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Op = *OutOp; + } + + 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 == + CONTROL_CONDITIONAL_EXECUTING)) + { + DEBUG_PRINT (TRACE_EXEC, ("BeginOp: Exec predicate Op=%X State=%X\n", + Op, WalkState)); + + WalkState->ControlState->Common.State = CONTROL_PREDICATE_EXECUTING; + + /* Save start of predicate */ + + WalkState->ControlState->Control.PredicateOp = Op; + } + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + + /* We want to send namepaths to the load code */ + + if (Op->Opcode == AML_NAMEPATH_OP) + { + OpInfo->Flags = OPTYPE_NAMED_OBJECT; + } + + + /* + * Handle the opcode based upon the opcode type + */ + + switch (ACPI_GET_OP_CLASS (OpInfo)) + { + case OPTYPE_CONTROL: + + Status = AcpiDsExecBeginControlOp (WalkState, Op); + break; + + + case OPTYPE_NAMED_OBJECT: + + if (WalkState->WalkType == WALK_METHOD) + { + /* + * Found a named object declaration during method + * execution; we must enter this object into the + * namespace. The created object is temporary and + * will be deleted upon completion of the execution + * of this method. + */ + + Status = AcpiDsLoad2BeginOp (Op->Opcode, Op, WalkState, NULL); + } + break; + + + default: + break; + } + + /* Nothing to do here during method execution */ + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecEndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been completed in the + * walk; Arguments have now been evaluated. + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the execution of control + * methods. The only thing we really need to do here is to + * notice the beginning of IF, ELSE, and WHILE blocks. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + UINT16 Opcode; + UINT8 Optype; + ACPI_PARSE_OBJECT *NextOp; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *FirstArg; + ACPI_OPERAND_OBJECT *ResultObj = NULL; + ACPI_OPCODE_INFO *OpInfo; + UINT32 OperandIndex; + + + FUNCTION_TRACE_PTR ("DsExecEndOp", Op); + + + Opcode = (UINT16) Op->Opcode; + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + DEBUG_PRINT (ACPI_ERROR, ("ExecEndOp: Unknown opcode. Op=%X\n", + Op)); + + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + Optype = (UINT8) ACPI_GET_OP_CLASS (OpInfo); + FirstArg = Op->Value.Arg; + + /* Init the walk state */ + + WalkState->NumOperands = 0; + WalkState->ReturnDesc = NULL; + + + /* Call debugger for single step support (DEBUG build only) */ + + DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, Optype)); + DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);}); + + + /* Decode the opcode */ + + switch (Optype) + { + case OPTYPE_UNDEFINED: + + DEBUG_PRINT (ACPI_ERROR, ("ExecEndOp: Undefined opcode type Op=%X\n", + Op)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + break; + + + case OPTYPE_BOGUS: + DEBUG_PRINT (TRACE_DISPATCH, + ("ExecEndOp: Internal opcode=%X type Op=%X\n", + Opcode, Op)); + break; + + case OPTYPE_CONSTANT: /* argument type only */ + case OPTYPE_LITERAL: /* argument type only */ + case OPTYPE_DATA_TERM: /* argument type only */ + case OPTYPE_LOCAL_VARIABLE: /* argument type only */ + case OPTYPE_METHOD_ARGUMENT: /* argument type only */ + break; + + + /* most operators with arguments */ + + case OPTYPE_MONADIC1: + case OPTYPE_DYADIC1: + case OPTYPE_MONADIC2: + case OPTYPE_MONADIC2R: + case OPTYPE_DYADIC2: + case OPTYPE_DYADIC2R: + case OPTYPE_DYADIC2S: + case OPTYPE_RECONFIGURATION: + case OPTYPE_INDEX: + case OPTYPE_MATCH: + case OPTYPE_FATAL: + + + Status = AcpiDsCreateOperands (WalkState, FirstArg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + OperandIndex = WalkState->NumOperands - 1; + + switch (Optype) + { + + case OPTYPE_MONADIC1: + + /* 1 Operand, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiAmlExecMonadic1 (Opcode, WalkState); + break; + + + case OPTYPE_MONADIC2: + + /* 1 Operand, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecMonadic2 (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_MONADIC2R: + + /* 1 Operand, 1 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecMonadic2R (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_DYADIC1: + + /* 2 Operands, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiAmlExecDyadic1 (Opcode, WalkState); + + break; + + + case OPTYPE_DYADIC2: + + /* 2 Operands, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecDyadic2 (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_DYADIC2R: + + /* 2 Operands, 1 or 2 ExternalResults, 1 InternalResult */ + + + /* NEW INTERFACE: + * Pass in WalkState, keep result obj but let interpreter + * push the result + */ + + Status = AcpiAmlExecDyadic2R (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_DYADIC2S: /* Synchronization Operator */ + + /* 2 Operands, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecDyadic2S (Opcode, WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_RECONFIGURATION: + + /* 1 or 2 operands, 0 Internal Result */ + + Status = AcpiAmlExecReconfiguration (Opcode, WalkState); + break; + + + case OPTYPE_FATAL: + + /* 3 Operands, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiAmlExecFatal (WalkState); + break; + + + case OPTYPE_INDEX: /* Type 2 opcode with 3 operands */ + + /* 3 Operands, 1 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecIndex (WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + + + case OPTYPE_MATCH: /* Type 2 opcode with 6 operands */ + + /* 6 Operands, 0 ExternalResult, 1 InternalResult */ + + Status = AcpiAmlExecMatch (WalkState, &ResultObj); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiDsResultStackPush (ResultObj, WalkState); + } + + break; + } + + break; + + + case OPTYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ + + /* 1 Operand, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiDsExecEndControlOp (WalkState, Op); + + break; + + + case OPTYPE_METHOD_CALL: + + DEBUG_PRINT (TRACE_DISPATCH, + ("ExecEndOp: Method invocation, Op=%X\n", Op)); + + /* + * (AML_METHODCALL) Op->Value->Arg->Node contains + * the method Node pointer + */ + /* NextOp points to the op that holds the method name */ + + NextOp = FirstArg; + Node = NextOp->Node; + + /* NextOp points to first argument op */ + + NextOp = NextOp->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)) + { + 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); + break; + + + case OPTYPE_CREATE_FIELD: + + DEBUG_PRINT (TRACE_EXEC, + ("ExecEndOp: Executing CreateField Buffer/Index Op=%X\n", + Op)); + + Status = AcpiDsLoad2EndOp (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + + Status = AcpiDsEvalFieldUnitOperands (WalkState, Op); + break; + + + case OPTYPE_NAMED_OBJECT: + + Status = AcpiDsLoad2EndOp (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + + switch (Op->Opcode) + { + case AML_REGION_OP: + + DEBUG_PRINT (TRACE_EXEC, + ("ExecEndOp: Executing OpRegion Address/Length Op=%X\n", + Op)); + + Status = AcpiDsEvalRegionOperands (WalkState, Op); + + break; + + + case AML_METHOD_OP: + + break; + + + case AML_ALIAS_OP: + + /* Alias creation was already handled by call + to psxload above */ + break; + + + default: + /* Nothing needs to be done */ + + Status = AE_OK; + break; + } + + break; + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("ExecEndOp: Unimplemented opcode, type=%X Opcode=%X Op=%X\n", + Optype, Op->Opcode, Op)); + + Status = AE_NOT_IMPLEMENTED; + break; + } + + + /* + * Check if we just completed the evaluation of a + * conditional predicate + */ + + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + + Status = AcpiDsGetPredicateValue (WalkState, Op, (UINT32) ResultObj); + ResultObj = NULL; + } + + +Cleanup: + + if (ResultObj) + { + /* Break to debugger to display result */ + + DEBUGGER_EXEC (AcpiDbDisplayResultObject (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, ResultObj, WalkState); + } + + /* Always clear the object stack */ + + /* TBD: [Investigate] Clear stack of return value, + but don't delete it */ + WalkState->NumOperands = 0; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/dswload.c b/sys/contrib/dev/acpica/dswload.c new file mode 100644 index 0000000..c595c5d --- /dev/null +++ b/sys/contrib/dev/acpica/dswload.c @@ -0,0 +1,928 @@ +/****************************************************************************** + * + * Module Name: dswload - Dispatcher namespace load callbacks + * $Revision: 23 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWLOAD_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" + + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswload") + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad1BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been reached in the + * walk; Arguments have not been evaluated yet. + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + OBJECT_TYPE_INTERNAL DataType; + NATIVE_CHAR *Path; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: Op=%p State=%p\n", Op, WalkState)); + + + /* We are only interested in opcodes that have an associated name */ + + if (!AcpiPsIsNamedOp (Opcode)) + { + *OutOp = Op; + return (AE_OK); + } + + + /* Check if this object has already been installed in the namespace */ + + if (Op && Op->Node) + { + *OutOp = Op; + return (AE_OK); + } + + Path = AcpiPsGetNextNamestring (WalkState->ParserState); + + /* Map the raw opcode into an internal object type */ + + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + + + if (Opcode == AML_SCOPE_OP) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + } + + /* + * 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, + DataType, IMODE_LOAD_PASS1, + NS_NO_UPSEARCH, WalkState, &(Node)); + + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return (AE_NO_MEMORY); + } + } + + /* Initialize */ + + ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name; + + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Node = Node; + + + AcpiPsAppendArg (AcpiPsGetParentScope (WalkState->ParserState), Op); + + *OutOp = Op; + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad1EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been completed in the + * walk; Arguments have now been evaluated. + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + OBJECT_TYPE_INTERNAL DataType; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1EndOp: Op=%p State=%p\n", Op, WalkState)); + + /* We are only interested in opcodes that have an associated name */ + + if (!AcpiPsIsNamedOp (Op->Opcode)) + { + return (AE_OK); + } + + + /* Get the type to determine if we should pop the scope */ + + DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); + + if (Op->Opcode == AML_NAME_OP) + { + /* For Name opcode, check the argument */ + + if (Op->Value.Arg) + { + DataType = AcpiDsMapOpcodeToDataType ( + (Op->Value.Arg)->Opcode, NULL); + ((ACPI_NAMESPACE_NODE *)Op->Node)->Type = + (UINT8) DataType; + } + } + + + /* Pop the scope stack */ + + if (AcpiNsOpensScope (DataType)) + { + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load1EndOp/%s: Popping scope for Op %p\n", + AcpiCmGetTypeName (DataType), Op)); + AcpiDsScopeStackPop (WalkState); + } + + return (AE_OK); + +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad2BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been reached in the + * walk; Arguments have not been evaluated yet. + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + OBJECT_TYPE_INTERNAL DataType; + NATIVE_CHAR *BufferPtr; + void *Original = NULL; + + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2BeginOp: Op=%p State=%p\n", Op, WalkState)); + + + /* We only care about Namespace opcodes here */ + + if (!AcpiPsIsNamespaceOp (Opcode) && + Opcode != AML_NAMEPATH_OP) + { + return (AE_OK); + } + + + /* Temp! same code as in psparse */ + + if (!AcpiPsIsNamedOp (Opcode)) + { + return (AE_OK); + } + + if (Op) + { + /* + * Get the name we are going to enter or lookup in the namespace + */ + if (Opcode == AML_NAMEPATH_OP) + { + /* For Namepath op, get the path string */ + + BufferPtr = Op->Value.String; + if (!BufferPtr) + { + /* No name, just exit */ + + return (AE_OK); + } + } + + else + { + /* Get name from the op */ + + BufferPtr = (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Op)->Name; + } + } + + else + { + BufferPtr = AcpiPsGetNextNamestring (WalkState->ParserState); + } + + + /* Map the raw opcode into an internal object type */ + + DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); + + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2BeginOp: State=%p Op=%p Type=%x\n", WalkState, Op, DataType)); + + + if (Opcode == AML_DEF_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP) + { + Node = NULL; + Status = AE_OK; + } + + else if (Opcode == AML_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, + DataType, IMODE_EXECUTE, + NS_SEARCH_PARENT, WalkState, + &(Node)); + } + + else + { + if (Op && Op->Node) + { + Original = Op->Node; + Node = Op->Node; + + if (AcpiNsOpensScope (DataType)) + { + Status = AcpiDsScopeStackPush (Node, + DataType, + WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + } + return (AE_OK); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that involve + * arguments to the opcode must be created as we go back up the parse tree later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, + DataType, IMODE_EXECUTE, + NS_NO_UPSEARCH, WalkState, + &(Node)); + } + + if (ACPI_SUCCESS (Status)) + { + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Initialize */ + + ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name; + *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->Node = Node; + + if (Original) + { + DEBUG_PRINT (ACPI_INFO, + ("Lookup: old %p new %p\n", Original, Node)); + + if (Original != Node) + { + DEBUG_PRINT (ACPI_INFO, + ("Lookup match error: old %p new %p\n", Original, Node)); + } + } + } + + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsLoad2EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * Op - Op that has been just been completed in the + * walk; Arguments have now been evaluated. + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + OBJECT_TYPE_INTERNAL DataType; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *NewNode; + + + DEBUG_PRINT (TRACE_DISPATCH, ("Load2EndOp: Op=%p State=%p\n", Op, WalkState)); + + if (!AcpiPsIsNamespaceObjectOp (Op->Opcode)) + { + return (AE_OK); + } + + if (Op->Opcode == AML_SCOPE_OP) + { + DEBUG_PRINT (TRACE_DISPATCH, + ("Load2EndOp: ending scope Op=%p State=%p\n", Op, WalkState)); + + if (((ACPI_PARSE2_OBJECT *)Op)->Name == -1) + { + DEBUG_PRINT (ACPI_ERROR, + ("Load2EndOp: Un-named scope! Op=%p State=%p\n", Op, + WalkState)); + return (AE_OK); + } + } + + + DataType = AcpiDsMapNamedOpcodeToDataType (Op->Opcode); + + /* + * Get the Node/name from the earlier lookup + * (It was saved in the *op structure) + */ + Node = Op->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 (DataType)) + { + + DEBUG_PRINT (TRACE_DISPATCH, + ("AmlEndNamespaceScope/%s: Popping scope for Op %p\n", + AcpiCmGetTypeName (DataType), Op)); + AcpiDsScopeStackPop (WalkState); + } + + + /* + * Named operations are as follows: + * + * AML_SCOPE + * AML_DEVICE + * AML_THERMALZONE + * AML_METHOD + * AML_POWERRES + * AML_PROCESSOR + * AML_FIELD + * AML_INDEXFIELD + * AML_BANKFIELD + * AML_NAMEDFIELD + * AML_NAME + * AML_ALIAS + * AML_MUTEX + * AML_EVENT + * AML_OPREGION + * AML_CREATEFIELD + * AML_CREATEBITFIELD + * AML_CREATEBYTEFIELD + * AML_CREATEWORDFIELD + * AML_CREATEDWORDFIELD + * AML_METHODCALL + */ + + + /* Decode the opcode */ + + Arg = Op->Value.Arg; + + switch (Op->Opcode) + { + + case AML_CREATE_FIELD_OP: + case AML_BIT_FIELD_OP: + case AML_BYTE_FIELD_OP: + case AML_WORD_FIELD_OP: + case AML_DWORD_FIELD_OP: + + /* + * Create the field object, but the field buffer and index must + * be evaluated later during the execution phase + */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-CreateXxxField: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + /* Get the NameString argument */ + + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + Arg = AcpiPsGetArg (Op, 3); + } + else + { + /* Create Bit/Byte/Word/Dword field */ + + Arg = AcpiPsGetArg (Op, 2); + } + + /* + * Enter the NameString into the namespace + */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, + Arg->Value.String, + INTERNAL_TYPE_DEF_ANY, + IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); + + if (ACPI_SUCCESS (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->Node = NewNode; + + /* + * 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 (!NewNode->Object) + { + /* + * The Field definition is not fully parsed at this time. + * (We must save the address of the AML for the buffer and index operands) + */ + Status = AcpiAmlExecCreateField (((ACPI_PARSE2_OBJECT *) Op)->Data, + ((ACPI_PARSE2_OBJECT *) Op)->Length, + NewNode, WalkState); + } + } + + + break; + + + case AML_METHODCALL_OP: + + DEBUG_PRINT (TRACE_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->Value.String, + ACPI_TYPE_ANY, IMODE_LOAD_PASS2, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); + + if (ACPI_SUCCESS (Status)) + { + +/* has name already been resolved by here ??*/ + + /* TBD: [Restructure] Make sure that what we found is indeed a method! */ + /* We didn't search for a method on purpose, to see if the name would resolve! */ + + /* We 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->Node = NewNode; + } + + + break; + + + case AML_PROCESSOR_OP: + + /* Nothing to do other than enter object into namespace */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Processor: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Status = AcpiAmlExecCreateProcessor (Op, (ACPI_HANDLE) Node); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed Processor Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Node)); + break; + + + case AML_POWER_RES_OP: + + /* Nothing to do other than enter object into namespace */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-PowerResource: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Status = AcpiAmlExecCreatePowerResource (Op, (ACPI_HANDLE) Node); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed PowerResource Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Node)); + break; + + + case AML_THERMAL_ZONE_OP: + + /* Nothing to do other than enter object into namespace */ + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-ThermalZone: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + break; + + + case AML_DEF_FIELD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Field: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Arg = Op->Value.Arg; + + Status = AcpiDsCreateField (Op, + Arg->Node, + WalkState); + break; + + + case AML_INDEX_FIELD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-IndexField: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Arg = Op->Value.Arg; + + Status = AcpiDsCreateIndexField (Op, + (ACPI_HANDLE) Arg->Node, + WalkState); + break; + + + case AML_BANK_FIELD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-BankField: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + Arg = Op->Value.Arg; + Status = AcpiDsCreateBankField (Op, + Arg->Node, + WalkState); + break; + + + /* + * MethodOp PkgLength NamesString MethodFlags TermList + */ + case AML_METHOD_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Method: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + if (!Node->Object) + { + Status = AcpiAmlExecCreateMethod (((ACPI_PARSE2_OBJECT *) Op)->Data, + ((ACPI_PARSE2_OBJECT *) Op)->Length, + Arg->Value.Integer, (ACPI_HANDLE) Node); + } + + break; + + + case AML_MUTEX_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Mutex: Op=%p State=%p\n", Op, WalkState)); + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecCreateMutex (WalkState); + break; + + + case AML_EVENT_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Event: Op=%p State=%p\n", Op, WalkState)); + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecCreateEvent (WalkState); + break; + + + case AML_REGION_OP: + + if (Node->Object) + { + break; + } + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Opregion: Op=%p State=%p NamedObj=%p\n", Op, WalkState, Node)); + + + /* + * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId. + * (We must save the address of the AML of the address and length operands) + */ + + Status = AcpiAmlExecCreateRegion (((ACPI_PARSE2_OBJECT *) Op)->Data, + ((ACPI_PARSE2_OBJECT *) Op)->Length, + Arg->Value.Integer, WalkState); + + DEBUG_PRINT (TRACE_DISPATCH, + ("Completed OpRegion Init, Op=%p State=%p entry=%p\n", + Op, WalkState, Node)); + break; + + + /* Namespace Modifier Opcodes */ + + case AML_ALIAS_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Alias: Op=%p State=%p\n", Op, WalkState)); + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecCreateAlias (WalkState); + break; + + + case AML_NAME_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-Name: Op=%p State=%p\n", Op, WalkState)); + + /* + * 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 (!Node->Object) + { + Status = AcpiDsCreateNode (WalkState, Node, Op); + } + + break; + + + case AML_NAMEPATH_OP: + + DEBUG_PRINT (TRACE_DISPATCH, + ("LOADING-NamePath object: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + break; + + + default: + break; + } + + +Cleanup: + + /* Remove the Node pushed at the very beginning */ + + AcpiDsObjStackPop (1, WalkState); + return (Status); +} + + diff --git a/sys/contrib/dev/acpica/dswscope.c b/sys/contrib/dev/acpica/dswscope.c new file mode 100644 index 0000000..9d7f1da --- /dev/null +++ b/sys/contrib/dev/acpica/dswscope.c @@ -0,0 +1,268 @@ +/****************************************************************************** + * + * Module Name: dswscope - Scope stack manipulation + * $Revision: 39 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __DSWSCOPE_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acdispat.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("dswscope") + + +#define STACK_POP(head) head + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackClear + * + * PARAMETERS: None + * + * DESCRIPTION: Pop (and free) everything on the scope stack except the + * root scope object (which remains at the stack top.) + * + ***************************************************************************/ + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + + while (WalkState->ScopeInfo) + { + /* Pop a scope off the stack */ + + ScopeInfo = WalkState->ScopeInfo; + WalkState->ScopeInfo = ScopeInfo->Scope.Next; + + DEBUG_PRINT (TRACE_EXEC, + ("Popped object type 0x%X\n", ScopeInfo->Common.Value)); + AcpiCmDeleteGenericState (ScopeInfo); + } +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPush + * + * PARAMETERS: *Node, - Name to be made current + * Type, - Type of frame being pushed + * + * DESCRIPTION: Push the current scope on the scope stack, and make the + * passed Node current. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + + FUNCTION_TRACE ("DsScopeStackPush"); + + + if (!Node) + { + /* invalid scope */ + + REPORT_ERROR (("DsScopeStackPush: null scope passed\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Make sure object type is valid */ + + if (!AcpiAmlValidateObjectType (Type)) + { + REPORT_WARNING (("DsScopeStackPush: type code out of range\n")); + } + + + /* Allocate a new scope object */ + + ScopeInfo = AcpiCmCreateGenericState (); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init new scope object */ + + ScopeInfo->Scope.Node = Node; + ScopeInfo->Common.Value = (UINT16) Type; + + /* Push new scope object onto stack */ + + AcpiCmPushGenericState (&WalkState->ScopeInfo, ScopeInfo); + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPop + * + * PARAMETERS: Type - The type of frame to be found + * + * DESCRIPTION: Pop the scope stack until a frame of the requested type + * is found. + * + * RETURN: Count of frames popped. If no frame of the requested type + * was found, the count is returned as a negative number and + * the scope stack is emptied (which sets the current scope + * to the root). If the scope stack was empty at entry, the + * function is a no-op and returns 0. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + + FUNCTION_TRACE ("DsScopeStackPop"); + + /* + * Pop scope info object off the stack. + */ + + ScopeInfo = AcpiCmPopGenericState (&WalkState->ScopeInfo); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_STACK_UNDERFLOW); + } + + DEBUG_PRINT (TRACE_EXEC, + ("Popped object type 0x%X\n", ScopeInfo->Common.Value)); + + AcpiCmDeleteGenericState (ScopeInfo); + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/dswstate.c b/sys/contrib/dev/acpica/dswstate.c new file mode 100644 index 0000000..28ffce9 --- /dev/null +++ b/sys/contrib/dev/acpica/dswstate.c @@ -0,0 +1,841 @@ +/****************************************************************************** + * + * Module Name: dswstate - Dispatcher parse tree walk management routines + * $Revision: 31 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __DSWSTATE_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT DISPATCHER + MODULE_NAME ("dswstate") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackClear + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Reset this walk's result stack pointers to zero, thus setting + * the stack to zero. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultStackClear ( + ACPI_WALK_STATE *WalkState) +{ + + WalkState->NumResults = 0; + WalkState->CurrentResult = 0; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPush + * + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto this walk's result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState) +{ + + + if (WalkState->NumResults >= OBJ_NUM_OPERANDS) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsResultStackPush: overflow! Obj=%p State=%p Num=%X\n", + Object, WalkState, WalkState->NumResults)); + return (AE_STACK_OVERFLOW); + } + + WalkState->Results [WalkState->NumResults] = Object; + WalkState->NumResults++; + + DEBUG_PRINT (TRACE_EXEC, + ("DsResultStackPush: Obj=%p State=%p Num=%X Cur=%X\n", + Object, WalkState, WalkState->NumResults, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPop + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In + * other words, this is a FIFO. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + + + /* Check for stack underflow */ + + if (WalkState->NumResults == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsResultStackPop: Underflow! State=%p Cur=%X Num=%X\n", + WalkState, WalkState->CurrentResult, WalkState->NumResults)); + return (AE_AML_NO_OPERAND); + } + + + /* Pop the stack */ + + WalkState->NumResults--; + + /* Check for a valid result object */ + + if (!WalkState->Results [WalkState->NumResults]) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsResultStackPop: Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumResults)); + return (AE_AML_NO_OPERAND); + } + + *Object = WalkState->Results [WalkState->NumResults]; + WalkState->Results [WalkState->NumResults] = NULL; + + DEBUG_PRINT (TRACE_EXEC, + ("DsResultStackPop: Obj=%p State=%p Num=%X Cur=%X\n", + *Object, WalkState, WalkState->NumResults, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackDeleteAll + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Clear the object stack by deleting all objects that are on it. + * Should be used with great care, if at all! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); + + + /* The stack size is configurable, but fixed */ + + for (i = 0; i < OBJ_NUM_OPERANDS; i++) + { + if (WalkState->Operands[i]) + { + AcpiCmRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPush + * + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto this walk's object/operand stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState) +{ + + + /* Check for stack overflow */ + + if (WalkState->NumOperands >= OBJ_NUM_OPERANDS) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPush: overflow! Obj=%p State=%p #Ops=%X\n", + Object, WalkState, WalkState->NumOperands)); + return (AE_STACK_OVERFLOW); + } + + /* Put the object onto the stack */ + + WalkState->Operands [WalkState->NumOperands] = Object; + WalkState->NumOperands++; + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPush: Obj=%p State=%p #Ops=%X\n", + Object, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopObject + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT + * deleted by this routine. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + + + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Missing operand/stack empty! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + return (AE_AML_NO_OPERAND); + } + + + /* Pop the stack */ + + WalkState->NumOperands--; + + /* Check for a valid operand */ + + if (!WalkState->Operands [WalkState->NumOperands]) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + return (AE_AML_NO_OPERAND); + } + + /* Get operand and set stack entry to null */ + + *Object = WalkState->Operands [WalkState->NumOperands]; + WalkState->Operands [WalkState->NumOperands] = NULL; + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPopObject: State=%p #Ops=%X\n", + 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; + + + for (i = 0; i < PopCount; i++) + { + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + return (AE_STACK_UNDERFLOW); + } + + /* Just set the stack entry to null */ + + WalkState->NumOperands--; + WalkState->Operands [WalkState->NumOperands] = NULL; + } + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopAndDelete + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack and delete each object that is + * popped off. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; + + + for (i = 0; i < PopCount; i++) + { + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsObjStackPop: Underflow! Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + return (AE_STACK_UNDERFLOW); + } + + /* Pop the stack and delete an object if present in this stack entry */ + + WalkState->NumOperands--; + ObjDesc = WalkState->Operands [WalkState->NumOperands]; + if (ObjDesc) + { + AcpiCmRemoveReference (WalkState->Operands [WalkState->NumOperands]); + WalkState->Operands [WalkState->NumOperands] = NULL; + } + } + + DEBUG_PRINT (TRACE_EXEC, ("DsObjStackPop: Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackGetValue + * + * PARAMETERS: Index - Stack index whose value is desired. Based + * on the top of the stack (index=0 == top) + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Retrieve an object from this walk's object stack. Index must + * be within the range of the current stack pointer. + * + ******************************************************************************/ + +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + + FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); + + + /* Can't do it if the stack is empty */ + + if (WalkState->NumOperands == 0) + { + return_VALUE (NULL); + } + + /* or if the index is past the top of the stack */ + + if (Index > (WalkState->NumOperands - (UINT32) 1)) + { + return_VALUE (NULL); + } + + + return_PTR (WalkState->Operands[(NATIVE_UINT)(WalkState->NumOperands - 1) - + Index]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetCurrentWalkState + * + * PARAMETERS: WalkList - Get current active state for this walk list + * + * 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_WALK_LIST *WalkList) + +{ + + DEBUG_PRINT (TRACE_PARSE, ("DsGetCurrentWalkState, =%p\n", WalkList->WalkState)); + + if (!WalkList) + { + return (NULL); + } + + return (WalkList->WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPushWalkState + * + * PARAMETERS: WalkState - State to push + * WalkList - The list that owns the walk stack + * + * RETURN: None + * + * DESCRIPTION: Place the WalkState at the head of the state list. + * + ******************************************************************************/ + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_WALK_LIST *WalkList) +{ + + + FUNCTION_TRACE ("DsPushWalkState"); + + + WalkState->Next = WalkList->WalkState; + WalkList->WalkState = WalkState; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPopWalkState + * + * PARAMETERS: WalkList - The list that owns the walk stack + * + * RETURN: A WalkState object popped from the stack + * + * DESCRIPTION: Remove and return the walkstate object that is at the head of + * the walk stack for the given walk list. NULL indicates that + * the list is empty. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_WALK_LIST *WalkList) +{ + ACPI_WALK_STATE *WalkState; + + + FUNCTION_TRACE ("DsPopWalkState"); + + + WalkState = WalkList->WalkState; + + if (WalkState) + { + /* Next walk state becomes the current walk state */ + + WalkList->WalkState = WalkState->Next; + + /* + * Don't clear the NEXT field, this serves as an indicator + * that there is a parent WALK STATE + * WalkState->Next = NULL; + */ + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateWalkState + * + * PARAMETERS: Origin - Starting point for this walk + * WalkList - Owning walk list + * + * RETURN: Pointer to the new walk state. + * + * DESCRIPTION: Allocate and initialize a new walk state. The current walk state + * is set to this new state. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_WALK_LIST *WalkList) +{ + ACPI_WALK_STATE *WalkState; + + + FUNCTION_TRACE ("DsCreateWalkState"); + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_WalkStateCacheRequests++; + + /* Check the cache first */ + + if (AcpiGbl_WalkStateCache) + { + /* There is an object available, use it */ + + WalkState = AcpiGbl_WalkStateCache; + AcpiGbl_WalkStateCache = WalkState->Next; + + AcpiGbl_WalkStateCacheHits++; + AcpiGbl_WalkStateCacheDepth--; + + DEBUG_PRINT (TRACE_EXEC, ("DsCreateWalkState: State %p from cache\n", WalkState)); + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* The cache is empty, create a new object */ + + /* Avoid deadlock with AcpiCmCallocate */ + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + WalkState = AcpiCmCallocate (sizeof (ACPI_WALK_STATE)); + if (!WalkState) + { + return_VALUE (NULL); + } + } + + WalkState->DataType = ACPI_DESC_TYPE_WALK; + WalkState->OwnerId = OwnerId; + WalkState->Origin = Origin; + WalkState->MethodDesc = MthDesc; + + /* Init the method args/local */ + + AcpiDsMethodDataInit (WalkState); + + /* Put the new state at the head of the walk list */ + + AcpiDsPushWalkState (WalkState, WalkList); + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * 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; + + + FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); + + + if (!WalkState) + { + return; + } + + if (WalkState->DataType != ACPI_DESC_TYPE_WALK) + { + DEBUG_PRINT (ACPI_ERROR, + ("DsDeleteWalkState: **** %p not a valid walk state\n", WalkState)); + return; + } + + /* Always must free any linked control states */ + + while (WalkState->ControlState) + { + State = WalkState->ControlState; + WalkState->ControlState = State->Common.Next; + + AcpiCmDeleteGenericState (State); + } + + + /* Always must free any linked parse states */ + + while (WalkState->ScopeInfo) + { + State = WalkState->ScopeInfo; + WalkState->ScopeInfo = State->Common.Next; + + AcpiCmDeleteGenericState (State); + } + + /* If walk cache is full, just free this wallkstate object */ + + if (AcpiGbl_WalkStateCacheDepth >= MAX_WALK_CACHE_DEPTH) + { + AcpiCmFree (WalkState); + } + + /* Otherwise put this object back into the cache */ + + else + { + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + /* Clear the state */ + + MEMSET (WalkState, 0, sizeof (ACPI_WALK_STATE)); + WalkState->DataType = ACPI_DESC_TYPE_WALK; + + /* Put the object at the head of the global cache list */ + + WalkState->Next = AcpiGbl_WalkStateCache; + AcpiGbl_WalkStateCache = WalkState; + AcpiGbl_WalkStateCacheDepth++; + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDsDeleteWalkStateCache + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge the global state object cache. Used during subsystem + * termination. + * + ******************************************************************************/ + +void +AcpiDsDeleteWalkStateCache ( + void) +{ + ACPI_WALK_STATE *Next; + + + FUNCTION_TRACE ("DsDeleteWalkStateCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_WalkStateCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_WalkStateCache->Next; + AcpiCmFree (AcpiGbl_WalkStateCache); + AcpiGbl_WalkStateCache = Next; + AcpiGbl_WalkStateCacheDepth--; + } + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/evevent.c b/sys/contrib/dev/acpica/evevent.c new file mode 100644 index 0000000..066946c --- /dev/null +++ b/sys/contrib/dev/acpica/evevent.c @@ -0,0 +1,953 @@ +/****************************************************************************** + * + * Module Name: evevent - Fixed and General Purpose AcpiEvent + * handling and dispatch + * $Revision: 17 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "achware.h" +#include "acevents.h" +#include "acnamesp.h" +#include "accommon.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evevent") + + +/************************************************************************** + * + * FUNCTION: AcpiEvInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Ensures that the system control interrupt (SCI) is properly + * configured, disables SCI event sources, installs the SCI + * handler + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvInitialize ( + void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInitialize"); + + + /* Make sure we've got ACPI tables */ + + if (!AcpiGbl_DSDT) + { + DEBUG_PRINT (ACPI_WARN, ("EvInitialize: No ACPI tables present!\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + + /* Make sure the BIOS supports ACPI mode */ + + if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities()) + { + DEBUG_PRINT (ACPI_WARN, + ("EvInitialize: Only legacy mode supported!\n")); + return_ACPI_STATUS (AE_ERROR); + } + + + AcpiGbl_OriginalMode = AcpiHwGetMode(); + + /* + * Initialize the Fixed and General Purpose AcpiEvents prior. This is + * done prior to enabling SCIs to prevent interrupts from occuring + * before handers are installed. + */ + + Status = AcpiEvFixedEventInitialize (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, + ("EvInitialize: Unable to initialize fixed events.\n")); + return_ACPI_STATUS (Status); + } + + Status = AcpiEvGpeInitialize (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, + ("EvInitialize: Unable to initialize general purpose events.\n")); + return_ACPI_STATUS (Status); + } + + /* Install the SCI handler */ + + Status = AcpiEvInstallSciHandler (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, + ("EvInitialize: Unable to install System Control Interrupt Handler\n")); + return_ACPI_STATUS (Status); + } + + + /* Install handlers for control method GPE handlers (_Lxx, _Exx) */ + + AcpiEvInitGpeControlMethods (); + + /* Install the handler for the Global Lock */ + + Status = AcpiEvInitGlobalLockHandler (); + + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvFixedEventInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the Fixed AcpiEvent data structures + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvFixedEventInitialize(void) +{ + int i = 0; + + /* Initialize the structure that keeps track of fixed event handlers */ + + for (i = 0; i < NUM_FIXED_EVENTS; i++) + { + AcpiGbl_FixedEventHandlers[i].Handler = NULL; + AcpiGbl_FixedEventHandlers[i].Context = NULL; + } + + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_PMTIMER + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_GLOBAL + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_POWER_BUTTON + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_SLEEP_BUTTON + + TMR_EN, 0); + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_RTC + + TMR_EN, 0); + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvFixedEventDetect + * + * PARAMETERS: None + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Checks the PM status register for fixed events + * + ******************************************************************************/ + +UINT32 +AcpiEvFixedEventDetect(void) +{ + UINT32 IntStatus = INTERRUPT_NOT_HANDLED; + UINT32 StatusRegister = 0; + UINT32 EnableRegister = 0; + + /* + * Read the fixed feature status and enable registers, as all the cases + * depend on their values. + */ + + StatusRegister = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk); + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + StatusRegister |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk); + } + + EnableRegister = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + EnableRegister |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + } + + DEBUG_PRINT (TRACE_INTERRUPTS, + ("Fixed AcpiEvent Block: Enable = %08x\tStatus = %08x\n", + EnableRegister, StatusRegister)); + + /* power management timer roll over */ + + if ((StatusRegister & ACPI_STATUS_PMTIMER) && + (EnableRegister & ACPI_ENABLE_PMTIMER)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_PMTIMER); + } + + /* global event (BIOS want's the global lock) */ + + if ((StatusRegister & ACPI_STATUS_GLOBAL) && + (EnableRegister & ACPI_ENABLE_GLOBAL)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_GLOBAL); + } + + /* power button event */ + + if ((StatusRegister & ACPI_STATUS_POWER_BUTTON) && + (EnableRegister & ACPI_ENABLE_POWER_BUTTON)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_POWER_BUTTON); + } + + /* sleep button event */ + + if ((StatusRegister & ACPI_STATUS_SLEEP_BUTTON) && + (EnableRegister & ACPI_ENABLE_SLEEP_BUTTON)) + { + IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_SLEEP_BUTTON); + } + + return (IntStatus); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvFixedEventDispatch + * + * PARAMETERS: Event - Event type + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Clears the status bit for the requested event, calls the + * handler that previously registered for the event. + * + ******************************************************************************/ + +UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event) +{ + /* Clear the status bit */ + + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, TMR_STS + + Event, 1); + + /* + * 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) + { + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, + TMR_EN + Event, 0); + + REPORT_ERROR ( + ("EvGpeDispatch: No installed handler for fixed event [0x%08X]\n", + Event)); + + return (INTERRUPT_NOT_HANDLED); + } + + /* Invoke the handler */ + + return ((AcpiGbl_FixedEventHandlers[Event].Handler)( + AcpiGbl_FixedEventHandlers[Event].Context)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the GPE data structures + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvGpeInitialize (void) +{ + UINT32 i; + UINT32 j; + UINT32 RegisterIndex; + UINT32 GpeNumber; + UINT16 Gpe0RegisterCount; + UINT16 Gpe1RegisterCount; + + + FUNCTION_TRACE ("EvGpeInitialize"); + + /*******************************************************************/ + /* Setting up various GPE counts */ + /* */ + /* You may ask,why are the GPE register block lengths divided by 2?*/ + /* From the ACPI 2.0 Spec, section, 4.7.1.6 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." */ + /*******************************************************************/ + Gpe0RegisterCount = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); + Gpe1RegisterCount = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); + AcpiGbl_GpeRegisterCount = Gpe0RegisterCount + Gpe1RegisterCount; + + if (!AcpiGbl_GpeRegisterCount) + { + REPORT_WARNING (("Zero GPEs are defined in the FACP\n")); + return_ACPI_STATUS (AE_OK); + } + + /* + * Allocate the Gpe information block + */ + + AcpiGbl_GpeRegisters = AcpiCmCallocate (AcpiGbl_GpeRegisterCount * + sizeof (ACPI_GPE_REGISTERS)); + if (!AcpiGbl_GpeRegisters) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not allocate the GpeRegisters block\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Allocate the Gpe dispatch handler block + * There are eight distinct GP events per register. + * Initialization to zeros is sufficient + */ + + AcpiGbl_GpeInfo = AcpiCmCallocate (MUL_8 (AcpiGbl_GpeRegisterCount) * + sizeof (ACPI_GPE_LEVEL_INFO)); + if (!AcpiGbl_GpeInfo) + { + AcpiCmFree (AcpiGbl_GpeRegisters); + DEBUG_PRINT (ACPI_ERROR, ("Could not allocate the GpeInfo block\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Set the Gpe validation table to GPE_INVALID */ + + MEMSET (AcpiGbl_GpeValid, (int) ACPI_GPE_INVALID, NUM_GPE); + + /* + * Initialize the Gpe information and validation blocks. A goal of these + * blocks is to hide the fact that there are two separate GPE register sets + * In a given block, the status registers occupy the first half, and + * the enable registers occupy the second half. + */ + + /* GPE Block 0 */ + + RegisterIndex = 0; + + for (i = 0; i < Gpe0RegisterCount; i++) + { + AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr = + (UINT16) (AcpiGbl_FACP->Gpe0Blk + i); + + AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr = + (UINT16) (AcpiGbl_FACP->Gpe0Blk + i + Gpe0RegisterCount); + + AcpiGbl_GpeRegisters[RegisterIndex].GpeBase = (UINT8) MUL_8 (i); + + for (j = 0; j < 8; j++) + { + GpeNumber = AcpiGbl_GpeRegisters[RegisterIndex].GpeBase + j; + AcpiGbl_GpeValid[GpeNumber] = (UINT8) RegisterIndex; + } + + /* + * Clear the status/enable registers. Note that status registers + * are cleared by writing a '1', while enable registers are cleared + * by writing a '0'. + */ + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, 0x00); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, 0xFF); + + RegisterIndex++; + } + + /* GPE Block 1 */ + + for (i = 0; i < Gpe1RegisterCount; i++) + { + AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr = + (UINT16) (AcpiGbl_FACP->Gpe1Blk + i); + + AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr = + (UINT16) (AcpiGbl_FACP->Gpe1Blk + i + Gpe1RegisterCount); + + AcpiGbl_GpeRegisters[RegisterIndex].GpeBase = + (UINT8) (AcpiGbl_FACP->Gpe1Base + MUL_8 (i)); + + for (j = 0; j < 8; j++) + { + GpeNumber = AcpiGbl_GpeRegisters[RegisterIndex].GpeBase + j; + AcpiGbl_GpeValid[GpeNumber] = (UINT8) RegisterIndex; + } + + /* + * Clear the status/enable registers. Note that status registers + * are cleared by writing a '1', while enable registers are cleared + * by writing a '0'. + */ + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, 0x00); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, 0xFF); + + RegisterIndex++; + } + + DEBUG_PRINT (ACPI_INFO, + ("GPE registers: %d@%X (Blk0) %d@%X (Blk1)\n", + Gpe0RegisterCount, AcpiGbl_FACP->Gpe0Blk, Gpe1RegisterCount, + AcpiGbl_FACP->Gpe1Blk)); + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvSaveMethodInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * control method under the _GPE portion of the namespace. + * Extract the name and GPE type from the object, saving this + * information for quick lookup during GPE dispatch + * + * The name of each GPE control method is of the form: + * "_Lnn" or "_Enn" + * Where: + * L - means that the GPE is level triggered + * E - means that the GPE is edge triggered + * nn - is the GPE number + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue) +{ + UINT32 GpeNumber; + NATIVE_CHAR Name[ACPI_NAME_SIZE + 1]; + UINT8 Type; + + + /* Extract the name from the object and convert to a string */ + + MOVE_UNALIGNED32_TO_32 (Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name); + Name[ACPI_NAME_SIZE] = 0; + + /* + * Edge/Level determination is based on the 2nd INT8 of the method name + */ + if (Name[1] == 'L') + { + Type = ACPI_EVENT_LEVEL_TRIGGERED; + } + else if (Name[1] == 'E') + { + Type = ACPI_EVENT_EDGE_TRIGGERED; + } + else + { + /* Unknown method type, just ignore it! */ + + DEBUG_PRINT (ACPI_ERROR, + ("EvSaveMethodInfo: Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n", + Name)); + return (AE_OK); + } + + /* Convert the last two characters of the name to the Gpe Number */ + + GpeNumber = STRTOUL (&Name[2], NULL, 16); + if (GpeNumber == ACPI_UINT32_MAX) + { + /* Conversion failed; invalid method, just ignore it */ + + DEBUG_PRINT (ACPI_ERROR, + ("EvSaveMethodInfo: Could not extract GPE number from name: %s (name not of form _Lnn or _Enn)\n", + Name)); + return (AE_OK); + } + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + /* Not valid, all we can do here is ignore it */ + + return (AE_OK); + } + + /* + * Now we can add this information to the GpeInfo block + * for use during dispatch of this GPE. + */ + + AcpiGbl_GpeInfo [GpeNumber].Type = Type; + AcpiGbl_GpeInfo [GpeNumber].MethodHandle = ObjHandle; + + + /* + * Enable the GPE (SCIs should be disabled at this point) + */ + + AcpiHwEnableGpe (GpeNumber); + + DEBUG_PRINT (ACPI_INFO, + ("EvSaveMethodInfo: Registered GPE method %s as GPE number %d\n", + Name, GpeNumber)); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvInitGpeControlMethods + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Obtain the control methods associated with the GPEs. + * + * NOTE: Must be called AFTER namespace initialization! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitGpeControlMethods (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInitGpeControlMethods"); + + + /* Get a permanent handle to the _GPE object */ + + Status = AcpiGetHandle (NULL, "\\_GPE", &AcpiGbl_GpeObjHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Traverse the namespace under \_GPE to find all methods there */ + + Status = AcpiWalkNamespace (ACPI_TYPE_METHOD, AcpiGbl_GpeObjHandle, + ACPI_UINT32_MAX, AcpiEvSaveMethodInfo, + NULL, NULL); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeCleanup + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Cleanup in preparation for unload. + * + ******************************************************************************/ + +void +AcpiEvGpeCleanup (void) +{ + FUNCTION_TRACE ("EvGpeCleanup"); + + + AcpiCmFree (AcpiGbl_GpeRegisters); + AcpiCmFree (AcpiGbl_GpeInfo); + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeDetect + * + * PARAMETERS: None + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Detect if any GP events have occurred + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDetect (void) +{ + UINT32 IntStatus = INTERRUPT_NOT_HANDLED; + UINT32 i; + UINT32 j; + UINT8 EnabledStatusByte; + UINT8 BitMask; + + + /* + * Read all of the 8-bit GPE status and enable registers + * in both of the register blocks, saving all of it. + * Find all currently active GP events. + */ + + for (i = 0; i < AcpiGbl_GpeRegisterCount; i++) + { + AcpiGbl_GpeRegisters[i].Status = + AcpiOsIn8 (AcpiGbl_GpeRegisters[i].StatusAddr); + + AcpiGbl_GpeRegisters[i].Enable = + AcpiOsIn8 (AcpiGbl_GpeRegisters[i].EnableAddr); + + DEBUG_PRINT (TRACE_INTERRUPTS, + ("GPE block at %x - Enable: %08x\tStatus: %08x\n", + AcpiGbl_GpeRegisters[i].EnableAddr, AcpiGbl_GpeRegisters[i].Status, AcpiGbl_GpeRegisters[i].Enable)); + + /* First check if there is anything active at all in this register */ + + EnabledStatusByte = (UINT8) (AcpiGbl_GpeRegisters[i].Status & + AcpiGbl_GpeRegisters[i].Enable); + + if (!EnabledStatusByte) + { + /* No active GPEs in this register, move on */ + + continue; + } + + /* Now look at the individual GPEs in this byte register */ + + for (j = 0, BitMask = 1; j < 8; j++, BitMask <<= 1) + { + /* Examine one GPE bit */ + + if (EnabledStatusByte & BitMask) + { + /* + * Found an active GPE. Dispatch the event to a handler + * or method. + */ + IntStatus |= + AcpiEvGpeDispatch (AcpiGbl_GpeRegisters[i].GpeBase + j); + } + } + } + + return (IntStatus); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvAsynchExecuteGpeMethod + * + * PARAMETERS: GpeNumber - The 0-based Gpe number + * + * RETURN: None + * + * DESCRIPTION: Perform the actual execution of a GPE control method. This + * function is called from an invocation of AcpiOsQueueForExecution + * (and therefore does NOT execute at interrupt level) so that + * the control method itself is not executed in the context of + * the SCI interrupt handler. + * + ******************************************************************************/ + +void +AcpiEvAsynchExecuteGpeMethod ( + void *Context) +{ + UINT32 GpeNumber = (UINT32) Context; + ACPI_GPE_LEVEL_INFO GpeInfo; + + + FUNCTION_TRACE ("EvAsynchExecuteGpeMethod"); + + + /* Take a snapshot of the GPE info for this level */ + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + + /* + * Function Handler (e.g. EC): + * --------------------------- + * Execute the installed function handler to handle this event. + */ + if (GpeInfo.Handler) + { + GpeInfo.Handler (GpeInfo.Context); + } + + /* + * Method Handler (_Lxx, _Exx): + * ---------------------------- + * AcpiEvaluate the _Lxx/_Exx control method that corresponds to this GPE. + */ + else if (GpeInfo.MethodHandle) + { + AcpiNsEvaluateByHandle (GpeInfo.MethodHandle, NULL, NULL); + } + + /* + * Level-Triggered? + * ---------------- + * If level-triggered, clear the GPE status bit after execution. Note + * that edge-triggered events are cleared prior to calling (via DPC) + * this function. + */ + if (GpeInfo.Type | ACPI_EVENT_LEVEL_TRIGGERED) + { + AcpiHwClearGpe (GpeNumber); + } + + /* + * Enable the GPE. + */ + AcpiHwEnableGpe (GpeNumber); + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvGpeDispatch + * + * PARAMETERS: GpeNumber - The 0-based Gpe number + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Handle and dispatch a General Purpose AcpiEvent. + * Clears the status bit for the requested event. + * + * TBD: [Investigate] is this still valid or necessary: + * The Gpe handler differs from the fixed events in that it clears the enable + * bit rather than the status bit to clear the interrupt. This allows + * software outside of interrupt context to determine what caused the SCI and + * dispatch the correct AML. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDispatch ( + UINT32 GpeNumber) +{ + FUNCTION_TRACE ("EvGpeDispatch"); + + + DEBUG_PRINT (ACPI_INFO, ("GPE [%d] event occurred.\n", GpeNumber)); + + /*DEBUG_INCREMENT_EVENT_COUNT (EVENT_GENERAL);*/ + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + DEBUG_PRINT (ACPI_ERROR, ("Invalid GPE [%d].\n", GpeNumber)); + return_VALUE (INTERRUPT_NOT_HANDLED); + } + + /* + * Disable the GPE. + */ + AcpiHwDisableGpe (GpeNumber); + + /* + * Edge-Triggered? + * --------------- + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced + * (see AcpiEvAsynchExecuteGpeMethod). + */ + if (AcpiGbl_GpeInfo [GpeNumber].Type | ACPI_EVENT_EDGE_TRIGGERED) + { + AcpiHwClearGpe (GpeNumber); + } + + /* + * Queue-up the Handler: + * --------------------- + * Queue the handler, which is either an installable function handler + * (e.g. EC) or a control method (e.g. _Lxx/_Exx) for later execution. + */ + if (AcpiGbl_GpeInfo [GpeNumber].Handler || + AcpiGbl_GpeInfo [GpeNumber].MethodHandle) + { + if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE, + AcpiEvAsynchExecuteGpeMethod, + (void*)(NATIVE_UINT)GpeNumber))) + { + /* + * Shoudn't occur, but if it does report an error. Note that + * the GPE will remain disabled until the ACPI Core Subsystem + * is restarted, or the handler is removed/reinstalled. + */ + REPORT_ERROR ( + ("EvGpeDispatch: Unable to queue the handler for GPE [0x%08X]\n", + GpeNumber)); + } + } + + /* + * Non Handled GPEs: + * ----------------- + * GPEs without handlers are disabled and kept that way until a handler + * is registered for them. + */ + else + { + REPORT_ERROR ( + ("EvGpeDispatch: No installed handler for GPE [0x%08X]\n", + GpeNumber)); + } + + return_VALUE (INTERRUPT_HANDLED); +} diff --git a/sys/contrib/dev/acpica/evmisc.c b/sys/contrib/dev/acpica/evmisc.c new file mode 100644 index 0000000..cdb4af7 --- /dev/null +++ b/sys/contrib/dev/acpica/evmisc.c @@ -0,0 +1,486 @@ +/****************************************************************************** + * + * Module Name: evmisc - ACPI device notification handler dispatch + * and ACPI Global Lock support + * $Revision: 15 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "achware.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evmisc") + + +/************************************************************************** + * + * FUNCTION: AcpiEvNotifyDispatch + * + * PARAMETERS: + * + * RETURN: None. + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + *************************************************************************/ + +void +AcpiEvNotifyDispatch ( + ACPI_HANDLE Device, + UINT32 NotifyValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + NOTIFY_HANDLER Handler; + + + /* + * For value 1 (Ejection Request), some device method may need to be run. + * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run. + * For value 0x80 (Status Change) on the power button or sleep button, + * initiate soft-off or sleep operation? + */ + + + DEBUG_PRINT (ACPI_INFO, + ("Dispatching Notify(%d) on device %p\n", NotifyValue, Device)); + + switch (NotifyValue) + { + case 0: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Re-enumerate Devices\n")); + break; + + case 1: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Ejection Request\n")); + break; + + case 2: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Device Wake\n")); + break; + + case 0x80: + DEBUG_PRINT (ACPI_INFO, ("Notify value: Status Change\n")); + break; + + default: + DEBUG_PRINT (ACPI_INFO, ("Unknown Notify Value: %lx \n", NotifyValue)); + break; + } + + + /* + * Invoke a global notify handler if installed. + * This is done _before_ we invoke the per-device handler attached to the device. + */ + + if (NotifyValue <= MAX_SYS_NOTIFY) + { + /* Global system notification handler */ + + if (AcpiGbl_SysNotify.Handler) + { + AcpiGbl_SysNotify.Handler (Device, NotifyValue, + AcpiGbl_SysNotify.Context); + } + } + + else + { + /* Global driver notification handler */ + + if (AcpiGbl_DrvNotify.Handler) + { + AcpiGbl_DrvNotify.Handler (Device, NotifyValue, + AcpiGbl_DrvNotify.Context); + } + } + + + /* + * Get the notify object which must be attached to the device Node + */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Device); + if (!ObjDesc) + { + /* There can be no notify handler for this device */ + + DEBUG_PRINT (ACPI_INFO, + ("No notify handler for device %p \n", Device)); + return; + } + + + /* We have the notify object, Get the right handler */ + + if (NotifyValue <= MAX_SYS_NOTIFY) + { + HandlerObj = ObjDesc->Device.SysHandler; + } + else + { + HandlerObj = ObjDesc->Device.DrvHandler; + } + + /* Validate the handler */ + + if (!HandlerObj) + { + /* There is no notify handler for this device */ + + DEBUG_PRINT (ACPI_INFO, + ("No notify handler for device %p \n", Device)); + return; + } + + /* There is a handler, invoke it */ + + Handler = HandlerObj->NotifyHandler.Handler; + Handler (Device, NotifyValue, HandlerObj->NotifyHandler.Context); + +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvGlobalLockThread + * + * RETURN: None + * + * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the + * Global Lock. Simply signal all threads that are waiting + * for the lock. + * + **************************************************************************/ + +void +AcpiEvGlobalLockThread ( + void *Context) +{ + + /* Signal threads that are waiting for the lock */ + + if (AcpiGbl_GlobalLockThreadCount) + { + /* Send sufficient units to the semaphore */ + + AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, + AcpiGbl_GlobalLockThreadCount); + } +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvGlobalLockHandler + * + * RETURN: Status + * + * DESCRIPTION: Invoked directly from the SCI handler when a global lock + * release interrupt occurs. Grab the global lock and queue + * the global lock thread for execution + * + **************************************************************************/ + +UINT32 +AcpiEvGlobalLockHandler ( + void *Context) +{ + BOOLEAN Acquired = FALSE; + void *GlobalLock; + + + /* + * Attempt to get the lock + * If we don't get it now, it will be marked pending and we will + * take another interrupt when it becomes free. + */ + + GlobalLock = &AcpiGbl_FACS->GlobalLock; + ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); + if (Acquired) + { + /* Got the lock, now wake all threads waiting for it */ + + AcpiGbl_GlobalLockAcquired = TRUE; + + /* Run the Global Lock thread which will signal all waiting threads */ + + AcpiOsQueueForExecution (OSD_PRIORITY_HIGH, AcpiEvGlobalLockThread, + Context); + } + + return (INTERRUPT_HANDLED); +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvInitGlobalLockHandler + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for the global lock release event + * + **************************************************************************/ + +ACPI_STATUS +AcpiEvInitGlobalLockHandler (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInitGlobalLockHandler"); + + + Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler, NULL); + + return_ACPI_STATUS (Status); +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvAcquireGlobalLock + * + * RETURN: Status + * + * DESCRIPTION: Attempt to gain ownership of the Global Lock. + * + **************************************************************************/ + +ACPI_STATUS +AcpiEvAcquireGlobalLock(void) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN Acquired = FALSE; + void *GlobalLock; + + + FUNCTION_TRACE ("EvAcquireGlobalLock"); + + + /* One more thread wants the global lock */ + + AcpiGbl_GlobalLockThreadCount++; + + + /* If we (OS side) have the hardware lock already, we are done */ + + if (AcpiGbl_GlobalLockAcquired) + { + return_ACPI_STATUS (AE_OK); + } + + /* Only if the FACS is valid */ + + if (!AcpiGbl_FACS) + { + return_ACPI_STATUS (AE_OK); + } + + + /* We must acquire the actual hardware lock */ + + GlobalLock = &AcpiGbl_FACS->GlobalLock; + ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); + if (Acquired) + { + /* We got the lock */ + + DEBUG_PRINT (ACPI_INFO, ("Acquired the HW Global Lock\n")); + + AcpiGbl_GlobalLockAcquired = TRUE; + + return_ACPI_STATUS (AE_OK); + } + + + /* + * Did not get the lock. The pending bit was set above, and we must now + * wait until we get the global lock released interrupt. + */ + + DEBUG_PRINT (ACPI_INFO, ("Waiting for the HW Global Lock\n")); + + /* + * Acquire the global lock semaphore first. + * Since this wait will block, we must release the interpreter + */ + + Status = AcpiAmlSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, + ACPI_UINT32_MAX); + + return_ACPI_STATUS (Status); +} + + +/*************************************************************************** + * + * FUNCTION: AcpiEvReleaseGlobalLock + * + * DESCRIPTION: Releases ownership of the Global Lock. + * + **************************************************************************/ + +void +AcpiEvReleaseGlobalLock (void) +{ + BOOLEAN Pending = FALSE; + void *GlobalLock; + + + FUNCTION_TRACE ("EvReleaseGlobalLock"); + + if (!AcpiGbl_GlobalLockThreadCount) + { + REPORT_WARNING(("Releasing a non-acquired Global Lock\n")); + return_VOID; + } + + /* One fewer thread has the global lock */ + + AcpiGbl_GlobalLockThreadCount--; + + /* Have all threads released the lock? */ + + if (!AcpiGbl_GlobalLockThreadCount) + { + /* + * No more threads holding lock, we can do the actual hardware + * release + */ + + GlobalLock = &AcpiGbl_FACS->GlobalLock; + ACPI_RELEASE_GLOBAL_LOCK (GlobalLock, Pending); + AcpiGbl_GlobalLockAcquired = FALSE; + + /* + * If the pending bit was set, we must write GBL_RLS to the control + * register + */ + if (Pending) + { + AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, + PM1_CONTROL | GBL_RLS, 1); + } + } + + return_VOID; +} diff --git a/sys/contrib/dev/acpica/evregion.c b/sys/contrib/dev/acpica/evregion.c new file mode 100644 index 0000000..1248482 --- /dev/null +++ b/sys/contrib/dev/acpica/evregion.c @@ -0,0 +1,765 @@ +/****************************************************************************** + * + * Module Name: evregion - ACPI AddressSpace / OpRegion handler dispatch + * $Revision: 85 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVREGION_C__ + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evregion") + + +/************************************************************************** + * + * FUNCTION: AcpiEvInstallDefaultAddressSpaceHandlers + * + * PARAMETERS: + * + * RETURN: Status + * + * DESCRIPTION: Installs the core subsystem address space handlers. + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvInstallDefaultAddressSpaceHandlers ( + void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvInstallDefaultAddressSpaceHandlers"); + + /* + * All address spaces (PCI Config, EC, SMBus) are scope dependent + * and registration must occur for a specific device. In the case + * system memory and IO address spaces there is currently no device + * associated with the address space. For these we use the root. + * We install the default PCI config space handler at the root so + * that this space is immediately available even though the we have + * not enumerated all the PCI Root Buses yet. This is to conform + * to the ACPI specification which states that the PCI config + * space must be always available -- even though we are nowhere + * near ready to find the PCI root buses at this point. + * + * NOTE: We ignore AE_EXIST because this means that a handler has + * already been installed (via AcpiInstallAddressSpaceHandler) + */ + + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + ADDRESS_SPACE_SYSTEM_MEMORY, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if ((ACPI_FAILURE (Status)) && + (Status != AE_EXIST)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + ADDRESS_SPACE_SYSTEM_IO, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if ((ACPI_FAILURE (Status)) && + (Status != AE_EXIST)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + ADDRESS_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if ((ACPI_FAILURE (Status)) && + (Status != AE_EXIST)) + { + return_ACPI_STATUS (Status); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/* TBD: [Restructure] Move elsewhere */ + +/************************************************************************** + * + * FUNCTION: AcpiEvExecuteRegMethod + * + * PARAMETERS: RegionObj - Object structure + * Function - On (1) or Off (0) + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG method for a region + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function) +{ + ACPI_OPERAND_OBJECT *Params[3]; + ACPI_OPERAND_OBJECT SpaceID_Obj; + ACPI_OPERAND_OBJECT Function_Obj; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvExecuteRegMethod"); + + + if (RegionObj->Region.Extra->Extra.Method_REG == NULL) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * _REG method has two arguments + * Arg0: Integer: Operation region space ID + * Same value as RegionObj->Region.SpaceId + * Arg1: Integer: connection status + * 1 for connecting the handler, + * 0 for disconnecting the handler + * Passed as a parameter + */ + + AcpiCmInitStaticObject (&SpaceID_Obj); + AcpiCmInitStaticObject (&Function_Obj); + + /* + * Method requires two parameters. + */ + Params [0] = &SpaceID_Obj; + Params [1] = &Function_Obj; + Params [2] = NULL; + + /* + * Set up the parameter objects + */ + SpaceID_Obj.Common.Type = ACPI_TYPE_NUMBER; + SpaceID_Obj.Number.Value = RegionObj->Region.SpaceId; + + Function_Obj.Common.Type = ACPI_TYPE_NUMBER; + Function_Obj.Number.Value = Function; + + /* + * Execute the method, no return value + */ + Status = AcpiNsEvaluateByHandle (RegionObj->Region.Extra->Extra.Method_REG, Params, NULL); + return_ACPI_STATUS (Status); +} + + +/************************************************************************** + * + * FUNCTION: AcpiEvAddressSpaceDispatch + * + * PARAMETERS: RegionObj - internal region object + * SpaceId - ID of the address space (0-255) + * Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * + * RETURN: Status + * + * DESCRIPTION: Dispatch an address space or operation region access to + * a previously installed handler. + * + *************************************************************************/ + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value) +{ + ACPI_STATUS Status; + ADDRESS_SPACE_HANDLER Handler; + ADDRESS_SPACE_SETUP RegionSetup; + ACPI_OPERAND_OBJECT *HandlerDesc; + void *RegionContext = NULL; + + + FUNCTION_TRACE ("EvAddressSpaceDispatch"); + + + /* + * Check for an installed handler + */ + HandlerDesc = RegionObj->Region.AddrHandler; + + if (!HandlerDesc) + { + DEBUG_PRINT (TRACE_OPREGION, + ("Dispatch address access region 0x%p, no handler\n", RegionObj)); + return_ACPI_STATUS(AE_NOT_EXIST); + } + + /* + * It may be the case that the region has never been initialized + * Some types of regions require special init code + */ + if (!(RegionObj->Region.Flags & AOPOBJ_INITIALIZED)) + { + /* + * This region has not been initialized yet, do it + */ + RegionSetup = HandlerDesc->AddrHandler.Setup; + if (!RegionSetup) + { + /* + * Bad news, no init routine and not init'd + */ + DEBUG_PRINT (ACPI_ERROR, + ("EvAddressSpaceDispatch: No init routine for region %p\n", + RegionObj)); + return_ACPI_STATUS (AE_UNKNOWN_STATUS); + } + + /* + * We must exit the interpreter because the region setup will potentially + * execute control methods + */ + AcpiAmlExitInterpreter (); + + Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, + HandlerDesc->AddrHandler.Context, + &RegionContext); + + /* Re-enter the interpreter */ + + AcpiAmlEnterInterpreter (); + + /* + * Init routine may fail + */ + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("EvAddressSpaceDispatch: %s from region init, SpaceID %d\n", + AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); + return_ACPI_STATUS(Status); + } + + RegionObj->Region.Flags |= AOPOBJ_INITIALIZED; + + /* + * Save the returned context for use in all accesses to + * this particular region. + */ + RegionObj->Region.Extra->Extra.RegionContext = RegionContext; + } + + /* + * We have everything we need, begin the process + */ + Handler = HandlerDesc->AddrHandler.Handler; + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Addrhandler 0x%p (0x%p), Address 0x%p\n", + &RegionObj->Region.AddrHandler->AddrHandler, Handler, Address)); + + if (!(HandlerDesc->AddrHandler.Flags & 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. + */ + AcpiAmlExitInterpreter(); + } + + /* + * Invoke the handler. + */ + Status = Handler (Function, Address, BitWidth, Value, + HandlerDesc->AddrHandler.Context, + RegionObj->Region.Extra->Extra.RegionContext); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("EvAddressSpaceDispatch: %s from handler, SpaceID %d\n", + AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); + } + + if (!(HandlerDesc->AddrHandler.Flags & ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* We just returned from a non-default handler, we must re-enter the + interpreter */ + + AcpiAmlEnterInterpreter (); + } + + return_ACPI_STATUS (Status); +} + +/****************************************************************************** + * + * FUNCTION: AcpiEvDisassociateRegionFromHandler + * + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * + * RETURN: None + * + * DESCRIPTION: Break the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +void +AcpiEvDisassociateRegionFromHandler( + ACPI_OPERAND_OBJECT *RegionObj) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + ADDRESS_SPACE_SETUP RegionSetup; + void *RegionContext; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvDisassociateRegionFromHandler"); + + RegionContext = RegionObj->Region.Extra->Extra.RegionContext; + + /* + * Get the address handler from the region object + */ + + HandlerObj = RegionObj->Region.AddrHandler; + if (!HandlerObj) + { + /* + * This region has no handler, all done + */ + return_VOID; + } + + + /* + * Find this region in the handler's list + */ + + ObjDesc = HandlerObj->AddrHandler.RegionList; + LastObjPtr = &HandlerObj->AddrHandler.RegionList; + + while (ObjDesc) + { + /* + * See if this is the one + */ + if (ObjDesc == RegionObj) + { + DEBUG_PRINT (TRACE_OPREGION, + ("Removing Region 0x%p from address handler 0x%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 */ + + /* + * Now stop region accesses by executing the _REG method + */ + AcpiEvExecuteRegMethod (RegionObj, 0); + + /* + * Call the setup handler with the deactivate notification + */ + RegionSetup = HandlerObj->AddrHandler.Setup; + Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, + HandlerObj->AddrHandler.Context, + &RegionContext); + + /* + * Init routine may fail, Just ignore errors + */ + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("EvDisassociateRegionFromHandler: %s from region init, SpaceID %d\n", + AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); + } + + RegionObj->Region.Flags &= ~(AOPOBJ_INITIALIZED); + + /* + * Remove handler reference in the region + * + * NOTE: this doesn't mean that the region goes away + * The region is just inaccessible as indicated to + * the _REG method + * + * If the region is on the handler's list + * this better be the region's handler + */ + ACPI_ASSERT (RegionObj->Region.AddrHandler == HandlerObj); + + RegionObj->Region.AddrHandler = NULL; + + return_VOID; + + } /* found the right handler */ + + /* + * Move through the linked list of handlers + */ + LastObjPtr = &ObjDesc->Region.Next; + ObjDesc = ObjDesc->Region.Next; + } + + /* + * If we get here, the region was not in the handler's region list + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Cannot remove region 0x%p from address handler 0x%p\n", + RegionObj, HandlerObj)); + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvAssociateRegionAndHandler + * + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * + * RETURN: None + * + * DESCRIPTION: Create the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAssociateRegionAndHandler ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("EvAssociateRegionAndHandler"); + + + DEBUG_PRINT (TRACE_OPREGION, ("Adding Region 0x%p to address handler 0x%p\n", + RegionObj, HandlerObj)); + + ACPI_ASSERT (RegionObj->Region.SpaceId == HandlerObj->AddrHandler.SpaceId); + ACPI_ASSERT (RegionObj->Region.AddrHandler == 0); + + /* + * Link this region to the front of the handler's list + */ + + RegionObj->Region.Next = HandlerObj->AddrHandler.RegionList; + HandlerObj->AddrHandler.RegionList = RegionObj; + + /* + * set the region's handler + */ + +/* + HandlerObj->Common.ReferenceCount = + (UINT16) (HandlerObj->Common.ReferenceCount + + RegionObj->Common.ReferenceCount - 1); +*/ + RegionObj->Region.AddrHandler = HandlerObj; + + /* + * Last thing, tell all users that this region is usable + */ + if (AcpiNsIsLocked) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + Status = AcpiEvExecuteRegMethod (RegionObj, 1); + + if (AcpiNsIsLocked) + { + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + } + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiEvAddrHandlerHelper + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into AcpiNsWalkNamespace + * + * DESCRIPTION: This routine checks to see if the object is a Region if it + * is then the address handler is installed in it. + * + * If the Object is a Device, and the device has a handler of + * the same type then the search is terminated in that branch. + * + * This is because the existing handler is closer in proximity + * to any more regions than the one we are trying to install. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiEvAddrHandlerHelper ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *TmpObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + HandlerObj = (ACPI_OPERAND_OBJECT *) Context; + + /* Parameter validation */ + + if (!HandlerObj) + { + return (AE_OK); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsConvertHandleToEntry (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions.and objects + * that can have address handlers + */ + + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + if (!ObjDesc) + { + /* + * The object DNE, we don't care about it + */ + return (AE_OK); + } + + /* + * Devices are handled different than regions + */ + if (IS_THIS_OBJECT_TYPE (ObjDesc, ACPI_TYPE_DEVICE)) + { + /* + * See if this guy has any handlers + */ + TmpObj = ObjDesc->Device.AddrHandler; + while (TmpObj) + { + /* + * Now let's see if it's for the same address space. + */ + if (TmpObj->AddrHandler.SpaceId == HandlerObj->AddrHandler.SpaceId) + { + /* + * It's for the same address space + */ + + DEBUG_PRINT (TRACE_OPREGION, + ("Found handler for %s in device 0x%p (0x%p) handler 0x%p\n", + AcpiGbl_RegionTypes[HandlerObj->AddrHandler.SpaceId], ObjDesc, TmpObj, HandlerObj)); + + /* + * Since the object we found it on was a device, then it + * means that someone has already installed a handler for + * the branch of the namespace from this device on. Just + * bail out telling the walk routine to not traverse this + * branch. This preserves the scoping rule for handlers. + */ + return (AE_CTRL_DEPTH); + } + + /* + * Move through the linked list of handlers + */ + TmpObj = TmpObj->AddrHandler.Next; + } + + /* + * As long as the device didn't have a handler for this + * space we don't care about it. We just ignore it and + * proceed. + */ + return (AE_OK); + } + + /* + * Only here if it was a region + */ + ACPI_ASSERT (ObjDesc->Common.Type == ACPI_TYPE_REGION); + + if (ObjDesc->Region.SpaceId != HandlerObj->AddrHandler.SpaceId) + { + /* + * This region is for a different address space + * ignore it + */ + return (AE_OK); + } + + /* + * Now we have a region and it is for the handler's address + * space type. + * + * First disconnect region for any previous handler (if any) + */ + AcpiEvDisassociateRegionFromHandler (ObjDesc); + + /* + * Then connect the region to the new handler + */ + Status = AcpiEvAssociateRegionAndHandler (HandlerObj, ObjDesc, FALSE); + + return (Status); +} + + diff --git a/sys/contrib/dev/acpica/evrgnini.c b/sys/contrib/dev/acpica/evrgnini.c new file mode 100644 index 0000000..b4aaa7a --- /dev/null +++ b/sys/contrib/dev/acpica/evrgnini.c @@ -0,0 +1,557 @@ +/****************************************************************************** + * + * Module Name: evrgnini- ACPI AddressSpace / OpRegion init + * $Revision: 27 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVRGNINI_C__ + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evrgnini") + + +/***************************************************************************** + * + * FUNCTION: AcpiEvSystemMemoryRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling, a nop for now + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + FUNCTION_TRACE ("EvSystemMemoryRegionSetup"); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + if (*RegionContext) + { + AcpiCmFree (*RegionContext); + *RegionContext = NULL; + } + return_ACPI_STATUS (AE_OK); + } + + + /* Activate. Create a new context */ + + *RegionContext = AcpiCmCallocate (sizeof (MEM_HANDLER_CONTEXT)); + if (!(*RegionContext)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiEvIoSpaceRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + FUNCTION_TRACE ("EvIoSpaceRegionSetup"); + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiEvPciConfigRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling + * + * MUTEX: Assumes namespace is not locked + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Temp; + PCI_HANDLER_CONTEXT *PciContext = *RegionContext; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; + DEVICE_ID ObjectHID; + + FUNCTION_TRACE ("EvPciConfigRegionSetup"); + + HandlerObj = RegionObj->Region.AddrHandler; + + if (!HandlerObj) + { + /* + * No installed handler. This shouldn't happen because the dispatch + * routine checks before we get here, but we check again just in case. + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Attempting to init a region 0x%X, with no handler\n", RegionObj)); + return_ACPI_STATUS(AE_NOT_EXIST); + } + + if (Function == ACPI_REGION_DEACTIVATE) + { + if (PciContext) + { + AcpiCmFree (PciContext); + *RegionContext = NULL; + } + + return_ACPI_STATUS (Status); + } + + + /* Create a new context */ + + PciContext = AcpiCmCallocate (sizeof(PCI_HANDLER_CONTEXT)); + if (!PciContext) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * For PCI Config space access, we have to pass the segment, bus, + * device and function numbers. This routine must acquire those. + */ + + /* + * First get device and function numbers from the _ADR object + * in the parent's scope. + */ + ACPI_ASSERT(RegionObj->Region.Node); + + Node = AcpiNsGetParentObject (RegionObj->Region.Node); + + + /* AcpiEvaluate the _ADR object */ + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__ADR, Node, &Temp); + /* + * The default is zero, since the allocation above zeroed the data, just + * do nothing on failures. + */ + if (ACPI_SUCCESS (Status)) + { + /* + * Got it.. + */ + PciContext->DevFunc = (UINT32) Temp; + } + + /* + * Get the _SEG and _BBN values from the device upon which the handler + * is installed. + * + * We need to get the _SEG and _BBN objects relative to the PCI BUS device. + * This is the device the handler has been registered to handle. + */ + + /* + * If the AddrHandler.Node is still pointing to the root, we need + * to scan upward for a PCI Root bridge and re-associate the OpRegion + * handlers with that device. + */ + if (HandlerObj->AddrHandler.Node == AcpiGbl_RootNode) + { + /* + * Node is currently the parent object + */ + while (Node != AcpiGbl_RootNode) + { + Status = AcpiCmExecute_HID(Node, &ObjectHID); + + if (ACPI_SUCCESS (Status)) + { + if (!(STRNCMP(ObjectHID.Buffer, PCI_ROOT_HID_STRING, + sizeof (PCI_ROOT_HID_STRING)))) + { + AcpiInstallAddressSpaceHandler(Node, + ADDRESS_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + + break; + } + } + + Node = AcpiNsGetParentObject(Node); + } + } + else + { + Node = HandlerObj->AddrHandler.Node; + } + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__SEG, Node, &Temp); + if (ACPI_SUCCESS (Status)) + { + /* + * Got it.. + */ + PciContext->Seg = (UINT32) Temp; + } + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__BBN, Node, &Temp); + if (ACPI_SUCCESS (Status)) + { + /* + * Got it.. + */ + PciContext->Bus = (UINT32) Temp; + } + + *RegionContext = PciContext; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiEvDefaultRegionSetup + * + * PARAMETERS: RegionObj - region we are interested in + * Function - start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Do any prep work for region handling + * + ****************************************************************************/ + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + 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 + * + * 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 intialization. For + * example, PCI regions must have an _ADR object that contains + * a PCI address in the scope of the defintion. This address is + * required to perform an access to PCI config space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 SpaceId; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; + + + FUNCTION_TRACE_U32 ("EvInitializeRegion", AcpiNsLocked); + + + if (!RegionObj) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ACPI_ASSERT(RegionObj->Region.Node); + + Node = AcpiNsGetParentObject (RegionObj->Region.Node); + SpaceId = RegionObj->Region.SpaceId; + + RegionObj->Region.AddrHandler = NULL; + RegionObj->Region.Extra->Extra.Method_REG = NULL; + RegionObj->Region.Flags &= ~(AOPOBJ_INITIALIZED); + + /* + * Find any "_REG" associated with this region definition + */ + Status = AcpiNsSearchNode (*RegNamePtr, Node, + ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per region + * definition. This will be executed when the handler is attached + * or removed + */ + RegionObj->Region.Extra->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 ((ACPI_HANDLE) Node); + if (ObjDesc) + { + /* + * can only be a handler if the object exists + */ + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + + HandlerObj = ObjDesc->Device.AddrHandler; + break; + + case ACPI_TYPE_PROCESSOR: + + HandlerObj = ObjDesc->Processor.AddrHandler; + break; + + case ACPI_TYPE_THERMAL: + + HandlerObj = ObjDesc->ThermalZone.AddrHandler; + break; + } + + while (HandlerObj) + { + /* + * This guy has at least one address handler + * see if it has the type we want + */ + if (HandlerObj->AddrHandler.SpaceId == SpaceId) + { + DEBUG_PRINT (TRACE_OPREGION, + ("Found handler (0x%X) for region 0x%X in obj 0x%X\n", + HandlerObj, RegionObj, ObjDesc)); + + /* + * Found it! Now update the region and the handler + */ + AcpiEvAssociateRegionAndHandler (HandlerObj, RegionObj, AcpiNsLocked); + return_ACPI_STATUS (AE_OK); + } + + HandlerObj = HandlerObj->AddrHandler.Next; + + } /* while handlerobj */ + } + + /* + * This one does not have the handler we need + * Pop up one level + */ + Node = AcpiNsGetParentObject (Node); + + } /* while Node != ROOT */ + + /* + * If we get here, there is no handler for this region + */ + DEBUG_PRINT (TRACE_OPREGION, + ("No handler currently for SpaceId[%d] (Initializing region 0x%X)\n", + SpaceId, RegionObj)); + + return_ACPI_STATUS (AE_NOT_EXIST); +} + diff --git a/sys/contrib/dev/acpica/evsci.c b/sys/contrib/dev/acpica/evsci.c new file mode 100644 index 0000000..fb43444 --- /dev/null +++ b/sys/contrib/dev/acpica/evsci.c @@ -0,0 +1,448 @@ +/******************************************************************************* + * + * Module Name: evsci - System Control Interrupt configuration and + * legacy to ACPI mode state transition functions + * $Revision: 60 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evsci") + + +/* + * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC, + * and GENERAL respectively. These counts are modified by the ACPI interrupt + * handler. + * + * TBD: [Investigate] Note that GENERAL should probably be split out into + * one element for each bit in the GPE registers + */ + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSciHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Interrupt handler that will figure out what function or + * control method to call to deal with a SCI. Installed + * using BU interrupt support. + * + ******************************************************************************/ + +UINT32 +AcpiEvSciHandler (void *Context) +{ + UINT32 InterruptHandled = INTERRUPT_NOT_HANDLED; + + + FUNCTION_TRACE("EvSciHandler"); + + + /* + * Make sure that ACPI is enabled by checking SCI_EN. Note that we are + * required to treat the SCI interrupt as sharable, level, active low. + */ + if (!AcpiHwRegisterAccess (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) + { + /* ACPI is not enabled; this interrupt cannot be for us */ + + return_VALUE (INTERRUPT_NOT_HANDLED); + } + + /* + * Fixed AcpiEvents: + * ------------- + * Check for and dispatch any Fixed AcpiEvents that have occurred + */ + InterruptHandled |= AcpiEvFixedEventDetect (); + + /* + * GPEs: + * ----- + * Check for and dispatch any GPEs that have occurred + */ + InterruptHandled |= AcpiEvGpeDetect (); + + return_VALUE (InterruptHandled); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvInstallSciHandler + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Installs SCI handler. + * + ******************************************************************************/ + +UINT32 +AcpiEvInstallSciHandler (void) +{ + UINT32 Except = AE_OK; + + + FUNCTION_TRACE ("EvInstallSciHandler"); + + + Except = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FACP->SciInt, + AcpiEvSciHandler, + NULL); + + return_ACPI_STATUS (Except); +} + + +/****************************************************************************** + + * + * FUNCTION: AcpiEvRemoveSciHandler + * + * PARAMETERS: none + * + * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not + * installed to begin with + * + * DESCRIPTION: Restores original status of all fixed event enable bits and + * removes SCI handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvRemoveSciHandler (void) +{ + FUNCTION_TRACE ("EvRemoveSciHandler"); + +#if 0 + /* TBD:[Investigate] Figure this out!! Disable all events first ??? */ + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (TMR_FIXED_EVENT)) + { + AcpiEventDisableEvent (TMR_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (GBL_FIXED_EVENT)) + { + AcpiEventDisableEvent (GBL_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (PWR_BTN_FIXED_EVENT)) + { + AcpiEventDisableEvent (PWR_BTN_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (SLP_BTN_FIXED_EVENT)) + { + AcpiEventDisableEvent (SLP_BTN_FIXED_EVENT); + } + + if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (RTC_FIXED_EVENT)) + { + AcpiEventDisableEvent (RTC_FIXED_EVENT); + } + + OriginalFixedEnableBitStatus = 0; + +#endif + + AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FACP->SciInt, + AcpiEvSciHandler); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSciCount + * + * PARAMETERS: Event Event that generated an SCI. + * + * RETURN: Number of SCI's for requested event since last time + * SciOccured() was called for this event. + * + * DESCRIPTION: Checks to see if SCI has been generated from requested source + * since the last time this function was called. + * + ******************************************************************************/ + +#ifdef ACPI_DEBUG + +UINT32 +AcpiEvSciCount ( + UINT32 Event) +{ + UINT32 Count; + + FUNCTION_TRACE ("EvSciCount"); + + /* + * Elements correspond to counts for TMR, NOT_USED, GBL, + * PWR_BTN, SLP_BTN, RTC, and GENERAL respectively. + */ + + if (Event >= NUM_FIXED_EVENTS) + { + Count = (UINT32) -1; + } + else + { + Count = AcpiGbl_EventCount[Event]; + } + + return_VALUE (Count); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRestoreAcpiState + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Restore the original ACPI state of the machine + * + ******************************************************************************/ + +void +AcpiEvRestoreAcpiState (void) +{ + UINT32 Index; + + + FUNCTION_TRACE ("EvRestoreAcpiState"); + + + /* Restore the state of the chipset enable bits. */ + + if (AcpiGbl_RestoreAcpiChipset == TRUE) + { + /* Restore the fixed events */ + + if (AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk + 2) != + AcpiGbl_Pm1EnableRegisterSave) + { + AcpiOsOut16 ((AcpiGbl_FACP->Pm1aEvtBlk + 2), + AcpiGbl_Pm1EnableRegisterSave); + } + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + if (AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk + 2) != + AcpiGbl_Pm1EnableRegisterSave) + { + AcpiOsOut16 ((AcpiGbl_FACP->Pm1bEvtBlk + 2), + AcpiGbl_Pm1EnableRegisterSave); + } + } + + + /* Ensure that all status bits are clear */ + + AcpiHwClearAcpiStatus (); + + + /* Now restore the GPEs */ + + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); Index++) + { + if (AcpiOsIn8 (AcpiGbl_FACP->Gpe0Blk + + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)) != + AcpiGbl_Gpe0EnableRegisterSave[Index]) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe0Blk + + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)), + AcpiGbl_Gpe0EnableRegisterSave[Index]); + } + } + + if (AcpiGbl_FACP->Gpe1Blk && AcpiGbl_FACP->Gpe1BlkLen) + { + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); Index++) + { + if (AcpiOsIn8 (AcpiGbl_FACP->Gpe1Blk + + DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)) != + AcpiGbl_Gpe1EnableRegisterSave[Index]) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe1Blk + + DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)), + AcpiGbl_Gpe1EnableRegisterSave[Index]); + } + } + } + + if (AcpiHwGetMode() != AcpiGbl_OriginalMode) + { + AcpiHwSetMode (AcpiGbl_OriginalMode); + } + } + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiEvTerminate (void) +{ + + FUNCTION_TRACE ("EvTerminate"); + + + /* + * Free global tables, etc. + */ + + if (AcpiGbl_GpeRegisters) + { + AcpiCmFree (AcpiGbl_GpeRegisters); + } + + if (AcpiGbl_GpeInfo) + { + AcpiCmFree (AcpiGbl_GpeInfo); + } + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/evxface.c b/sys/contrib/dev/acpica/evxface.c new file mode 100644 index 0000000..03886ef --- /dev/null +++ b/sys/contrib/dev/acpica/evxface.c @@ -0,0 +1,744 @@ +/****************************************************************************** + * + * Module Name: evxface - External interfaces for ACPI events + * $Revision: 91 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial prton of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFACE_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acinterp.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evxface") + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallFixedEventHandler + * + * PARAMETERS: Event - Event type to enable. + * Handler - Pointer to the handler function for the + * event + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function and then enables the + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 Event, + FIXED_EVENT_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); + + + /* Sanity check the parameters. */ + + if (Event >= NUM_FIXED_EVENTS) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Don't allow two handlers. */ + + if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) + { + Status = AE_EXIST; + goto Cleanup; + } + + + /* Install the handler before enabling the event - just in case... */ + + AcpiGbl_FixedEventHandlers[Event].Handler = Handler; + AcpiGbl_FixedEventHandlers[Event].Context = Context; + + if (1 != AcpiHwRegisterAccess (ACPI_WRITE, + ACPI_MTX_LOCK, Event + TMR_EN, 1)) + { + DEBUG_PRINT (ACPI_WARN, + ("Could not write to fixed event enable register.\n")); + + /* Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + + Status = AE_ERROR; + goto Cleanup; + } + + DEBUG_PRINT (ACPI_INFO, + ("Enabled fixed event %d. Handler: %x\n", Event, Handler)); + + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiRemoveFixedEventHandler + * + * PARAMETERS: Event - Event type to disable. + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Disables the event and unregisters the event handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 Event, + FIXED_EVENT_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveFixedEventHandler"); + + + /* Sanity check the parameters. */ + + if (Event >= NUM_FIXED_EVENTS) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Disable the event before removing the handler - just in case... */ + + if (0 != AcpiHwRegisterAccess (ACPI_WRITE, + ACPI_MTX_LOCK, Event + TMR_EN, 0)) + { + DEBUG_PRINT (ACPI_WARN, + ("Could not write to fixed event enable register.\n")); + Status = AE_ERROR; + goto Cleanup; + } + + /* Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + + DEBUG_PRINT (ACPI_INFO, ("Disabled fixed event %d.\n", Event)); + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * Handler - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiInstallNotifyHandler"); + + + /* Parameter validation */ + + if ((!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Convert and validate the device handle */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + DeviceNode = AcpiNsConvertHandleToEntry (Device); + if (!DeviceNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* + * Support for global notify handlers. These handlers are invoked for + * every notifiy of the type specifiec + */ + + if (Device == ACPI_ROOT_OBJECT) + { + /* + * Make sure the handler is not already installed. + */ + + if (((HandlerType == ACPI_SYSTEM_NOTIFY) && + AcpiGbl_SysNotify.Handler) || + ((HandlerType == ACPI_DEVICE_NOTIFY) && + AcpiGbl_DrvNotify.Handler)) + { + Status = AE_EXIST; + goto UnlockAndExit; + } + + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SysNotify.Node = DeviceNode; + AcpiGbl_SysNotify.Handler = Handler; + AcpiGbl_SysNotify.Context = Context; + } + + else + { + AcpiGbl_DrvNotify.Node = DeviceNode; + AcpiGbl_DrvNotify.Handler = Handler; + AcpiGbl_DrvNotify.Context = Context; + } + + + /* Global notify handler installed */ + + goto UnlockAndExit; + } + + + /* + * These are the ONLY objects that can receive ACPI notifications + */ + + if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && + (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && + (DeviceNode->Type != ACPI_TYPE_POWER) && + (DeviceNode->Type != ACPI_TYPE_THERMAL)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); + if (ObjDesc) + { + /* + * The object exists. + * Make sure the handler is not already installed. + */ + + if (((HandlerType == ACPI_SYSTEM_NOTIFY) && + ObjDesc->Device.SysHandler) || + ((HandlerType == ACPI_DEVICE_NOTIFY) && + ObjDesc->Device.DrvHandler)) + { + Status = AE_EXIST; + goto UnlockAndExit; + } + } + + else + { + /* Create a new object */ + + ObjDesc = AcpiCmCreateInternalObject (DeviceNode->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Attach new object to the Node */ + + Status = AcpiNsAttachObject (Device, ObjDesc, (UINT8) DeviceNode->Type); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + + /* + * If we get here, we know that there is no handler installed + * so let's party + */ + NotifyObj = AcpiCmCreateInternalObject (INTERNAL_TYPE_NOTIFY); + if (!NotifyObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + NotifyObj->NotifyHandler.Node = DeviceNode; + NotifyObj->NotifyHandler.Handler = Handler; + NotifyObj->NotifyHandler.Context = Context; + + + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + ObjDesc->Device.SysHandler = NotifyObj; + } + + else + { + ObjDesc->Device.DrvHandler = NotifyObj; + } + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiRemoveNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * Handler - Address of the handler + * RETURN: Status + * + * DESCRIPTION: Remove a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + NOTIFY_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *DeviceNode; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); + + + /* Parameter validation */ + + if ((!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the device handle */ + + DeviceNode = AcpiNsConvertHandleToEntry (Device); + if (!DeviceNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * These are the ONLY objects that can receive ACPI notifications + */ + + if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && + (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && + (DeviceNode->Type != ACPI_TYPE_POWER) && + (DeviceNode->Type != ACPI_TYPE_THERMAL)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* + * The object exists. + * + * Make sure the handler is installed. + */ + + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + NotifyObj = ObjDesc->Device.SysHandler; + } + else + { + NotifyObj = ObjDesc->Device.DrvHandler; + } + + if ((!NotifyObj) || + (NotifyObj->NotifyHandler.Handler != Handler)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * Now we can remove the handler + */ + if (HandlerType == ACPI_SYSTEM_NOTIFY) + { + ObjDesc->Device.SysHandler = NULL; + } + else + { + ObjDesc->Device.DrvHandler = NULL; + } + + AcpiCmRemoveReference (NotifyObj); + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +/****************************************************************************** + * + * FUNCTION: AcpiInstallGpeHandler + * + * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is + * bank 0 first, then bank 1. + * Type - Whether this GPE should be treated as an + * edge- or level-triggered interrupt. + * Handler - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for a General Purpose Event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGpeHandler ( + UINT32 GpeNumber, + UINT32 Type, + GPE_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + + FUNCTION_TRACE ("AcpiInstallGpeHandler"); + + /* Parameter validation */ + + if (!Handler || (GpeNumber > NUM_GPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Make sure that there isn't a handler there already */ + + if (AcpiGbl_GpeInfo[GpeNumber].Handler) + { + Status = AE_EXIST; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_GpeInfo[GpeNumber].Handler = Handler; + AcpiGbl_GpeInfo[GpeNumber].Context = Context; + AcpiGbl_GpeInfo[GpeNumber].Type = (UINT8) Type; + + /* Clear the GPE (of stale events), the enable it */ + + AcpiHwClearGpe (GpeNumber); + AcpiHwEnableGpe (GpeNumber); + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiRemoveGpeHandler + * + * PARAMETERS: GpeNumber - The event to remove a handler + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveGpeHandler ( + UINT32 GpeNumber, + GPE_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveGpeHandler"); + + + /* Parameter validation */ + + if (!Handler || (GpeNumber > NUM_GPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Ensure that we have a valid GPE number */ + + if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the GPE before removing the handler */ + + AcpiHwDisableGpe (GpeNumber); + + AcpiCmAcquireMutex (ACPI_MTX_EVENTS); + + /* Make sure that the installed handler is the same */ + + if (AcpiGbl_GpeInfo[GpeNumber].Handler != Handler) + { + AcpiHwEnableGpe (GpeNumber); + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* Remove the handler */ + + AcpiGbl_GpeInfo[GpeNumber].Handler = NULL; + AcpiGbl_GpeInfo[GpeNumber].Context = NULL; + +Cleanup: + AcpiCmReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiAcquireGlobalLock + * + * PARAMETERS: Timeout - How long the caller is willing to wait + * OutHandle - A handle to the lock if acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire the ACPI Global Lock + * + ******************************************************************************/ +ACPI_STATUS +AcpiAcquireGlobalLock ( + void) +{ + ACPI_STATUS Status; + + + AcpiAmlEnterInterpreter (); + + /* + * TBD: [Restructure] add timeout param to internal interface, and + * perhaps INTERPRETER_LOCKED + */ + + Status = AcpiEvAcquireGlobalLock (); + AcpiAmlExitInterpreter (); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiReleaseGlobalLock + * + * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock + * + * RETURN: Status + * + * DESCRIPTION: Release the ACPI Global Lock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReleaseGlobalLock ( + void) +{ + AcpiEvReleaseGlobalLock (); + return (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/evxfevnt.c b/sys/contrib/dev/acpica/evxfevnt.c new file mode 100644 index 0000000..d6c849e --- /dev/null +++ b/sys/contrib/dev/acpica/evxfevnt.c @@ -0,0 +1,610 @@ +/****************************************************************************** + * + * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial prton of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __EVXFEVNT_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acinterp.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evxfevnt") + + +/************************************************************************** + * + * FUNCTION: AcpiEnable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into ACPI mode. + * + *************************************************************************/ + +ACPI_STATUS +AcpiEnable (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiEnable"); + + + /* Make sure we've got ACPI tables */ + + if (!AcpiGbl_DSDT) + { + DEBUG_PRINT (ACPI_WARN, ("No ACPI tables present!\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Make sure the BIOS supports ACPI mode */ + + if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities()) + { + DEBUG_PRINT (ACPI_WARN, + ("AcpiEnable: Only legacy mode supported!\n")); + return_ACPI_STATUS (AE_ERROR); + } + + /* Transition to ACPI mode */ + + Status = AcpiHwSetMode (SYS_MODE_ACPI); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_FATAL, ("Could not transition to ACPI mode.\n")); + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (ACPI_OK, ("Transition to ACPI mode successful\n")); + + return_ACPI_STATUS (Status); +} + + +/************************************************************************** + * + * FUNCTION: AcpiDisable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Returns the system to original ACPI/legacy mode, and + * uninstalls the SCI interrupt handler. + * + *************************************************************************/ + +ACPI_STATUS +AcpiDisable (void) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiDisable"); + + + /* Restore original mode */ + + Status = AcpiHwSetMode (AcpiGbl_OriginalMode); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("Unable to transition to original mode")); + return_ACPI_STATUS (Status); + } + + /* Unload the SCI interrupt handler */ + + AcpiEvRemoveSciHandler (); + AcpiEvRestoreAcpiState (); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEnableEvent + * + * PARAMETERS: Event - The fixed event or GPE to be enabled + * Type - The type of event + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (fixed and general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Type) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiEnableEvent"); + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_EN; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_EN; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_EN; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_EN; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_EN; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* + * Enable the requested fixed event (by writing a one to the + * enable register bit) + */ + + AcpiHwRegisterAccess (ACPI_WRITE, TRUE, RegisterId, 1); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Enable the requested GPE number */ + + AcpiHwEnableGpe (Event); + break; + + + default: + + Status = AE_BAD_PARAMETER; + } + + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDisableEvent + * + * PARAMETERS: Event - The fixed event or GPE to be enabled + * Type - The type of event + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (fixed and general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Type) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiDisableEvent"); + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_EN; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_EN; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_EN; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_EN; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_EN; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* + * Disable the requested fixed event (by writing a zero to the + * enable register bit) + */ + + AcpiHwRegisterAccess (ACPI_WRITE, TRUE, RegisterId, 0); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the requested GPE number */ + + AcpiHwDisableGpe (Event); + break; + + + default: + Status = AE_BAD_PARAMETER; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiClearEvent + * + * PARAMETERS: Event - The fixed event or GPE to be cleared + * Type - The type of event + * + * RETURN: Status + * + * DESCRIPTION: Clear an ACPI event (fixed and general purpose) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event, + UINT32 Type) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiClearEvent"); + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_STS; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_STS; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_STS; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_STS; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_STS; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* + * Clear the requested fixed event (By writing a one to the + * status register bit) + */ + + AcpiHwRegisterAccess (ACPI_WRITE, TRUE, RegisterId, 1); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + AcpiHwClearGpe (Event); + break; + + + default: + + Status = AE_BAD_PARAMETER; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetEventStatus + * + * PARAMETERS: Event - The fixed event or GPE + * Type - The type of event + * Status - Where the current status of the event will + * be returned + * + * RETURN: Status + * + * DESCRIPTION: Obtains and returns the current status of the event + * + ******************************************************************************/ + + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + UINT32 Type, + ACPI_EVENT_STATUS *EventStatus) +{ + ACPI_STATUS Status = AE_OK; + UINT32 RegisterId; + + + FUNCTION_TRACE ("AcpiGetEventStatus"); + + + if (!EventStatus) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* The Type must be either Fixed AcpiEvent or GPE */ + + switch (Type) + { + + case ACPI_EVENT_FIXED: + + /* Decode the Fixed AcpiEvent */ + + switch (Event) + { + case ACPI_EVENT_PMTIMER: + RegisterId = TMR_STS; + break; + + case ACPI_EVENT_GLOBAL: + RegisterId = GBL_STS; + break; + + case ACPI_EVENT_POWER_BUTTON: + RegisterId = PWRBTN_STS; + break; + + case ACPI_EVENT_SLEEP_BUTTON: + RegisterId = SLPBTN_STS; + break; + + case ACPI_EVENT_RTC: + RegisterId = RTC_STS; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + break; + } + + /* Get the status of the requested fixed event */ + + *EventStatus = AcpiHwRegisterAccess (ACPI_READ, TRUE, RegisterId); + break; + + + case ACPI_EVENT_GPE: + + /* Ensure that we have a valid GPE number */ + + if ((Event >= NUM_GPE) || + (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Obtain status on the requested GPE number */ + + AcpiHwGetGpeStatus (Event, EventStatus); + break; + + + default: + Status = AE_BAD_PARAMETER; + } + + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/evxfregn.c b/sys/contrib/dev/acpica/evxfregn.c new file mode 100644 index 0000000..fad4040 --- /dev/null +++ b/sys/contrib/dev/acpica/evxfregn.c @@ -0,0 +1,515 @@ +/****************************************************************************** + * + * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and + * Address Spaces. + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial prton of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __EVXFREGN_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acinterp.h" + +#define _COMPONENT EVENT_HANDLING + MODULE_NAME ("evxfregn") + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_SPACE_HANDLER Handler, + ADDRESS_SPACE_SETUP Setup, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status = AE_OK; + OBJECT_TYPE_INTERNAL Type; + UINT16 Flags = 0; + + + FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler"); + + /* Parameter validation */ + + if ((!Device) || + ((!Handler) && (Handler != ACPI_DEFAULT_HANDLER)) || + (SpaceId > ACPI_MAX_ADDRESS_SPACE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the device handle */ + + Node = AcpiNsConvertHandleToEntry (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * This registration is valid for only the types below + * and the root. This is where the default handlers + * get placed. + */ + + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if (Handler == ACPI_DEFAULT_HANDLER) + { + Flags = ADDR_HANDLER_DEFAULT_INSTALLED; + + switch (SpaceId) + { + case ADDRESS_SPACE_SYSTEM_MEMORY: + Handler = AcpiAmlSystemMemorySpaceHandler; + Setup = AcpiEvSystemMemoryRegionSetup; + break; + + case ADDRESS_SPACE_SYSTEM_IO: + Handler = AcpiAmlSystemIoSpaceHandler; + Setup = AcpiEvIoSpaceRegionSetup; + break; + + case ADDRESS_SPACE_PCI_CONFIG: + Handler = AcpiAmlPciConfigSpaceHandler; + Setup = AcpiEvPciConfigRegionSetup; + break; + + default: + Status = AE_NOT_EXIST; + goto UnlockAndExit; + break; + } + } + + /* + * If the caller hasn't specified a setup routine, use the default + */ + if (!Setup) + { + Setup = AcpiEvDefaultRegionSetup; + } + + /* + * Check for an existing internal object + */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + if (ObjDesc) + { + /* + * The object exists. + * Make sure the handler is not already installed. + */ + + /* check the address handler the user requested */ + + HandlerObj = ObjDesc->Device.AddrHandler; + while (HandlerObj) + { + /* + * We have an Address handler, see if user requested this + * address space. + */ + if(HandlerObj->AddrHandler.SpaceId == SpaceId) + { + Status = AE_EXIST; + goto UnlockAndExit; + } + + /* + * Move through the linked list of handlers + */ + HandlerObj = HandlerObj->AddrHandler.Next; + } + } + + else + { + DEBUG_PRINT (TRACE_OPREGION, + ("Creating object on Device 0x%X 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 = AcpiCmCreateInternalObject (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, (UINT8) Type); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + goto UnlockAndExit; + } + } + + DEBUG_PRINT (TRACE_OPREGION, + ("Installing address handler for %s on Device 0x%p (0x%p)\n", + AcpiGbl_RegionTypes[SpaceId], Node, ObjDesc)); + + /* + * Now we can install the handler + * + * At this point we know that there is no existing handler. + * So, we just allocate the object for the handler and link it + * into the list. + */ + HandlerObj = AcpiCmCreateInternalObject (INTERNAL_TYPE_ADDRESS_HANDLER); + if (!HandlerObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + HandlerObj->AddrHandler.SpaceId = (UINT8) SpaceId; + HandlerObj->AddrHandler.Hflags = Flags; + HandlerObj->AddrHandler.Next = ObjDesc->Device.AddrHandler; + HandlerObj->AddrHandler.RegionList = NULL; + HandlerObj->AddrHandler.Node = Node; + HandlerObj->AddrHandler.Handler = Handler; + HandlerObj->AddrHandler.Context = Context; + HandlerObj->AddrHandler.Setup = Setup; + + /* + * Now walk the namespace finding all of the regions this + * handler will manage. + * + * We start at the device and search the branch toward + * the leaf nodes until either the leaf is encountered or + * a device is detected that has an address handler of the + * same type. + * + * In either case we back up and search down the remainder + * of the branch + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, + ACPI_UINT32_MAX, NS_WALK_UNLOCK, + AcpiEvAddrHandlerHelper, + HandlerObj, NULL); + + /* + * Place this handler 1st on the list + */ + + HandlerObj->Common.ReferenceCount = + (UINT16) (HandlerObj->Common.ReferenceCount + + ObjDesc->Common.ReferenceCount - 1); + ObjDesc->Device.AddrHandler = HandlerObj; + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiRemoveAddressSpaceHandler + * + * PARAMETERS: SpaceId - The address space ID + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for accesses on an Operation Region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADDRESS_SPACE_TYPE SpaceId, + ADDRESS_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 = AE_OK; + + + FUNCTION_TRACE ("AcpiRemoveAddressSpaceHandler"); + + + /* Parameter validation */ + + if ((!Device) || + ((!Handler) && (Handler != ACPI_DEFAULT_HANDLER)) || + (SpaceId > ACPI_MAX_ADDRESS_SPACE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the device handle */ + + Node = AcpiNsConvertHandleToEntry (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* Make sure the internal object exists */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + if (!ObjDesc) + { + /* + * The object DNE. + */ + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* + * find the address handler the user requested + */ + + HandlerObj = ObjDesc->Device.AddrHandler; + LastObjPtr = &ObjDesc->Device.AddrHandler; + while (HandlerObj) + { + /* + * We have a handler, see if user requested this one + */ + + if(HandlerObj->AddrHandler.SpaceId == SpaceId) + { + /* + * Got it, first dereference this in the Regions + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Removing address handler 0x%p (0x%p) for %s on Device 0x%p (0x%p)\n", + HandlerObj, Handler, AcpiGbl_RegionTypes[SpaceId], + Node, ObjDesc)); + + RegionObj = HandlerObj->AddrHandler.RegionList; + + /* Walk the handler's region list */ + + while (RegionObj) + { + /* + * First disassociate the handler from the region. + * + * NOTE: this doesn't mean that the region goes away + * The region is just inaccessible as indicated to + * the _REG method + */ + AcpiEvDisassociateRegionFromHandler(RegionObj); + + /* + * Walk the list, since we took the first region and it + * was removed from the list by the dissassociate call + * we just get the first item on the list again + */ + RegionObj = HandlerObj->AddrHandler.RegionList; + + } + + /* + * Remove this Handler object from the list + */ + *LastObjPtr = HandlerObj->AddrHandler.Next; + + /* + * Now we can delete the handler object + */ + AcpiCmRemoveReference (HandlerObj); + AcpiCmRemoveReference (HandlerObj); + + goto UnlockAndExit; + } + + /* + * Move through the linked list of handlers + */ + LastObjPtr = &HandlerObj->AddrHandler.Next; + HandlerObj = HandlerObj->AddrHandler.Next; + } + + + /* + * The handler does not exist + */ + DEBUG_PRINT (TRACE_OPREGION, + ("Unable to remove address handler 0x%p for %s, DeviceNode 0x%p, obj 0x%p\n", + Handler, AcpiGbl_RegionTypes[SpaceId], Node, ObjDesc)); + + Status = AE_NOT_EXIST; + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exconfig.c b/sys/contrib/dev/acpica/exconfig.c new file mode 100644 index 0000000..835bc76 --- /dev/null +++ b/sys/contrib/dev/acpica/exconfig.c @@ -0,0 +1,433 @@ +/****************************************************************************** + * + * Module Name: amconfig - Namespace reconfiguration (Load/Unload opcodes) + * $Revision: 24 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMCONFIG_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amconfig") + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecLoadTable + * + * PARAMETERS: RgnDesc - Op region where the table will be obtained + * DdbHandle - Where a handle to the table will be returned + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecLoadTable ( + ACPI_OPERAND_OBJECT *RgnDesc, + ACPI_HANDLE *DdbHandle) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *TableDesc = NULL; + UINT8 *TablePtr; + UINT8 *TableDataPtr; + ACPI_TABLE_HEADER TableHeader; + ACPI_TABLE_DESC TableInfo; + UINT32 i; + + + FUNCTION_TRACE ("AmlExecLoadTable"); + + /* TBD: [Unhandled] Object can be either a field or an opregion */ + + + /* Get the table header */ + + TableHeader.Length = 0; + for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) + { + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, + i, 8, (UINT32 *) ((UINT8 *) &TableHeader + i)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Allocate a buffer for the entire table */ + + TablePtr = AcpiCmAllocate (TableHeader.Length); + if (!TablePtr) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the header to the buffer */ + + MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER)); + TableDataPtr = TablePtr + sizeof (ACPI_TABLE_HEADER); + + + /* Get the table from the op region */ + + for (i = 0; i < TableHeader.Length; i++) + { + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, + i, 8, (UINT32 *) (TableDataPtr + i)); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + + /* Table must be either an SSDT or a PSDT */ + + if ((!STRNCMP (TableHeader.Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].SigLength)) && + (!STRNCMP (TableHeader.Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].Signature, + AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].SigLength))) + { + DEBUG_PRINT (ACPI_ERROR, + ("Table has invalid signature [%4.4s], must be SSDT or PSDT\n", + TableHeader.Signature)); + Status = AE_BAD_SIGNATURE; + goto Cleanup; + } + + /* Create an object to be the table handle */ + + TableDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!TableDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + + /* Install the new table into the local data structures */ + + TableInfo.Pointer = (ACPI_TABLE_HEADER *) TablePtr; + TableInfo.Length = TableHeader.Length; + TableInfo.Allocation = ACPI_MEM_ALLOCATED; + TableInfo.BasePointer = TablePtr; + + Status = AcpiTbInstallTable (NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Add the table to the namespace */ + + /* TBD: [Restructure] - change to whatever new interface is appropriate */ +/* + Status = AcpiLoadNamespace (); + if (ACPI_FAILURE (Status)) + { +*/ + /* TBD: [Errors] Unload the table on failure ? */ +/* + goto Cleanup; + } +*/ + + + /* TBD: [Investigate] we need a pointer to the table desc */ + + /* Init the table handle */ + + TableDesc->Reference.OpCode = AML_LOAD_OP; + TableDesc->Reference.Object = TableInfo.InstalledDesc; + + *DdbHandle = TableDesc; + + return_ACPI_STATUS (Status); + + +Cleanup: + + AcpiCmFree (TableDesc); + AcpiCmFree (TablePtr); + return_ACPI_STATUS (Status); + +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecUnloadTable + * + * PARAMETERS: DdbHandle - Handle to a previously loaded table + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecUnloadTable ( + ACPI_HANDLE DdbHandle) +{ + ACPI_STATUS Status = AE_NOT_IMPLEMENTED; + ACPI_OPERAND_OBJECT *TableDesc = (ACPI_OPERAND_OBJECT *) DdbHandle; + ACPI_TABLE_DESC *TableInfo; + + + FUNCTION_TRACE ("AmlExecUnloadTable"); + + + /* Validate the handle */ + /* Although the handle is partially validated in AcpiAmlExecReconfiguration(), + * when it calls AcpiAmlResolveOperands(), the handle is more completely + * validated here. + */ + + if ((!DdbHandle) || + (!VALID_DESCRIPTOR_TYPE (DdbHandle, ACPI_DESC_TYPE_INTERNAL)) || + (((ACPI_OPERAND_OBJECT *)DdbHandle)->Common.Type != + INTERNAL_TYPE_REFERENCE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get the actual table descriptor from the DdbHandle */ + + TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object; + + /* + * Delete the entire namespace under this table Node + * (Offset contains the TableId) + */ + + Status = AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Delete the table itself */ + + AcpiTbUninstallTable (TableInfo->InstalledDesc); + + /* Delete the table descriptor (DdbHandle) */ + + AcpiCmRemoveReference (TableDesc); + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecReconfiguration + * + * PARAMETERS: Opcode - The opcode to be executed + * WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Reconfiguration opcodes such as LOAD and UNLOAD + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecReconfiguration ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RegionDesc = NULL; + ACPI_HANDLE *DdbHandle; + + + FUNCTION_TRACE ("AmlExecReconfiguration"); + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get the table handle, common for both opcodes */ + + Status |= AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &DdbHandle, + WalkState); + + switch (Opcode) + { + + case AML_LOAD_OP: + + /* Get the region or field descriptor */ + + Status |= AcpiDsObjStackPopObject (&RegionDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecReconfiguration/AML_LOAD_OP: bad operand(s) (0x%X)\n", + Status)); + + AcpiCmRemoveReference (RegionDesc); + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlExecLoadTable (RegionDesc, DdbHandle); + break; + + + case AML_UNLOAD_OP: + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecReconfiguration/AML_UNLOAD_OP: bad operand(s) (0x%X)\n", + Status)); + + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlExecUnloadTable (DdbHandle); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, ("AmlExecReconfiguration: bad opcode=%X\n", + Opcode)); + + Status = AE_AML_BAD_OPCODE; + break; + } + + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/excreate.c b/sys/contrib/dev/acpica/excreate.c new file mode 100644 index 0000000..e1c93d9 --- /dev/null +++ b/sys/contrib/dev/acpica/excreate.c @@ -0,0 +1,1216 @@ +/****************************************************************************** + * + * Module Name: amcreate - Named object creation + * $Revision: 48 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMCREATE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amcreate") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecCreateField + * + * PARAMETERS: Opcode - The opcode to be executed + * Operands - List of operands for the opcode + * + * RETURN: Status + * + * DESCRIPTION: Execute CreateField operators: CreateBitFieldOp, + * CreateByteFieldOp, CreateWordFieldOp, CreateDWordFieldOp, + * CreateFieldOp (which define fields in buffers) + * + * ALLOCATION: Deletes CreateFieldOp's count operand descriptor + * + * + * ACPI SPECIFICATION REFERENCES: + * DefCreateBitField := CreateBitFieldOp SrcBuf BitIdx NameString + * DefCreateByteField := CreateByteFieldOp SrcBuf ByteIdx NameString + * DefCreateDWordField := CreateDWordFieldOp SrcBuf ByteIdx NameString + * DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString + * DefCreateWordField := CreateWordFieldOp SrcBuf ByteIdx NameString + * BitIndex := TermArg=>Integer + * ByteIndex := TermArg=>Integer + * NumBits := TermArg=>Integer + * SourceBuff := TermArg=>Buffer + * + ******************************************************************************/ + + +ACPI_STATUS +AcpiAmlExecCreateField ( + UINT8 *AmlPtr, + UINT32 AmlLength, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *TmpDesc; + + + FUNCTION_TRACE ("AmlExecCreateField"); + + + /* Create the region descriptor */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Construct the field object */ + + ObjDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC; + ObjDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK; + ObjDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE; + + /* + * Allocate a method object for this field unit + */ + + ObjDesc->FieldUnit.Extra = AcpiCmCreateInternalObject ( + INTERNAL_TYPE_EXTRA); + if (!ObjDesc->FieldUnit.Extra) + { + 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. + */ + + ObjDesc->FieldUnit.Extra->Extra.Pcode = AmlPtr; + ObjDesc->FieldUnit.Extra->Extra.PcodeLength = AmlLength; + ObjDesc->FieldUnit.Node = Node; + + +/* + Status = AcpiNsAttachObject (Node, ObjDesc, + (UINT8) ACPI_TYPE_FIELD_UNIT); + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } +*/ + + /* + * This operation is supposed to cause the destination Name to refer + * to the defined FieldUnit -- it must not store the constructed + * FieldUnit object (or its current value) in some location that the + * Name may already be pointing to. So, if the Name currently contains + * a reference which would cause AcpiAmlExecStore() to perform an indirect + * store rather than setting the value of the Name itself, clobber that + * reference before calling AcpiAmlExecStore(). + */ + + /* Type of Name's existing value */ + + switch (AcpiNsGetType (Node)) + { + + case ACPI_TYPE_FIELD_UNIT: + + case INTERNAL_TYPE_ALIAS: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_DEF_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + + TmpDesc = AcpiNsGetAttachedObject (Node); + if (TmpDesc) + { + /* + * There is an existing object here; delete it and zero out the + * object field within the Node + */ + + DUMP_PATHNAME (Node, + "AmlExecCreateField: Removing Current Reference", + TRACE_BFIELD, _COMPONENT); + + DUMP_ENTRY (Node, TRACE_BFIELD); + DUMP_STACK_ENTRY (TmpDesc); + + AcpiCmRemoveReference (TmpDesc); + AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Node, NULL, + ACPI_TYPE_ANY); + } + + /* Set the type to ANY (or the store below will fail) */ + + ((ACPI_NAMESPACE_NODE *) Node)->Type = ACPI_TYPE_ANY; + + break; + + + default: + + break; + } + + + /* Store constructed field descriptor in result location */ + + Status = AcpiAmlExecStore (ObjDesc, (ACPI_OPERAND_OBJECT *) Node, WalkState); + + /* + * If the field descriptor was not physically stored (or if a failure + * above), we must delete it + */ + if (ObjDesc->Common.ReferenceCount <= 1) + { + AcpiCmRemoveReference (ObjDesc); + } + + + return_ACPI_STATUS (AE_OK); + + +Cleanup: + + /* Delete region object and method subobject */ + + if (ObjDesc) + { + /* Remove deletes both objects! */ + + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + + return_ACPI_STATUS (Status); +} + + +ACPI_STATUS +AcpiAmlExecCreateField_original ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ResDesc = NULL; + ACPI_OPERAND_OBJECT *CntDesc = NULL; + ACPI_OPERAND_OBJECT *OffDesc = NULL; + ACPI_OPERAND_OBJECT *SrcDesc = NULL; + ACPI_OPERAND_OBJECT *FieldDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + OBJECT_TYPE_INTERNAL ResType; + ACPI_STATUS Status; + UINT32 NumOperands = 3; + UINT32 Offset; + UINT32 BitOffset; + UINT16 BitCount; + UINT8 TypeFound; + + + FUNCTION_TRACE ("AmlExecCreateField"); + + + /* Resolve the operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + NumOperands, "after AcpiAmlResolveOperands"); + + + /* Get the operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + if (AML_CREATE_FIELD_OP == Opcode) + { + NumOperands = 4; + Status |= AcpiDsObjStackPopObject (&CntDesc, WalkState); + } + + Status |= AcpiDsObjStackPopObject (&OffDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&SrcDesc, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecCreateField/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + Offset = (UINT32) OffDesc->Number.Value; + + + /* + * If ResDesc is a Name, it will be a direct name pointer after + * AcpiAmlResolveOperands() + */ + + if (!VALID_DESCRIPTOR_TYPE (ResDesc, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField (%s): destination must be a Node\n", + AcpiPsGetOpcodeName (Opcode))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + + switch (Opcode) + { + + /* DefCreateBitField */ + + case AML_BIT_FIELD_OP: + + /* Offset is in bits, Field is a bit */ + + BitOffset = Offset; + BitCount = 1; + break; + + + /* DefCreateByteField */ + + case AML_BYTE_FIELD_OP: + + /* Offset is in bytes, field is a byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + break; + + + /* DefCreateWordField */ + + case AML_WORD_FIELD_OP: + + /* Offset is in bytes, field is a word */ + + BitOffset = 8 * Offset; + BitCount = 16; + break; + + + /* DefCreateDWordField */ + + case AML_DWORD_FIELD_OP: + + /* Offset is in bytes, field is a dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + break; + + + /* DefCreateField */ + + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + BitOffset = Offset; + BitCount = (UINT16) CntDesc->Number.Value; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Internal error - unknown field creation opcode %02x\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Setup field according to the object type + */ + + switch (SrcDesc->Common.Type) + { + + /* SourceBuff := TermArg=>Buffer */ + + case ACPI_TYPE_BUFFER: + + if (BitOffset + (UINT32) BitCount > + (8 * (UINT32) SrcDesc->Buffer.Length)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Field exceeds Buffer %d > %d\n", + BitOffset + (UINT32) BitCount, + 8 * (UINT32) SrcDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + + /* Allocate an object for the field */ + + FieldDesc = AcpiCmCreateInternalObject (ACPI_TYPE_FIELD_UNIT); + if (!FieldDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Construct the field object */ + + FieldDesc->FieldUnit.Access = (UINT8) ACCESS_ANY_ACC; + FieldDesc->FieldUnit.LockRule = (UINT8) GLOCK_NEVER_LOCK; + FieldDesc->FieldUnit.UpdateRule = (UINT8) UPDATE_PRESERVE; + FieldDesc->FieldUnit.Length = BitCount; + FieldDesc->FieldUnit.BitOffset = (UINT8) (BitOffset % 8); + FieldDesc->FieldUnit.Offset = DIV_8 (BitOffset); + FieldDesc->FieldUnit.Container = SrcDesc; + + /* An additional reference for SrcDesc */ + + AcpiCmAddReference (SrcDesc); + + break; + + + /* Improper object type */ + + default: + + TypeFound = SrcDesc->Common.Type; + + if ((TypeFound > (UINT8) INTERNAL_TYPE_REFERENCE) || + !AcpiCmValidObjectType (TypeFound)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in invalid object type - 0x%X\n", + TypeFound)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecCreateField: Tried to create field in improper object type - %s\n", + AcpiCmGetTypeName (TypeFound))); + } + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + if (AML_CREATE_FIELD_OP == Opcode) + { + /* Delete object descriptor unique to CreateField */ + + AcpiCmRemoveReference (CntDesc); + CntDesc = NULL; + } + + /* + * This operation is supposed to cause the destination Name to refer + * to the defined FieldUnit -- it must not store the constructed + * FieldUnit object (or its current value) in some location that the + * Name may already be pointing to. So, if the Name currently contains + * a reference which would cause AcpiAmlExecStore() to perform an indirect + * store rather than setting the value of the Name itself, clobber that + * reference before calling AcpiAmlExecStore(). + */ + + ResType = AcpiNsGetType (ResDesc); + + /* Type of Name's existing value */ + + switch (ResType) + { + + case ACPI_TYPE_FIELD_UNIT: + + case INTERNAL_TYPE_ALIAS: + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_DEF_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + + ObjDesc = AcpiNsGetAttachedObject (ResDesc); + if (ObjDesc) + { + /* + * There is an existing object here; delete it and zero out the + * object field within the Node + */ + + DUMP_PATHNAME (ResDesc, + "AmlExecCreateField: Removing Current Reference", + TRACE_BFIELD, _COMPONENT); + + DUMP_ENTRY (ResDesc, TRACE_BFIELD); + DUMP_STACK_ENTRY (ObjDesc); + + AcpiCmRemoveReference (ObjDesc); + AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) ResDesc, NULL, + ACPI_TYPE_ANY); + } + + /* Set the type to ANY (or the store below will fail) */ + + ((ACPI_NAMESPACE_NODE *) ResDesc)->Type = ACPI_TYPE_ANY; + + break; + + + default: + + break; + } + + + /* Store constructed field descriptor in result location */ + + Status = AcpiAmlExecStore (FieldDesc, ResDesc, WalkState); + + /* + * If the field descriptor was not physically stored (or if a failure + * above), we must delete it + */ + if (FieldDesc->Common.ReferenceCount <= 1) + { + AcpiCmRemoveReference (FieldDesc); + } + + +Cleanup: + + /* Always delete the operands */ + + AcpiCmRemoveReference (OffDesc); + AcpiCmRemoveReference (SrcDesc); + + if (AML_CREATE_FIELD_OP == Opcode) + { + AcpiCmRemoveReference (CntDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); /* Result descriptor */ + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateAlias + * + * PARAMETERS: Operands - List of operands for the opcode + * + * RETURN: Status + * + * DESCRIPTION: Create a new named alias + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateAlias ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_NAMESPACE_NODE *SourceNode; + ACPI_NAMESPACE_NODE *AliasNode; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecCreateAlias"); + + + /* Get the source/alias operands (both NTEs) */ + + Status = AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &SourceNode, + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Don't pop it, it gets removed in the calling routine + */ + + AliasNode = AcpiDsObjStackGetValue (0, WalkState); + + /* Add an additional reference to the object */ + + AcpiCmAddReference (SourceNode->Object); + + /* + * Attach the original source Node to the new Alias Node. + */ + Status = AcpiNsAttachObject (AliasNode, SourceNode->Object, + SourceNode->Type); + + + /* + * The new alias assumes the type of the source, but it points + * to the same object. The reference count of the object has two + * additional references to prevent deletion out from under either the + * source or the alias Node + */ + + /* Since both operands are NTEs, we don't need to delete them */ + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateEvent + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a new event object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateEvent ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("AmlExecCreateEvent"); + + + BREAKPOINT3; + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_EVENT); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS semaphore */ + + /* TBD: [Investigate] should be created with 0 or 1 units? */ + + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 1, + &ObjDesc->Event.Semaphore); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + /* Attach object to the Node */ + + Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), + ObjDesc, (UINT8) ACPI_TYPE_EVENT); + if (ACPI_FAILURE (Status)) + { + AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore); + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateMutex + * + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) + * Operands - List of operands for the opcode + * + * RETURN: Status + * + * DESCRIPTION: Create a new mutex object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateMutex ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *SyncDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("AmlExecCreateMutex", WALK_OPERANDS); + + + /* Get the operand */ + + Status = AcpiDsObjStackPopObject (&SyncDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Attempt to allocate a new object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_MUTEX); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS semaphore */ + + Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Number.Value; + + /* ObjDesc was on the stack top, and the name is below it */ + + Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), + ObjDesc, (UINT8) ACPI_TYPE_MUTEX); + if (ACPI_FAILURE (Status)) + { + AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore); + AcpiCmRemoveReference (ObjDesc); + goto Cleanup; + } + + +Cleanup: + + /* Always delete the operand */ + + AcpiCmRemoveReference (SyncDesc); + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateRegion + * + * PARAMETERS: AmlPtr - Pointer to the region declaration AML + * AmlLength - Max length of the declaration AML + * Operands - List of operands for the opcode + * InterpreterMode - Load1/Load2/Execute + * + * RETURN: Status + * + * DESCRIPTION: Create a new operation region object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateRegion ( + UINT8 *AmlPtr, + UINT32 AmlLength, + UINT32 RegionSpace, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + + + FUNCTION_TRACE ("AmlExecCreateRegion"); + + + if (RegionSpace >= NUM_REGION_TYPES) + { + /* TBD: [Future] In ACPI 2.0, valid region space + * includes types 0-6 (Adding CMOS and PCIBARTarget). + * Also, types 0x80-0xff are defined as "OEM Region + * Space handler" + * + * Should this return an error, or should we just keep + * going? How do we handle the OEM region handlers? + */ + REPORT_WARNING (("Invalid AddressSpace type %X\n", RegionSpace)); + } + + DEBUG_PRINT (TRACE_LOAD, ("AmlDoNode: Region Type [%s]\n", + AcpiGbl_RegionTypes[RegionSpace])); + + + /* Get the Node from the object stack */ + + Node = (ACPI_NAMESPACE_NODE *) AcpiDsObjStackGetValue (0, WalkState); + + /* Create the region descriptor */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_REGION); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Allocate a method object for this region. + */ + + ObjDesc->Region.Extra = AcpiCmCreateInternalObject ( + INTERNAL_TYPE_EXTRA); + if (!ObjDesc->Region.Extra) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of address & length + * operands since they need to be evaluated at run time. + */ + + ObjDesc->Region.Extra->Extra.Pcode = AmlPtr; + ObjDesc->Region.Extra->Extra.PcodeLength = AmlLength; + + /* Init the region from the operands */ + + ObjDesc->Region.SpaceId = (UINT8) RegionSpace; + ObjDesc->Region.Address = 0; + ObjDesc->Region.Length = 0; + + + /* Install the new region object in the parent Node */ + + ObjDesc->Region.Node = Node; + + Status = AcpiNsAttachObject (Node, ObjDesc, + (UINT8) ACPI_TYPE_REGION); + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * If we have a valid region, initialize it + * Namespace is NOT locked at this point. + */ + + Status = AcpiEvInitializeRegion (ObjDesc, FALSE); + + if (ACPI_FAILURE (Status)) + { + /* + * If AE_NOT_EXIST is returned, it is not fatal + * because many regions get created before a handler + * is installed for said region. + */ + if (AE_NOT_EXIST == Status) + { + Status = AE_OK; + } + } + +Cleanup: + + if (ACPI_FAILURE (Status)) + { + /* Delete region object and method subobject */ + + if (ObjDesc) + { + /* Remove deletes both objects! */ + + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateProcessor + * + * PARAMETERS: Op - Op containing the Processor definition and + * args + * ProcessorNTE - Node for the containing Node + * + * RETURN: Status + * + * DESCRIPTION: Create a new processor object and populate the fields + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateProcessor ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE ProcessorNTE) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("AmlExecCreateProcessor", Op); + + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_PROCESSOR); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + return_ACPI_STATUS (Status); + } + + /* Install the new processor object in the parent Node */ + + Status = AcpiNsAttachObject (ProcessorNTE, ObjDesc, + (UINT8) ACPI_TYPE_PROCESSOR); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS(Status); + } + + Arg = Op->Value.Arg; + + /* check existence */ + + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* First arg is the Processor ID */ + + ObjDesc->Processor.ProcId = (UINT8) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Second arg is the PBlock Address */ + + ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Third arg is the PBlock Length */ + + ObjDesc->Processor.Length = (UINT8) Arg->Value.Integer; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreatePowerResource + * + * PARAMETERS: Op - Op containing the PowerResource definition + * and args + * PowerResNTE - Node for the containing Node + * + * RETURN: Status + * + * DESCRIPTION: Create a new PowerResource object and populate the fields + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreatePowerResource ( + ACPI_PARSE_OBJECT *Op, + ACPI_HANDLE PowerResNTE) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE_PTR ("AmlExecCreatePowerResource", Op); + + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_POWER); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + return_ACPI_STATUS (Status); + } + + /* Install the new power resource object in the parent Node */ + + Status = AcpiNsAttachObject (PowerResNTE, ObjDesc, + (UINT8) ACPI_TYPE_POWER); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS(Status); + } + + Arg = Op->Value.Arg; + + /* check existence */ + + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* First arg is the SystemLevel */ + + ObjDesc->PowerResource.SystemLevel = (UINT8) Arg->Value.Integer; + + /* Move to next arg and check existence */ + + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_NO_OPERAND; + return_ACPI_STATUS (Status); + } + + /* Second arg is the PBlock Address */ + + ObjDesc->PowerResource.ResourceOrder = (UINT16) Arg->Value.Integer; + + return_ACPI_STATUS (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecCreateMethod + * + * PARAMETERS: AmlPtr - First byte of the method's AML + * AmlLength - AML byte count for this method + * MethodFlags - AML method flag byte + * Method - Method Node + * + * RETURN: Status + * + * DESCRIPTION: Create a new method object + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecCreateMethod ( + UINT8 *AmlPtr, + UINT32 AmlLength, + UINT32 MethodFlags, + ACPI_HANDLE Method) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("AmlExecCreateMethod", Method); + + + /* Create a new method object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_METHOD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Get the method's AML pointer/length from the Op */ + + ObjDesc->Method.Pcode = AmlPtr; + ObjDesc->Method.PcodeLength = AmlLength; + + /* + * First argument is the Method Flags (contains parameter count for the + * method) + */ + + ObjDesc->Method.MethodFlags = (UINT8) MethodFlags; + ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & + METHOD_FLAGS_ARG_COUNT); + + /* + * Get the concurrency count. If required, a semaphore will be + * created for this method when it is parsed. + * + * TBD: [Future] for APCI 2.0, there will be a SyncLevel value, not + * just a flag + * Concurrency = SyncLevel + 1;. + */ + + if (MethodFlags & METHOD_FLAGS_SERIALIZED) + { + ObjDesc->Method.Concurrency = 1; + } + + else + { + ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; + } + + /* Attach the new object to the method Node */ + + Status = AcpiNsAttachObject (Method, ObjDesc, (UINT8) ACPI_TYPE_METHOD); + if (ACPI_FAILURE (Status)) + { + AcpiCmDeleteObjectDesc (ObjDesc); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exdump.c b/sys/contrib/dev/acpica/exdump.c new file mode 100644 index 0000000..a3662d7 --- /dev/null +++ b/sys/contrib/dev/acpica/exdump.c @@ -0,0 +1,992 @@ +/****************************************************************************** + * + * Module Name: amdump - Interpreter debug output routines + * $Revision: 94 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMDUMP_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amdump") + + +/* + * The following routines are used for debug output only + */ + +#ifdef ACPI_DEBUG + +/***************************************************************************** + * + * FUNCTION: AcpiAmlShowHexValue + * + * PARAMETERS: ByteCount - Number of bytes to print (1, 2, or 4) + * *AmlPtr - Address in AML stream of bytes to print + * InterpreterMode - Current running mode (load1/Load2/Exec) + * LeadSpace - # of spaces to print ahead of value + * 0 => none ahead but one behind + * + * DESCRIPTION: Print ByteCount byte(s) starting at AcpiAmlPtr as a single + * value, in hex. If ByteCount > 1 or the value printed is > 9, also + * print in decimal. + * + ****************************************************************************/ + +void +AcpiAmlShowHexValue ( + UINT32 ByteCount, + UINT8 *AmlPtr, + UINT32 LeadSpace) +{ + UINT32 Value; /* Value retrieved from AML stream */ + UINT32 ShowDecimalValue; + UINT32 Length; /* Length of printed field */ + UINT8 *CurrentAmlPtr = NULL; /* Pointer to current byte of AML value */ + + + FUNCTION_TRACE ("AmlShowHexValue"); + + + if (!AmlPtr) + { + REPORT_ERROR (("AmlShowHexValue: null pointer\n")); + } + + /* + * AML numbers are always stored little-endian, + * even if the processor is big-endian. + */ + for (CurrentAmlPtr = AmlPtr + ByteCount, + Value = 0; + CurrentAmlPtr > AmlPtr; ) + { + Value = (Value << 8) + (UINT32)* --CurrentAmlPtr; + } + + Length = LeadSpace * ByteCount + 2; + if (ByteCount > 1) + { + Length += (ByteCount - 1); + } + + ShowDecimalValue = (ByteCount > 1 || Value > 9); + if (ShowDecimalValue) + { + Length += 3 + AcpiAmlDigitsNeeded (Value, 10); + } + + DEBUG_PRINT (TRACE_LOAD, ("")); + + for (Length = LeadSpace; Length; --Length ) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" ")); + } + + while (ByteCount--) + { + DEBUG_PRINT_RAW (TRACE_LOAD, ("%02x", *AmlPtr++)); + + if (ByteCount) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" ")); + } + } + + if (ShowDecimalValue) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" [%ld]", Value)); + } + + if (0 == LeadSpace) + { + DEBUG_PRINT_RAW (TRACE_LOAD, (" ")); + } + + DEBUG_PRINT_RAW (TRACE_LOAD, ("\n")); + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpOperand + * + * PARAMETERS: *EntryDesc - Pointer to entry to be dumped + * + * RETURN: Status + * + * DESCRIPTION: Dump a stack entry + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlDumpOperand ( + ACPI_OPERAND_OBJECT *EntryDesc) +{ + UINT8 *Buf = NULL; + UINT32 Length; + UINT32 i; + + + if (!EntryDesc) + { + /* + * This usually indicates that something serious is wrong -- + * since most (if not all) + * code that dumps the stack expects something to be there! + */ + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: *** Possible error: Null stack entry ptr\n")); + return (AE_OK); + } + + if (VALID_DESCRIPTOR_TYPE (EntryDesc, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: Node: \n")); + DUMP_ENTRY (EntryDesc, ACPI_INFO); + return (AE_OK); + } + + if (AcpiTbSystemTablePointer (EntryDesc)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: %p is a Pcode pointer\n", + EntryDesc)); + return (AE_OK); + } + + if (!VALID_DESCRIPTOR_TYPE (EntryDesc, ACPI_DESC_TYPE_INTERNAL)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlDumpOperand: %p Not a local object \n", EntryDesc)); + DUMP_BUFFER (EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + return (AE_OK); + } + + /* EntryDesc is a valid object */ + + DEBUG_PRINT (ACPI_INFO, ("AmlDumpOperand: %p ", EntryDesc)); + + switch (EntryDesc->Common.Type) + { + case INTERNAL_TYPE_REFERENCE: + + switch (EntryDesc->Reference.OpCode) + { + case AML_ZERO_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Zero\n")); + break; + + + case AML_ONE_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: One\n")); + break; + + + case AML_ONES_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Ones\n")); + break; + + + case AML_DEBUG_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Debug\n")); + break; + + + case AML_NAME_OP: + + DUMP_PATHNAME (EntryDesc->Reference.Object, "Reference: Name: ", + ACPI_INFO, _COMPONENT); + DUMP_ENTRY (EntryDesc->Reference.Object, ACPI_INFO); + break; + + + case AML_INDEX_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Index %p\n", + EntryDesc->Reference.Object)); + break; + + + case AML_ARG_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Arg%d", + EntryDesc->Reference.Offset)); + + if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type) + { + /* Value is a Number */ + + DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]", + EntryDesc->Number.Value)); + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + break; + + + case AML_LOCAL_OP: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference: Local%d", + EntryDesc->Reference.Offset)); + + if (ACPI_TYPE_NUMBER == EntryDesc->Common.Type) + { + + /* Value is a Number */ + + DEBUG_PRINT_RAW (ACPI_INFO, (" value is [%ld]", + EntryDesc->Number.Value)); + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + break; + + + case AML_NAMEPATH_OP: + DEBUG_PRINT_RAW (ACPI_INFO, ("Reference.Node->Name %x\n", + EntryDesc->Reference.Node->Name)); + break; + + default: + + /* unknown opcode */ + + DEBUG_PRINT_RAW (ACPI_INFO, ("Unknown opcode=%X\n", + EntryDesc->Reference.OpCode)); + break; + + } + + break; + + + case ACPI_TYPE_BUFFER: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Buffer[%d] seq %lx @ %p \n", + EntryDesc->Buffer.Length, EntryDesc->Buffer.Sequence, + EntryDesc->Buffer.Pointer)); + + Length = EntryDesc->Buffer.Length; + + if (Length > 64) + { + Length = 64; + } + + /* Debug only -- dump the buffer contents */ + + if (EntryDesc->Buffer.Pointer) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("Buffer Contents: ")); + + for (Buf = EntryDesc->Buffer.Pointer; Length--; ++Buf) + { + DEBUG_PRINT_RAW (ACPI_INFO, + (Length ? " %02x" : " %02x", *Buf)); + } + DEBUG_PRINT_RAW (ACPI_INFO,("\n")); + } + + break; + + + case ACPI_TYPE_NUMBER: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Number 0x%lx\n", + EntryDesc->Number.Value)); + break; + + + case INTERNAL_TYPE_IF: + + DEBUG_PRINT_RAW (ACPI_INFO, ("If [Number] 0x%lx\n", + EntryDesc->Number.Value)); + break; + + + case INTERNAL_TYPE_WHILE: + + DEBUG_PRINT_RAW (ACPI_INFO, ("While [Number] 0x%lx\n", + EntryDesc->Number.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Package[%d] @ %p\n", + EntryDesc->Package.Count, EntryDesc->Package.Elements)); + + + /* + * If elements exist, package vector pointer is valid, + * and debug_level exceeds 1, dump package's elements. + */ + if (EntryDesc->Package.Count && + EntryDesc->Package.Elements && + GetDebugLevel () > 1) + { + ACPI_OPERAND_OBJECT**Element; + UINT16 ElementIndex; + + for (ElementIndex = 0, Element = EntryDesc->Package.Elements; + ElementIndex < EntryDesc->Package.Count; + ++ElementIndex, ++Element) + { + AcpiAmlDumpOperand (*Element); + } + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + + break; + + + case ACPI_TYPE_REGION: + + if (EntryDesc->Region.SpaceId >= NUM_REGION_TYPES) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("Region **** Unknown ID=0x%X", + EntryDesc->Region.SpaceId)); + } + else + { + DEBUG_PRINT_RAW (ACPI_INFO, ("Region %s", + AcpiGbl_RegionTypes[EntryDesc->Region.SpaceId])); + } + + /* + * If the address and length have not been evaluated, + * don't print them. + */ + if (!(EntryDesc->Region.Flags & AOPOBJ_DATA_VALID)) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("\n")); + } + else + { + DEBUG_PRINT_RAW (ACPI_INFO, (" base %p Length 0x%X\n", + EntryDesc->Region.Address, EntryDesc->Region.Length)); + } + break; + + + case ACPI_TYPE_STRING: + + DEBUG_PRINT_RAW (ACPI_INFO, ("String[%d] @ %p\n\n", + EntryDesc->String.Length, EntryDesc->String.Pointer)); + + for (i=0; i < EntryDesc->String.Length; i++) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("%c", + EntryDesc->String.Pointer[i])); + } + + DEBUG_PRINT_RAW (ACPI_INFO, ("\n\n")); + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + DEBUG_PRINT_RAW (ACPI_INFO, ("BankField\n")); + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + DEBUG_PRINT_RAW (ACPI_INFO, + ("DefField: bits=%d acc=%d lock=%d update=%d at byte=%lx bit=%d of below:\n", + EntryDesc->Field.Length, EntryDesc->Field.Access, + EntryDesc->Field.LockRule, EntryDesc->Field.UpdateRule, + EntryDesc->Field.Offset, EntryDesc->Field.BitOffset)); + DUMP_STACK_ENTRY (EntryDesc->Field.Container); + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + DEBUG_PRINT_RAW (ACPI_INFO, ("IndexField\n")); + break; + + + case ACPI_TYPE_FIELD_UNIT: + + DEBUG_PRINT_RAW (ACPI_INFO, + ("FieldUnit: %d bits acc %d lock %d update %d at byte %lx bit %d of \n", + EntryDesc->FieldUnit.Length, EntryDesc->FieldUnit.Access, + EntryDesc->FieldUnit.LockRule, EntryDesc->FieldUnit.UpdateRule, + EntryDesc->FieldUnit.Offset, EntryDesc->FieldUnit.BitOffset)); + + if (!EntryDesc->FieldUnit.Container) + { + DEBUG_PRINT (ACPI_INFO, ("*NULL* \n")); + } + + else if (ACPI_TYPE_BUFFER != + EntryDesc->FieldUnit.Container->Common.Type) + { + DEBUG_PRINT_RAW (ACPI_INFO, ("*not a Buffer* \n")); + } + + else + { + DUMP_STACK_ENTRY (EntryDesc->FieldUnit.Container); + } + + break; + + + case ACPI_TYPE_EVENT: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Event\n")); + break; + + + case ACPI_TYPE_METHOD: + + DEBUG_PRINT_RAW (ACPI_INFO, + ("Method(%d) @ %p:%lx\n", + EntryDesc->Method.ParamCount, + EntryDesc->Method.Pcode, EntryDesc->Method.PcodeLength)); + break; + + + case ACPI_TYPE_MUTEX: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Mutex\n")); + break; + + + case ACPI_TYPE_DEVICE: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Device\n")); + break; + + + case ACPI_TYPE_POWER: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Power\n")); + break; + + + case ACPI_TYPE_PROCESSOR: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Processor\n")); + break; + + + case ACPI_TYPE_THERMAL: + + DEBUG_PRINT_RAW (ACPI_INFO, ("Thermal\n")); + break; + + + default: + /* unknown EntryDesc->Common.Type value */ + + DEBUG_PRINT_RAW (ACPI_INFO, ("Unknown Type 0x%X\n", + EntryDesc->Common.Type)); + + /* Back up to previous entry */ + + EntryDesc--; + + + /* TBD: [Restructure] Change to use dump object routine !! */ + /* What is all of this?? */ + + DUMP_BUFFER (EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + DUMP_BUFFER (++EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + DUMP_BUFFER (++EntryDesc, sizeof (ACPI_OPERAND_OBJECT)); + break; + + } + + return (AE_OK); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpOperands + * + * PARAMETERS: InterpreterMode - Load or Exec + * *Ident - Identification + * NumLevels - # of stack entries to dump above line + * *Note - Output notation + * + * DESCRIPTION: Dump the object stack + * + ****************************************************************************/ + +void +AcpiAmlDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + OPERATING_MODE InterpreterMode, + NATIVE_CHAR *Ident, + UINT32 NumLevels, + NATIVE_CHAR *Note, + NATIVE_CHAR *ModuleName, + UINT32 LineNumber) +{ + NATIVE_UINT i; + ACPI_OPERAND_OBJECT **EntryDesc; + + + if (!Ident) + { + Ident = "?"; + } + + if (!Note) + { + Note = "?"; + } + + + DEBUG_PRINT (ACPI_INFO, + ("************* AcpiAmlDumpOperands Mode=%X ******************\n", + InterpreterMode)); + DEBUG_PRINT (ACPI_INFO, + ("From %12s(%d) %s: %s\n", ModuleName, LineNumber, Ident, Note)); + + if (NumLevels == 0) + NumLevels = 1; + + /* Dump the stack starting at the top, working down */ + + for (i = 0; NumLevels > 0; i--, NumLevels--) + { + EntryDesc = &Operands[i]; + + if (ACPI_FAILURE (AcpiAmlDumpOperand (*EntryDesc))) + { + break; + } + } + + return; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpNode + * + * PARAMETERS: *Node - Descriptor to dump + * Flags - Force display + * + * DESCRIPTION: Dumps the members of the given.Node + * + ****************************************************************************/ + +void +AcpiAmlDumpNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags) +{ + + if (!Flags) + { + if (!((TRACE_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + } + + + AcpiOsPrintf ("%20s : %4.4s\n", "Name", &Node->Name); + AcpiOsPrintf ("%20s : %s\n", "Type", AcpiCmGetTypeName (Node->Type)); + AcpiOsPrintf ("%20s : 0x%X\n", "Flags", Node->Flags); + AcpiOsPrintf ("%20s : 0x%X\n", "Owner Id", Node->OwnerId); + AcpiOsPrintf ("%20s : 0x%X\n", "Reference Count", Node->ReferenceCount); + AcpiOsPrintf ("%20s : 0x%p\n", "Attached Object", Node->Object); + AcpiOsPrintf ("%20s : 0x%p\n", "ChildList", Node->Child); + AcpiOsPrintf ("%20s : 0x%p\n", "NextPeer", Node->Peer); + AcpiOsPrintf ("%20s : 0x%p\n", "Parent", AcpiNsGetParentObject (Node)); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlDumpObjectDescriptor + * + * PARAMETERS: *Object - Descriptor to dump + * Flags - Force display + * + * DESCRIPTION: Dumps the members of the object descriptor given. + * + ****************************************************************************/ + +void +AcpiAmlDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Flags) +{ + FUNCTION_TRACE ("AmlDumpObjectDescriptor"); + + + if (!Flags) + { + if (!((TRACE_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + } + + if (!(VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))) + { + AcpiOsPrintf ("0x%p is not a valid ACPI object\n", ObjDesc); + return; + } + + /* Common Fields */ + + AcpiOsPrintf ("%20s : 0x%X\n", "Reference Count", ObjDesc->Common.ReferenceCount); + AcpiOsPrintf ("%20s : 0x%X\n", "Flags", ObjDesc->Common.Flags); + + /* Object-specific Fields */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Number"); + AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->Number.Value); + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("%20s : %s\n", "Type", "String"); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->String.Length); + AcpiOsPrintf ("%20s : 0x%p\n", "Pointer", ObjDesc->String.Pointer); + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Buffer"); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Buffer.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "Sequence", ObjDesc->Buffer.Sequence); + AcpiOsPrintf ("%20s : 0x%p\n", "Pointer", ObjDesc->Buffer.Pointer); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Package"); + AcpiOsPrintf ("%20s : 0x%X\n", "Count", ObjDesc->Package.Count); + AcpiOsPrintf ("%20s : 0x%p\n", "Elements", ObjDesc->Package.Elements); + AcpiOsPrintf ("%20s : 0x%p\n", "NextElement", ObjDesc->Package.NextElement); + break; + + + case ACPI_TYPE_FIELD_UNIT: + + AcpiOsPrintf ("%20s : %s\n", "Type", "FieldUnit"); + AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->FieldUnit.Access); + AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->FieldUnit.LockRule); + AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->FieldUnit.UpdateRule); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->FieldUnit.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->FieldUnit.BitOffset); + AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->FieldUnit.Offset); + AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->FieldUnit.Container); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Device"); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Device.AddrHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->Device.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->Device.DrvHandler); + break; + + case ACPI_TYPE_EVENT: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Event"); + AcpiOsPrintf ("%20s : 0x%X\n", "Semaphore", ObjDesc->Event.Semaphore); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Method"); + AcpiOsPrintf ("%20s : 0x%X\n", "ParamCount", ObjDesc->Method.ParamCount); + AcpiOsPrintf ("%20s : 0x%X\n", "Concurrency", ObjDesc->Method.Concurrency); + AcpiOsPrintf ("%20s : 0x%p\n", "Semaphore", ObjDesc->Method.Semaphore); + AcpiOsPrintf ("%20s : 0x%X\n", "PcodeLength", ObjDesc->Method.PcodeLength); + AcpiOsPrintf ("%20s : 0x%X\n", "Pcode", ObjDesc->Method.Pcode); + break; + + + case ACPI_TYPE_MUTEX: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Mutex"); + AcpiOsPrintf ("%20s : 0x%X\n", "SyncLevel", ObjDesc->Mutex.SyncLevel); + AcpiOsPrintf ("%20s : 0x%p\n", "Semaphore", ObjDesc->Mutex.Semaphore); + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Region"); + AcpiOsPrintf ("%20s : 0x%X\n", "SpaceId", ObjDesc->Region.SpaceId); + AcpiOsPrintf ("%20s : 0x%X\n", "Flags", ObjDesc->Region.Flags); + AcpiOsPrintf ("%20s : 0x%X\n", "Address", ObjDesc->Region.Address); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Region.Length); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Region.AddrHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "Next", ObjDesc->Region.Next); + break; + + + case ACPI_TYPE_POWER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "PowerResource"); + AcpiOsPrintf ("%20s : 0x%X\n", "SystemLevel", ObjDesc->PowerResource.SystemLevel); + AcpiOsPrintf ("%20s : 0x%X\n", "ResourceOrder", ObjDesc->PowerResource.ResourceOrder); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->PowerResource.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->PowerResource.DrvHandler); + break; + + + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Processor"); + AcpiOsPrintf ("%20s : 0x%X\n", "Processor ID", ObjDesc->Processor.ProcId); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->Processor.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "Address", ObjDesc->Processor.Address); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->Processor.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->Processor.DrvHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->Processor.AddrHandler); + break; + + + case ACPI_TYPE_THERMAL: + + AcpiOsPrintf ("%20s : %s\n", "Type", "ThermalZone"); + AcpiOsPrintf ("%20s : 0x%p\n", "SysHandler", ObjDesc->ThermalZone.SysHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "DrvHandler", ObjDesc->ThermalZone.DrvHandler); + AcpiOsPrintf ("%20s : 0x%p\n", "AddrHandler", ObjDesc->ThermalZone.AddrHandler); + break; + + case INTERNAL_TYPE_BANK_FIELD: + + AcpiOsPrintf ("%20s : %s\n", "Type", "BankField"); + AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->BankField.Access); + AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->BankField.LockRule); + AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->BankField.UpdateRule); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->BankField.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->BankField.BitOffset); + AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->BankField.Offset); + AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->BankField.Value); + AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->BankField.Container); + AcpiOsPrintf ("%20s : 0x%X\n", "BankSelect", ObjDesc->BankField.BankSelect); + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + AcpiOsPrintf ("%20s : %s\n", "Type", "IndexField"); + AcpiOsPrintf ("%20s : 0x%X\n", "Access", ObjDesc->IndexField.Access); + AcpiOsPrintf ("%20s : 0x%X\n", "LockRule", ObjDesc->IndexField.LockRule); + AcpiOsPrintf ("%20s : 0x%X\n", "UpdateRule", ObjDesc->IndexField.UpdateRule); + AcpiOsPrintf ("%20s : 0x%X\n", "Length", ObjDesc->IndexField.Length); + AcpiOsPrintf ("%20s : 0x%X\n", "BitOffset", ObjDesc->IndexField.BitOffset); + AcpiOsPrintf ("%20s : 0x%X\n", "Value", ObjDesc->IndexField.Value); + AcpiOsPrintf ("%20s : 0x%X\n", "Index", ObjDesc->IndexField.Index); + AcpiOsPrintf ("%20s : 0x%X\n", "Data", ObjDesc->IndexField.Data); + break; + + + case INTERNAL_TYPE_REFERENCE: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Reference"); + AcpiOsPrintf ("%20s : 0x%X\n", "TargetType", ObjDesc->Reference.TargetType); + AcpiOsPrintf ("%20s : 0x%X\n", "OpCode", ObjDesc->Reference.OpCode); + AcpiOsPrintf ("%20s : 0x%X\n", "Offset", ObjDesc->Reference.Offset); + AcpiOsPrintf ("%20s : 0x%p\n", "ObjDesc", ObjDesc->Reference.Object); + AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->Reference.Node); + AcpiOsPrintf ("%20s : 0x%p\n", "Where", ObjDesc->Reference.Where); + break; + + + case INTERNAL_TYPE_ADDRESS_HANDLER: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Address Handler"); + AcpiOsPrintf ("%20s : 0x%X\n", "SpaceId", ObjDesc->AddrHandler.SpaceId); + AcpiOsPrintf ("%20s : 0x%p\n", "Next", ObjDesc->AddrHandler.Next); + AcpiOsPrintf ("%20s : 0x%p\n", "RegionList", ObjDesc->AddrHandler.RegionList); + AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->AddrHandler.Node); + AcpiOsPrintf ("%20s : 0x%p\n", "Handler", ObjDesc->AddrHandler.Handler); + AcpiOsPrintf ("%20s : 0x%p\n", "Context", ObjDesc->AddrHandler.Context); + break; + + + case INTERNAL_TYPE_NOTIFY: + + AcpiOsPrintf ("%20s : %s\n", "Type", "Notify Handler"); + AcpiOsPrintf ("%20s : 0x%p\n", "Node", ObjDesc->NotifyHandler.Node); + AcpiOsPrintf ("%20s : 0x%p\n", "Handler", ObjDesc->NotifyHandler.Handler); + AcpiOsPrintf ("%20s : 0x%p\n", "Context", ObjDesc->NotifyHandler.Context); + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + AcpiOsPrintf ("%20s : 0x%p\n", "Granularity", ObjDesc->Field.Granularity); + AcpiOsPrintf ("%20s : 0x%p\n", "Length", ObjDesc->Field.Length); + AcpiOsPrintf ("%20s : 0x%p\n", "Offset", ObjDesc->Field.Offset); + AcpiOsPrintf ("%20s : 0x%p\n", "BitOffset", ObjDesc->Field.BitOffset); + AcpiOsPrintf ("%20s : 0x%p\n", "Container", ObjDesc->Field.Container); + break; + + + case INTERNAL_TYPE_ALIAS: + case INTERNAL_TYPE_DEF_FIELD_DEFN: + case INTERNAL_TYPE_BANK_FIELD_DEFN: + case INTERNAL_TYPE_INDEX_FIELD_DEFN: + case INTERNAL_TYPE_IF: + case INTERNAL_TYPE_ELSE: + case INTERNAL_TYPE_WHILE: + case INTERNAL_TYPE_SCOPE: + case INTERNAL_TYPE_DEF_ANY: + + AcpiOsPrintf ("*** Structure display not implemented for type 0x%X! ***\n", + ObjDesc->Common.Type); + break; + + + default: + + AcpiOsPrintf ("*** Cannot display unknown type 0x%X! ***\n", ObjDesc->Common.Type); + break; + } + + return_VOID; +} + +#endif + diff --git a/sys/contrib/dev/acpica/exdyadic.c b/sys/contrib/dev/acpica/exdyadic.c new file mode 100644 index 0000000..fdc998b --- /dev/null +++ b/sys/contrib/dev/acpica/exdyadic.c @@ -0,0 +1,906 @@ +/****************************************************************************** + * + * Module Name: amdyadic - ACPI AML (p-code) execution for dyadic operators + * $Revision: 65 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMDYADIC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acevents.h" +#include "amlcode.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amdyadic") + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic1 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 1 dyadic operator with numeric operands: + * NotifyOp + * + * ALLOCATION: Deletes both operands + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_OPERAND_OBJECT *ValDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AmlExecDyadic1", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get the operands */ + + Status |= AcpiDsObjStackPopObject (&ValDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic1/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Examine the opcode */ + + switch (Opcode) + { + + /* DefNotify := NotifyOp NotifyObject NotifyValue */ + + case AML_NOTIFY_OP: + + /* The ObjDesc is actually an Node */ + + Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + ObjDesc = NULL; + + /* Object must be a device or thermal zone */ + + if (Node && ValDesc) + { + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + /* + * Requires that Device and ThermalZone be compatible + * mappings + */ + + /* Dispatch the notify to the appropriate handler */ + + AcpiEvNotifyDispatch (Node, (UINT32) ValDesc->Number.Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecDyadic1/NotifyOp: unexpected notify object type %d\n", + ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + } + } + break; + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic1: Unknown dyadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + } + + +Cleanup: + + /* Always delete both operands */ + + AcpiCmRemoveReference (ValDesc); + AcpiCmRemoveReference (ObjDesc); + + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic2R + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and + * one or two result operands. + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_OPERAND_OBJECT *ObjDesc2 = NULL; + ACPI_OPERAND_OBJECT *ResDesc = NULL; + ACPI_OPERAND_OBJECT *ResDesc2 = NULL; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_OPERAND_OBJECT *RetDesc2 = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Remainder; + UINT32 NumOperands = 3; + NATIVE_CHAR *NewBuf; + + + FUNCTION_TRACE_U32 ("AmlExecDyadic2R", Opcode); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + NumOperands, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + if (AML_DIVIDE_OP == Opcode) + { + NumOperands = 4; + Status |= AcpiDsObjStackPopObject (&ResDesc2, WalkState); + } + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic2R/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create an internal return object if necessary */ + + switch (Opcode) + { + case AML_ADD_OP: + case AML_BIT_AND_OP: + case AML_BIT_NAND_OP: + case AML_BIT_OR_OP: + case AML_BIT_NOR_OP: + case AML_BIT_XOR_OP: + case AML_DIVIDE_OP: + case AML_MULTIPLY_OP: + case AML_SHIFT_LEFT_OP: + case AML_SHIFT_RIGHT_OP: + case AML_SUBTRACT_OP: + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + break; + } + + + /* + * Execute the opcode + */ + + switch (Opcode) + { + + /* DefAdd := AddOp Operand1 Operand2 Result */ + + case AML_ADD_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value + + ObjDesc2->Number.Value; + break; + + + /* DefAnd := AndOp Operand1 Operand2 Result */ + + case AML_BIT_AND_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value & + ObjDesc2->Number.Value; + break; + + + /* DefNAnd := NAndOp Operand1 Operand2 Result */ + + case AML_BIT_NAND_OP: + + RetDesc->Number.Value = ~(ObjDesc->Number.Value & + ObjDesc2->Number.Value); + break; + + + /* DefOr := OrOp Operand1 Operand2 Result */ + + case AML_BIT_OR_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value | + ObjDesc2->Number.Value; + break; + + + /* DefNOr := NOrOp Operand1 Operand2 Result */ + + case AML_BIT_NOR_OP: + + RetDesc->Number.Value = ~(ObjDesc->Number.Value | + ObjDesc2->Number.Value); + break; + + + /* DefXOr := XOrOp Operand1 Operand2 Result */ + + case AML_BIT_XOR_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value ^ + ObjDesc2->Number.Value; + break; + + + /* DefDivide := DivideOp Dividend Divisor Remainder Quotient */ + + case AML_DIVIDE_OP: + + if ((UINT32) 0 == ObjDesc2->Number.Value) + { + REPORT_ERROR + (("AmlExecDyadic2R/DivideOp: Divide by zero\n")); + + Status = AE_AML_DIVIDE_BY_ZERO; + goto Cleanup; + } + + RetDesc2 = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc2) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Remainder = ObjDesc->Number.Value % + ObjDesc2->Number.Value; + RetDesc->Number.Value = Remainder; + + /* Result (what we used to call the quotient) */ + + RetDesc2->Number.Value = ObjDesc->Number.Value / + ObjDesc2->Number.Value; + break; + + + /* DefMultiply := MultiplyOp Operand1 Operand2 Result */ + + case AML_MULTIPLY_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value * + ObjDesc2->Number.Value; + break; + + + /* DefShiftLeft := ShiftLeftOp Operand ShiftCount Result */ + + case AML_SHIFT_LEFT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value << + ObjDesc2->Number.Value; + break; + + + /* DefShiftRight := ShiftRightOp Operand ShiftCount Result */ + + case AML_SHIFT_RIGHT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value >> + ObjDesc2->Number.Value; + break; + + + /* DefSubtract := SubtractOp Operand1 Operand2 Result */ + + case AML_SUBTRACT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value - + ObjDesc2->Number.Value; + break; + + + /* DefConcat := ConcatOp Data1 Data2 Result */ + + case AML_CONCAT_OP: + + if (ObjDesc2->Common.Type != ObjDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecDyadic2R/ConcatOp: operand type mismatch %d %d\n", + ObjDesc->Common.Type, ObjDesc2->Common.Type)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* Both operands are now known to be the same */ + + if (ACPI_TYPE_STRING == ObjDesc->Common.Type) + { + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Operand1 is string */ + + NewBuf = AcpiCmAllocate (ObjDesc->String.Length + + ObjDesc2->String.Length + 1); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: String allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + STRCPY (NewBuf, ObjDesc->String.Pointer); + STRCPY (NewBuf + ObjDesc->String.Length, + ObjDesc2->String.Pointer); + + /* Point the return object to the new string */ + + RetDesc->String.Pointer = NewBuf; + RetDesc->String.Length = ObjDesc->String.Length += + ObjDesc2->String.Length; + } + + else + { + /* Operand1 is not a string ==> must be a buffer */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_BUFFER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = AcpiCmAllocate (ObjDesc->Buffer.Length + + ObjDesc2->Buffer.Length); + if (!NewBuf) + { + REPORT_ERROR + (("AmlExecDyadic2R/ConcatOp: Buffer allocation failure\n")); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + MEMCPY (NewBuf, ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length); + MEMCPY (NewBuf + ObjDesc->Buffer.Length, ObjDesc2->Buffer.Pointer, + ObjDesc2->Buffer.Length); + + /* + * Point the return object to the new buffer + */ + + RetDesc->Buffer.Pointer = (UINT8 *) NewBuf; + RetDesc->Buffer.Length = ObjDesc->Buffer.Length + + ObjDesc2->Buffer.Length; + } + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic2R: Unknown dyadic opcode %X\n", Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Store the result of the operation (which is now in ObjDesc) into + * the result descriptor, or the location pointed to by the result + * descriptor (ResDesc). + */ + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (AML_DIVIDE_OP == Opcode) + { + Status = AcpiAmlExecStore (RetDesc2, ResDesc2, WalkState); + + /* + * Since the remainder is not returned, remove a reference to + * the object we created earlier + */ + + AcpiCmRemoveReference (RetDesc2); + } + + +Cleanup: + + /* Always delete the operands */ + + AcpiCmRemoveReference (ObjDesc); + AcpiCmRemoveReference (ObjDesc2); + + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + /* On failure, delete the result ops */ + + AcpiCmRemoveReference (ResDesc); + AcpiCmRemoveReference (ResDesc2); + + if (RetDesc) + { + /* And delete the internal return object */ + + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + } + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic2S + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 dyadic synchronization operator + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic2S ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *TimeDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("AmlExecDyadic2S", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&TimeDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic2S/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create the internal return object */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Default return value is FALSE, operation did not time out */ + + RetDesc->Number.Value = 0; + + + /* Examine the opcode */ + + switch (Opcode) + { + + /* DefAcquire := AcquireOp MutexObject Timeout */ + + case AML_ACQUIRE_OP: + + Status = AcpiAmlSystemAcquireMutex (TimeDesc, ObjDesc); + break; + + + /* DefWait := WaitOp AcpiEventObject Timeout */ + + case AML_WAIT_OP: + + Status = AcpiAmlSystemWaitEvent (TimeDesc, ObjDesc); + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic2S: Unknown dyadic synchronization opcode %X\n", Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + /* + * Return a boolean indicating if operation timed out + * (TRUE) or not (FALSE) + */ + + if (Status == AE_TIME) + { + RetDesc->Number.Value = ACPI_INTEGER_MAX; /* TRUE, op timed out */ + Status = AE_OK; + } + + +Cleanup: + + /* Delete params */ + + AcpiCmRemoveReference (TimeDesc); + AcpiCmRemoveReference (ObjDesc); + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlExecDyadic2 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and + * no result operands + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * containing result value + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlExecDyadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *ObjDesc2; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS Status; + BOOLEAN Lboolean; + + + FUNCTION_TRACE_PTR ("AmlExecDyadic2", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ObjDesc2, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecDyadic2/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create the internal return object */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Execute the Opcode + */ + + Lboolean = FALSE; + switch (Opcode) + { + + /* DefLAnd := LAndOp Operand1 Operand2 */ + + case AML_LAND_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value && + ObjDesc2->Number.Value); + break; + + + /* DefLEqual := LEqualOp Operand1 Operand2 */ + + case AML_LEQUAL_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value == + ObjDesc2->Number.Value); + break; + + + /* DefLGreater := LGreaterOp Operand1 Operand2 */ + + case AML_LGREATER_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value > + ObjDesc2->Number.Value); + break; + + + /* DefLLess := LLessOp Operand1 Operand2 */ + + case AML_LLESS_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value < + ObjDesc2->Number.Value); + break; + + + /* DefLOr := LOrOp Operand1 Operand2 */ + + case AML_LOR_OP: + + Lboolean = (BOOLEAN) (ObjDesc->Number.Value || + ObjDesc2->Number.Value); + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecDyadic2: Unknown dyadic opcode %X\n", Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + break; + } + + + /* Set return value to logical TRUE (all ones) or FALSE (zero) */ + + if (Lboolean) + { + RetDesc->Number.Value = ACPI_INTEGER_MAX; + } + else + { + RetDesc->Number.Value = 0; + } + + +Cleanup: + + /* Always delete operands */ + + AcpiCmRemoveReference (ObjDesc); + AcpiCmRemoveReference (ObjDesc2); + + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exfield.c b/sys/contrib/dev/acpica/exfield.c new file mode 100644 index 0000000..d450fbf --- /dev/null +++ b/sys/contrib/dev/acpica/exfield.c @@ -0,0 +1,446 @@ +/****************************************************************************** + * + * Module Name: amfield - ACPI AML (p-code) execution - field manipulation + * $Revision: 73 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMFIELD_C__ + +#include "acpi.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amfield") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSetupField + * + * PARAMETERS: *ObjDesc - Field to be read or written + * *RgnDesc - Region containing field + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Common processing for AcpiAmlReadField and AcpiAmlWriteField + * + * ACPI SPECIFICATION REFERENCES: + * Each of the Type1Opcodes is defined as specified in in-line + * comments below. For each one, use the following definitions. + * + * DefBitField := BitFieldOp SrcBuf BitIdx Destination + * DefByteField := ByteFieldOp SrcBuf ByteIdx Destination + * DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString + * DefDWordField := DWordFieldOp SrcBuf ByteIdx Destination + * DefWordField := WordFieldOp SrcBuf ByteIdx Destination + * BitIndex := TermArg=>Integer + * ByteIndex := TermArg=>Integer + * Destination := NameString + * NumBits := TermArg=>Integer + * SourceBuf := TermArg=>Buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSetupField ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *RgnDesc, + UINT32 FieldBitWidth) +{ + ACPI_STATUS Status = AE_OK; + UINT32 FieldByteWidth; + + + FUNCTION_TRACE ("AmlSetupField"); + + + /* Parameter validation */ + + if (!ObjDesc || !RgnDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Internal error - null handle\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (ACPI_TYPE_REGION != RgnDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Needed Region, found type %x %s\n", + RgnDesc->Common.Type, AcpiCmGetTypeName (RgnDesc->Common.Type))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* + * TBD: [Future] Acpi 2.0 supports Qword fields + * + * Init and validate Field width + * Possible values are 1, 2, 4 + */ + + FieldByteWidth = DIV_8 (FieldBitWidth); + + if ((FieldBitWidth != 8) && + (FieldBitWidth != 16) && + (FieldBitWidth != 32)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Internal error - bad width %d\n", FieldBitWidth)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them and save the results. + */ + if (!(RgnDesc->Region.Flags & AOPOBJ_DATA_VALID)) + { + + Status = AcpiDsGetRegionArguments (RgnDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + if ((ObjDesc->Common.Type == ACPI_TYPE_FIELD_UNIT) && + (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))) + { + /* + * Field Buffer and Index have not been previously evaluated, + */ + DEBUG_PRINT (ACPI_ERROR, ("Uninitialized field!\n")); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + if (RgnDesc->Region.Length < + (ObjDesc->Field.Offset & ~((UINT32) FieldByteWidth - 1)) + + FieldByteWidth) + { + /* + * Offset rounded up to next multiple of field width + * exceeds region length, indicate an error + */ + + DUMP_STACK_ENTRY (RgnDesc); + DUMP_STACK_ENTRY (ObjDesc); + + DEBUG_PRINT (ACPI_ERROR, + ("AmlSetupField: Operation at %08lX width %d bits exceeds len %08lX field=%p region=%p\n", + ObjDesc->Field.Offset, FieldBitWidth, RgnDesc->Region.Length, + ObjDesc, RgnDesc)); + + return_ACPI_STATUS (AE_AML_REGION_LIMIT); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlAccessNamedField + * + * PARAMETERS: Mode - ACPI_READ or ACPI_WRITE + * NamedField - Handle for field to be accessed + * *Buffer - Value(s) to be read or written + * BufferLength - Number of bytes to transfer + * + * RETURN: Status + * + * DESCRIPTION: Read or write a named field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlAccessNamedField ( + UINT32 Mode, + ACPI_HANDLE NamedField, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_STATUS Status = AE_OK; + BOOLEAN Locked = FALSE; + UINT32 BitGranularity = 0; + UINT32 ByteGranularity; + UINT32 DatumLength; + UINT32 ActualByteLength; + UINT32 ByteFieldLength; + + + FUNCTION_TRACE_PTR ("AmlAccessNamedField", NamedField); + + + /* Basic data checking */ + if ((!NamedField) || (ACPI_READ == Mode && !Buffer)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AcpiAmlAccessNamedField: Internal error - null parameter\n")); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Get the attached field object */ + + ObjDesc = AcpiNsGetAttachedObject (NamedField); + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlAccessNamedField: Internal error - null value pointer\n")); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Check the type */ + + if (INTERNAL_TYPE_DEF_FIELD != AcpiNsGetType (NamedField)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlAccessNamedField: Name %4.4s type %x is not a defined field\n", + &(((ACPI_NAMESPACE_NODE *) NamedField)->Name), + AcpiNsGetType (NamedField))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* ObjDesc valid and NamedField is a defined field */ + + DEBUG_PRINT (ACPI_INFO, + ("AccessNamedField: Obj=%p Type=%x Buf=%p Len=%x\n", + ObjDesc, ObjDesc->Common.Type, Buffer, BufferLength)); + DEBUG_PRINT (ACPI_INFO, + ("AccessNamedField: Mode=%d FieldLen=%d, BitOffset=%d\n", + Mode, ObjDesc->FieldUnit.Length, ObjDesc->FieldUnit.BitOffset)); + DUMP_ENTRY (NamedField, ACPI_INFO); + + + /* Double-check that the attached object is also a field */ + + if (INTERNAL_TYPE_DEF_FIELD != ObjDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlAccessNamedField: Internal error - Name %4.4s type %x does not match value-type %x at %p\n", + &(((ACPI_NAMESPACE_NODE *) NamedField)->Name), + AcpiNsGetType (NamedField), ObjDesc->Common.Type, ObjDesc)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* + * Granularity was decoded from the field access type + * (AnyAcc will be the same as ByteAcc) + */ + + BitGranularity = ObjDesc->FieldUnit.Granularity; + ByteGranularity = DIV_8 (BitGranularity); + + /* + * Check if request is too large for the field, and silently truncate + * if necessary + */ + + /* TBD: [Errors] should an error be returned in this case? */ + + ByteFieldLength = (UINT32) DIV_8 (ObjDesc->FieldUnit.Length + 7); + + + ActualByteLength = BufferLength; + if (BufferLength > ByteFieldLength) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlAccessNamedField: Byte length %d too large, truncated to %x\n", + ActualByteLength, ByteFieldLength)); + + ActualByteLength = ByteFieldLength; + } + + /* TBD: should these round down to a power of 2? */ + + if (DIV_8(BitGranularity) > ByteFieldLength) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlAccessNamedField: Bit granularity %d too large, truncated to %x\n", + BitGranularity, MUL_8(ByteFieldLength))); + + BitGranularity = MUL_8(ByteFieldLength); + } + + if (ByteGranularity > ByteFieldLength) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlAccessNamedField: Byte granularity %d too large, truncated to %x\n", + ByteGranularity, ByteFieldLength)); + + ByteGranularity = ByteFieldLength; + } + + + /* Convert byte count to datum count, round up if necessary */ + + DatumLength = (ActualByteLength + (ByteGranularity-1)) / ByteGranularity; + + DEBUG_PRINT (ACPI_INFO, + ("ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n", + ActualByteLength, DatumLength, BitGranularity, ByteGranularity)); + + + /* Get the global lock if needed */ + + Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule); + + + /* Perform the actual read or write of the buffer */ + + switch (Mode) + { + case ACPI_READ: + + Status = AcpiAmlReadField (ObjDesc, Buffer, BufferLength, + ActualByteLength, DatumLength, + BitGranularity, ByteGranularity); + break; + + + case ACPI_WRITE: + + Status = AcpiAmlWriteField (ObjDesc, Buffer, BufferLength, + ActualByteLength, DatumLength, + BitGranularity, ByteGranularity); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AccessNamedField: Unknown I/O Mode: %X\n", Mode)); + Status = AE_BAD_PARAMETER; + break; + } + + + /* Release global lock if we acquired it earlier */ + + AcpiAmlReleaseGlobalLock (Locked); + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c new file mode 100644 index 0000000..ce7bb28 --- /dev/null +++ b/sys/contrib/dev/acpica/exfldio.c @@ -0,0 +1,857 @@ +/****************************************************************************** + * + * Module Name: amfldio - Aml Field I/O + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMFLDIO_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amfldio") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlReadFieldData + * + * PARAMETERS: *ObjDesc - Field to be read + * *Value - Where to store value + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value of the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlReadFieldData ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldByteOffset, + UINT32 FieldBitWidth, + UINT32 *Value) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RgnDesc = NULL; + ACPI_INTEGER Address; + UINT32 LocalValue = 0; + UINT32 FieldByteWidth; + + + FUNCTION_TRACE ("AmlReadFieldData"); + + + /* ObjDesc is validated by callers */ + + if (ObjDesc) + { + RgnDesc = ObjDesc->Field.Container; + } + + + FieldByteWidth = DIV_8 (FieldBitWidth); + Status = AcpiAmlSetupField (ObjDesc, RgnDesc, FieldBitWidth); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* SetupField validated RgnDesc and FieldBitWidth */ + + if (!Value) + { + Value = &LocalValue; /* support reads without saving value */ + } + + + /* + * Set offset to next multiple of field width, + * add region base address and offset within the field + */ + Address = RgnDesc->Region.Address + + (ObjDesc->Field.Offset * FieldByteWidth) + + FieldByteOffset; + + + if (RgnDesc->Region.SpaceId >= NUM_REGION_TYPES) + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlReadFieldData: **** Unknown OpRegion SpaceID %d at %08lx width %d\n", + RgnDesc->Region.SpaceId, Address, FieldBitWidth)); + } + + else + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlReadFieldData: OpRegion %s at %08lx width %d\n", + AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId], Address, + FieldBitWidth)); + } + + + /* Invoke the appropriate AddressSpace/OpRegion handler */ + + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_READ, + Address, FieldBitWidth, Value); + + if (Status == AE_NOT_IMPLEMENTED) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlReadFieldData: **** OpRegion type %s not implemented\n", + AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId])); + } + + else if (Status == AE_NOT_EXIST) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlReadFieldData: **** Unknown OpRegion SpaceID %d\n", + RgnDesc->Region.SpaceId)); + } + + DEBUG_PRINT (TRACE_OPREGION, + ("AmlReadField: Returned value=%08lx \n", *Value)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlReadField + * + * PARAMETERS: *ObjDesc - Field to be read + * *Value - Where to store value + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value of the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlReadField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity) +{ + ACPI_STATUS Status; + UINT32 ThisFieldByteOffset; + UINT32 ThisFieldDatumOffset; + UINT32 PreviousRawDatum; + UINT32 ThisRawDatum; + UINT32 ValidFieldBits; + UINT32 Mask; + UINT32 MergedDatum = 0; + + + FUNCTION_TRACE ("AmlReadField"); + + /* + * Clear the caller's buffer (the whole buffer length as given) + * This is very important, especially in the cases where a byte is read, + * but the buffer is really a UINT32 (4 bytes). + */ + + MEMSET (Buffer, 0, BufferLength); + + /* Read the first raw datum to prime the loop */ + + ThisFieldByteOffset = 0; + ThisFieldDatumOffset= 0; + + Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, BitGranularity, + &PreviousRawDatum); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* We might actually be done if the request fits in one datum */ + + if ((DatumLength == 1) && + ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) <= + (UINT16) BitGranularity)) + { + MergedDatum = PreviousRawDatum; + + MergedDatum = (MergedDatum >> ObjDesc->Field.BitOffset); + + ValidFieldBits = ObjDesc->FieldUnit.Length % BitGranularity; + if (ValidFieldBits) + { + Mask = (((UINT32) 1 << ValidFieldBits) - (UINT32) 1); + MergedDatum &= Mask; + } + + + /* + * Place the MergedDatum into the proper format and return buffer + * field + */ + + switch (ByteGranularity) + { + case 1: + ((UINT8 *) Buffer) [ThisFieldDatumOffset] = (UINT8) MergedDatum; + break; + + case 2: + MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[ThisFieldDatumOffset]), &MergedDatum); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[ThisFieldDatumOffset]), &MergedDatum); + break; + } + + ThisFieldByteOffset = 1; + ThisFieldDatumOffset = 1; + } + + else + { + /* We need to get more raw data to complete one or more field data */ + + while (ThisFieldDatumOffset < DatumLength) + { + /* + * Get the next raw datum, it contains bits of the current + * field datum + */ + + Status = AcpiAmlReadFieldData (ObjDesc, + ThisFieldByteOffset + ByteGranularity, + BitGranularity, &ThisRawDatum); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Before merging the data, make sure the unused bits are clear */ + + switch (ByteGranularity) + { + case 1: + ThisRawDatum &= 0x000000FF; + PreviousRawDatum &= 0x000000FF; + break; + + case 2: + ThisRawDatum &= 0x0000FFFF; + PreviousRawDatum &= 0x0000FFFF; + break; + } + + /* + * Put together bits of the two raw data to make a complete + * field datum + */ + + + if (ObjDesc->Field.BitOffset != 0) + { + MergedDatum = + (PreviousRawDatum >> ObjDesc->Field.BitOffset) | + (ThisRawDatum << (BitGranularity - ObjDesc->Field.BitOffset)); + } + + else + { + MergedDatum = PreviousRawDatum; + } + + /* + * Prepare the merged datum for storing into the caller's + * buffer. It is possible to have a 32-bit buffer + * (ByteGranularity == 4), but a ObjDesc->Field.Length + * of 8 or 16, meaning that the upper bytes of merged data + * are undesired. This section fixes that. + */ + switch (ObjDesc->Field.Length) + { + case 8: + MergedDatum &= 0x000000FF; + break; + + case 16: + MergedDatum &= 0x0000FFFF; + break; + } + + /* + * Now store the datum in the caller's buffer, according to + * the data type + */ + switch (ByteGranularity) + { + case 1: + ((UINT8 *) Buffer) [ThisFieldDatumOffset] = (UINT8) MergedDatum; + break; + + case 2: + MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer) [ThisFieldDatumOffset]), &MergedDatum); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer) [ThisFieldDatumOffset]), &MergedDatum); + break; + } + + /* + * Save the most recent datum since it contains bits of + * the *next* field datum + */ + + PreviousRawDatum = ThisRawDatum; + + ThisFieldByteOffset += ByteGranularity; + ThisFieldDatumOffset++; + + } /* while */ + } + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlWriteFieldData + * + * PARAMETERS: *ObjDesc - Field to be set + * Value - Value to store + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Store the value into the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlWriteFieldData ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldByteOffset, + UINT32 FieldBitWidth, + UINT32 Value) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RgnDesc = NULL; + ACPI_INTEGER Address; + UINT32 FieldByteWidth; + + + FUNCTION_TRACE ("AmlWriteFieldData"); + + + /* ObjDesc is validated by callers */ + + if (ObjDesc) + { + RgnDesc = ObjDesc->Field.Container; + } + + FieldByteWidth = DIV_8 (FieldBitWidth); + Status = AcpiAmlSetupField (ObjDesc, RgnDesc, FieldBitWidth); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* + * Set offset to next multiple of field width, + * add region base address and offset within the field + */ + Address = RgnDesc->Region.Address + + (ObjDesc->Field.Offset * FieldByteWidth) + + FieldByteOffset; + + + if (RgnDesc->Region.SpaceId >= NUM_REGION_TYPES) + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlWriteField: **** Store %lx in unknown OpRegion SpaceID %d at %p width %d ** \n", + Value, RgnDesc->Region.SpaceId, Address, FieldBitWidth)); + } + else + { + DEBUG_PRINT (TRACE_OPREGION, + ("AmlWriteField: Store %lx in OpRegion %s at %p width %d\n", + Value, AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId], Address, + FieldBitWidth)); + } + + /* Invoke the appropriate AddressSpace/OpRegion handler */ + + Status = AcpiEvAddressSpaceDispatch (RgnDesc, ADDRESS_SPACE_WRITE, + Address, FieldBitWidth, &Value); + + if (Status == AE_NOT_IMPLEMENTED) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlWriteField: **** OpRegion type %s not implemented\n", + AcpiGbl_RegionTypes[RgnDesc->Region.SpaceId])); + } + + else if (Status == AE_NOT_EXIST) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlWriteField: **** Unknown OpRegion SpaceID %x\n", + RgnDesc->Region.SpaceId)); + } + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlWriteFieldDataWithUpdateRule + * + * PARAMETERS: *ObjDesc - Field to be set + * Value - Value to store + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Apply the field update rule to a field write + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlWriteFieldDataWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Mask, + UINT32 FieldValue, + UINT32 ThisFieldByteOffset, + UINT32 BitGranularity) +{ + ACPI_STATUS Status = AE_OK; + UINT32 MergedValue; + UINT32 CurrentValue; + + + /* Start with the new bits */ + + MergedValue = FieldValue; + + /* Check if update rule needs to be applied (not if mask is all ones) */ + + + /* Decode the update rule */ + + switch (ObjDesc->Field.UpdateRule) + { + + case UPDATE_PRESERVE: + + /* + * Read the current contents of the byte/word/dword containing + * the field, and merge with the new field value. + */ + Status = AcpiAmlReadFieldData (ObjDesc, ThisFieldByteOffset, + BitGranularity, &CurrentValue); + MergedValue |= (CurrentValue & ~Mask); + break; + + + case UPDATE_WRITE_AS_ONES: + + /* Set positions outside the field to all ones */ + + MergedValue |= ~Mask; + break; + + + case UPDATE_WRITE_AS_ZEROS: + + /* Set positions outside the field to all zeros */ + + MergedValue &= Mask; + break; + + + default: + DEBUG_PRINT (ACPI_ERROR, + ("WriteFieldDataWithUpdateRule: Unknown UpdateRule setting: %x\n", + ObjDesc->Field.UpdateRule)); + Status = AE_AML_OPERAND_VALUE; + } + + + /* Write the merged value */ + + if (ACPI_SUCCESS (Status)) + { + Status = AcpiAmlWriteFieldData (ObjDesc, ThisFieldByteOffset, + BitGranularity, MergedValue); + } + + return (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiAmlWriteField + * + * PARAMETERS: *ObjDesc - Field to be set + * Value - Value to store + * FieldBitWidth - Field Width in bits (8, 16, or 32) + * + * RETURN: Status + * + * DESCRIPTION: Store the value into the given field + * + ****************************************************************************/ + +ACPI_STATUS +AcpiAmlWriteField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteLength, + UINT32 DatumLength, + UINT32 BitGranularity, + UINT32 ByteGranularity) +{ + ACPI_STATUS Status; + UINT32 ThisFieldByteOffset; + UINT32 ThisFieldDatumOffset; + UINT32 Mask; + UINT32 MergedDatum; + UINT32 PreviousRawDatum; + UINT32 ThisRawDatum; + UINT32 FieldValue; + UINT32 ValidFieldBits; + + + FUNCTION_TRACE ("AmlWriteField"); + + + /* + * Break the request into up to three parts: + * non-aligned part at start, aligned part in middle, non-aligned part + * at end --- Just like an I/O request --- + */ + + ThisFieldByteOffset = 0; + ThisFieldDatumOffset= 0; + + /* Get a datum */ + + switch (ByteGranularity) + { + case 1: + PreviousRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset]; + break; + + case 2: + MOVE_UNALIGNED16_TO_32 (&PreviousRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset])); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&PreviousRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset])); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ("AmlWriteField: Invalid granularity: %x\n", + ByteGranularity)); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + + /* + * Write a partial field datum if field does not begin on a datum boundary + * + * Construct Mask with 1 bits where the field is, 0 bits elsewhere + * + * 1) Bits above the field + */ + + Mask = (((UINT32)(-1)) << (UINT32)ObjDesc->Field.BitOffset); + + /* 2) Only the bottom 5 bits are valid for a shift operation. */ + + if ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) < 32) + { + /* Bits above the field */ + + Mask &= (~(((UINT32)(-1)) << ((UINT32)ObjDesc->Field.BitOffset + + (UINT32)ObjDesc->FieldUnit.Length))); + } + + /* 3) Shift and mask the value into the field position */ + + FieldValue = (PreviousRawDatum << ObjDesc->Field.BitOffset) & Mask; + + Status = AcpiAmlWriteFieldDataWithUpdateRule (ObjDesc, Mask, FieldValue, + ThisFieldByteOffset, + BitGranularity); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* If the field fits within one datum, we are done. */ + + if ((DatumLength == 1) && + ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) <= + (UINT16) BitGranularity)) + { + goto Cleanup; + } + + /* + * We don't need to worry about the update rule for these data, because + * all of the bits are part of the field. + * + * Can't write the last datum, however, because it might contain bits that + * are not part of the field -- the update rule must be applied. + */ + + while (ThisFieldDatumOffset < (DatumLength - 1)) + { + ThisFieldDatumOffset++; + + /* Get the next raw datum, it contains bits of the current field datum... */ + + switch (ByteGranularity) + { + case 1: + ThisRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset]; + break; + + case 2: + MOVE_UNALIGNED16_TO_32 (&ThisRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset])); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&ThisRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset])); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ("AmlWriteField: Invalid Byte Granularity: %x\n", + ByteGranularity)); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + /* + * Put together bits of the two raw data to make a complete field + * datum + */ + + if (ObjDesc->Field.BitOffset != 0) + { + MergedDatum = + (PreviousRawDatum >> (BitGranularity - ObjDesc->Field.BitOffset)) | + (ThisRawDatum << ObjDesc->Field.BitOffset); + } + + else + { + MergedDatum = ThisRawDatum; + } + + /* Now write the completed datum */ + + + Status = AcpiAmlWriteFieldData (ObjDesc, + ThisFieldByteOffset + ByteGranularity, + BitGranularity, MergedDatum); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* + * Save the most recent datum since it contains bits of + * the *next* field datum + */ + + PreviousRawDatum = ThisRawDatum; + + ThisFieldByteOffset += ByteGranularity; + + } /* while */ + + + /* Write a partial field datum if field does not end on a datum boundary */ + + if ((ObjDesc->FieldUnit.Length + ObjDesc->FieldUnit.BitOffset) % + BitGranularity) + { + switch (ByteGranularity) + { + case 1: + ThisRawDatum = ((UINT8 *) Buffer) [ThisFieldDatumOffset]; + break; + + case 2: + MOVE_UNALIGNED16_TO_32 (&ThisRawDatum, &(((UINT16 *) Buffer) [ThisFieldDatumOffset])); + break; + + case 4: + MOVE_UNALIGNED32_TO_32 (&ThisRawDatum, &(((UINT32 *) Buffer) [ThisFieldDatumOffset])); + break; + } + + /* Construct Mask with 1 bits where the field is, 0 bits elsewhere */ + + ValidFieldBits = ((ObjDesc->FieldUnit.Length % BitGranularity) + + ObjDesc->Field.BitOffset); + + Mask = (((UINT32) 1 << ValidFieldBits) - (UINT32) 1); + + /* Shift and mask the value into the field position */ + + FieldValue = (PreviousRawDatum >> + (BitGranularity - ObjDesc->Field.BitOffset)) & Mask; + + Status = AcpiAmlWriteFieldDataWithUpdateRule (ObjDesc, Mask, FieldValue, + ThisFieldByteOffset + ByteGranularity, + BitGranularity); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exmisc.c b/sys/contrib/dev/acpica/exmisc.c new file mode 100644 index 0000000..7decf64 --- /dev/null +++ b/sys/contrib/dev/acpica/exmisc.c @@ -0,0 +1,682 @@ + +/****************************************************************************** + * + * Module Name: ammisc - ACPI AML (p-code) execution - specific opcodes + * $Revision: 70 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMMISC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acdispat.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("ammisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecFatal + * + * PARAMETERS: none + * + * RETURN: Status. If the OS returns from the OSD call, we just keep + * on going. + * + * DESCRIPTION: Execute Fatal operator + * + * ACPI SPECIFICATION REFERENCES: + * DefFatal := FatalOp FatalType FatalCode FatalArg + * FatalType := ByteData + * FatalCode := DWordData + * FatalArg := TermArg=>Integer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecFatal ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *TypeDesc; + ACPI_OPERAND_OBJECT *CodeDesc; + ACPI_OPERAND_OBJECT *ArgDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecFatal"); + + + /* Resolve operands */ + + Status = AcpiAmlResolveOperands (AML_FATAL_OP, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (AML_FATAL_OP), + 3, "after AcpiAmlResolveOperands"); + + /* Get operands */ + + Status |= AcpiDsObjStackPopObject (&ArgDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&CodeDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&TypeDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("AcpiAmlExecFatal/AML_FATAL_OP: bad operand(s) (0x%X)\n", + Status)); + + goto Cleanup; + } + + + /* DefFatal := FatalOp FatalType FatalCode FatalArg */ + + + DEBUG_PRINT (ACPI_INFO, + ("FatalOp: Type %x Code %x Arg %x <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + TypeDesc->Number.Value, CodeDesc->Number.Value, ArgDesc->Number.Value)); + + + /* + * TBD: [Unhandled] call OSD interface to notify OS of fatal error + * requiring shutdown! + */ + + +Cleanup: + + /* Free the operands */ + + AcpiCmRemoveReference (ArgDesc); + AcpiCmRemoveReference (CodeDesc); + AcpiCmRemoveReference (TypeDesc); + + + /* If we get back from the OS call, we might as well keep going. */ + + REPORT_WARNING (("An AML \"Fatal\" Opcode (FatalOp) was executed\n")); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecIndex + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Execute Index operator + * + * ALLOCATION: Deletes one operand descriptor -- other remains on stack + * + * ACPI SPECIFICATION REFERENCES: + * DefIndex := IndexOp BuffPkgObj IndexValue Result + * IndexValue := TermArg=>Integer + * NameString := | + * Result := SuperName + * SuperName := NameString | ArgObj | LocalObj | DebugObj | DefIndex + * Local4Op | Local5Op | Local6Op | Local7Op + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecIndex ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *IdxDesc; + ACPI_OPERAND_OBJECT *ResDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_OPERAND_OBJECT *TmpDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecIndex"); + + + /* Resolve operands */ + /* First operand can be either a package or a buffer */ + + Status = AcpiAmlResolveOperands (AML_INDEX_OP, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (AML_INDEX_OP), + 3, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&IdxDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("AcpiAmlExecIndex/AML_INDEX_OP: bad operand(s) (0x%X)\n", + Status)); + + goto Cleanup; + } + + + /* Create the internal return object */ + + RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + + /* + * At this point, the ObjDesc operand is either a Package or a Buffer + */ + + if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + /* Object to be indexed is a Package */ + + if (IdxDesc->Number.Value >= ObjDesc->Package.Count) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecIndex: Index value out of range\n")); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } + + if ((ResDesc->Common.Type == INTERNAL_TYPE_REFERENCE) && + (ResDesc->Reference.OpCode == AML_ZERO_OP)) + { + /* + * There is no actual result descriptor (the ZeroOp Result + * descriptor is a placeholder), so just delete the placeholder and + * return a reference to the package element + */ + + AcpiCmRemoveReference (ResDesc); + } + + else + { + /* + * Each element of the package is an internal object. Get the one + * we are after. + */ + + TmpDesc = ObjDesc->Package.Elements[IdxDesc->Number.Value]; + RetDesc->Reference.OpCode = AML_INDEX_OP; + RetDesc->Reference.TargetType = TmpDesc->Common.Type; + RetDesc->Reference.Object = TmpDesc; + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + RetDesc->Reference.Object = NULL; + } + + /* + * The local return object must always be a reference to the package element, + * not the element itself. + */ + RetDesc->Reference.OpCode = AML_INDEX_OP; + RetDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + RetDesc->Reference.Where = &ObjDesc->Package.Elements[IdxDesc->Number.Value]; + } + + else + { + /* Object to be indexed is a Buffer */ + + if (IdxDesc->Number.Value >= ObjDesc->Buffer.Length) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecIndex: Index value out of range\n")); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + RetDesc->Reference.OpCode = AML_INDEX_OP; + RetDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + RetDesc->Reference.Object = ObjDesc; + RetDesc->Reference.Offset = (UINT32) IdxDesc->Number.Value; + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + } + + +Cleanup: + + /* Always delete operands */ + + AcpiCmRemoveReference (ObjDesc); + AcpiCmRemoveReference (IdxDesc); + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); + + if (RetDesc) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + } + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMatch + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Execute Match operator + * + * ACPI SPECIFICATION REFERENCES: + * DefMatch := MatchOp SearchPkg Opcode1 Operand1 + * Opcode2 Operand2 StartIndex + * Opcode1 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT + * Opcode2 := ByteData: MTR, MEQ, MLE, MLT, MGE, or MGT + * Operand1 := TermArg=>Integer + * Operand2 := TermArg=>Integer + * SearchPkg := TermArg=>PackageObject + * StartIndex := TermArg=>Integer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMatch ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *PkgDesc; + ACPI_OPERAND_OBJECT *Op1Desc; + ACPI_OPERAND_OBJECT *V1Desc; + ACPI_OPERAND_OBJECT *Op2Desc; + ACPI_OPERAND_OBJECT *V2Desc; + ACPI_OPERAND_OBJECT *StartDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS Status; + UINT32 Index; + UINT32 MatchValue = (UINT32) -1; + + + FUNCTION_TRACE ("AmlExecMatch"); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (AML_MATCH_OP, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (AML_MATCH_OP), + 6, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&StartDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&V2Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&Op2Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&V1Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&Op1Desc, WalkState); + Status |= AcpiDsObjStackPopObject (&PkgDesc, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* Invalid parameters on object stack */ + + DEBUG_PRINT (ACPI_ERROR, + ("ExecMatch/AML_MATCH_OP: bad operand(s) (0x%X)\n", + Status)); + + goto Cleanup; + } + + /* Validate match comparison sub-opcodes */ + + if ((Op1Desc->Number.Value > MAX_MATCH_OPERATOR) || + (Op2Desc->Number.Value > MAX_MATCH_OPERATOR)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMatch: operation encoding out of range\n")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + Index = (UINT32) StartDesc->Number.Value; + if (Index >= (UINT32) PkgDesc->Package.Count) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMatch: start position value out of range\n")); + Status = AE_AML_PACKAGE_LIMIT; + goto Cleanup; + } + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + + } + + /* + * Examine each element until a match is found. Within the loop, + * "continue" signifies that the current element does not match + * and the next should be examined. + * Upon finding a match, the loop will terminate via "break" at + * the bottom. If it terminates "normally", MatchValue will be -1 + * (its initial value) indicating that no match was found. When + * returned as a Number, this will produce the Ones value as specified. + */ + + for ( ; Index < PkgDesc->Package.Count; ++Index) + { + /* + * Treat any NULL or non-numeric elements as non-matching. + * TBD [Unhandled] - if an element is a Name, + * should we examine its value? + */ + if (!PkgDesc->Package.Elements[Index] || + ACPI_TYPE_NUMBER != PkgDesc->Package.Elements[Index]->Common.Type) + { + continue; + } + + /* + * Within these switch statements: + * "break" (exit from the switch) signifies a match; + * "continue" (proceed to next iteration of enclosing + * "for" loop) signifies a non-match. + */ + switch (Op1Desc->Number.Value) + { + + case MATCH_MTR: /* always true */ + + break; + + + case MATCH_MEQ: /* true if equal */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + != V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLE: /* true if less than or equal */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + > V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLT: /* true if less than */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + >= V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGE: /* true if greater than or equal */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + < V1Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGT: /* true if greater than */ + + if (PkgDesc->Package.Elements[Index]->Number.Value + <= V1Desc->Number.Value) + { + continue; + } + break; + + + default: /* undefined */ + + continue; + } + + + switch(Op2Desc->Number.Value) + { + + case MATCH_MTR: + + break; + + + case MATCH_MEQ: + + if (PkgDesc->Package.Elements[Index]->Number.Value + != V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLE: + + if (PkgDesc->Package.Elements[Index]->Number.Value + > V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MLT: + + if (PkgDesc->Package.Elements[Index]->Number.Value + >= V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGE: + + if (PkgDesc->Package.Elements[Index]->Number.Value + < V2Desc->Number.Value) + { + continue; + } + break; + + + case MATCH_MGT: + + if (PkgDesc->Package.Elements[Index]->Number.Value + <= V2Desc->Number.Value) + { + continue; + } + break; + + + default: + + continue; + } + + /* Match found: exit from loop */ + + MatchValue = Index; + break; + } + + /* MatchValue is the return value */ + + RetDesc->Number.Value = MatchValue; + + +Cleanup: + + /* Free the operands */ + + AcpiCmRemoveReference (StartDesc); + AcpiCmRemoveReference (V2Desc); + AcpiCmRemoveReference (Op2Desc); + AcpiCmRemoveReference (V1Desc); + AcpiCmRemoveReference (Op1Desc); + AcpiCmRemoveReference (PkgDesc); + + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/exmonad.c b/sys/contrib/dev/acpica/exmonad.c new file mode 100644 index 0000000..dbba804 --- /dev/null +++ b/sys/contrib/dev/acpica/exmonad.c @@ -0,0 +1,1183 @@ + +/****************************************************************************** + * + * Module Name: ammonad - ACPI AML (p-code) execution for monadic operators + * $Revision: 81 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMMONAD_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("ammonad") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlGetObjectReference + * + * PARAMETERS: ObjDesc - Create a reference to this object + * RetDesc - Where to store the reference + * + * RETURN: Status + * + * DESCRIPTION: Obtain and return a "reference" to the target object + * Common code for the RefOfOp and the CondRefOfOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AmlGetObjectReference", ObjDesc); + + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) + { + if (ObjDesc->Common.Type != INTERNAL_TYPE_REFERENCE) + { + *RetDesc = NULL; + Status = AE_TYPE; + goto Cleanup; + } + + /* + * Not a Name -- an indirect name pointer would have + * been converted to a direct name pointer in AcpiAmlResolveOperands + */ + switch (ObjDesc->Reference.OpCode) + { + case AML_LOCAL_OP: + + *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_LOCAL, + (ObjDesc->Reference.Offset), WalkState); + break; + + + case AML_ARG_OP: + + *RetDesc = (void *) AcpiDsMethodDataGetNte (MTH_TYPE_ARG, + (ObjDesc->Reference.Offset), WalkState); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetObjectReference: (Internal) Unknown Ref subtype %02x\n", + ObjDesc->Reference.OpCode)); + *RetDesc = NULL; + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Must be a named object; Just return the Node */ + + *RetDesc = ObjDesc; + } + + else + { + *RetDesc = NULL; + Status = AE_TYPE; + } + + +Cleanup: + + DEBUG_PRINT (TRACE_EXEC, + ("AmlGetObjectReference: Obj=%p Ref=%p\n", ObjDesc, *RetDesc)); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMonadic1 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on + * object stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMonadic1 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("AmlExecMonadic1", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (Opcode), + 1, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic1/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Examine the opcode */ + + switch (Opcode) + { + + /* DefRelease := ReleaseOp MutexObject */ + + case AML_RELEASE_OP: + + Status = AcpiAmlSystemReleaseMutex (ObjDesc); + break; + + + /* DefReset := ResetOp AcpiEventObject */ + + case AML_RESET_OP: + + Status = AcpiAmlSystemResetEvent (ObjDesc); + break; + + + /* DefSignal := SignalOp AcpiEventObject */ + + case AML_SIGNAL_OP: + + Status = AcpiAmlSystemSignalEvent (ObjDesc); + break; + + + /* DefSleep := SleepOp MsecTime */ + + case AML_SLEEP_OP: + + AcpiAmlSystemDoSuspend ((UINT32) ObjDesc->Number.Value); + break; + + + /* DefStall := StallOp UsecTime */ + + case AML_STALL_OP: + + AcpiAmlSystemDoStall ((UINT32) ObjDesc->Number.Value); + break; + + + /* Unknown opcode */ + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic1: Unknown monadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + + } /* switch */ + + +Cleanup: + + /* Always delete the operand */ + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMonadic2R + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 monadic operator with numeric operand and + * result operand on operand stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMonadic2R ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *ResDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_OPERAND_OBJECT *RetDesc2 = NULL; + UINT32 ResVal; + ACPI_STATUS Status; + UINT32 d0; + UINT32 d1; + UINT32 d2; + UINT32 d3; + + + FUNCTION_TRACE_PTR ("AmlExecMonadic2R", WALK_OPERANDS); + + + /* Resolve all operands */ + + Status = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (Opcode), + 2, "after AcpiAmlResolveOperands"); + + /* Get all operands */ + + Status |= AcpiDsObjStackPopObject (&ResDesc, WalkState); + Status |= AcpiDsObjStackPopObject (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2R/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + + /* Create a return object of type NUMBER for most opcodes */ + + switch (Opcode) + { + case AML_BIT_NOT_OP: + case AML_FIND_SET_LEFT_BIT_OP: + case AML_FIND_SET_RIGHT_BIT_OP: + case AML_FROM_BCD_OP: + case AML_TO_BCD_OP: + case AML_COND_REF_OF_OP: + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + break; + } + + + switch (Opcode) + { + /* DefNot := NotOp Operand Result */ + + case AML_BIT_NOT_OP: + + RetDesc->Number.Value = ~ObjDesc->Number.Value; + break; + + + /* DefFindSetLeftBit := FindSetLeftBitOp Operand Result */ + + case AML_FIND_SET_LEFT_BIT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value; + + /* + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundry condition is valid. + */ + for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) + { + RetDesc->Number.Value >>= 1; + } + + RetDesc->Number.Value = ResVal; + break; + + + /* DefFindSetRightBit := FindSetRightBitOp Operand Result */ + + case AML_FIND_SET_RIGHT_BIT_OP: + + RetDesc->Number.Value = ObjDesc->Number.Value; + + /* + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundry condition is valid. + */ + for (ResVal = 0; RetDesc->Number.Value && ResVal < ACPI_INTEGER_BIT_SIZE; ++ResVal) + { + RetDesc->Number.Value <<= 1; + } + + /* Since returns must be 1-based, subtract from 33 (65) */ + + RetDesc->Number.Value = ResVal == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - ResVal; + break; + + + /* DefFromBDC := FromBCDOp BCDValue Result */ + + case AML_FROM_BCD_OP: + + d0 = (UINT32) (ObjDesc->Number.Value & 15); + d1 = (UINT32) (ObjDesc->Number.Value >> 4 & 15); + d2 = (UINT32) (ObjDesc->Number.Value >> 8 & 15); + d3 = (UINT32) (ObjDesc->Number.Value >> 12 & 15); + + if (d0 > 9 || d1 > 9 || d2 > 9 || d3 > 9) + { + DEBUG_PRINT (ACPI_ERROR, + ("Monadic2R/FromBCDOp: BCD digit too large %d %d %d %d\n", + d3, d2, d1, d0)); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + RetDesc->Number.Value = d0 + d1 * 10 + d2 * 100 + d3 * 1000; + break; + + + /* DefToBDC := ToBCDOp Operand Result */ + + case AML_TO_BCD_OP: + + + if (ObjDesc->Number.Value > 9999) + { + DEBUG_PRINT (ACPI_ERROR, ("Monadic2R/ToBCDOp: BCD overflow: %d\n", + ObjDesc->Number.Value)); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + RetDesc->Number.Value + = ObjDesc->Number.Value % 10 + + (ObjDesc->Number.Value / 10 % 10 << 4) + + (ObjDesc->Number.Value / 100 % 10 << 8) + + (ObjDesc->Number.Value / 1000 % 10 << 12); + + break; + + + /* DefCondRefOf := CondRefOfOp SourceObject Result */ + + case AML_COND_REF_OF_OP: + + /* + * This op is a little strange because the internal return value is + * different than the return value stored in the result descriptor + * (There are really two return values) + */ + + if ((ACPI_NAMESPACE_NODE *) ObjDesc == AcpiGbl_RootNode) + { + /* + * This means that the object does not exist in the namespace, + * return FALSE + */ + + RetDesc->Number.Value = 0; + + /* + * Must delete the result descriptor since there is no reference + * being returned + */ + + AcpiCmRemoveReference (ResDesc); + goto Cleanup; + } + + /* Get the object reference and store it */ + + Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc2, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiAmlExecStore (RetDesc2, ResDesc, WalkState); + + /* The object exists in the namespace, return TRUE */ + + RetDesc->Number.Value = ACPI_INTEGER_MAX + goto Cleanup; + break; + + + case AML_STORE_OP: + + /* + * A store operand is typically a number, string, buffer or lvalue + * TBD: [Unhandled] What about a store to a package? + */ + + /* + * Do the store, and be careful about deleting the source object, + * since the object itself may have been stored. + */ + + Status = AcpiAmlExecStore (ObjDesc, ResDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* On failure, just delete the ObjDesc */ + + AcpiCmRemoveReference (ObjDesc); + } + + else + { + /* + * Normally, we would remove a reference on the ObjDesc parameter; + * But since it is being used as the internal return object + * (meaning we would normally increment it), the two cancel out, + * and we simply don't do anything. + */ + *ReturnDesc = ObjDesc; + } + + ObjDesc = NULL; + return_ACPI_STATUS (Status); + + break; + + + case AML_DEBUG_OP: + + /* Reference, returning an Reference */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2R: DebugOp should never get here!\n")); + return_ACPI_STATUS (AE_OK); + break; + + + /* + * These are obsolete opcodes + */ + + /* DefShiftLeftBit := ShiftLeftBitOp Source BitNum */ + /* DefShiftRightBit := ShiftRightBitOp Source BitNum */ + + case AML_SHIFT_LEFT_BIT_OP: + case AML_SHIFT_RIGHT_BIT_OP: + + DEBUG_PRINT (ACPI_ERROR, ("AmlExecMonadic2R: %s unimplemented\n", + AcpiPsGetOpcodeName (Opcode))); + Status = AE_SUPPORT; + goto Cleanup; + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic2R: Unknown monadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + + Status = AcpiAmlExecStore (RetDesc, ResDesc, WalkState); + + +Cleanup: + /* Always delete the operand object */ + + AcpiCmRemoveReference (ObjDesc); + + /* Delete return object(s) on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ResDesc); /* Result descriptor */ + if (RetDesc) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + } + + /* Set the return object and exit */ + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecMonadic2 + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 2 monadic operator with numeric operand: + * DerefOfOp, RefOfOp, SizeOfOp, TypeOp, IncrementOp, + * DecrementOp, LNotOp, + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecMonadic2 ( + UINT16 Opcode, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *TmpDesc; + ACPI_OPERAND_OBJECT *RetDesc = NULL; + ACPI_STATUS ResolveStatus; + ACPI_STATUS Status; + UINT32 Type; + ACPI_INTEGER Value; + + + FUNCTION_TRACE_PTR ("AmlExecMonadic2", WALK_OPERANDS); + + + /* Attempt to resolve the operands */ + + ResolveStatus = AcpiAmlResolveOperands (Opcode, WALK_OPERANDS, WalkState); + DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, + AcpiPsGetOpcodeName (Opcode), + 1, "after AcpiAmlResolveOperands"); + + /* Always get all operands */ + + Status = AcpiDsObjStackPopObject (&ObjDesc, WalkState); + + + /* Now we can check the status codes */ + + if (ACPI_FAILURE (ResolveStatus)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2[%s]: Could not resolve operands, %s\n", + AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (ResolveStatus))); + + goto Cleanup; + } + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2[%s]: Bad operand(s), %s\n", + AcpiPsGetOpcodeName (Opcode), AcpiCmFormatException (Status))); + + goto Cleanup; + } + + + /* Get the operand and decode the opcode */ + + + switch (Opcode) + { + + /* DefLNot := LNotOp Operand */ + + case AML_LNOT_OP: + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Number.Value = !ObjDesc->Number.Value; + break; + + + /* DefDecrement := DecrementOp Target */ + /* DefIncrement := IncrementOp Target */ + + case AML_DECREMENT_OP: + case AML_INCREMENT_OP: + + /* + * Since we are expecting an Reference on the top of the stack, it + * can be either an Node or an internal object. + * + * TBD: [Future] This may be the prototype code for all cases where + * an Reference is expected!! 10/99 + */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + RetDesc = ObjDesc; + } + + else + { + /* + * Duplicate the Reference in a new object so that we can resolve it + * without destroying the original Reference object + */ + + RetDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Reference.OpCode = ObjDesc->Reference.OpCode; + RetDesc->Reference.Offset = ObjDesc->Reference.Offset; + RetDesc->Reference.Object = ObjDesc->Reference.Object; + } + + + /* + * Convert the RetDesc Reference to a Number + * (This deletes the original RetDesc) + */ + + Status = AcpiAmlResolveOperands (AML_LNOT_OP, &RetDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("ExecMonadic2/%s: bad operand(s) (0x%X)\n", + AcpiPsGetOpcodeName (Opcode), Status)); + + goto Cleanup; + } + + /* Do the actual increment or decrement */ + + if (AML_INCREMENT_OP == Opcode) + { + RetDesc->Number.Value++; + } + else + { + RetDesc->Number.Value--; + } + + /* Store the result back in the original descriptor */ + + Status = AcpiAmlExecStore (RetDesc, ObjDesc, WalkState); + + /* Objdesc was just deleted (because it is an Reference) */ + + ObjDesc = NULL; + + break; + + + /* DefObjectType := ObjectTypeOp SourceObject */ + + case AML_TYPE_OP: + + if (INTERNAL_TYPE_REFERENCE == ObjDesc->Common.Type) + { + /* + * Not a Name -- an indirect name pointer would have + * been converted to a direct name pointer in ResolveOperands + */ + switch (ObjDesc->Reference.OpCode) + { + case AML_ZERO_OP: + case AML_ONE_OP: + case AML_ONES_OP: + + /* Constants are of type Number */ + + Type = ACPI_TYPE_NUMBER; + break; + + + case AML_DEBUG_OP: + + /* Per 1.0b spec, Debug object is of type DebugObject */ + + Type = ACPI_TYPE_DEBUG_OBJECT; + break; + + + case AML_INDEX_OP: + + /* Get the type of this reference (index into another object) */ + + Type = ObjDesc->Reference.TargetType; + if (Type == ACPI_TYPE_PACKAGE) + { + /* + * The main object is a package, we want to get the type + * of the individual package element that is referenced by + * the index. + */ + Type = (*(ObjDesc->Reference.Where))->Common.Type; + } + + break; + + + case AML_LOCAL_OP: + + Type = AcpiDsMethodDataGetType (MTH_TYPE_LOCAL, + (ObjDesc->Reference.Offset), WalkState); + break; + + + case AML_ARG_OP: + + Type = AcpiDsMethodDataGetType (MTH_TYPE_ARG, + (ObjDesc->Reference.Offset), WalkState); + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic2/TypeOp: Internal error - Unknown Reference subtype %X\n", + ObjDesc->Reference.OpCode)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + } + + else + { + /* + * It's not a Reference, so it must be a direct name pointer. + */ + Type = AcpiNsGetType ((ACPI_HANDLE) ObjDesc); + } + + /* Allocate a descriptor to hold the type. */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Number.Value = Type; + break; + + + /* DefSizeOf := SizeOfOp SourceObject */ + + case AML_SIZE_OF_OP: + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + ObjDesc = AcpiNsGetAttachedObject (ObjDesc); + } + + if (!ObjDesc) + { + Value = 0; + } + + else + { + switch (ObjDesc->Common.Type) + { + + case ACPI_TYPE_BUFFER: + + Value = ObjDesc->Buffer.Length; + break; + + + case ACPI_TYPE_STRING: + + Value = ObjDesc->String.Length; + break; + + + case ACPI_TYPE_PACKAGE: + + Value = ObjDesc->Package.Count; + break; + + case INTERNAL_TYPE_REFERENCE: + + Value = 4; + break; + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: Not Buf/Str/Pkg - found type 0x%X\n", + ObjDesc->Common.Type)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + + /* + * Now that we have the size of the object, create a result + * object to hold the value + */ + + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + RetDesc->Number.Value = Value; + break; + + + /* DefRefOf := RefOfOp SourceObject */ + + case AML_REF_OF_OP: + + Status = AcpiAmlGetObjectReference (ObjDesc, &RetDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + /* DefDerefOf := DerefOfOp ObjReference */ + + case AML_DEREF_OF_OP: + + + /* Check for a method local or argument */ + + if (!VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* + * Must resolve/dereference the local/arg reference first + */ + switch (ObjDesc->Reference.OpCode) + { + /* Set ObjDesc to the value of the local/arg */ + + case AML_LOCAL_OP: + + AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL, + (ObjDesc->Reference.Offset), WalkState, &TmpDesc); + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiCmRemoveReference (ObjDesc); + ObjDesc = TmpDesc; + break; + + + case AML_ARG_OP: + + AcpiDsMethodDataGetValue (MTH_TYPE_ARG, + (ObjDesc->Reference.Offset), WalkState, &TmpDesc); + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiCmRemoveReference (ObjDesc); + ObjDesc = TmpDesc; + break; + + default: + + /* Index op - handled below */ + break; + } + } + + + /* ObjDesc may have changed from the code above */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Get the actual object from the Node (This is the dereference) */ + + RetDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object; + + /* Returning a pointer to the object, add another reference! */ + + AcpiCmAddReference (RetDesc); + } + + else + { + /* + * This must be a reference object produced by the Index + * ASL operation -- check internal opcode + */ + + if ((ObjDesc->Reference.OpCode != AML_INDEX_OP) && + (ObjDesc->Reference.OpCode != AML_REF_OF_OP)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: DerefOf, invalid obj ref %p\n", + ObjDesc)); + + Status = AE_TYPE; + goto Cleanup; + } + + + switch (ObjDesc->Reference.OpCode) + { + case AML_INDEX_OP: + + /* + * Supported target types for the Index operator are + * 1) A Buffer + * 2) A Package + */ + + if (ObjDesc->Reference.TargetType == ACPI_TYPE_BUFFER_FIELD) + { + /* + * The target is a buffer, we must create a new object that + * contains one element of the buffer, the element pointed + * to by the index. + * + * NOTE: index into a buffer is NOT a pointer to a + * sub-buffer of the main buffer, it is only a pointer to a + * single element (byte) of the buffer! + */ + RetDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!RetDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + TmpDesc = ObjDesc->Reference.Object; + RetDesc->Number.Value = + TmpDesc->Buffer.Pointer[ObjDesc->Reference.Offset]; + + /* TBD: [Investigate] (see below) Don't add an additional + * ref! + */ + } + + else if (ObjDesc->Reference.TargetType == ACPI_TYPE_PACKAGE) + { + /* + * The target is a package, we want to return the referenced + * element of the package. We must add another reference to + * this object, however. + */ + + RetDesc = *(ObjDesc->Reference.Where); + if (!RetDesc) + { + /* + * We can't return a NULL dereferenced value. This is + * an uninitialized package element and is thus a + * severe error. + */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: DerefOf, NULL package element obj %p\n", + ObjDesc)); + Status = AE_AML_UNINITIALIZED_ELEMENT; + goto Cleanup; + } + + AcpiCmAddReference (RetDesc); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecMonadic2: DerefOf, Unknown TargetType %X in obj %p\n", + ObjDesc->Reference.TargetType, ObjDesc)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + break; + + + case AML_REF_OF_OP: + + RetDesc = ObjDesc->Reference.Object; + + /* Add another reference to the object! */ + + AcpiCmAddReference (RetDesc); + break; + } + } + + break; + + + default: + + REPORT_ERROR (("AcpiAmlExecMonadic2: Unknown monadic opcode %X\n", + Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + if (ObjDesc) + { + AcpiCmRemoveReference (ObjDesc); + } + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) && + (RetDesc)) + { + AcpiCmRemoveReference (RetDesc); + RetDesc = NULL; + } + + *ReturnDesc = RetDesc; + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/exnames.c b/sys/contrib/dev/acpica/exnames.c new file mode 100644 index 0000000..60de051 --- /dev/null +++ b/sys/contrib/dev/acpica/exnames.c @@ -0,0 +1,551 @@ + +/****************************************************************************** + * + * Module Name: amnames - interpreter/scanner name load/execute + * $Revision: 71 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMNAMES_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amnames") + + +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlAllocateNameString + * + * PARAMETERS: PrefixCount - Count of parent levels. Special cases: + * (-1) = root, 0 = none + * NumNameSegs - count of 4-character name segments + * + * RETURN: A pointer to the allocated string segment. This segment must + * be deleted by the caller. + * + * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name + * string is long enough, and set up prefix if any. + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiAmlAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs) +{ + NATIVE_CHAR *TempPtr; + NATIVE_CHAR *NameString; + UINT32 SizeNeeded; + + FUNCTION_TRACE ("AmlAllocateNameString"); + + + /* + * 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 == (UINT32) -1) + { + /* 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 = AcpiCmAllocate (SizeNeeded); + if (!NameString) + { + REPORT_ERROR (("AmlAllocateNameString: name allocation failure\n")); + return_PTR (NULL); + } + + TempPtr = NameString; + + /* Set up Root or Parent prefixes if needed */ + + if (PrefixCount == (UINT32) -1) + { + *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. AcpiAmlExecNameSegment() will + * append the segment(s) + */ + + *TempPtr = 0; + + return_PTR (NameString); +} + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecNameSegment + * + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) + * + * RETURN: Status + * + * DESCRIPTION: Execute a name segment (4 bytes) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecNameSegment ( + UINT8 **InAmlAddress, + NATIVE_CHAR *NameString) +{ + UINT8 *AmlAddress = *InAmlAddress; + ACPI_STATUS Status = AE_OK; + UINT32 Index; + NATIVE_CHAR CharBuf[5]; + + + FUNCTION_TRACE ("AmlExecNameSegment"); + + + /* + * 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') + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecNameSegment: leading digit: %c\n", CharBuf[0])); + return_ACPI_STATUS (AE_CTRL_PENDING); + } + + DEBUG_PRINT (TRACE_LOAD, ("AmlExecNameSegment: Bytes from stream:\n")); + + for (Index = 4; + (Index > 0) && (AcpiCmValidAcpiCharacter (*AmlAddress)); + --Index) + { + CharBuf[4 - Index] = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("%c\n", CharBuf[4 - Index])); + } + + + /* Valid name segment */ + + if (0 == Index) + { + /* Found 4 valid characters */ + + CharBuf[4] = '\0'; + + if (NameString) + { + STRCAT (NameString, CharBuf); + DEBUG_PRINT (TRACE_NAMES, + ("AmlExecNameSegment: Appended to - %s \n", NameString)); + } + + else + { + DEBUG_PRINT (TRACE_NAMES, + ("AmlExecNameSegment: No Name string - %s \n", CharBuf)); + } + } + + else if (4 == Index) + { + /* + * First character was not a valid name character, + * so we are looking at something other than a name. + */ + DEBUG_PRINT (ACPI_INFO, + ("AmlExecNameSegment: Leading INT8 not alpha: %02Xh (not a name)\n", + CharBuf[0])); + Status = AE_CTRL_PENDING; + } + + else + { + /* Segment started with one or more valid characters, but fewer than 4 */ + + Status = AE_AML_BAD_NAME; + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecNameSegment: Bad INT8 %02x in name, at %p\n", + *AmlAddress, AmlAddress)); + } + + DEBUG_PRINT (TRACE_EXEC, ("Leave AcpiAmlExecNameSegment %s \n", + AcpiCmFormatException (Status))); + + *InAmlAddress = AmlAddress; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlGetNameString + * + * PARAMETERS: DataType - Data type to be associated with this name + * + * RETURN: Status + * + * DESCRIPTION: Get a name, including any prefixes. + * + ******************************************************************************/ + + +ACPI_STATUS +AcpiAmlGetNameString ( + OBJECT_TYPE_INTERNAL DataType, + UINT8 *InAmlAddress, + NATIVE_CHAR **OutNameString, + UINT32 *OutNameLength) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *AmlAddress = InAmlAddress; + NATIVE_CHAR *NameString = NULL; + UINT32 NumSegments; + UINT32 PrefixCount = 0; + UINT8 Prefix = 0; + BOOLEAN HasPrefix = FALSE; + + + FUNCTION_TRACE_PTR ("AmlGetNameString", AmlAddress); + + + if (INTERNAL_TYPE_DEF_FIELD == DataType || + INTERNAL_TYPE_BANK_FIELD == DataType || + INTERNAL_TYPE_INDEX_FIELD == DataType) + { + /* Disallow prefixes for types associated with field names */ + + NameString = AcpiAmlAllocateNameString (0, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + } + else + { + Status = AcpiAmlExecNameSegment (&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: + + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("RootPrefix: %x\n", Prefix)); + + /* + * Remember that we have a RootPrefix -- + * see comment in AcpiAmlAllocateNameString() + */ + PrefixCount = (UINT32) -1; + HasPrefix = TRUE; + break; + + + case AML_PARENT_PREFIX: + + /* Increment past possibly multiple parent prefixes */ + + do + { + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("ParentPrefix: %x\n", Prefix)); + + ++PrefixCount; + + } while (*AmlAddress == AML_PARENT_PREFIX); + HasPrefix = TRUE; + break; + + + default: + + break; + } + + + /* Examine first character of name for name segment prefix operator */ + + switch (*AmlAddress) + { + + case AML_DUAL_NAME_PREFIX: + + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("DualNamePrefix: %x\n", Prefix)); + + NameString = AcpiAmlAllocateNameString (PrefixCount, 2); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + HasPrefix = TRUE; + + Status = AcpiAmlExecNameSegment (&AmlAddress, NameString); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiAmlExecNameSegment (&AmlAddress, NameString); + } + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + Prefix = *AmlAddress++; + DEBUG_PRINT (TRACE_LOAD, ("MultiNamePrefix: %x\n", Prefix)); + + /* Fetch count of segments remaining in name path */ + + NumSegments = *AmlAddress++; + + NameString = AcpiAmlAllocateNameString (PrefixCount, NumSegments); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + HasPrefix = TRUE; + + while (NumSegments && + (Status = AcpiAmlExecNameSegment (&AmlAddress, NameString)) == AE_OK) + { + --NumSegments; + } + + break; + + + case 0: + + /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ + + if (-1 == PrefixCount) + { + DEBUG_PRINT (TRACE_EXEC, + ("AmlDoName: NameSeg is \"\\\" followed by NULL\n")); + } + + /* Consume the NULL byte */ + + AmlAddress++; + NameString = AcpiAmlAllocateNameString (PrefixCount, 0); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + break; + + + default: + + /* Name segment string */ + + NameString = AcpiAmlAllocateNameString (PrefixCount, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + Status = AcpiAmlExecNameSegment (&AmlAddress, NameString); + break; + + } /* Switch (PeekOp ()) */ + } + + + if (AE_CTRL_PENDING == Status && HasPrefix) + { + /* Ran out of segments after processing a prefix */ + + REPORT_ERROR ( + ("AmlDoName: Malformed Name at %p\n", NameString)); + Status = AE_AML_BAD_NAME; + } + + + *OutNameString = NameString; + *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exprep.c b/sys/contrib/dev/acpica/exprep.c new file mode 100644 index 0000000..5771610 --- /dev/null +++ b/sys/contrib/dev/acpica/exprep.c @@ -0,0 +1,580 @@ + +/****************************************************************************** + * + * Module Name: amprep - ACPI AML (p-code) execution - field prep utilities + * $Revision: 67 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMPREP_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acparser.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amprep") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlDecodeFieldAccessType + * + * PARAMETERS: Access - Encoded field access bits + * + * RETURN: Field granularity (8, 16, or 32) + * + * DESCRIPTION: Decode the AccessType bits of a field definition. + * + ******************************************************************************/ + +UINT32 +AcpiAmlDecodeFieldAccessType ( + UINT32 Access) +{ + + switch (Access) + { + case ACCESS_ANY_ACC: + return (8); + break; + + case ACCESS_BYTE_ACC: + return (8); + break; + + case ACCESS_WORD_ACC: + return (16); + break; + + case ACCESS_DWORD_ACC: + return (32); + break; + + default: + /* Invalid field access type */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlDecodeFieldAccessType: Unknown field access type %x\n", + Access)); + return (0); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepCommonFieldObjec + * + * PARAMETERS: ObjDesc - The field object + * FieldFlags - Access, LockRule, or UpdateRule. + * The format of a FieldFlag is described + * in the ACPI specification + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Initialize the areas of the field object that are common + * to the various types of fields. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + UINT32 Granularity; + + + FUNCTION_TRACE ("AmlPrepCommonFieldObject"); + + + /* + * Note: the structure being initialized is the + * ACPI_COMMON_FIELD_INFO; Therefore, we can just use the Field union to + * access this common area. No structure fields outside of the common area + * are initialized by this procedure. + */ + + /* Decode the FieldFlags */ + + ObjDesc->Field.Access = (UINT8) ((FieldFlags & ACCESS_TYPE_MASK) + >> ACCESS_TYPE_SHIFT); + ObjDesc->Field.LockRule = (UINT8) ((FieldFlags & LOCK_RULE_MASK) + >> LOCK_RULE_SHIFT); + ObjDesc->Field.UpdateRule = (UINT8) ((FieldFlags & UPDATE_RULE_MASK) + >> UPDATE_RULE_SHIFT); + + /* Other misc fields */ + + ObjDesc->Field.Length = (UINT16) FieldLength; + ObjDesc->Field.AccessAttribute = FieldAttribute; + + /* Decode the access type so we can compute offsets */ + + Granularity = AcpiAmlDecodeFieldAccessType (ObjDesc->Field.Access); + if (!Granularity) + { + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + /* Access granularity based fields */ + + ObjDesc->Field.Granularity = (UINT8) Granularity; + ObjDesc->Field.BitOffset = (UINT8) (FieldPosition % Granularity); + ObjDesc->Field.Offset = (UINT32) FieldPosition / Granularity; + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepDefFieldValue + * + * PARAMETERS: Node - Owning Node + * Region - Region in which field is being defined + * FieldFlags - Access, LockRule, or UpdateRule. + * The format of a FieldFlag is described + * in the ACPI specification + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepDefFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Type; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlPrepDefFieldValue"); + + + /* Parameter validation */ + + if (!Region) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlPrepDefFieldValue: null Region\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + Type = AcpiNsGetType (Region); + if (Type != ACPI_TYPE_REGION) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlPrepDefFieldValue: Needed Region, found %d %s\n", + Type, AcpiCmGetTypeName (Type))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Allocate a new object */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_DEF_FIELD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + /* ObjDesc and Region valid */ + + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE, + "AmlPrepDefFieldValue", 1, "case DefField"); + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE, + "AmlPrepDefFieldValue", 1, "case DefField"); + + /* Initialize areas of the object that are common to all fields */ + + Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, + FieldPosition, FieldLength); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to this field type */ + + ObjDesc->Field.Container = AcpiNsGetAttachedObject (Region); + + /* An additional reference for the container */ + + AcpiCmAddReference (ObjDesc->Field.Container); + + + /* Debug info */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepDefFieldValue: bitoff=%X off=%X gran=%X\n", + ObjDesc->Field.BitOffset, ObjDesc->Field.Offset, + ObjDesc->Field.Granularity)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepDefFieldValue: set NamedObj %p (%4.4s) val = %p\n", + Node, &(Node->Name), ObjDesc)); + + DUMP_STACK_ENTRY (ObjDesc); + DUMP_ENTRY (Region, ACPI_INFO); + DEBUG_PRINT (ACPI_INFO, ("\t%p \n", ObjDesc->Field.Container)); + if (ObjDesc->Field.Container) + { + DUMP_STACK_ENTRY (ObjDesc->Field.Container); + } + DEBUG_PRINT (ACPI_INFO, + ("============================================================\n")); + + /* + * Store the constructed descriptor (ObjDesc) into the NamedObj whose + * handle is on TOS, preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepBankFieldValue + * + * PARAMETERS: Node - Owning Node + * Region - Region in which field is being defined + * BankReg - Bank selection register + * BankVal - Value to store in selection register + * FieldFlags - Access, LockRule, or UpdateRule + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type BankField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepBankFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE Region, + ACPI_HANDLE BankReg, + UINT32 BankVal, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Type; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlPrepBankFieldValue"); + + + /* Parameter validation */ + + if (!Region) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlPrepBankFieldValue: null Region\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + Type = AcpiNsGetType (Region); + if (Type != ACPI_TYPE_REGION) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlPrepBankFieldValue: Needed Region, found %d %s\n", + Type, AcpiCmGetTypeName (Type))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Allocate a new object */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_BANK_FIELD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* ObjDesc and Region valid */ + + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Node, IMODE_EXECUTE, + "AmlPrepBankFieldValue", 1, "case BankField"); + DUMP_OPERANDS ((ACPI_OPERAND_OBJECT **) &Region, IMODE_EXECUTE, + "AmlPrepBankFieldValue", 1, "case BankField"); + + /* Initialize areas of the object that are common to all fields */ + + Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, + FieldPosition, FieldLength); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to this field type */ + + ObjDesc->BankField.Value = BankVal; + ObjDesc->BankField.Container = AcpiNsGetAttachedObject (Region); + ObjDesc->BankField.BankSelect = AcpiNsGetAttachedObject (BankReg); + + /* An additional reference for the container and bank select */ + /* TBD: [Restructure] is "BankSelect" ever a real internal object?? */ + + AcpiCmAddReference (ObjDesc->BankField.Container); + AcpiCmAddReference (ObjDesc->BankField.BankSelect); + + /* Debug info */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepBankFieldValue: bitoff=%X off=%X gran=%X\n", + ObjDesc->BankField.BitOffset, ObjDesc->BankField.Offset, + ObjDesc->Field.Granularity)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepBankFieldValue: set NamedObj %p (%4.4s) val = %p\n", + Node, &(Node->Name), ObjDesc)); + + DUMP_STACK_ENTRY (ObjDesc); + DUMP_ENTRY (Region, ACPI_INFO); + DUMP_ENTRY (BankReg, ACPI_INFO); + DEBUG_PRINT (ACPI_INFO, + ("============================================================\n")); + + /* + * Store the constructed descriptor (ObjDesc) into the NamedObj whose + * handle is on TOS, preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPrepIndexFieldValue + * + * PARAMETERS: Node - Owning Node + * IndexReg - Index register + * DataReg - Data register + * FieldFlags - Access, LockRule, or UpdateRule + * FieldPosition - Field position + * FieldLength - Field length + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type IndexField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlPrepIndexFieldValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_HANDLE IndexReg, + ACPI_HANDLE DataReg, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldPosition, + UINT32 FieldLength) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlPrepIndexFieldValue"); + + + /* Parameter validation */ + + if (!IndexReg || !DataReg) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlPrepIndexFieldValue: null handle\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* Allocate a new object descriptor */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_INDEX_FIELD); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize areas of the object that are common to all fields */ + + Status = AcpiAmlPrepCommonFieldObject (ObjDesc, FieldFlags, FieldAttribute, + FieldPosition, FieldLength); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to this field type */ + + ObjDesc->IndexField.Value = (UINT32) (FieldPosition / + ObjDesc->Field.Granularity); + ObjDesc->IndexField.Index = IndexReg; + ObjDesc->IndexField.Data = DataReg; + + /* Debug info */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepIndexFieldValue: bitoff=%X off=%X gran=%X\n", + ObjDesc->IndexField.BitOffset, ObjDesc->IndexField.Offset, + ObjDesc->Field.Granularity)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlPrepIndexFieldValue: set NamedObj %p (%4.4s) val = %p\n", + Node, &(Node->Name), ObjDesc)); + + DUMP_STACK_ENTRY (ObjDesc); + DUMP_ENTRY (IndexReg, ACPI_INFO); + DUMP_ENTRY (DataReg, ACPI_INFO); + DEBUG_PRINT (ACPI_INFO, + ("============================================================\n")); + + /* + * Store the constructed descriptor (ObjDesc) into the NamedObj whose + * handle is on TOS, preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject ((ACPI_HANDLE) Node, ObjDesc, + (UINT8) AcpiNsGetType ((ACPI_HANDLE) Node)); + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/exregion.c b/sys/contrib/dev/acpica/exregion.c new file mode 100644 index 0000000..181ef59 --- /dev/null +++ b/sys/contrib/dev/acpica/exregion.c @@ -0,0 +1,561 @@ + +/****************************************************************************** + * + * Module Name: amregion - ACPI default OpRegion (address space) handlers + * $Revision: 36 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __AMREGION_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amregion") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemMemorySpaceHandler + * + * 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 +AcpiAmlSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + void *LogicalAddrPtr = NULL; + MEM_HANDLER_CONTEXT *MemInfo = RegionContext; + UINT32 Length; + + + FUNCTION_TRACE ("AmlSystemMemorySpaceHandler"); + + + /* Validate and translate the bit width */ + + switch (BitWidth) + { + case 8: + Length = 1; + break; + + case 16: + Length = 2; + break; + + case 32: + Length = 4; + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlSystemMemorySpaceHandler: Invalid SystemMemory width %d\n", + BitWidth)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + break; + } + + + /* + * 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 < (ACPI_INTEGER) MemInfo->MappedPhysicalAddress) || + ((Address + Length) > + (ACPI_INTEGER) (MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + { + /* + * The request cannot be resolved by the current memory mapping; + * Delete the existing mapping and create a new one. + */ + + if (MemInfo->MappedLength) + { + /* Valid mapping, delete it */ + + AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress, + MemInfo->MappedLength); + } + + MemInfo->MappedLength = 0; /* In case of failure below */ + + /* Create a new mapping starting at the address given */ + + Status = AcpiOsMapMemory ((void *) (UINT32) Address, SYSMEM_REGION_WINDOW_SIZE, + (void **) &MemInfo->MappedLogicalAddress); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* TBD: should these pointers go to 64-bit in all cases ? */ + + MemInfo->MappedPhysicalAddress = (UINT8 *) (UINT32) Address; + MemInfo->MappedLength = SYSMEM_REGION_WINDOW_SIZE; + } + + + /* + * Generate a logical pointer corresponding to the address we want to + * access + */ + + /* TBD: should these pointers go to 64-bit in all cases ? */ + + LogicalAddrPtr = MemInfo->MappedLogicalAddress + + ((UINT8 *) (UINT32) Address - MemInfo->MappedPhysicalAddress); + + /* Perform the memory read or write */ + + switch (Function) + { + + case ADDRESS_SPACE_READ: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Read (%d width) Address:0x%X\n", BitWidth, Address)); + + switch (BitWidth) + { + case 8: + *Value = (UINT32)* (UINT8 *) LogicalAddrPtr; + break; + + case 16: + MOVE_UNALIGNED16_TO_32 (Value, LogicalAddrPtr); + break; + + case 32: + MOVE_UNALIGNED32_TO_32 (Value, LogicalAddrPtr); + break; + } + + break; + + + case ADDRESS_SPACE_WRITE: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Write (%d width) Address:0x%p Value 0x%X\n", + BitWidth, Address, *Value)); + + switch (BitWidth) + { + case 8: + *(UINT8 *) LogicalAddrPtr = (UINT8) *Value; + break; + + case 16: + MOVE_UNALIGNED16_TO_16 (LogicalAddrPtr, Value); + break; + + case 32: + MOVE_UNALIGNED32_TO_32 (LogicalAddrPtr, Value); + break; + } + + break; + + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemIoSpaceHandler + * + * 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 +AcpiAmlSystemIoSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AmlSystemIoSpaceHandler"); + + + /* Decode the function parameter */ + + switch (Function) + { + + case ADDRESS_SPACE_READ: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Read(%d width) Address:0x%08x\n", BitWidth, Address)); + + switch (BitWidth) + { + /* I/O Port width */ + + case 8: + *Value = (UINT32) AcpiOsIn8 ((ACPI_IO_ADDRESS) Address); + break; + + case 16: + *Value = (UINT32) AcpiOsIn16 ((ACPI_IO_ADDRESS) Address); + break; + + case 32: + *Value = AcpiOsIn32 ((ACPI_IO_ADDRESS) Address); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlSystemIoSpaceHandler: Invalid SystemIO width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + } + + break; + + + case ADDRESS_SPACE_WRITE: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("Write(%d width) Address:0x%08x Value 0x%08x\n", + BitWidth, Address, *Value)); + + switch (BitWidth) + { + /* I/O Port width */ + case 8: + AcpiOsOut8 ((ACPI_IO_ADDRESS) Address, (UINT8) *Value); + break; + + case 16: + AcpiOsOut16 ((ACPI_IO_ADDRESS) Address, (UINT16) *Value); + break; + + case 32: + AcpiOsOut32 ((ACPI_IO_ADDRESS) Address, *Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ( + "AmlSystemIoSpaceHandler: Invalid SystemIO width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + } + + break; + + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + +/******************************************************************************* + * + * FUNCTION: AcpiAmlPciConfigSpaceHandler + * + * 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 +AcpiAmlPciConfigSpaceHandler ( + UINT32 Function, + ACPI_INTEGER Address, + UINT32 BitWidth, + UINT32 *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + UINT32 PciBus; + UINT32 DevFunc; + UINT8 PciReg; + PCI_HANDLER_CONTEXT *PCIContext; + + + FUNCTION_TRACE ("AmlPciConfigSpaceHandler"); + + /* + * The arguments to AcpiOs(Read|Write)PciCfg(Byte|Word|Dword) are: + * + * SegBus - 0xSSSSBBBB - SSSS is the PCI bus segment + * BBBB is the PCI bus number + * + * DevFunc - 0xDDDDFFFF - DDDD is the PCI device number + * FFFF is the PCI device function number + * + * RegNum - Config space register must be < 40h + * + * Value - input value for write, output for read + * + */ + + PCIContext = (PCI_HANDLER_CONTEXT *) RegionContext; + + PciBus = LOWORD(PCIContext->Seg) << 16; + PciBus |= LOWORD(PCIContext->Bus); + + DevFunc = PCIContext->DevFunc; + + PciReg = (UINT8) Address; + + switch (Function) + { + + case ADDRESS_SPACE_READ: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("R%d S(%04x) B(%04x) DF(%08x) R(%04x)\n", BitWidth, + PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc, PciReg)); + + *Value = 0; + + switch (BitWidth) + { + /* PCI Register width */ + + case 8: + Status = AcpiOsReadPciCfgByte (PciBus, DevFunc, PciReg, + (UINT8 *) Value); + break; + + case 16: + Status = AcpiOsReadPciCfgWord (PciBus, DevFunc, PciReg, + (UINT16 *) Value); + break; + + case 32: + Status = AcpiOsReadPciCfgDword (PciBus, DevFunc, PciReg, + Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlPciConfigSpaceHandler: Invalid PCIConfig width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + + } /* Switch bitWidth */ + + break; + + + case ADDRESS_SPACE_WRITE: + + DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), + ("W%d S(%04x) B(%04x) DF(%08x) R(%04x) D(%08x)\n", BitWidth, + PCIContext->Seg,PCIContext->Bus,PCIContext->DevFunc, + PciReg,*Value)); + + switch (BitWidth) + { + /* PCI Register width */ + + case 8: + Status = AcpiOsWritePciCfgByte (PciBus, DevFunc, PciReg, + *(UINT8 *) Value); + break; + + case 16: + Status = AcpiOsWritePciCfgWord (PciBus, DevFunc, PciReg, + *(UINT16 *) Value); + break; + + case 32: + Status = AcpiOsWritePciCfgDword (PciBus, DevFunc, PciReg, + *Value); + break; + + default: + DEBUG_PRINT (ACPI_ERROR, ( + "AmlPciConfigSpaceHandler: Invalid PCIConfig width %d\n", + BitWidth)); + Status = AE_AML_OPERAND_VALUE; + + } /* Switch bitWidth */ + + break; + + + default: + + Status = AE_BAD_PARAMETER; + break; + + } + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/exresnte.c b/sys/contrib/dev/acpica/exresnte.c new file mode 100644 index 0000000..a7785a9 --- /dev/null +++ b/sys/contrib/dev/acpica/exresnte.c @@ -0,0 +1,693 @@ + +/****************************************************************************** + * + * Module Name: amresnte - AML Interpreter object resolution + * $Revision: 23 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMRESNTE_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amresnte") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveNodeToValue + * + * PARAMETERS: StackPtr - Pointer to a location on a stack that contains + * a pointer to an Node + * + * RETURN: Status + * + * DESCRIPTION: Resolve a ACPI_NAMESPACE_NODE (Node, + * A.K.A. a "direct name pointer") + * + * 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_NUMBER + * ACPI_TYPE_STRING + * ACPI_TYPE_BUFFER + * ACPI_TYPE_MUTEX + * ACPI_TYPE_PACKAGE + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveNodeToValue ( + ACPI_NAMESPACE_NODE **StackPtr) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ValDesc = NULL; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + UINT8 *AmlPointer = NULL; + OBJECT_TYPE_INTERNAL EntryType; + BOOLEAN Locked; + BOOLEAN AttachedAmlPointer = FALSE; + UINT8 AmlOpcode = 0; + ACPI_INTEGER TempVal; + OBJECT_TYPE_INTERNAL ObjectType; + + + FUNCTION_TRACE ("AmlResolveEntryToValue"); + + Node = *StackPtr; + + + /* + * The stack pointer is a "Direct name ptr", and points to a + * a ACPI_NAMESPACE_NODE (Node). Get the pointer that is attached to + * the Node. + */ + + ValDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveEntryToValue: Entry=%p ValDesc=%p Type=%X\n", + Node, ValDesc, EntryType)); + + /* + * The ValDesc attached to the Node can be either: + * 1) An internal ACPI object + * 2) A pointer into the AML stream (into one of the ACPI system tables) + */ + + if (AcpiTbSystemTablePointer (ValDesc)) + { + AttachedAmlPointer = TRUE; + AmlOpcode = *((UINT8 *) ValDesc); + AmlPointer = ((UINT8 *) ValDesc) + 1; + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveEntryToValue: Unparsed AML: %p Len=%X\n", + AmlOpcode, AmlPointer)); + } + + + /* + * Several EntryTypes do not require further processing, so + * we will return immediately + */ + /* Devices rarely have an attached object, return the Node + * and Method locals and arguments have a pseudo-Node + */ + if (EntryType == ACPI_TYPE_DEVICE || + EntryType == INTERNAL_TYPE_METHOD_ARGUMENT || + EntryType == INTERNAL_TYPE_METHOD_LOCAL_VAR) + { + return_ACPI_STATUS (AE_OK); + } + + if (!ValDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: No object attached to node %p\n", + Node)); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Action is based on the type of the Node, which indicates the type + * of the attached object or pointer + */ + switch (EntryType) + { + + case ACPI_TYPE_PACKAGE: + + if (AttachedAmlPointer) + { + /* + * This means that the package initialization is not parsed + * -- should not happen + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Unparsed Packages not supported!\n")); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + /* ValDesc is an internal object in all cases by the time we get here */ + + if (ACPI_TYPE_PACKAGE != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Object not a package, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + case ACPI_TYPE_BUFFER: + + if (AttachedAmlPointer) + { + /* + * This means that the buffer initialization is not parsed + * -- should not happen + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Unparsed Buffers not supported!\n")); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + /* ValDesc is an internal object in all cases by the time we get here */ + + if (ACPI_TYPE_BUFFER != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Object not a buffer, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + case ACPI_TYPE_STRING: + + if (AttachedAmlPointer) + { + /* Allocate a new string object */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_STRING); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init the internal object */ + + ObjDesc->String.Pointer = (NATIVE_CHAR *) AmlPointer; + ObjDesc->String.Length = STRLEN (ObjDesc->String.Pointer); + } + + else + { + if (ACPI_TYPE_STRING != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Object not a string, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + } + + break; + + + case ACPI_TYPE_NUMBER: + + DEBUG_PRINT (TRACE_EXEC, ("AmlResolveEntryToValue: case Number \n")); + + /* + * The Node has an attached internal object, make sure that it's a + * number + */ + + if (ACPI_TYPE_NUMBER != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveToValue: Object not a Number, type %X\n", + ValDesc->Common.Type)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + /* + * TBD: [Investigate] Is this the correct solution? + * + * This section was extended to convert to generic buffer if + * the return length is greater than 32 bits, but still allows + * for returning a type Number for smaller values because the + * caller can then apply arithmetic operators on those fields. + * + * XXX - Implementation limitation: Fields are implemented as type + * XXX - Number, but they really are supposed to be type Buffer. + * XXX - The two are interchangeable only for lengths <= 32 bits. + */ + if(ValDesc->Field.Length > 32) + { + ObjectType = ACPI_TYPE_BUFFER; + } + else + { + ObjectType = ACPI_TYPE_NUMBER; + } + + /* + * Create the destination buffer object and the buffer space. + */ + ObjDesc = AcpiCmCreateInternalObject (ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Fill in the object specific details + */ + if (ACPI_TYPE_BUFFER == ObjectType) + { + ObjDesc->Buffer.Pointer = AcpiCmCallocate (ValDesc->Field.Length); + if (!ObjDesc->Buffer.Pointer) + { + AcpiCmRemoveReference(ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Buffer.Length = ValDesc->Field.Length; + + Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node, + ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + Status = AcpiAmlAccessNamedField (ACPI_READ, (ACPI_HANDLE) Node, + &TempVal, sizeof (TempVal)); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc->Number.Value = TempVal; + } + + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveEntryToValue: DefField Entry=%p ValDesc=%p Type=%X\n", + Node, ValDesc, EntryType)); + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + if (AttachedAmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: BankField cannot be an Aml ptr\n")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (INTERNAL_TYPE_BANK_FIELD != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlResolveToValue: Object not a BankField, type %X\n", + ValDesc->Common.Type)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* Get the global lock if needed */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr; + Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule); + + /* Set Index value to select proper Data register */ + /* perform the update */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + ValDesc->BankField.BankSelect, &ValDesc->BankField.Value, + sizeof (ValDesc->BankField.Value)); + + AcpiAmlReleaseGlobalLock (Locked); + + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Read Data value */ + + Status = AcpiAmlAccessNamedField (ACPI_READ, + (ACPI_HANDLE) ValDesc->BankField.Container, + &TempVal, sizeof (TempVal)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create an object for the result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Number.Value = TempVal; + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + if (AttachedAmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlResolveEntryToValue: Internal - IndexField cannot be an Aml ptr\n")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (INTERNAL_TYPE_INDEX_FIELD != ValDesc->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlResolveToValue: Object not an IndexField, type %X\n", + ValDesc->Common.Type)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* Set Index value to select proper Data register */ + /* Get the global lock if needed */ + + ObjDesc = (ACPI_OPERAND_OBJECT *) *StackPtr; + Locked = AcpiAmlAcquireGlobalLock (ObjDesc->FieldUnit.LockRule); + + /* Perform the update */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + ValDesc->IndexField.Index, &ValDesc->IndexField.Value, + sizeof (ValDesc->IndexField.Value)); + + AcpiAmlReleaseGlobalLock (Locked); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Read Data value */ + + Status = AcpiAmlAccessNamedField (ACPI_READ, ValDesc->IndexField.Data, + &TempVal, sizeof (TempVal)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create an object for the result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Number.Value = TempVal; + break; + + + case ACPI_TYPE_FIELD_UNIT: + + if (AttachedAmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: FieldUnit cannot be an Aml ptr\n")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ValDesc->Common.Type != (UINT8) EntryType) + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlResolveToValue: Object type %X not same as EntryType %X\n", + ValDesc->Common.Type, EntryType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + break; + } + + /* Create object for result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiAmlGetFieldUnitValue (ValDesc, ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); + } + + break; + + + /* + * For these objects, just return the object attached to the Node + */ + + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_METHOD: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + + /* Return an additional reference to the object */ + + ObjDesc = ValDesc; + AcpiCmAddReference (ObjDesc); + break; + + + /* TYPE_Any is untyped, and thus there is no object associated with it */ + + case ACPI_TYPE_ANY: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Untyped entry %p, no attached object!\n", + Node)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ + break; + + + /* + * The only named references allowed are named constants + * + * e.g. Name (\OSFL, Ones) + */ + case INTERNAL_TYPE_REFERENCE: + + switch (ValDesc->Reference.OpCode) + { + + case AML_ZERO_OP: + + TempVal = 0; + break; + + + case AML_ONE_OP: + + TempVal = 1; + break; + + + case AML_ONES_OP: + + TempVal = ACPI_UINT32_MAX; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveToValue/Number: Unsupported reference opcode %X\n", + ValDesc->Reference.OpCode)); + + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + /* Create object for result */ + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Number.Value = TempVal; + + break; + + + /* Default case is for unknown types */ + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveEntryToValue: Node %p - Unknown object type %X\n", + Node, EntryType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + + } /* switch (EntryType) */ + + + /* Put the object descriptor on the stack */ + + *StackPtr = (void *) ObjDesc; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exresolv.c b/sys/contrib/dev/acpica/exresolv.c new file mode 100644 index 0000000..5f23c2d --- /dev/null +++ b/sys/contrib/dev/acpica/exresolv.c @@ -0,0 +1,629 @@ + +/****************************************************************************** + * + * Module Name: amresolv - AML Interpreter object resolution + * $Revision: 76 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMRESOLV_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amresolv") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlGetFieldUnitValue + * + * PARAMETERS: *FieldDesc - Pointer to a FieldUnit + * *ResultDesc - Pointer to an empty descriptor + * which will become a Number + * containing the field's value. + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value from a FieldUnit + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlGetFieldUnitValue ( + ACPI_OPERAND_OBJECT *FieldDesc, + ACPI_OPERAND_OBJECT *ResultDesc) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Mask; + UINT8 *Location = NULL; + BOOLEAN Locked = FALSE; + + + FUNCTION_TRACE ("AmlGetFieldUnitValue"); + + + if (!FieldDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - null field pointer\n")); + Status = AE_AML_NO_OPERAND; + } + + if (!(FieldDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetFieldUnitArguments (FieldDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (!FieldDesc->FieldUnit.Container) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - null container pointer\n")); + Status = AE_AML_INTERNAL; + } + + else if (ACPI_TYPE_BUFFER != FieldDesc->FieldUnit.Container->Common.Type) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - container is not a Buffer\n")); + Status = AE_AML_OPERAND_TYPE; + } + + else if (!ResultDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlGetFieldUnitValue: Internal error - null result pointer\n")); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Get the global lock if needed */ + + Locked = AcpiAmlAcquireGlobalLock (FieldDesc->FieldUnit.LockRule); + + /* Field location is (base of buffer) + (byte offset) */ + + Location = FieldDesc->FieldUnit.Container->Buffer.Pointer + + FieldDesc->FieldUnit.Offset; + + /* + * Construct Mask with as many 1 bits as the field width + * + * NOTE: Only the bottom 5 bits are valid for a shift operation, so + * special care must be taken for any shift greater than 31 bits. + * + * TBD: [Unhandled] Fields greater than 32-bits will not work. + */ + + if (FieldDesc->FieldUnit.Length < 32) + { + Mask = ((UINT32) 1 << FieldDesc->FieldUnit.Length) - (UINT32) 1; + } + else + { + Mask = ACPI_UINT32_MAX; + } + + ResultDesc->Number.Type = (UINT8) ACPI_TYPE_NUMBER; + + /* Get the 32 bit value at the location */ + + MOVE_UNALIGNED32_TO_32 (&ResultDesc->Number.Value, Location); + + /* + * Shift the 32-bit word containing the field, and mask off the + * resulting value + */ + + ResultDesc->Number.Value = + (ResultDesc->Number.Value >> FieldDesc->FieldUnit.BitOffset) & Mask; + + DEBUG_PRINT (ACPI_INFO, + ("** Read from buffer %p byte %ld bit %d width %d addr %p mask %08lx val %08lx\n", + FieldDesc->FieldUnit.Container->Buffer.Pointer, + FieldDesc->FieldUnit.Offset, + FieldDesc->FieldUnit.BitOffset, + FieldDesc->FieldUnit.Length, + Location, Mask, ResultDesc->Number.Value)); + + /* Release global lock if we acquired it earlier */ + + AcpiAmlReleaseGlobalLock (Locked); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveToValue + * + * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can + * be either an (ACPI_OPERAND_OBJECT *) + * or an ACPI_HANDLE. + * + * RETURN: Status + * + * DESCRIPTION: Convert Reference entries on ObjStack to Rvalues + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AmlResolveToValue", StackPtr); + + + if (!StackPtr || !*StackPtr) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveToValue: Internal error - null pointer\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + + /* + * The entity pointed to by the StackPtr can be either + * 1) A valid ACPI_OPERAND_OBJECT, or + * 2) A ACPI_NAMESPACE_NODE (NamedObj) + */ + + if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_INTERNAL)) + { + + Status = AcpiAmlResolveObjectToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Object on the stack may have changed if AcpiAmlResolveObjectToValue() + * was called (i.e., we can't use an _else_ here.) + */ + + if (VALID_DESCRIPTOR_TYPE (*StackPtr, ACPI_DESC_TYPE_NAMED)) + { + Status = AcpiAmlResolveNodeToValue ((ACPI_NAMESPACE_NODE **) StackPtr); + } + + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveToValue: Returning resolved object %p\n", *StackPtr)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveObjectToValue + * + * PARAMETERS: StackPtr - Pointer to a stack location that contains a + * ptr to an internal object. + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value from an internal object. The Reference type + * uses the associated AML opcode to determine the value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *StackDesc; + ACPI_STATUS Status = AE_OK; + ACPI_HANDLE TempHandle = NULL; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + UINT32 Index = 0; + UINT16 Opcode; + + + FUNCTION_TRACE ("AmlResolveObjectToValue"); + + + StackDesc = *StackPtr; + + /* This is an ACPI_OPERAND_OBJECT */ + + switch (StackDesc->Common.Type) + { + + case INTERNAL_TYPE_REFERENCE: + + Opcode = StackDesc->Reference.OpCode; + + switch (Opcode) + { + + case AML_NAME_OP: + + /* + * Convert indirect name ptr to a direct name ptr. + * Then, AcpiAmlResolveNodeToValue can be used to get the value + */ + + TempHandle = StackDesc->Reference.Object; + + /* Delete the Reference Object */ + + AcpiCmRemoveReference (StackDesc); + + /* Put direct name pointer onto stack and exit */ + + (*StackPtr) = TempHandle; + Status = AE_OK; + break; + + + case AML_LOCAL_OP: + + Index = StackDesc->Reference.Offset; + + /* + * Get the local from the method's state info + * Note: this increments the local's object reference count + */ + + Status = AcpiDsMethodDataGetValue (MTH_TYPE_LOCAL, Index, + WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now we can delete the original Reference Object and + * replace it with the resolve value + */ + + AcpiCmRemoveReference (StackDesc); + *StackPtr = ObjDesc; + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveObjectToValue: [Local%d] ValueObj is %p\n", + Index, ObjDesc)); + + if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) + { + /* Value is a Number */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveObjectToValue: [Local%d] value is [0x%X] \n", + Index, ObjDesc->Number.Value)); + } + + break; + + + case AML_ARG_OP: + + Index = StackDesc->Reference.Offset; + + + /* + * Get the argument from the method's state info + * Note: this increments the object reference count + */ + + Status = AcpiDsMethodDataGetValue (MTH_TYPE_ARG, Index, + WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now we can delete the original Reference Object and + * replace it with the resolve value + */ + + AcpiCmRemoveReference (StackDesc); + *StackPtr = ObjDesc; + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveObjectToValue: [Arg%d] ValueObj is %p\n", + Index, ObjDesc)); + + if (ACPI_TYPE_NUMBER == ObjDesc->Common.Type) + { + /* Value is a Number */ + + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveObjectToValue: [Arg%d] value is [0x%X] \n", + Index, ObjDesc->Number.Value)); + } + + break; + + + /* + * TBD: [Restructure] These next three opcodes change the type of + * the object, which is actually a no-no. + */ + + case AML_ZERO_OP: + + StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; + StackDesc->Number.Value = 0; + break; + + + case AML_ONE_OP: + + StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; + StackDesc->Number.Value = 1; + break; + + + case AML_ONES_OP: + + StackDesc->Common.Type = (UINT8) ACPI_TYPE_NUMBER; + StackDesc->Number.Value = ACPI_INTEGER_MAX; + break; + + + case AML_INDEX_OP: + + switch (StackDesc->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + /* Just return - leave the Reference on the stack */ + break; + + + case ACPI_TYPE_PACKAGE: + ObjDesc = *StackDesc->Reference.Where; + if (ObjDesc) + { + /* + * Valid obj descriptor, copy pointer to return value + * (i.e., dereference the package index) + * Delete the ref object, increment the returned object + */ + AcpiCmRemoveReference (StackDesc); + AcpiCmAddReference (ObjDesc); + *StackPtr = ObjDesc; + } + + else + { + /* + * A NULL object descriptor means an unitialized element of + * the package, can't deref it + */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveObjectToValue: Attempt to deref an Index to NULL pkg element Idx=%p\n", StackDesc)); + Status = AE_AML_UNINITIALIZED_ELEMENT; + } + break; + + default: + /* Invalid reference OBJ*/ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveObjectToValue: Unknown TargetType %d in Index/Reference obj %p\n", + StackDesc->Reference.TargetType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + + break; + + + case AML_DEBUG_OP: + + /* Just leave the object as-is */ + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveObjectToValue: Unknown Reference object subtype %02x in %p\n", + Opcode, StackDesc)); + Status = AE_AML_INTERNAL; + + } /* switch (Opcode) */ + + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + break; /* case INTERNAL_TYPE_REFERENCE */ + + + case ACPI_TYPE_FIELD_UNIT: + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); + if (!ObjDesc) + { + /* Descriptor allocation failure */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + + *StackPtr = (void *) ObjDesc; + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_ANY); + if (!ObjDesc) + { + /* Descriptor allocation failure */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiAmlGetFieldUnitValue (StackDesc, ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + } + + *StackPtr = (void *) ObjDesc; + break; + + + /* TBD: [Future] - may need to handle IndexField, and DefField someday */ + + default: + + break; + + } /* switch (StackDesc->Common.Type) */ + + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exresop.c b/sys/contrib/dev/acpica/exresop.c new file mode 100644 index 0000000..02a13d4 --- /dev/null +++ b/sys/contrib/dev/acpica/exresop.c @@ -0,0 +1,629 @@ + +/****************************************************************************** + * + * Module Name: amresop - AML Interpreter operand/object resolution + * $Revision: 15 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMRESOP_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amresop") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlResolveOperands + * + * PARAMETERS: Opcode Opcode being interpreted + * StackPtr Top of operand stack + * + * RETURN: Status + * + * DESCRIPTION: Convert stack entries to required types + * + * Each nibble in ArgTypes represents one required operand + * and indicates the required Type: + * + * The corresponding stack entry will be converted to the + * required type if possible, else return an exception + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + UINT8 ObjectType; + ACPI_HANDLE TempHandle; + UINT32 ArgTypes; + ACPI_OPCODE_INFO *OpInfo; + UINT32 ThisArgType; + + + FUNCTION_TRACE_U32 ("AmlResolveOperands", Opcode); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + + ArgTypes = OpInfo->RuntimeArgs; + if (ArgTypes == ARGI_INVALID_OPCODE) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Internal error - %X is not a runtime opcode\n", Opcode)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + DEBUG_PRINT (TRACE_EXEC, + ("AmlResolveOperands: Opcode %X OperandTypes=%X \n", + Opcode, ArgTypes)); + + + /* + * Normal exit is with *Types == '\0' at end of string. + * Function will return an exception from within the loop upon + * finding an entry which is not, and cannot be converted + * to, the required type; if stack underflows; or upon + * finding a NULL stack entry (which "should never happen"). + */ + + while (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + if (!StackPtr || !*StackPtr) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Internal error - null stack entry at %X\n", StackPtr)); + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + /* Extract useful items */ + + ObjDesc = *StackPtr; + + /* Decode the descriptor type */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Node */ + + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + } + + else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL)) + { + /* ACPI internal object */ + + ObjectType = ObjDesc->Common.Type; + + /* Check for bad ACPI_OBJECT_TYPE */ + + if (!AcpiAmlValidateObjectType (ObjectType)) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Bad operand object type [0x%x]\n", + ObjectType)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (ObjectType == (UINT8) INTERNAL_TYPE_REFERENCE) + { + /* + * Decode the Reference + */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + + switch (ObjDesc->Reference.OpCode) + { + case AML_ZERO_OP: + case AML_ONE_OP: + case AML_ONES_OP: + case AML_DEBUG_OP: + case AML_NAME_OP: + case AML_INDEX_OP: + case AML_ARG_OP: + case AML_LOCAL_OP: + + DEBUG_ONLY_MEMBERS (DEBUG_PRINT (ACPI_INFO, + ("Reference Opcode: %s\n", OpInfo->Name))); + break; + + default: + DEBUG_PRINT (ACPI_INFO, + ("Reference Opcode: Unknown [%02x]\n", + ObjDesc->Reference.OpCode)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + break; + } + } + + } + + else + { + /* Invalid descriptor */ + + DEBUG_PRINT (ACPI_ERROR, + ("Bad descriptor type 0x%X in Obj %p\n", + ObjDesc->Common.DataType, ObjDesc)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + + /* + * Decode a character from the type string + */ + + ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); + INCREMENT_ARG_LIST (ArgTypes); + + + switch (ThisArgType) + { + + case ARGI_REFERENCE: /* Reference */ + case ARGI_TARGETREF: + + /* Need an operand of type INTERNAL_TYPE_REFERENCE */ + + if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) /* direct name ptr OK as-is */ + { + break; + } + + if (INTERNAL_TYPE_REFERENCE != ObjectType) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Reference, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (AML_NAME_OP == ObjDesc->Reference.OpCode) + { + /* + * Convert an indirect name ptr to direct name ptr and put + * it on the stack + */ + + TempHandle = ObjDesc->Reference.Object; + AcpiCmRemoveReference (ObjDesc); + (*StackPtr) = TempHandle; + } + break; + + + case ARGI_NUMBER: /* Number */ + + /* Need an operand of type ACPI_TYPE_NUMBER */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_NUMBER != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Number, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_STRING: + + /* Need an operand of type ACPI_TYPE_STRING or ACPI_TYPE_BUFFER */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if ((ACPI_TYPE_STRING != (*StackPtr)->Common.Type) && + (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed String or Buffer, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_BUFFER: + + /* Need an operand of type ACPI_TYPE_BUFFER */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Buffer, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_MUTEX: + + /* Need an operand of type ACPI_TYPE_MUTEX */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_MUTEX != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Mutex, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_EVENT: + + /* Need an operand of type ACPI_TYPE_EVENT */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_EVENT != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed AcpiEvent, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_REGION: + + /* Need an operand of type ACPI_TYPE_REGION */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_REGION != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Region, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_IF: /* If */ + + /* Need an operand of type INTERNAL_TYPE_IF */ + + if (INTERNAL_TYPE_IF != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed If, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_PACKAGE: /* Package */ + + /* Need an operand of type ACPI_TYPE_PACKAGE */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_TYPE_PACKAGE != (*StackPtr)->Common.Type) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Package, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ARGI_ANYTYPE: + + + /* + * We don't want to resolve IndexOp reference objects during + * a store because this would be an implicit DeRefOf operation. + * Instead, we just want to store the reference object. + */ + + if ((Opcode == AML_STORE_OP) && + ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) && + ((*StackPtr)->Reference.OpCode == AML_INDEX_OP)) + { + break; + } + + /* All others must be resolved */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* All types OK, so we don't perform any typechecks */ + + break; + + + case ARGI_DATAOBJECT: + /* + * ARGI_DATAOBJECT is only used by the SizeOf operator. + * + * The ACPI specification allows SizeOf to return the size of + * a Buffer, String or Package. However, the MS ACPI.SYS AML + * Interpreter also allows an Node reference to return without + * error with a size of 4. + */ + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Need a buffer, string, package or Node reference */ + + if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) && + ((*StackPtr)->Common.Type != ACPI_TYPE_STRING) && + ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE) && + ((*StackPtr)->Common.Type != INTERNAL_TYPE_REFERENCE)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Buf/Str/Pkg, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * If this is a reference, only allow a reference to an Node. + */ + if ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) + { + if (!(*StackPtr)->Reference.Node) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Node reference, found %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + + break; + + + case ARGI_COMPLEXOBJ: + + Status = AcpiAmlResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Need a buffer or package */ + + if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) && + ((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE)) + { + DEBUG_PRINT (ACPI_INFO, + ("AmlResolveOperands: Needed Package, Buf/Pkg %s Obj=%p\n", + AcpiCmGetTypeName (ObjectType), *StackPtr)); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + /* Unknown abbreviation passed in */ + + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlResolveOperands: Internal error - Unknown arg type %X\n", + ThisArgType)); + Status = AE_BAD_PARAMETER; + goto Cleanup; + + } /* switch (*Types++) */ + + + /* + * If more operands needed, decrement StackPtr to point + * to next operand on stack (after checking for underflow). + */ + if (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + StackPtr--; + } + + } /* while (*Types) */ + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c new file mode 100644 index 0000000..976ecc7 --- /dev/null +++ b/sys/contrib/dev/acpica/exstore.c @@ -0,0 +1,531 @@ + +/****************************************************************************** + * + * Module Name: amstore - AML Interpreter object store support + * $Revision: 116 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSTORE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amstore") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecStore + * + * PARAMETERS: *ValDesc - Value to be stored + * *DestDesc - Where to store it 0 Must be (ACPI_HANDLE) + * or an ACPI_OPERAND_OBJECT of type + * Reference; if the latter the descriptor + * will be either reused or deleted. + * + * RETURN: Status + * + * DESCRIPTION: Store the value described by ValDesc into the location + * described by DestDesc. Called by various interpreter + * functions to store the result of an operation into + * the destination operand. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecStore ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *DeleteDestDesc = NULL; + ACPI_OPERAND_OBJECT *TmpDesc; + ACPI_NAMESPACE_NODE *Node = NULL; + UINT8 Value = 0; + UINT32 Length; + UINT32 i; + + + FUNCTION_TRACE ("AmlExecStore"); + + DEBUG_PRINT (ACPI_INFO, ("entered AcpiAmlExecStore: Val=%p, Dest=%p\n", + ValDesc, DestDesc)); + + + /* Validate parameters */ + + if (!ValDesc || !DestDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore: Internal error - null pointer\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* Examine the datatype of the DestDesc */ + + if (VALID_DESCRIPTOR_TYPE (DestDesc, ACPI_DESC_TYPE_NAMED)) + { + /* Dest is an ACPI_HANDLE, create a new object */ + + Node = (ACPI_NAMESPACE_NODE *) DestDesc; + DestDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!DestDesc) + { + /* Allocation failure */ + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Build a new Reference wrapper around the handle */ + + DestDesc->Reference.OpCode = AML_NAME_OP; + DestDesc->Reference.Object = Node; + } + + else + { + DEBUG_PRINT (ACPI_INFO, + ("AmlExecStore: Dest is object (not handle) - may be deleted!\n")); + } + + /* Destination object must be of type Reference */ + + if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE) + { + /* Destination is not an Reference */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore: Destination is not an Reference [%p]\n", DestDesc)); + + DUMP_STACK_ENTRY (ValDesc); + DUMP_STACK_ENTRY (DestDesc); + DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "AmlExecStore", + 2, "target not Reference"); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Examine the Reference opcode */ + + switch (DestDesc->Reference.OpCode) + { + + case AML_NAME_OP: + + /* + * Storing into a Name + */ + DeleteDestDesc = DestDesc; + Status = AcpiAmlStoreObjectToNode (ValDesc, DestDesc->Reference.Object, + WalkState); + + break; /* Case NameOp */ + + + case AML_INDEX_OP: + + DeleteDestDesc = DestDesc; + + /* + * Valid source value and destination reference pointer. + * + * ACPI Specification 1.0B section 15.2.3.4.2.13: + * Destination should point to either a buffer or a package + */ + + /* + * Actually, storing to a package is not so simple. The source must be + * evaluated and converted to the type of the destination and then the + * source is copied into the destination - we can't just point to the + * source object. + */ + if (DestDesc->Reference.TargetType == ACPI_TYPE_PACKAGE) + { + /* + * The object at *(DestDesc->Reference.Where) is the + * element within the package that is to be modified. + */ + TmpDesc = *(DestDesc->Reference.Where); + if (TmpDesc) + { + /* + * If the Destination element is a package, we will delete + * that object and construct a new one. + * + * TBD: [Investigate] Should both the src and dest be required + * to be packages? + * && (ValDesc->Common.Type == ACPI_TYPE_PACKAGE) + */ + if (TmpDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + /* + * Take away the reference for being part of a package and + * delete + */ + AcpiCmRemoveReference (TmpDesc); + AcpiCmRemoveReference (TmpDesc); + + TmpDesc = NULL; + } + } + + if (!TmpDesc) + { + /* + * If the TmpDesc is NULL, that means an uninitialized package + * has been used as a destination, therefore, we must create + * the destination element to match the type of the source + * element NOTE: ValDesc can be of any type. + */ + TmpDesc = AcpiCmCreateInternalObject (ValDesc->Common.Type); + if (!TmpDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * If the source is a package, copy the source to the new dest + */ + if (ACPI_TYPE_PACKAGE == TmpDesc->Common.Type) + { + Status = AcpiAmlBuildCopyInternalPackageObject ( + ValDesc, TmpDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiCmRemoveReference (TmpDesc); + TmpDesc = NULL; + goto Cleanup; + } + } + + /* + * Install the new descriptor into the package and add a + * reference to the newly created descriptor for now being + * part of the parent package + */ + + *(DestDesc->Reference.Where) = TmpDesc; + AcpiCmAddReference (TmpDesc); + } + + if (ACPI_TYPE_PACKAGE != TmpDesc->Common.Type) + { + /* + * The destination element is not a package, so we need to + * convert the contents of the source (ValDesc) and copy into + * the destination (TmpDesc) + */ + Status = AcpiAmlStoreObjectToObject (ValDesc, TmpDesc, + WalkState); + if (ACPI_FAILURE (Status)) + { + /* + * An error occurrered when copying the internal object + * so delete the reference. + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore/Index: Unable to copy the internal object\n")); + Status = AE_AML_OPERAND_TYPE; + } + } + + break; + } + + /* + * Check that the destination is a Buffer Field type + */ + if (DestDesc->Reference.TargetType != ACPI_TYPE_BUFFER_FIELD) + { + Status = AE_AML_OPERAND_TYPE; + break; + } + + /* + * Storing into a buffer at a location defined by an Index. + * + * Each 8-bit element of the source object is written to the + * 8-bit Buffer Field of the Index destination object. + */ + + /* + * Set the TmpDesc to the destination object and type check. + */ + TmpDesc = DestDesc->Reference.Object; + + if (TmpDesc->Common.Type != ACPI_TYPE_BUFFER) + { + Status = AE_AML_OPERAND_TYPE; + break; + } + + /* + * The assignment of the individual elements will be slightly + * different for each source type. + */ + + switch (ValDesc->Common.Type) + { + /* + * If the type is Integer, the Length is 4. + * This loop to assign each of the elements is somewhat + * backward because of the Big Endian-ness of IA-64 + */ + case ACPI_TYPE_NUMBER: + Length = 4; + for (i = Length; i != 0; i--) + { + Value = (UINT8)(ValDesc->Number.Value >> (MUL_8 (i - 1))); + TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + } + break; + + /* + * If the type is Buffer, the Length is in the structure. + * Just loop through the elements and assign each one in turn. + */ + case ACPI_TYPE_BUFFER: + Length = ValDesc->Buffer.Length; + for (i = 0; i < Length; i++) + { + Value = *(ValDesc->Buffer.Pointer + i); + TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + } + break; + + /* + * If the type is String, the Length is in the structure. + * Just loop through the elements and assign each one in turn. + */ + case ACPI_TYPE_STRING: + Length = ValDesc->String.Length; + for (i = 0; i < Length; i++) + { + Value = *(ValDesc->String.Pointer + i); + TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value; + } + break; + + /* + * If source is not a valid type so return an error. + */ + default: + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore/Index: Source must be Number/Buffer/String type, not 0x%x\n", + ValDesc->Common.Type)); + Status = AE_AML_OPERAND_TYPE; + break; + } + + /* + * If we had an error, break out of this case statement. + */ + if (ACPI_FAILURE (Status)) + { + break; + } + + /* + * Set the return pointer + */ + DestDesc = TmpDesc; + + break; + + case AML_ZERO_OP: + case AML_ONE_OP: + case AML_ONES_OP: + + /* + * Storing to a constant is a no-op -- see ACPI Specification + * Delete the result descriptor. + */ + + DeleteDestDesc = DestDesc; + break; + + + case AML_LOCAL_OP: + + Status = AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, + (DestDesc->Reference.Offset), ValDesc, WalkState); + DeleteDestDesc = DestDesc; + break; + + + case AML_ARG_OP: + + Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG, + (DestDesc->Reference.Offset), ValDesc, WalkState); + DeleteDestDesc = DestDesc; + break; + + + case AML_DEBUG_OP: + + /* + * Storing to the Debug object causes the value stored to be + * displayed and otherwise has no effect -- see ACPI Specification + */ + DEBUG_PRINT (ACPI_INFO, ("**** Write to Debug Object: ****: \n")); + if (ValDesc->Common.Type == ACPI_TYPE_STRING) + { + DEBUG_PRINT (ACPI_INFO, ("%s\n", ValDesc->String.Pointer)); + } + else + { + DUMP_STACK_ENTRY (ValDesc); + } + + DeleteDestDesc = DestDesc; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AmlExecStore: Internal error - Unknown Reference subtype %02x\n", + DestDesc->Reference.OpCode)); + + /* TBD: [Restructure] use object dump routine !! */ + + DUMP_BUFFER (DestDesc, sizeof (ACPI_OPERAND_OBJECT)); + + DeleteDestDesc = DestDesc; + Status = AE_AML_INTERNAL; + + } /* switch(DestDesc->Reference.OpCode) */ + + +Cleanup: + + /* Cleanup and exit*/ + + if (DeleteDestDesc) + { + AcpiCmRemoveReference (DeleteDestDesc); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exstoren.c b/sys/contrib/dev/acpica/exstoren.c new file mode 100644 index 0000000..1b626bf --- /dev/null +++ b/sys/contrib/dev/acpica/exstoren.c @@ -0,0 +1,713 @@ + +/****************************************************************************** + * + * Module Name: amstoren - AML Interpreter object store support, + * Store to Node (namespace object) + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSTOREN_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amstoren") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObjectToNode + * + * PARAMETERS: *ValDesc - Value to be stored + * *Node - Named object to recieve the value + * + * RETURN: Status + * + * DESCRIPTION: Store the object to the named object. + * + * The Assignment of an object to a named object is handled here + * The val 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. + * + * NOTE: the global lock is acquired early. This will result + * in the global lock being held a bit longer. Also, if the + * function fails during set up we may get the lock when we + * don't really need it. I don't think we care. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObjectToNode ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *Buffer = NULL; + UINT32 Length = 0; + UINT32 Mask; + UINT32 NewValue; + BOOLEAN Locked = FALSE; + UINT8 *Location=NULL; + ACPI_OPERAND_OBJECT *DestDesc; + OBJECT_TYPE_INTERNAL DestinationType = ACPI_TYPE_ANY; + + + FUNCTION_TRACE ("AmlStoreObjectToNte"); + + DEBUG_PRINT (ACPI_INFO, + ("entered AcpiAmlStoreObjectToNode: NamedObj=%p, Obj=%p\n", + Node, ValDesc)); + + /* + * Assuming the parameters are valid!!! + */ + ACPI_ASSERT((Node) && (ValDesc)); + + DestinationType = AcpiNsGetType (Node); + + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToNte: Storing %s into %s\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + + /* + * First ensure we have a value that can be stored in the target + */ + switch (DestinationType) + { + /* Type of Name's existing value */ + + case INTERNAL_TYPE_ALIAS: + + /* + * Aliases are resolved by AcpiAmlPrepOperands + */ + + DEBUG_PRINT (ACPI_WARN, + ("AmlStoreObjectToNte: Store into Alias - should never happen\n")); + Status = AE_AML_INTERNAL; + break; + + + case INTERNAL_TYPE_BANK_FIELD: + case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_FIELD_UNIT: + case ACPI_TYPE_NUMBER: + + /* + * These cases all require only number values or values that + * can be converted to numbers. + * + * If value is not a Number, try to resolve it to one. + */ + + if (ValDesc->Common.Type != ACPI_TYPE_NUMBER) + { + /* + * Initially not a number, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER)) + { + /* + * Conversion successful but still not a number + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Value assigned to %s must be Number, not %s\n", + AcpiCmGetTypeName (DestinationType), + AcpiCmGetTypeName (ValDesc->Common.Type))); + Status = AE_AML_OPERAND_TYPE; + } + } + + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case INTERNAL_TYPE_DEF_FIELD: + + /* + * Storing into a Field in a region or into a buffer or into + * a string all is essentially the same. + * + * If value is not a valid type, try to resolve it to one. + */ + + if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Initially not a valid type, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Conversion successful but still not a valid type + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Assign wrong type %s to %s (must be type Num/Str/Buf)\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + Status = AE_AML_OPERAND_TYPE; + } + } + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * TBD: [Unhandled] Not real sure what to do here + */ + Status = AE_NOT_IMPLEMENTED; + break; + + + default: + + /* + * All other types than Alias and the various Fields come here. + * Store ValDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * ValDesc reference count is incremented by AttachObject. + */ + + Status = AcpiNsAttachObject (Node, ValDesc, ValDesc->Common.Type); + + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: Store %s into %s via Attach\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + + goto CleanUpAndBailOut; + break; + } + + /* Exit now if failure above */ + + if (ACPI_FAILURE (Status)) + { + goto CleanUpAndBailOut; + } + + /* + * Get descriptor for object attached to Node + */ + DestDesc = AcpiNsGetAttachedObject (Node); + if (!DestDesc) + { + /* + * There is no existing object attached to this Node + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Internal error - no destination object for %4.4s type %d\n", + &Node->Name, DestinationType)); + Status = AE_AML_INTERNAL; + goto CleanUpAndBailOut; + } + + /* + * Make sure the destination Object is the same as the Node + */ + if (DestDesc->Common.Type != (UINT8) DestinationType) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: Internal error - Name %4.4s type %d does not match value-type %d at %p\n", + &Node->Name, AcpiNsGetType (Node), + DestDesc->Common.Type, DestDesc)); + Status = AE_AML_INTERNAL; + goto CleanUpAndBailOut; + } + + /* + * AcpiEverything is ready to execute now, We have + * a value we can handle, just perform the update + */ + + switch (DestinationType) + { + /* Type of Name's existing value */ + + case INTERNAL_TYPE_BANK_FIELD: + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (DestDesc->BankField.LockRule); + + /* + * Set Bank value to select proper Bank + * Perform the update (Set Bank Select) + */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->BankField.BankSelect, + &DestDesc->BankField.Value, + sizeof (DestDesc->BankField.Value)); + if (ACPI_SUCCESS (Status)) + { + /* Set bank select successful, set data value */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->BankField.BankSelect, + &ValDesc->BankField.Value, + sizeof (ValDesc->BankField.Value)); + } + + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (ValDesc->Field.LockRule); + + /* + * Perform the update + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + Node, Buffer, Length); + + break; /* Global Lock released below */ + + + case ACPI_TYPE_STRING: + + /* + * Perform the update + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * Setting a string value replaces the old string + */ + + if (Length < DestDesc->String.Length) + { + /* + * Zero fill, not willing to do pointer arithmetic for + * archetecture independance. Just clear the whole thing + */ + MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length); + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + else + { + /* + * Free the current buffer, then allocate a buffer + * large enough to hold the value + */ + if ( DestDesc->String.Pointer && + !AcpiTbSystemTablePointer (DestDesc->String.Pointer)) + { + /* + * Only free if not a pointer into the DSDT + */ + + AcpiCmFree(DestDesc->String.Pointer); + } + + DestDesc->String.Pointer = AcpiCmAllocate (Length + 1); + DestDesc->String.Length = Length; + + if (!DestDesc->String.Pointer) + { + Status = AE_NO_MEMORY; + goto CleanUpAndBailOut; + } + + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + break; + + + case ACPI_TYPE_BUFFER: + + /* + * Perform the update to the buffer + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * Buffer is a static allocation, + * only place what will fit in the buffer. + */ + if (Length <= DestDesc->Buffer.Length) + { + /* + * Zero fill first, not willing to do pointer arithmetic for + * archetecture independence. Just clear the whole thing + */ + MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length); + MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length); + } + else + { + /* + * truncate, copy only what will fit + */ + MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length); + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: Truncating src buffer from %d to %d\n", + Length, DestDesc->Buffer.Length)); + } + break; + + + case INTERNAL_TYPE_INDEX_FIELD: + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (DestDesc->IndexField.LockRule); + + /* + * Set Index value to select proper Data register + * perform the update (Set index) + */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->IndexField.Index, + &DestDesc->IndexField.Value, + sizeof (DestDesc->IndexField.Value)); + + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: IndexField: set index returned %s\n", + AcpiCmFormatException (Status))); + + if (ACPI_SUCCESS (Status)) + { + /* set index successful, next set Data value */ + + Status = AcpiAmlAccessNamedField (ACPI_WRITE, + DestDesc->IndexField.Data, + &ValDesc->Number.Value, + sizeof (ValDesc->Number.Value)); + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToNte: IndexField: set data returned %s\n", + AcpiCmFormatException (Status))); + } + break; + + + case ACPI_TYPE_FIELD_UNIT: + + + /* + * If the Field Buffer and Index have not been previously evaluated, + * evaluate them and save the results. + */ + if (!(DestDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetFieldUnitArguments (DestDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if ((!DestDesc->FieldUnit.Container || + ACPI_TYPE_BUFFER != DestDesc->FieldUnit.Container->Common.Type)) + { + DUMP_PATHNAME (Node, + "AmlStoreObjectToNte: FieldUnit: Bad container in ", + ACPI_ERROR, _COMPONENT); + DUMP_ENTRY (Node, ACPI_ERROR); + DEBUG_PRINT (ACPI_ERROR, + ("Container: %p", DestDesc->FieldUnit.Container)); + + if (DestDesc->FieldUnit.Container) + { + DEBUG_PRINT_RAW (ACPI_ERROR, (" Type %d", + DestDesc->FieldUnit.Container->Common.Type)); + } + DEBUG_PRINT_RAW (ACPI_ERROR, ("\n")); + + Status = AE_AML_INTERNAL; + goto CleanUpAndBailOut; + } + + /* + * Get the global lock if needed + */ + Locked = AcpiAmlAcquireGlobalLock (DestDesc->FieldUnit.LockRule); + + /* + * TBD: [Unhandled] REMOVE this limitation + * Make sure the operation is within the limits of our implementation + * this is not a Spec limitation!! + */ + if (DestDesc->FieldUnit.Length + DestDesc->FieldUnit.BitOffset > 32) + { + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToNte: FieldUnit: Implementation limitation - Field exceeds UINT32\n")); + Status = AE_NOT_IMPLEMENTED; + goto CleanUpAndBailOut; + } + + /* Field location is (base of buffer) + (byte offset) */ + + Location = DestDesc->FieldUnit.Container->Buffer.Pointer + + DestDesc->FieldUnit.Offset; + + /* + * Construct Mask with 1 bits where the field is, + * 0 bits elsewhere + */ + Mask = ((UINT32) 1 << DestDesc->FieldUnit.Length) - ((UINT32)1 + << DestDesc->FieldUnit.BitOffset); + + DEBUG_PRINT (TRACE_EXEC, + ("** Store %lx in buffer %p byte %ld bit %d width %d addr %p mask %08lx\n", + ValDesc->Number.Value, + DestDesc->FieldUnit.Container->Buffer.Pointer, + DestDesc->FieldUnit.Offset, DestDesc->FieldUnit.BitOffset, + DestDesc->FieldUnit.Length,Location, Mask)); + + /* Zero out the field in the buffer */ + + MOVE_UNALIGNED32_TO_32 (&NewValue, Location); + NewValue &= ~Mask; + + /* + * Shift and mask the new value into position, + * and or it into the buffer. + */ + NewValue |= (ValDesc->Number.Value << DestDesc->FieldUnit.BitOffset) & + Mask; + + /* Store back the value */ + + MOVE_UNALIGNED32_TO_32 (Location, &NewValue); + + DEBUG_PRINT (TRACE_EXEC, ("New Field value %08lx\n", NewValue)); + break; + + + case ACPI_TYPE_NUMBER: + + DestDesc->Number.Value = ValDesc->Number.Value; + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * TBD: [Unhandled] Not real sure what to do here + */ + Status = AE_NOT_IMPLEMENTED; + break; + + + default: + + /* + * All other types than Alias and the various Fields come here. + * Store ValDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * ValDesc reference count is incremented by AttachObject. + */ + + DEBUG_PRINT (ACPI_WARN, + ("AmlStoreObjectToNte: Store into %s not implemented\n", + AcpiCmGetTypeName (AcpiNsGetType (Node)))); + + Status = AE_NOT_IMPLEMENTED; + break; + } + + +CleanUpAndBailOut: + + /* + * Release global lock if we acquired it earlier + */ + AcpiAmlReleaseGlobalLock (Locked); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/exstorob.c b/sys/contrib/dev/acpica/exstorob.c new file mode 100644 index 0000000..205fdad --- /dev/null +++ b/sys/contrib/dev/acpica/exstorob.c @@ -0,0 +1,442 @@ + +/****************************************************************************** + * + * Module Name: amstorob - AML Interpreter object store support, store to object + * $Revision: 16 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSTOROB_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amstorob") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlStoreObjectToObject + * + * PARAMETERS: *ValDesc - Value to be stored + * *DestDesc - Object to receive the value + * + * RETURN: Status + * + * DESCRIPTION: Store an object to another object. + * + * The Assignment of an object to another (not named) object + * is handled here. + * The val 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, + * and Buffer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlStoreObjectToObject ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *Buffer = NULL; + UINT32 Length = 0; + OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type; + + + FUNCTION_TRACE ("AmlStoreObjectToObject"); + + DEBUG_PRINT (ACPI_INFO, + ("entered AcpiAmlStoreObjectToObject: Dest=%p, Val=%p\n", + DestDesc, ValDesc)); + + /* + * Assuming the parameters are valid!!! + */ + ACPI_ASSERT((DestDesc) && (ValDesc)); + + DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %s into %s\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestDesc->Common.Type))); + + /* + * First ensure we have a value that can be stored in the target + */ + switch (DestinationType) + { + /* Type of Name's existing value */ + + case ACPI_TYPE_NUMBER: + + /* + * These cases all require only number values or values that + * can be converted to numbers. + * + * If value is not a Number, try to resolve it to one. + */ + + if (ValDesc->Common.Type != ACPI_TYPE_NUMBER) + { + /* + * Initially not a number, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER)) + { + /* + * Conversion successful but still not a number + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToObject: Value assigned to %s must be Number, not %s\n", + AcpiCmGetTypeName (DestinationType), + AcpiCmGetTypeName (ValDesc->Common.Type))); + Status = AE_AML_OPERAND_TYPE; + } + } + + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * Storing into a Field in a region or into a buffer or into + * a string all is essentially the same. + * + * If value is not a valid type, try to resolve it to one. + */ + + if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Initially not a valid type, convert + */ + Status = AcpiAmlResolveToValue (&ValDesc, WalkState); + if (ACPI_SUCCESS (Status) && + (ValDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ValDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ValDesc->Common.Type != ACPI_TYPE_STRING)) + { + /* + * Conversion successful but still not a valid type + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlStoreObjectToObject: Assign wrong type %s to %s (must be type Num/Str/Buf)\n", + AcpiCmGetTypeName (ValDesc->Common.Type), + AcpiCmGetTypeName (DestinationType))); + Status = AE_AML_OPERAND_TYPE; + } + } + break; + + + default: + + /* + * TBD: [Unhandled] What other combinations must be implemented? + */ + Status = AE_NOT_IMPLEMENTED; + break; + } + + /* Exit now if failure above */ + + if (ACPI_FAILURE (Status)) + { + goto CleanUpAndBailOut; + } + + /* + * AcpiEverything is ready to execute now, We have + * a value we can handle, just perform the update + */ + + switch (DestinationType) + { + + case ACPI_TYPE_STRING: + + /* + * Perform the update + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * Setting a string value replaces the old string + */ + + if (Length < DestDesc->String.Length) + { + /* + * Zero fill, not willing to do pointer arithmetic for + * architecture independence. Just clear the whole thing + */ + MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length); + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + else + { + /* + * Free the current buffer, then allocate a buffer + * large enough to hold the value + */ + if ( DestDesc->String.Pointer && + !AcpiTbSystemTablePointer (DestDesc->String.Pointer)) + { + /* + * Only free if not a pointer into the DSDT + */ + + AcpiCmFree(DestDesc->String.Pointer); + } + + DestDesc->String.Pointer = AcpiCmAllocate (Length + 1); + DestDesc->String.Length = Length; + + if (!DestDesc->String.Pointer) + { + Status = AE_NO_MEMORY; + goto CleanUpAndBailOut; + } + + MEMCPY(DestDesc->String.Pointer, Buffer, Length); + } + break; + + + case ACPI_TYPE_BUFFER: + + /* + * Perform the update to the buffer + */ + + switch (ValDesc->Common.Type) + { + case ACPI_TYPE_NUMBER: + Buffer = (UINT8 *) &ValDesc->Number.Value; + Length = sizeof (ValDesc->Number.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = (UINT8 *) ValDesc->Buffer.Pointer; + Length = ValDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = (UINT8 *) ValDesc->String.Pointer; + Length = ValDesc->String.Length; + break; + } + + /* + * If the buffer is uninitialized, + * memory needs to be allocated for the copy. + */ + if(0 == DestDesc->Buffer.Length) + { + DestDesc->Buffer.Pointer = AcpiCmCallocate(Length); + DestDesc->Buffer.Length = Length; + + if (!DestDesc->Buffer.Pointer) + { + Status = AE_NO_MEMORY; + goto CleanUpAndBailOut; + } + } + + /* + * Buffer is a static allocation, + * only place what will fit in the buffer. + */ + if (Length <= DestDesc->Buffer.Length) + { + /* + * Zero fill first, not willing to do pointer arithmetic for + * architecture independence. Just clear the whole thing + */ + MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length); + MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length); + } + else + { + /* + * truncate, copy only what will fit + */ + MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length); + DEBUG_PRINT (ACPI_INFO, + ("AmlStoreObjectToObject: Truncating src buffer from %d to %d\n", + Length, DestDesc->Buffer.Length)); + } + break; + + case ACPI_TYPE_NUMBER: + + DestDesc->Number.Value = ValDesc->Number.Value; + break; + + default: + + /* + * All other types than Alias and the various Fields come here. + * Store ValDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * ValDesc reference count is incremented by AttachObject. + */ + + DEBUG_PRINT (ACPI_WARN, + ("AmlStoreObjectToObject: Store into %s not implemented\n", + AcpiCmGetTypeName (DestDesc->Common.Type))); + + Status = AE_NOT_IMPLEMENTED; + break; + } + +CleanUpAndBailOut: + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/exsystem.c b/sys/contrib/dev/acpica/exsystem.c new file mode 100644 index 0000000..d4c1923 --- /dev/null +++ b/sys/contrib/dev/acpica/exsystem.c @@ -0,0 +1,463 @@ + +/****************************************************************************** + * + * Module Name: amsystem - Interface to OS services + * $Revision: 52 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMSYSTEM_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amsystem") + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemThreadId + * + * PARAMETERS: None + * + * RETURN: Current Thread ID (for this implementation a 1 is returned) + * + * DESCRIPTION: An invocation is identified by its Thread ID. In a single + * threaded OS the Thread ID is undefined so a 1 will be + * returned. + * + ******************************************************************************/ + +UINT16 +AcpiAmlSystemThreadId (void) +{ + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemWaitSemaphore + * + * PARAMETERS: Semaphore - OSD semaphore to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a semaphore wait with a check to see if the + * semaphore is available immediately. If it is not, the + * interpreter is released. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemWaitSemaphore ( + ACPI_HANDLE Semaphore, + UINT32 Timeout) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiAmlSystemWaitSemaphore"); + + Status = AcpiOsWaitSemaphore (Semaphore, 1, 0); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiAmlExitInterpreter (); + + Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); + + /* Reacquire the interpreter */ + + AcpiAmlEnterInterpreter (); + + DEBUG_PRINT (TRACE_EXEC, + ("*** Thread awake and inside interpreter after blocking, %s\n", + AcpiCmFormatException (Status))); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemDoStall + * + * PARAMETERS: HowLong - The amount of time to stall + * + * RETURN: None + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * + ******************************************************************************/ + +void +AcpiAmlSystemDoStall ( + UINT32 HowLong) +{ + + if (HowLong > 1000) /* 1 millisecond */ + { + /* Since this thread will sleep, we must release the interpreter */ + + AcpiAmlExitInterpreter (); + + AcpiOsSleepUsec (HowLong); + + /* And now we must get the interpreter again */ + + AcpiAmlEnterInterpreter (); + } + + else + { + AcpiOsSleepUsec (HowLong); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemDoSuspend + * + * PARAMETERS: HowLong - The amount of time to suspend + * + * RETURN: None + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * + ******************************************************************************/ + +void +AcpiAmlSystemDoSuspend ( + UINT32 HowLong) +{ + /* Since this thread will sleep, we must release the interpreter */ + + AcpiAmlExitInterpreter (); + + AcpiOsSleep ((UINT16) (HowLong / (UINT32) 1000), + (UINT16) (HowLong % (UINT32) 1000)); + + /* And now we must get the interpreter again */ + + AcpiAmlEnterInterpreter (); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemAcquireMutex + * + * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor + * *ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. This function will cause a lock to be generated + * for the Mutex pointed to by ObjDesc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("AcpiAmlSystemAcquireMutex", ObjDesc); + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Support for the _GL_ Mutex object -- go get the global lock + */ + + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) + { + Status = AcpiEvAcquireGlobalLock (); + return_ACPI_STATUS (Status); + } + + Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Mutex.Semaphore, + (UINT32) TimeDesc->Number.Value); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemReleaseMutex + * + * PARAMETERS: *ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. This operation is a request to release a + * previously acquired Mutex. If the Mutex variable is set then + * it will be decremented. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiAmlSystemReleaseMutex"); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Support for the _GL_ Mutex object -- release the global lock + */ + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) + { + AcpiEvReleaseGlobalLock (); + return_ACPI_STATUS (AE_OK); + } + + Status = AcpiOsSignalSemaphore (ObjDesc->Mutex.Semaphore, 1); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemSignalEvent + * + * PARAMETERS: *ObjDesc - The object descriptor for this op + * + * RETURN: AE_OK + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemSignalEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiAmlSystemSignalEvent"); + + + if (ObjDesc) + { + Status = AcpiOsSignalSemaphore (ObjDesc->Event.Semaphore, 1); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemWaitEvent + * + * 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 +AcpiAmlSystemWaitEvent ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiAmlSystemWaitEvent"); + + + if (ObjDesc) + { + Status = AcpiAmlSystemWaitSemaphore (ObjDesc->Event.Semaphore, + (UINT32) TimeDesc->Number.Value); + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlSystemResetEvent + * + * PARAMETERS: *ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlSystemResetEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + void *TempSemaphore; + + + /* + * 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)) + { + AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore); + ObjDesc->Mutex.Semaphore = TempSemaphore; + } + + return (Status); +} + diff --git a/sys/contrib/dev/acpica/exutils.c b/sys/contrib/dev/acpica/exutils.c new file mode 100644 index 0000000..56dbc67 --- /dev/null +++ b/sys/contrib/dev/acpica/exutils.c @@ -0,0 +1,652 @@ + +/****************************************************************************** + * + * Module Name: amutils - interpreter/scanner utilities + * $Revision: 56 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMUTILS_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acevents.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amutils") + + +typedef struct Internal_Search_st +{ + ACPI_OPERAND_OBJECT *DestObj; + UINT32 Index; + ACPI_OPERAND_OBJECT *SourceObj; + +} INTERNAL_PKG_SEARCH_INFO; + + +/* Used to traverse nested packages when copying*/ + +INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH]; + + +static NATIVE_CHAR hex[] = + {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlEnterInterpreter + * + * PARAMETERS: None + * + * DESCRIPTION: Enter the interpreter execution region + * + ******************************************************************************/ + +void +AcpiAmlEnterInterpreter (void) +{ + FUNCTION_TRACE ("AmlEnterInterpreter"); + + + AcpiCmAcquireMutex (ACPI_MTX_EXECUTE); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExitInterpreter + * + * PARAMETERS: None + * + * DESCRIPTION: Exit the interpreter execution region + * + * Cases where the interpreter is unlocked: + * 1) Completion of the execution of a control method + * 2) Method blocked on a Sleep() AML opcode + * 3) Method blocked on an Acquire() AML opcode + * 4) Method blocked on a Wait() AML opcode + * 5) Method blocked to acquire the global lock + * 6) Method blocked to execute a serialized control method that is + * already executing + * 7) About to invoke a user-installed opregion handler + * + ******************************************************************************/ + +void +AcpiAmlExitInterpreter (void) +{ + FUNCTION_TRACE ("AmlExitInterpreter"); + + + AcpiCmReleaseMutex (ACPI_MTX_EXECUTE); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlValidateObjectType + * + * PARAMETERS: Type Object type to validate + * + * DESCRIPTION: Determine if a type is a valid ACPI object type + * + ******************************************************************************/ + +BOOLEAN +AcpiAmlValidateObjectType ( + ACPI_OBJECT_TYPE Type) +{ + + if ((Type > ACPI_TYPE_MAX && Type < INTERNAL_TYPE_BEGIN) || + (Type > INTERNAL_TYPE_MAX)) + { + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlBufSeq + * + * RETURN: The next buffer descriptor sequence number + * + * DESCRIPTION: Provide a unique sequence number for each Buffer descriptor + * allocated during the interpreter's existence. These numbers + * are used to relate FieldUnit descriptors to the Buffers + * within which the fields are defined. + * + * Just increment the global counter and return it. + * + ******************************************************************************/ + +UINT32 +AcpiAmlBufSeq (void) +{ + + return (++AcpiGbl_BufSeq); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlAcquireGlobalLock + * + * PARAMETERS: Rule - Lock rule: AlwaysLock, NeverLock + * + * RETURN: TRUE/FALSE indicating whether the lock was actually acquired + * + * DESCRIPTION: Obtain the global lock and keep track of this fact via two + * methods. A global variable keeps the state of the lock, and + * the state is returned to the caller. + * + ******************************************************************************/ + +BOOLEAN +AcpiAmlAcquireGlobalLock ( + UINT32 Rule) +{ + BOOLEAN Locked = FALSE; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlAcquireGlobalLock"); + + + /* Only attempt lock if the Rule says so */ + + if (Rule == (UINT32) GLOCK_ALWAYS_LOCK) + { + /* OK to get the lock */ + + Status = AcpiEvAcquireGlobalLock (); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("Get Global Lock Failed!!\n")); + } + + if (ACPI_SUCCESS (Status)) + { + AcpiGbl_GlobalLockSet = TRUE; + Locked = TRUE; + } + } + + return_VALUE (Locked); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlReleaseGlobalLock + * + * PARAMETERS: LockedByMe - Return value from corresponding call to + * AcquireGlobalLock. + * + * RETURN: Status + * + * DESCRIPTION: Release the global lock if it is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlReleaseGlobalLock ( + BOOLEAN LockedByMe) +{ + + FUNCTION_TRACE ("AmlReleaseGlobalLock"); + + + /* Only attempt unlock if the caller locked it */ + + if (LockedByMe) + { + /* Double check against the global flag */ + + if (AcpiGbl_GlobalLockSet) + { + /* OK, now release the lock */ + + AcpiEvReleaseGlobalLock (); + AcpiGbl_GlobalLockSet = FALSE; + } + + else + { + DEBUG_PRINT (ACPI_ERROR, ("Global lock was not set\n")); + } + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlDigitsNeeded + * + * PARAMETERS: val - Value to be represented + * base - Base of representation + * + * RETURN: the number of digits needed to represent val in base + * + ******************************************************************************/ + +UINT32 +AcpiAmlDigitsNeeded ( + ACPI_INTEGER val, + UINT32 base) +{ + UINT32 NumDigits = 0; + + + FUNCTION_TRACE ("AmlDigitsNeeded"); + + + if (base < 1) + { + REPORT_ERROR (("AmlDigitsNeeded: Internal error - Invalid base\n")); + } + + else + { + for (NumDigits = 1 + (val < 0) ; val /= base ; ++NumDigits) + { ; } + } + + return_VALUE (NumDigits); +} + + +/******************************************************************************* + * + * FUNCTION: ntohl + * + * PARAMETERS: Value - Value to be converted + * + * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) + * + ******************************************************************************/ + +UINT32 +_ntohl ( + UINT32 Value) +{ + union + { + UINT32 Value; + UINT8 Bytes[4]; + } Out; + + union + { + UINT32 Value; + UINT8 Bytes[4]; + } In; + + + 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: AcpiAmlEisaIdToString + * + * PARAMETERS: NumericId - EISA ID to be converted + * OutString - Where to put the converted string (8 bytes) + * + * DESCRIPTION: Convert a numeric EISA ID to string representation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlEisaIdToString ( + UINT32 NumericId, + NATIVE_CHAR *OutString) +{ + UINT32 id; + + /* swap to big-endian to get contiguous bits */ + + id = _ntohl (NumericId); + + OutString[0] = (char) ('@' + ((id >> 26) & 0x1f)); + OutString[1] = (char) ('@' + ((id >> 21) & 0x1f)); + OutString[2] = (char) ('@' + ((id >> 16) & 0x1f)); + OutString[3] = hex[(id >> 12) & 0xf]; + OutString[4] = hex[(id >> 8) & 0xf]; + OutString[5] = hex[(id >> 4) & 0xf]; + OutString[6] = hex[id & 0xf]; + OutString[7] = 0; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlUnsignedIntegerToString + * + * PARAMETERS: Value - Value to be converted + * OutString - Where to put the converted string (8 bytes) + * + * RETURN: Convert a number to string representation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlUnsignedIntegerToString ( + ACPI_INTEGER Value, + NATIVE_CHAR *OutString) +{ + UINT32 Count; + UINT32 DigitsNeeded; + + + DigitsNeeded = AcpiAmlDigitsNeeded (Value, 10); + + OutString[DigitsNeeded] = '\0'; + + for (Count = DigitsNeeded; Count > 0; Count--) + { + OutString[Count-1] = (NATIVE_CHAR) ('0' + (Value % 10)); + Value /= 10; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlBuildCopyInternalPackageObject + * + * PARAMETERS: *SourceObj - Pointer to the source package object + * *DestObj - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to copy an internal package object + * into another internal package object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlBuildCopyInternalPackageObject ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState) +{ + UINT32 CurrentDepth = 0; + ACPI_STATUS Status = AE_OK; + UINT32 Length = 0; + UINT32 ThisIndex; + UINT32 ObjectSpace = 0; + ACPI_OPERAND_OBJECT *ThisDestObj; + ACPI_OPERAND_OBJECT *ThisSourceObj; + INTERNAL_PKG_SEARCH_INFO *LevelPtr; + + + FUNCTION_TRACE ("AmlBuildCopyInternalPackageObject"); + + + /* + * Initialize the working variables + */ + + MEMSET ((void *) CopyLevel, 0, sizeof(CopyLevel)); + + CopyLevel[0].DestObj = DestObj; + CopyLevel[0].SourceObj = SourceObj; + LevelPtr = &CopyLevel[0]; + CurrentDepth = 0; + + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Package.Count = SourceObj->Package.Count; + + + /* + * Build an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + + DestObj->Package.Elements = AcpiCmCallocate ( + (DestObj->Package.Count + 1) * + sizeof (void *)); + if (!DestObj->Package.Elements) + { + /* Package vector allocation failure */ + + REPORT_ERROR (("AmlBuildCopyInternalPackageObject: Package vector allocation failure\n")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + DestObj->Package.NextElement = DestObj->Package.Elements; + + + while (1) + { + ThisIndex = LevelPtr->Index; + ThisDestObj = (ACPI_OPERAND_OBJECT *) LevelPtr->DestObj->Package.Elements[ThisIndex]; + ThisSourceObj = (ACPI_OPERAND_OBJECT *) LevelPtr->SourceObj->Package.Elements[ThisIndex]; + + if (IS_THIS_OBJECT_TYPE (ThisSourceObj, ACPI_TYPE_PACKAGE)) + { + /* + * If this object is a package then we go one deeper + */ + if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) + { + /* + * Too many nested levels of packages for us to handle + */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlBuildCopyInternalPackageObject: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* + * Build the package object + */ + ThisDestObj = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); + LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; + + + ThisDestObj->Common.Type = ACPI_TYPE_PACKAGE; + ThisDestObj->Package.Count = ThisDestObj->Package.Count; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = ThisDestObj->Package.Count * + sizeof (ACPI_OPERAND_OBJECT); + Length += ObjectSpace; + CurrentDepth++; + LevelPtr = &CopyLevel[CurrentDepth]; + LevelPtr->DestObj = ThisDestObj; + LevelPtr->SourceObj = ThisSourceObj; + LevelPtr->Index = 0; + + } /* if object is a package */ + + else + { + + ThisDestObj = AcpiCmCreateInternalObject ( + ThisSourceObj->Common.Type); + LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; + + Status = AcpiAmlStoreObjectToObject(ThisSourceObj, ThisDestObj, WalkState); + + if (ACPI_FAILURE (Status)) + { + /* + * Failure get out + */ + return_ACPI_STATUS (Status); + } + + Length +=ObjectSpace; + + LevelPtr->Index++; + while (LevelPtr->Index >= LevelPtr->DestObj->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 + */ + if (CurrentDepth == 0) + { + /* + * 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. + */ + CurrentDepth--; + LevelPtr = &CopyLevel[CurrentDepth]; + LevelPtr->Index++; + } + } /* else object is NOT a package */ + } /* while (1) */ +} + + diff --git a/sys/contrib/dev/acpica/exxface.c b/sys/contrib/dev/acpica/exxface.c new file mode 100644 index 0000000..1c0380e --- /dev/null +++ b/sys/contrib/dev/acpica/exxface.c @@ -0,0 +1,190 @@ + +/****************************************************************************** + * + * Module Name: amxface - External interpreter interfaces + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __AMXFACE_C__ + +#include "acpi.h" +#include "acinterp.h" + + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amxface") + + +/* + * 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 "amlcode.h" +#include "acparser.h" +#include "acnamesp.h" + + +/******************************************************************************* + * + * FUNCTION: AcpiAmlExecuteMethod + * + * PARAMETERS: Pcode - Pointer to the pcode stream + * PcodeLength - Length of pcode that comprises the method + * **Params - List of parameters to pass to method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAmlExecuteMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AmlExecuteMethod"); + + + /* + * The point here is to lock the interpreter and call the low + * level execute. + */ + + AcpiAmlEnterInterpreter (); + + Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc); + + AcpiAmlExitInterpreter (); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/hwacpi.c b/sys/contrib/dev/acpica/hwacpi.c new file mode 100644 index 0000000..e709688 --- /dev/null +++ b/sys/contrib/dev/acpica/hwacpi.c @@ -0,0 +1,501 @@ +/****************************************************************************** + * + * Module Name: hwacpi - ACPI hardware functions - mode and timer + * $Revision: 24 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWACPI_C__ + +#include "acpi.h" +#include "achware.h" + + +#define _COMPONENT HARDWARE + MODULE_NAME ("hwacpi") + + +/****************************************************************************** + * + * FUNCTION: AcpiHwInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize and validate various ACPI registers + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwInitialize ( + void) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Index; + + + FUNCTION_TRACE ("HwInitialize"); + + + /* We must have the ACPI tables by the time we get here */ + + if (!AcpiGbl_FACP) + { + AcpiGbl_RestoreAcpiChipset = FALSE; + + DEBUG_PRINT (ACPI_ERROR, ("HwInitialize: No FACP!\n")); + + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Must support *some* mode! */ +/* + if (!(SystemFlags & SYS_MODES_MASK)) + { + RestoreAcpiChipset = FALSE; + + DEBUG_PRINT (ACPI_ERROR, + ("CmHardwareInitialize: Supported modes uninitialized!\n")); + return_ACPI_STATUS (AE_ERROR); + } + +*/ + + + switch (AcpiGbl_SystemFlags & SYS_MODES_MASK) + { + /* Identify current ACPI/legacy mode */ + + case (SYS_MODE_ACPI): + + AcpiGbl_OriginalMode = SYS_MODE_ACPI; + DEBUG_PRINT (ACPI_INFO, ("System supports ACPI mode only.\n")); + break; + + + case (SYS_MODE_LEGACY): + + AcpiGbl_OriginalMode = SYS_MODE_LEGACY; + DEBUG_PRINT (ACPI_INFO, + ("Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n")); + break; + + + case (SYS_MODE_ACPI | SYS_MODE_LEGACY): + + if (AcpiHwGetMode () == SYS_MODE_ACPI) + { + AcpiGbl_OriginalMode = SYS_MODE_ACPI; + } + else + { + AcpiGbl_OriginalMode = SYS_MODE_LEGACY; + } + + DEBUG_PRINT (ACPI_INFO, + ("System supports both ACPI and LEGACY modes.\n")); + + DEBUG_PRINT (ACPI_INFO, + ("System is currently in %s mode.\n", + (AcpiGbl_OriginalMode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY")); + break; + } + + + if (AcpiGbl_SystemFlags & SYS_MODE_ACPI) + { + /* Target system supports ACPI mode */ + + /* + * The purpose of this block of code is to save the initial state + * of the ACPI event enable registers. An exit function will be + * registered which will restore this state when the application + * exits. The exit function will also clear all of the ACPI event + * status bits prior to restoring the original mode. + * + * The location of the PM1aEvtBlk enable registers is defined as the + * base of PM1aEvtBlk + PM1aEvtBlkLength / 2. Since the spec further + * fully defines the PM1aEvtBlk to be a total of 4 bytes, the offset + * for the enable registers is always 2 from the base. It is hard + * coded here. If this changes in the spec, this code will need to + * be modified. The PM1bEvtBlk behaves as expected. + */ + + AcpiGbl_Pm1EnableRegisterSave = + AcpiOsIn16 ((AcpiGbl_FACP->Pm1aEvtBlk + 2)); + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiGbl_Pm1EnableRegisterSave |= + AcpiOsIn16 ((AcpiGbl_FACP->Pm1bEvtBlk + 2)); + } + + + /* + * The GPEs behave similarly, except that the length of the register + * block is not fixed, so the buffer must be allocated with malloc + */ + + if (AcpiGbl_FACP->Gpe0Blk && AcpiGbl_FACP->Gpe0BlkLen) + { + /* GPE0 specified in FACP */ + + AcpiGbl_Gpe0EnableRegisterSave = + AcpiCmAllocate (DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)); + if (!AcpiGbl_Gpe0EnableRegisterSave) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save state of GPE0 enable bits */ + + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); Index++) + { + AcpiGbl_Gpe0EnableRegisterSave[Index] = + AcpiOsIn8 (AcpiGbl_FACP->Gpe0Blk + + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen)); + } + } + + else + { + AcpiGbl_Gpe0EnableRegisterSave = NULL; + } + + if (AcpiGbl_FACP->Gpe1Blk && AcpiGbl_FACP->Gpe1BlkLen) + { + /* GPE1 defined */ + + AcpiGbl_Gpe1EnableRegisterSave = + AcpiCmAllocate (DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)); + if (!AcpiGbl_Gpe1EnableRegisterSave) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* save state of GPE1 enable bits */ + + for (Index = 0; Index < DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); Index++) + { + AcpiGbl_Gpe1EnableRegisterSave[Index] = + AcpiOsIn8 (AcpiGbl_FACP->Gpe1Blk + + DIV_2 (AcpiGbl_FACP->Gpe1BlkLen)); + } + } + + else + { + AcpiGbl_Gpe1EnableRegisterSave = NULL; + } + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwSetMode + * + * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * RETURN: Status + * + * DESCRIPTION: Transitions the system into the requested mode or does nothing + * if the system is already in that mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode) +{ + + ACPI_STATUS Status = AE_ERROR; + + FUNCTION_TRACE ("HwSetMode"); + + + if (Mode == SYS_MODE_ACPI) + { + /* BIOS should have disabled ALL fixed and GP events */ + + AcpiOsOut8 (AcpiGbl_FACP->SmiCmd, AcpiGbl_FACP->AcpiEnable); + DEBUG_PRINT (ACPI_INFO, ("Attempting to enable ACPI mode\n")); + } + + else if (Mode == SYS_MODE_LEGACY) + { + /* + * BIOS should clear all fixed status bits and restore fixed event + * enable bits to default + */ + + AcpiOsOut8 (AcpiGbl_FACP->SmiCmd, AcpiGbl_FACP->AcpiDisable); + DEBUG_PRINT (ACPI_INFO, + ("Attempting to enable Legacy (non-ACPI) mode\n")); + } + + if (AcpiHwGetMode () == Mode) + { + DEBUG_PRINT (ACPI_INFO, ("Mode %d successfully enabled\n", Mode)); + Status = AE_OK; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetMode + * + * PARAMETERS: none + * + * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * DESCRIPTION: Return current operating state of system. Determined by + * querying the SCI_EN bit. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetMode (void) +{ + + FUNCTION_TRACE ("HwGetMode"); + + + if (AcpiHwRegisterAccess (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) + { + return_VALUE (SYS_MODE_ACPI); + } + else + { + return_VALUE (SYS_MODE_LEGACY); + } +} + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetModeCapabilities + * + * PARAMETERS: none + * + * RETURN: logical OR of SYS_MODE_ACPI and SYS_MODE_LEGACY determined at initial + * system state. + * + * DESCRIPTION: Returns capablities of system + * + ******************************************************************************/ + +UINT32 +AcpiHwGetModeCapabilities (void) +{ + + FUNCTION_TRACE ("HwGetModeCapabilities"); + + + if (!(AcpiGbl_SystemFlags & SYS_MODES_MASK)) + { + if (AcpiHwGetMode () == SYS_MODE_LEGACY) + { + /* + * Assume that if this call is being made, AcpiInit has been called + * and ACPI support has been established by the presence of the + * tables. Therefore since we're in SYS_MODE_LEGACY, the system + * must support both modes + */ + + AcpiGbl_SystemFlags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); + } + + else + { + /* TBD: [Investigate] !!! this may be unsafe... */ + /* + * system is is ACPI mode, so try to switch back to LEGACY to see if + * it is supported + */ + AcpiHwSetMode (SYS_MODE_LEGACY); + + if (AcpiHwGetMode () == SYS_MODE_LEGACY) + { + /* Now in SYS_MODE_LEGACY, so both are supported */ + + AcpiGbl_SystemFlags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); + AcpiHwSetMode (SYS_MODE_ACPI); + } + + else + { + /* Still in SYS_MODE_ACPI so this must be an ACPI only system */ + + AcpiGbl_SystemFlags |= SYS_MODE_ACPI; + } + } + } + + return_VALUE (AcpiGbl_SystemFlags & SYS_MODES_MASK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwPmtTicks + * + * PARAMETERS: none + * + * RETURN: Current value of the ACPI PMT (timer) + * + * DESCRIPTION: Obtains current value of ACPI PMT + * + ******************************************************************************/ + +UINT32 +AcpiHwPmtTicks (void) +{ + UINT32 Ticks; + + FUNCTION_TRACE ("AcpiPmtTicks"); + + Ticks = AcpiOsIn32 (AcpiGbl_FACP->PmTmrBlk); + + return_VALUE (Ticks); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwPmtResolution + * + * PARAMETERS: none + * + * RETURN: Number of bits of resolution in the PMT (either 24 or 32) + * + * DESCRIPTION: Obtains resolution of the ACPI PMT (either 24bit or 32bit) + * + ******************************************************************************/ + +UINT32 +AcpiHwPmtResolution (void) +{ + FUNCTION_TRACE ("AcpiPmtResolution"); + + if (0 == AcpiGbl_FACP->TmrValExt) + { + return_VALUE (24); + } + + return_VALUE (32); +} + diff --git a/sys/contrib/dev/acpica/hwgpe.c b/sys/contrib/dev/acpica/hwgpe.c new file mode 100644 index 0000000..2385116 --- /dev/null +++ b/sys/contrib/dev/acpica/hwgpe.c @@ -0,0 +1,303 @@ +/****************************************************************************** + * + * Module Name: hwgpe - Low level GPE enable/disable/clear functions + * $Revision: 22 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" + +#define _COMPONENT HARDWARE + MODULE_NAME ("hwgpe") + + +UINT8 DecodeTo8bit [8] = {1,2,4,8,16,32,64,128}; + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableGpe + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Enable a single GPE. + * + ******************************************************************************/ + +void +AcpiHwEnableGpe ( + UINT32 GpeNumber) +{ + UINT8 InByte; + UINT32 RegisterIndex; + UINT8 BitMask; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Read the current value of the register, set the appropriate bit + * to enable the GPE, and write out the new register. + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, + (UINT8)(InByte | BitMask)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableGpe + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Disable a single GPE. + * + ******************************************************************************/ + +void +AcpiHwDisableGpe ( + UINT32 GpeNumber) +{ + UINT8 InByte; + UINT32 RegisterIndex; + UINT8 BitMask; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Read the current value of the register, clear the appropriate bit, + * and write out the new register value to disable the GPE. + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr); + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, + (UINT8)(InByte & ~BitMask)); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpe + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Clear a single GPE. + * + ******************************************************************************/ + +void +AcpiHwClearGpe ( + UINT32 GpeNumber) +{ + UINT32 RegisterIndex; + UINT8 BitMask; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Write a one to the appropriate bit in the status register to + * clear this GPE. + */ + AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, BitMask); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetGpeStatus + * + * PARAMETERS: GpeNumber - The GPE + * + * RETURN: None + * + * DESCRIPTION: Return the status of a single GPE. + * + ******************************************************************************/ + +void +AcpiHwGetGpeStatus ( + UINT32 GpeNumber, + ACPI_EVENT_STATUS *EventStatus) +{ + UINT8 InByte = 0; + UINT32 RegisterIndex = 0; + UINT8 BitMask = 0; + + if (!EventStatus) + { + return; + } + + (*EventStatus) = 0; + + /* + * Translate GPE number to index into global registers array. + */ + RegisterIndex = AcpiGbl_GpeValid[GpeNumber]; + + /* + * Figure out the bit offset for this GPE within the target register. + */ + BitMask = DecodeTo8bit [MOD_8 (GpeNumber)]; + + /* + * Enabled?: + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr); + + if (BitMask & InByte) + { + (*EventStatus) |= ACPI_EVENT_FLAG_ENABLED; + } + + /* + * Set? + */ + InByte = AcpiOsIn8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr); + + if (BitMask & InByte) + { + (*EventStatus) |= ACPI_EVENT_FLAG_SET; + } +} diff --git a/sys/contrib/dev/acpica/hwregs.c b/sys/contrib/dev/acpica/hwregs.c new file mode 100644 index 0000000..dab4533 --- /dev/null +++ b/sys/contrib/dev/acpica/hwregs.c @@ -0,0 +1,825 @@ + +/******************************************************************************* + * + * Module Name: hwregs - Read/write access functions for the various ACPI + * control and status registers. + * $Revision: 71 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __HWREGS_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" + +#define _COMPONENT HARDWARE + MODULE_NAME ("hwregs") + + +/* This matches the #defines in actypes.h. */ + +NATIVE_CHAR *SleepStateTable[] = {"\\_S0_","\\_S1_","\\_S2_","\\_S3_", + "\\_S4_","\\_S4B","\\_S5_"}; + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetBitShift + * + * PARAMETERS: Mask - Input mask to determine bit shift from. + * Must have at least 1 bit set. + * + * RETURN: Bit location of the lsb of the mask + * + * DESCRIPTION: Returns the bit number for the low order bit that's set. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetBitShift ( + UINT32 Mask) +{ + UINT32 Shift; + + + FUNCTION_TRACE ("HwGetBitShift"); + + + for (Shift = 0; ((Mask >> Shift) & 1) == 0; Shift++) + { ; } + + return_VALUE (Shift); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwClearAcpiStatus + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Clears all fixed and general purpose status bits + * + ******************************************************************************/ + +void +AcpiHwClearAcpiStatus (void) +{ + UINT16 GpeLength; + UINT16 Index; + + + FUNCTION_TRACE ("HwClearAcpiStatus"); + + + DEBUG_PRINT (TRACE_IO, ("About to write %04X to %04X\n", + ALL_FIXED_STS_BITS, (UINT16) AcpiGbl_FACP->Pm1aEvtBlk)); + + + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + + AcpiOsOut16 (AcpiGbl_FACP->Pm1aEvtBlk, (UINT16) ALL_FIXED_STS_BITS); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiOsOut16 ((UINT16) AcpiGbl_FACP->Pm1bEvtBlk, + (UINT16) ALL_FIXED_STS_BITS); + } + + /* now clear the GPE Bits */ + + if (AcpiGbl_FACP->Gpe0BlkLen) + { + GpeLength = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); + + for (Index = 0; Index < GpeLength; Index++) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe0Blk + Index), (UINT8) 0xff); + } + } + + if (AcpiGbl_FACP->Gpe1BlkLen) + { + GpeLength = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe1BlkLen); + + for (Index = 0; Index < GpeLength; Index++) + { + AcpiOsOut8 ((AcpiGbl_FACP->Gpe1Blk + Index), (UINT8) 0xff); + } + } + + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwObtainSleepTypeRegisterData + * + * PARAMETERS: SleepState - Numeric state requested + * *Slp_TypA - Pointer to byte to receive SLP_TYPa value + * *Slp_TypB - Pointer to byte to receive SLP_TYPb value + * + * RETURN: Status - ACPI status + * + * DESCRIPTION: AcpiHwObtainSleepTypeRegisterData() obtains the SLP_TYP and + * SLP_TYPb values for the sleep state requested. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwObtainSleepTypeRegisterData ( + UINT8 SleepState, + UINT8 *Slp_TypA, + UINT8 *Slp_TypB) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("HwObtainSleepTypeRegisterData"); + + + /* + * Validate parameters + */ + + if ((SleepState > ACPI_S_STATES_MAX) || + !Slp_TypA || !Slp_TypB) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * AcpiEvaluate the namespace object containing the values for this state + */ + + Status = AcpiNsEvaluateByName (SleepStateTable[SleepState], NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!ObjDesc) + { + REPORT_ERROR (("Missing Sleep State object\n")); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * We got something, now ensure it is correct. The object must + * be a package and must have at least 2 numeric values as the + * two elements + */ + + Status = AcpiCmResolvePackageReferences(ObjDesc); + + if (ObjDesc->Package.Count < 2) + { + /* Must have at least two elements */ + + REPORT_ERROR (("Sleep State package does not have at least two elements\n")); + Status = AE_ERROR; + } + + else if (((ObjDesc->Package.Elements[0])->Common.Type != + ACPI_TYPE_NUMBER) || + ((ObjDesc->Package.Elements[1])->Common.Type != + ACPI_TYPE_NUMBER)) + { + /* Must have two */ + + REPORT_ERROR (("Sleep State package elements are not both of type Number\n")); + Status = AE_ERROR; + } + + else + { + /* + * Valid _Sx_ package size, type, and value + */ + *Slp_TypA = (UINT8) (ObjDesc->Package.Elements[0])->Number.Value; + + *Slp_TypB = (UINT8) (ObjDesc->Package.Elements[1])->Number.Value; + } + + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("SleepTypeRegisterData: Bad Sleep object %p type %X\n", + ObjDesc, ObjDesc->Common.Type)); + } + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwRegisterAccess + * + * PARAMETERS: ReadWrite - Either ACPI_READ or ACPI_WRITE. + * UseLock - Lock the hardware + * RegisterId - index of ACPI register to access + * Value - (only used on write) value to write to the + * register. Shifted all the way right. + * + * RETURN: Value written to or read from specified register. This value + * is shifted all the way right. + * + * DESCRIPTION: Generic ACPI register read/write function. + * + ******************************************************************************/ + +UINT32 +AcpiHwRegisterAccess ( + NATIVE_UINT ReadWrite, + BOOLEAN UseLock, + UINT32 RegisterId, + ...) /* Value (only used on write) */ +{ + UINT32 RegisterValue = 0; + UINT32 Mask = 0; + UINT32 Value = 0; + ACPI_IO_ADDRESS GpeReg = 0; + + + FUNCTION_TRACE ("HwRegisterIO"); + + + if (ReadWrite == ACPI_WRITE) + { + va_list marker; + + va_start (marker, RegisterId); + Value = va_arg (marker, UINT32); + va_end (marker); + } + + /* + * TBD: [Restructure] May want to split the AcpiEvent code and the + * Control code + */ + + /* + * Decode the Register ID + */ + + switch (RegisterId & REGISTER_BLOCK_MASK) + { + case PM1_EVT: + + if (RegisterId < TMR_EN) + { + /* status register */ + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk); + DEBUG_PRINT (TRACE_IO, ("PM1a status: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1aEvtBlk)); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + RegisterValue |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk); + DEBUG_PRINT (TRACE_IO, ("PM1b status: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1bEvtBlk)); + } + + switch (RegisterId) + { + case TMR_STS: + Mask = TMR_STS_MASK; + break; + + case BM_STS: + Mask = BM_STS_MASK; + break; + + case GBL_STS: + Mask = GBL_STS_MASK; + break; + + case PWRBTN_STS: + Mask = PWRBTN_STS_MASK; + break; + + case SLPBTN_STS: + Mask = SLPBTN_STS_MASK; + break; + + case RTC_STS: + Mask = RTC_STS_MASK; + break; + + case WAK_STS: + Mask = WAK_STS_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + /* + * Status registers are different from the rest. Clear by + * writing 1, writing 0 has no effect. So, the only relevent + * information is the single bit we're interested in, all + * others should be written as 0 so they will be left + * unchanged + */ + + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + + if (Value) + { + DEBUG_PRINT (TRACE_IO, + ("About to write 0x%X to 0x%X\n", Value, + AcpiGbl_FACP->Pm1aEvtBlk)); + + AcpiOsOut16 (AcpiGbl_FACP->Pm1aEvtBlk, (UINT16) Value); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiOsOut16 (AcpiGbl_FACP->Pm1bEvtBlk, (UINT16) Value); + } + + RegisterValue = 0; + } + } + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + } + + else + { + /* enable register */ + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + + DEBUG_PRINT (TRACE_IO, ("PM1a enable: Read 0x%X from 0x%X\n", + RegisterValue, (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)))); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + RegisterValue |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)); + + DEBUG_PRINT (TRACE_IO, ("PM1b enable: Read 0x%X from 0x%X\n", + RegisterValue, (AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)))); + } + + switch (RegisterId) + { + case TMR_EN: + Mask = TMR_EN_MASK; + break; + + case GBL_EN: + Mask = GBL_EN_MASK; + break; + + case PWRBTN_EN: + Mask = PWRBTN_EN_MASK; + break; + + case SLPBTN_EN: + Mask = SLPBTN_EN_MASK; + break; + + case RTC_EN: + Mask = RTC_EN_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + DEBUG_PRINT (TRACE_IO, + ("About to write %04X to %04X\n", RegisterValue, + (AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)))); + + AcpiOsOut16 ((AcpiGbl_FACP->Pm1aEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)), + (UINT16) RegisterValue); + + if (AcpiGbl_FACP->Pm1bEvtBlk) + { + AcpiOsOut16 ((AcpiGbl_FACP->Pm1bEvtBlk + + DIV_2 (AcpiGbl_FACP->Pm1EvtLen)), + (UINT16) RegisterValue); + } + } + if(ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + } + break; + + + case PM1_CONTROL: + + RegisterValue = 0; + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + if (RegisterId != SLP_TYPE_B) + { + /* + * SLP_TYPx registers are written differently + * than any other control registers with + * respect to A and B registers. The value + * for A may be different than the value for B + */ + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aCntBlk); + DEBUG_PRINT (TRACE_IO, ("PM1a control: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1aCntBlk)); + } + + if (AcpiGbl_FACP->Pm1bCntBlk && RegisterId != (UINT32) SLP_TYPE_A) + { + RegisterValue |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bCntBlk); + DEBUG_PRINT (TRACE_IO, ("PM1b control: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm1bCntBlk)); + } + + switch (RegisterId) + { + case SCI_EN: + Mask = SCI_EN_MASK; + break; + + case BM_RLD: + Mask = BM_RLD_MASK; + break; + + case GBL_RLS: + Mask = GBL_RLS_MASK; + break; + + case SLP_TYPE_A: + case SLP_TYPE_B: + Mask = SLP_TYPE_X_MASK; + break; + + case SLP_EN: + Mask = SLP_EN_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + /* + * SLP_TYPE_x registers are written differently + * than any other control registers with + * respect to A and B registers. The value + * for A may be different than the value for B + */ + + if (RegisterId != SLP_TYPE_B) + { + if (Mask == SLP_EN_MASK) + { + disable(); /* disable interrupts */ + } + + AcpiOsOut16 (AcpiGbl_FACP->Pm1aCntBlk, (UINT16) RegisterValue); + + if (Mask == SLP_EN_MASK) + { + /* + * Enable interrupts, the SCI handler is likely going to + * be invoked as soon as interrupts are enabled, since gpe's + * and most fixed resume events also generate SCI's. + */ + enable(); + } + } + + if (AcpiGbl_FACP->Pm1bCntBlk && RegisterId != (UINT32) SLP_TYPE_A) + { + AcpiOsOut16 (AcpiGbl_FACP->Pm1bCntBlk, (UINT16) RegisterValue); + } + } + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + break; + + + case PM2_CONTROL: + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + RegisterValue = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm2CntBlk); + DEBUG_PRINT (TRACE_IO, ("PM2 control: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->Pm2CntBlk)); + + switch (RegisterId) + { + case ARB_DIS: + Mask = ARB_DIS_MASK; + break; + + default: + Mask = 0; + break; + } + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + DEBUG_PRINT (TRACE_IO, + ("About to write %04X to %04X\n", RegisterValue, + AcpiGbl_FACP->Pm2CntBlk)); + + AcpiOsOut16 (AcpiGbl_FACP->Pm2CntBlk, (UINT16) RegisterValue); + } + + if (ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + break; + + + case PM_TIMER: + + RegisterValue = AcpiOsIn32 (AcpiGbl_FACP->PmTmrBlk); + DEBUG_PRINT (TRACE_IO, ("PM_TIMER: Read 0x%X from 0x%X\n", + RegisterValue, AcpiGbl_FACP->PmTmrBlk)); + + Mask = ACPI_UINT32_MAX; + break; + + + case GPE1_EN_BLOCK: + + GpeReg = (AcpiGbl_FACP->Gpe1Blk + AcpiGbl_FACP->Gpe1Base) + + (GpeReg + (DIV_2 (AcpiGbl_FACP->Gpe1BlkLen))); + + + case GPE1_STS_BLOCK: + + if (!GpeReg) + { + GpeReg = (AcpiGbl_FACP->Gpe1Blk + AcpiGbl_FACP->Gpe1Base); + } + + + case GPE0_EN_BLOCK: + + if (!GpeReg) + { + GpeReg = AcpiGbl_FACP->Gpe0Blk + DIV_2 (AcpiGbl_FACP->Gpe0BlkLen); + } + + + case GPE0_STS_BLOCK: + + if (!GpeReg) + { + GpeReg = AcpiGbl_FACP->Gpe0Blk; + } + + /* Determine the bit to be accessed */ + + Mask = (((UINT32) RegisterId) & BIT_IN_REGISTER_MASK); + Mask = 1 << (Mask-1); + + /* + * The base address of the GPE 0 Register Block + * Plus 1/2 the length of the GPE 0 Register Block + * The enable register is the register following the Status Register + * and each register is defined as 1/2 of the total Register Block + */ + + /* + * This sets the bit within EnableBit that needs to be written to + * the register indicated in Mask to a 1, all others are 0 + */ + + if (Mask > LOW_BYTE) + { + /* Shift the value 1 byte to the right and add 1 to the register */ + + Mask >>= ONE_BYTE; + GpeReg++; + } + + /* Now get the current Enable Bits in the selected Reg */ + + if(ACPI_MTX_LOCK == UseLock) + { + AcpiCmAcquireMutex (ACPI_MTX_HARDWARE); + } + + RegisterValue = (UINT32) AcpiOsIn8 (GpeReg); + DEBUG_PRINT (TRACE_IO, ("GPE Enable bits: Read 0x%X from 0x%X\n", + RegisterValue, GpeReg)); + + if (ReadWrite == ACPI_WRITE) + { + RegisterValue &= ~Mask; + Value <<= AcpiHwGetBitShift (Mask); + Value &= Mask; + RegisterValue |= Value; + + /* This write will put the Action state into the General Purpose */ + + /* Enable Register indexed by the value in Mask */ + + DEBUG_PRINT (TRACE_IO, ("About to write %04X to %04X\n", + RegisterValue, GpeReg)); + + AcpiOsOut8 (GpeReg, (UINT8) RegisterValue); + RegisterValue = (UINT32) AcpiOsIn8 (GpeReg); + } + + if(ACPI_MTX_LOCK == UseLock) + { + AcpiCmReleaseMutex (ACPI_MTX_HARDWARE); + } + break; + + + case PROCESSOR_BLOCK: + default: + + Mask = 0; + break; + } + + + RegisterValue &= Mask; + RegisterValue >>= AcpiHwGetBitShift (Mask); + + DEBUG_PRINT (TRACE_IO, ("Register I/O: returning 0x%X\n", RegisterValue)); + return_VALUE (RegisterValue); +} diff --git a/sys/contrib/dev/acpica/nsaccess.c b/sys/contrib/dev/acpica/nsaccess.c new file mode 100644 index 0000000..78bd747 --- /dev/null +++ b/sys/contrib/dev/acpica/nsaccess.c @@ -0,0 +1,737 @@ +/******************************************************************************* + * + * Module Name: nsaccess - Top-level functions for accessing ACPI namespace + * $Revision: 111 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSACCESS_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT NAMESPACE + 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 = AE_OK; + PREDEFINED_NAMES *InitVal = NULL; + ACPI_NAMESPACE_NODE *NewNode; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("NsRootInitialize"); + + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* + * 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 */ + + DEBUG_PRINT (ACPI_INFO, + ("Entering predefined name table entries into namespace\n")); + + for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) + { + Status = AcpiNsLookup (NULL, InitVal->Name, + (OBJECT_TYPE_INTERNAL) InitVal->Type, + IMODE_LOAD_PASS2, NS_NO_UPSEARCH, + NULL, &NewNode); + + if (ACPI_FAILURE (Status) || + (!NewNode)) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not create predefined name %s, %s\n", + InitVal->Name, AcpiCmFormatException (Status))); + } + + /* + * Name entered successfully. + * If entry in PreDefinedNames[] specifies an + * initial value, create the initial value. + */ + + if (InitVal->Val) + { + /* + * Entry requests an initial value, allocate a + * descriptor for it. + */ + + ObjDesc = AcpiCmCreateInternalObject ( + (OBJECT_TYPE_INTERNAL) 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_NUMBER: + + ObjDesc->Number.Value = + (ACPI_INTEGER) STRTOUL (InitVal->Val, NULL, 10); + break; + + + case ACPI_TYPE_STRING: + + ObjDesc->String.Length = + (UINT16) STRLEN (InitVal->Val); + + /* + * Allocate a buffer for the string. All + * String.Pointers must be allocated buffers! + * (makes deletion simpler) + */ + ObjDesc->String.Pointer = AcpiCmAllocate ( + (ObjDesc->String.Length + 1)); + if (!ObjDesc->String.Pointer) + { + AcpiCmRemoveReference (ObjDesc); + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + STRCPY (ObjDesc->String.Pointer, InitVal->Val); + break; + + + case ACPI_TYPE_MUTEX: + + ObjDesc->Mutex.SyncLevel = + (UINT16) STRTOUL (InitVal->Val, NULL, 10); + + if (STRCMP (InitVal->Name, "_GL_") == 0) + { + /* + * Create a counting semaphore for the + * global lock + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, + 1, &ObjDesc->Mutex.Semaphore); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + /* + * We just created the mutex for the + * global lock, save it + */ + + AcpiGbl_GlobalLockSemaphore = ObjDesc->Mutex.Semaphore; + } + + else + { + /* Create a mutex */ + + Status = AcpiOsCreateSemaphore (1, 1, + &ObjDesc->Mutex.Semaphore); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + break; + + + default: + REPORT_ERROR (("Unsupported initial type value %X\n", + InitVal->Type)); + AcpiCmRemoveReference (ObjDesc); + ObjDesc = NULL; + continue; + } + + /* Store pointer to value descriptor in the Node */ + + AcpiNsAttachObject (NewNode, ObjDesc, + ObjDesc->Common.Type); + } + } + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLookup + * + * PARAMETERS: PrefixNode - Search scope if name is not fully qualified + * Pathname - Search pathname, in internal format + * (as represented in the AML stream) + * Type - Type associated with name + * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found + * Flags - Flags describing the search restrictions + * WalkState - Current state of the walk + * ReturnNode - Where the Node is placed (if found + * or created successfully) + * + * RETURN: Status + * + * DESCRIPTION: Find or enter the passed name in the name space. + * Log an error if name not found in Exec mode. + * + * MUTEX: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + NATIVE_CHAR *Pathname, + OBJECT_TYPE_INTERNAL Type, + OPERATING_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *PrefixNode; + ACPI_NAMESPACE_NODE *CurrentNode = NULL; + ACPI_NAMESPACE_NODE *ScopeToPush = NULL; + ACPI_NAMESPACE_NODE *ThisNode = NULL; + UINT32 NumSegments; + ACPI_NAME SimpleName; + BOOLEAN NullNamePath = FALSE; + OBJECT_TYPE_INTERNAL TypeToCheckFor; + OBJECT_TYPE_INTERNAL ThisSearchType; + DEBUG_EXEC (UINT32 i) + + + FUNCTION_TRACE ("NsLookup"); + + + if (!ReturnNode) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + AcpiGbl_NsLookupCount++; + + *ReturnNode = ENTRY_NOT_FOUND; + + + if (!AcpiGbl_RootNode) + { + return (AE_NO_NAMESPACE); + } + + /* + * Get the prefix scope. + * A null scope means use the root scope + */ + + if ((!ScopeInfo) || + (!ScopeInfo->Scope.Node)) + { + PrefixNode = AcpiGbl_RootNode; + } + else + { + PrefixNode = ScopeInfo->Scope.Node; + } + + + /* + * This check is explicitly split provide relax the TypeToCheckFor + * conditions for BankFieldDefn. Originally, both BankFieldDefn and + * DefFieldDefn caused TypeToCheckFor to be set to ACPI_TYPE_REGION, + * but the BankFieldDefn may also check for a Field definition as well + * as an OperationRegion. + */ + + if (INTERNAL_TYPE_DEF_FIELD_DEFN == Type) + { + /* DefFieldDefn defines fields in a Region */ + + TypeToCheckFor = ACPI_TYPE_REGION; + } + + else if (INTERNAL_TYPE_BANK_FIELD_DEFN == Type) + { + /* BankFieldDefn defines data fields in a Field Object */ + + TypeToCheckFor = ACPI_TYPE_ANY; + } + + else + { + TypeToCheckFor = Type; + } + + + /* TBD: [Restructure] - Move the pathname stuff into a new procedure */ + + /* Examine the name pointer */ + + if (!Pathname) + { + /* 8-12-98 ASL Grammar Update supports null NamePath */ + + NullNamePath = TRUE; + NumSegments = 0; + ThisNode = AcpiGbl_RootNode; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Null Pathname (Zero segments), Flags=%x\n", Flags)); + } + + else + { + /* + * Valid name pointer (Internal name format) + * + * Check for prefixes. As represented in the AML stream, a + * Pathname consists of an optional scope prefix followed by + * a segment part. + * + * If present, the scope prefix is either a RootPrefix (in + * which case the name is fully qualified), or zero or more + * ParentPrefixes (in which case the name's scope is relative + * to the current scope). + * + * The segment part consists of either: + * - A single 4-byte name segment, or + * - A DualNamePrefix followed by two 4-byte name segments, or + * - A MultiNamePrefixOp, followed by a byte indicating the + * number of segments and the segments themselves. + */ + + if (*Pathname == AML_ROOT_PREFIX) + { + /* Pathname is fully qualified, look in root name table */ + + CurrentNode = AcpiGbl_RootNode; + + /* point to segment part */ + + Pathname++; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Searching from root [%p]\n", + CurrentNode)); + + /* Direct reference to root, "\" */ + + if (!(*Pathname)) + { + ThisNode = AcpiGbl_RootNode; + goto CheckForNewScopeAndExit; + } + } + + else + { + /* Pathname is relative to current scope, start there */ + + CurrentNode = PrefixNode; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Searching relative to pfx scope [%p]\n", + PrefixNode)); + + /* + * Handle up-prefix (carat). More than one prefix + * is supported + */ + + while (*Pathname == AML_PARENT_PREFIX) + { + /* Point to segment part or next ParentPrefix */ + + Pathname++; + + /* Backup to the parent's scope */ + + ThisNode = AcpiNsGetParentObject (CurrentNode); + if (!ThisNode) + { + /* Current scope has no parent scope */ + + REPORT_ERROR (("Too many parent prefixes (^) - reached root\n")); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + CurrentNode = ThisNode; + } + } + + + /* + * Examine the name prefix opcode, if any, + * to determine the number of segments + */ + + if (*Pathname == AML_DUAL_NAME_PREFIX) + { + NumSegments = 2; + + /* point to first segment */ + + Pathname++; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Dual Pathname (2 segments, Flags=%X)\n", Flags)); + } + + else if (*Pathname == AML_MULTI_NAME_PREFIX_OP) + { + NumSegments = (UINT32)* (UINT8 *) ++Pathname; + + /* point to first segment */ + + Pathname++; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Multi Pathname (%d Segments, Flags=%X) \n", + NumSegments, Flags)); + } + + else + { + /* + * No Dual or Multi prefix, hence there is only one + * segment and Pathname is already pointing to it. + */ + NumSegments = 1; + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Simple Pathname (1 segment, Flags=%X)\n", Flags)); + } + +#ifdef ACPI_DEBUG + + /* TBD: [Restructure] Make this a procedure */ + + /* Debug only: print the entire name that we are about to lookup */ + + DEBUG_PRINT (TRACE_NAMES, ("NsLookup: [")); + + for (i = 0; i < NumSegments; i++) + { + DEBUG_PRINT_RAW (TRACE_NAMES, ("%4.4s/", &Pathname[i * 4])); + } + DEBUG_PRINT_RAW (TRACE_NAMES, ("]\n")); +#endif + } + + + /* + * Search namespace for each segment of the name. + * Loop through and verify/add each name segment. + */ + + + while (NumSegments-- && CurrentNode) + { + /* + * Search for the current name segment under the current + * named object. The Type is significant only at the last (topmost) + * level. (We don't care about the types along the path, only + * the type of the final target object.) + */ + ThisSearchType = ACPI_TYPE_ANY; + if (!NumSegments) + { + ThisSearchType = Type; + } + + /* Pluck and ACPI name from the front of the pathname */ + + MOVE_UNALIGNED32_TO_32 (&SimpleName, Pathname); + + /* Try to find the ACPI name */ + + Status = AcpiNsSearchAndEnter (SimpleName, WalkState, + CurrentNode, InterpreterMode, + ThisSearchType, Flags, + &ThisNode); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + /* Name not found in ACPI namespace */ + + DEBUG_PRINT (TRACE_NAMES, + ("NsLookup: Name [%4.4s] not found in scope %X\n", + &SimpleName, CurrentNode)); + } + + return_ACPI_STATUS (Status); + } + + + /* + * If 1) This is the last segment (NumSegments == 0) + * 2) and looking for a specific type + * (Not checking for TYPE_ANY) + * 3) Which is not an alias + * 4) which is not a local type (TYPE_DEF_ANY) + * 5) which is not a local type (TYPE_SCOPE) + * 6) which is not a local type (TYPE_INDEX_FIELD_DEFN) + * 7) and type of object is known (not TYPE_ANY) + * 8) and object does not match request + * + * Then we have a type mismatch. Just warn and ignore it. + */ + if ((NumSegments == 0) && + (TypeToCheckFor != ACPI_TYPE_ANY) && + (TypeToCheckFor != INTERNAL_TYPE_ALIAS) && + (TypeToCheckFor != INTERNAL_TYPE_DEF_ANY) && + (TypeToCheckFor != INTERNAL_TYPE_SCOPE) && + (TypeToCheckFor != INTERNAL_TYPE_INDEX_FIELD_DEFN) && + (ThisNode->Type != ACPI_TYPE_ANY) && + (ThisNode->Type != TypeToCheckFor)) + { + /* Complain about a type mismatch */ + + REPORT_WARNING ( + ("NsLookup: %4.4s, type 0x%X, checking for type 0x%X\n", + &SimpleName, ThisNode->Type, TypeToCheckFor)); + } + + /* + * If this is the last name segment and we are not looking for a + * specific type, but the type of found object is known, use that type + * to see if it opens a scope. + */ + + if ((0 == NumSegments) && (ACPI_TYPE_ANY == Type)) + { + Type = ThisNode->Type; + } + + if ((NumSegments || AcpiNsOpensScope (Type)) && + (ThisNode->Child == NULL)) + { + /* + * More segments or the type implies enclosed scope, + * and the next scope has not been allocated. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsLookup: Load mode=%d ThisNode=%x\n", + InterpreterMode, ThisNode)); + } + + CurrentNode = ThisNode; + + /* point to next name segment */ + + Pathname += ACPI_NAME_SIZE; + } + + + /* + * Always check if we need to open a new scope + */ + +CheckForNewScopeAndExit: + + if (!(Flags & NS_DONT_OPEN_SCOPE) && (WalkState)) + { + /* + * If entry is a type which opens a scope, + * push the new scope on the scope stack. + */ + + if (AcpiNsOpensScope (TypeToCheckFor)) + { + /* 8-12-98 ASL Grammar Update supports null NamePath */ + + if (NullNamePath) + { + /* TBD: [Investigate] - is this the correct thing to do? */ + + ScopeToPush = NULL; + } + else + { + ScopeToPush = ThisNode; + } + + Status = AcpiDsScopeStackPush (ScopeToPush, Type, + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (ACPI_INFO, + ("NsLookup: Set global scope to %p\n", ScopeToPush)); + } + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/nsalloc.c b/sys/contrib/dev/acpica/nsalloc.c new file mode 100644 index 0000000..881a083 --- /dev/null +++ b/sys/contrib/dev/acpica/nsalloc.c @@ -0,0 +1,728 @@ +/******************************************************************************* + * + * Module Name: nsalloc - Namespace allocation and deletion utilities + * $Revision: 41 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSALLOC_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCreateNode + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 AcpiName) +{ + ACPI_NAMESPACE_NODE *Node; + + FUNCTION_TRACE ("NsCreateNode"); + + + Node = AcpiCmCallocate (sizeof (ACPI_NAMESPACE_NODE)); + if (!Node) + { + return_PTR (NULL); + } + + INCREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + Node->DataType = ACPI_DESC_TYPE_NAMED; + Node->Name = AcpiName; + Node->ReferenceCount = 1; + + return_PTR (Node); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNode + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PrevNode; + ACPI_NAMESPACE_NODE *NextNode; + + + FUNCTION_TRACE_PTR ("NsDeleteNode", Node); + + ParentNode = AcpiNsGetParentObject (Node); + + PrevNode = NULL; + NextNode = ParentNode->Child; + + while (NextNode != Node) + { + PrevNode = NextNode; + NextNode = PrevNode->Peer; + } + + if (PrevNode) + { + PrevNode->Peer = NextNode->Peer; + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; + } + } + else + { + ParentNode->Child = NextNode->Peer; + } + + + DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + /* + * Detach an object if there is one + */ + + if (Node->Object) + { + AcpiNsDetachObject (Node); + } + + AcpiCmFree (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 entry within a namespace table. + * + ******************************************************************************/ + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ + ACPI_NAMESPACE_NODE *Node, /* New Child*/ + OBJECT_TYPE_INTERNAL Type) +{ + UINT16 OwnerId = TABLE_ID_DSDT; + ACPI_NAMESPACE_NODE *ChildNode; + + + FUNCTION_TRACE ("NsInstallNode"); + + + /* + * Get the owner ID from the Walk state + * The owner ID is used to track table deletion and + * deletion of objects created by methods + */ + if (WalkState) + { + OwnerId = WalkState->OwnerId; + } + + + /* link the new entry into the parent and existing children */ + + /* TBD: Could be first, last, or alphabetic */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + ParentNode->Child = Node; + } + + else + { + while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) + { + ChildNode = ChildNode->Peer; + } + + ChildNode->Peer = Node; + + /* Clear end-of-list flag */ + + ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; + } + + /* Init the new entry */ + + Node->OwnerId = OwnerId; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + + + /* + * If adding a name with unknown type, or having to + * add the region in order to define fields in it, we + * have a forward reference. + */ + + if ((ACPI_TYPE_ANY == Type) || + (INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) + { + /* + * We don't want to abort here, however! + * We will fill in the actual type when the + * real definition is found later. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsInstallNode: [%4.4s] is a forward reference\n", + &Node->Name)); + + } + + /* + * The DefFieldDefn and BankFieldDefn cases are actually + * looking up the Region in which the field will be defined + */ + + if ((INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) + { + Type = ACPI_TYPE_REGION; + } + + /* + * Scope, DefAny, and IndexFieldDefn are bogus "types" which do + * not actually have anything to do with the type of the name + * being looked up. Save any other value of Type as the type of + * the entry. + */ + + if ((Type != INTERNAL_TYPE_SCOPE) && + (Type != INTERNAL_TYPE_DEF_ANY) && + (Type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) + { + Node->Type = (UINT8) Type; + } + + DEBUG_PRINT (TRACE_NAMES, + ("NsInstallNode: %4.4s added to %p at %p\n", + &Node->Name, ParentNode, Node)); + + /* + * Increment the reference count(s) of all parents up to + * the root! + */ + + while ((Node = AcpiNsGetParentObject (Node)) != NULL) + { + Node->ReferenceCount++; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteChildren + * + * PARAMETERS: ParentNode - Delete this objects children + * + * RETURN: None. + * + * DESCRIPTION: Delete all children of the parent object. Deletes a + * "scope". + * + ******************************************************************************/ + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *NextNode; + UINT8 Flags; + + + FUNCTION_TRACE_PTR ("AcpiNsDeleteChildren", ParentNode); + + + if (!ParentNode) + { + return_VOID; + } + + /* If no children, all done! */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + return_VOID; + } + + /* + * Deallocate all children at this level + */ + do + { + /* Get the things we need */ + + NextNode = ChildNode->Peer; + Flags = ChildNode->Flags; + + /* Grandchildren should have all been deleted already */ + + if (ChildNode->Child) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsDeleteChildren: Found a grandchild! P=%X C=%X\n", + ParentNode, ChildNode)); + } + + /* Now we can free this child object */ + + DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + DEBUG_PRINT (ACPI_INFO, + ("AcpiNsDeleteChildren: Object %p, Remaining %d\n", + ChildNode, AcpiGbl_CurrentNodeCount)); + + /* + * Detach an object if there is one + */ + + if (ChildNode->Object) + { + AcpiNsDetachObject (ChildNode); + } + + AcpiCmFree (ChildNode); + + /* And move on to the next child in the list */ + + ChildNode = NextNode; + + } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); + + + /* Clear the parent's child pointer */ + + ParentNode->Child = NULL; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceSubtree + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete a subtree of the namespace. This includes all objects + * stored within the subtree. Scope tables are deleted also + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 Level; + + + FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); + + + if (!ParentNode) + { + return_ACPI_STATUS (AE_OK); + } + + + ChildNode = 0; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + + while (Level > 0) + { + /* + * Get the next typed object in this scope. + * Null returned if not found + */ + + ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, ParentNode, + ChildNode); + if (ChildNode) + { + /* + * Found an object - delete the object within + * the Value field + */ + + ObjDesc = AcpiNsGetAttachedObject (ChildNode); + if (ObjDesc) + { + AcpiNsDetachObject (ChildNode); + AcpiCmRemoveReference (ObjDesc); + } + + + /* Check if this object has any children */ + + if (AcpiNsGetNextObject (ACPI_TYPE_ANY, ChildNode, 0)) + { + /* + * There is at least one child of this object, + * visit the object + */ + + Level++; + ParentNode = ChildNode; + ChildNode = 0; + } + } + + else + { + /* + * No more children in this object. + * We will 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 object */ + + ChildNode = ParentNode; + + /* Now we can move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentObject (ParentNode); + } + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRemoveReference + * + * PARAMETERS: Node - Named object whose reference count is to be + * decremented + * + * RETURN: None. + * + * DESCRIPTION: Remove a Node reference. Decrements the reference count + * of all parent Nodes up to the root. Any object along + * the way that reaches zero references is freed. + * + ******************************************************************************/ + +void +AcpiNsRemoveReference ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_NAMESPACE_NODE *NextNode; + + + /* + * Decrement the reference count(s) of this object and all + * objects up to the root, Delete anything with zero remaining references. + */ + NextNode = Node; + while (NextNode) + { + /* Decrement the reference count on this object*/ + + NextNode->ReferenceCount--; + + /* Delete the object if no more references */ + + if (!NextNode->ReferenceCount) + { + /* Delete all children and delete the object */ + + AcpiNsDeleteChildren (NextNode); + AcpiNsDeleteNode (NextNode); + } + + /* Move up to parent */ + + NextNode = AcpiNsGetParentObject (NextNode); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceByOwner + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete entries within the namespace that are owned by a + * specific ID. Used to delete entire ACPI tables. All + * reference counts are updated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDeleteNamespaceByOwner ( + UINT16 OwnerId) +{ + ACPI_NAMESPACE_NODE *ChildNode; + UINT32 Level; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); + + + ParentNode = AcpiGbl_RootNode; + ChildNode = 0; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + + while (Level > 0) + { + /* + * Get the next typed object in this scope. + * Null returned if not found + */ + + ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, ParentNode, + ChildNode); + + if (ChildNode) + { + if (ChildNode->OwnerId == OwnerId) + { + /* + * Found an object - delete the object within + * the Value field + */ + + ObjDesc = AcpiNsGetAttachedObject (ChildNode); + if (ObjDesc) + { + AcpiNsDetachObject (ChildNode); + AcpiCmRemoveReference (ObjDesc); + } + } + + /* Check if this object has any children */ + + if (AcpiNsGetNextObject (ACPI_TYPE_ANY, ChildNode, 0)) + { + /* + * There is at least one child of this object, + * visit the object + */ + + Level++; + ParentNode = ChildNode; + ChildNode = 0; + } + + else if (ChildNode->OwnerId == OwnerId) + { + AcpiNsRemoveReference (ChildNode); + } + } + + else + { + /* + * No more children in this object. Move up to grandparent. + */ + Level--; + + if (Level != 0) + { + if (ParentNode->OwnerId == OwnerId) + { + AcpiNsRemoveReference (ParentNode); + } + } + + /* New "last child" is this parent object */ + + ChildNode = ParentNode; + + /* Now we can move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentObject (ParentNode); + } + } + + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/nsdump.c b/sys/contrib/dev/acpica/nsdump.c new file mode 100644 index 0000000..365638d --- /dev/null +++ b/sys/contrib/dev/acpica/nsdump.c @@ -0,0 +1,677 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * $Revision: 80 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSDUMP_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsdump") + + +#ifdef ACPI_DEBUG + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpPathname + * + * PARAMETERS: Handle - Object + * Msg - Prefix message + * Level - Desired debug level + * Component - Caller's component ID + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ***************************************************************************/ + +ACPI_STATUS +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + NATIVE_CHAR *Msg, + UINT32 Level, + UINT32 Component) +{ + NATIVE_CHAR *Buffer; + UINT32 Length; + + + FUNCTION_TRACE ("NsDumpPathname"); + + /* Do this only if the requested debug level and component are enabled */ + + if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) + { + return_ACPI_STATUS (AE_OK); + } + + Buffer = AcpiCmAllocate (PATHNAME_MAX); + if (!Buffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Convert handle to a full pathname and print it (with supplied message) */ + + Length = PATHNAME_MAX; + if (ACPI_SUCCESS (AcpiNsHandleToPathname (Handle, &Length, Buffer))) + { + AcpiOsPrintf ("%s %s (%p)\n", Msg, Buffer, Handle); + } + + AcpiCmFree (Buffer); + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpOneObject + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * + * DESCRIPTION: Dump a single Node + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *ThisNode; + UINT8 *Value; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + OBJECT_TYPE_INTERNAL ObjType; + OBJECT_TYPE_INTERNAL Type; + UINT32 BytesToDump; + UINT32 DownstreamSiblingMask = 0; + UINT32 LevelTmp; + UINT32 WhichBit; + + + ThisNode = AcpiNsConvertHandleToEntry (ObjHandle); + + LevelTmp = Level; + Type = ThisNode->Type; + WhichBit = 1; + + + if (!(AcpiDbgLevel & Info->DebugLevel)) + { + return (AE_OK); + } + + if (!ObjHandle) + { + DEBUG_PRINT (ACPI_INFO, ("Null object handle\n")); + return (AE_OK); + } + + /* Check if the owner matches */ + + if ((Info->OwnerId != ACPI_UINT32_MAX) && + (Info->OwnerId != ThisNode->OwnerId)) + { + return (AE_OK); + } + + + /* Indent the object according to the level */ + + while (LevelTmp--) + { + + /* Print appropriate characters to form tree structure */ + + if (LevelTmp) + { + if (DownstreamSiblingMask & WhichBit) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("|")); + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); + } + + WhichBit <<= 1; + } + + else + { + if (AcpiNsExistDownstreamSibling (ThisNode + 1)) + { + DownstreamSiblingMask |= (1 << (Level - 1)); + DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); + } + + else + { + DownstreamSiblingMask &= ACPI_UINT32_MAX ^ (1 << (Level - 1)); + DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); + } + + if (ThisNode->Child == NULL) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); + } + + else if (AcpiNsExistDownstreamSibling (ThisNode->Child)) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); + } + } + } + + + /* Check the integrity of our data */ + + if (Type > INTERNAL_TYPE_MAX) + { + Type = INTERNAL_TYPE_DEF_ANY; /* prints as *ERROR* */ + } + + if (!AcpiCmValidAcpiName (ThisNode->Name)) + { + REPORT_WARNING (("Invalid ACPI Name 0x%X\n", ThisNode->Name)); + } + + /* + * Now we can print out the pertinent information + */ + + DEBUG_PRINT_RAW (TRACE_TABLES, (" %4.4s %-9s ", &ThisNode->Name, AcpiCmGetTypeName (Type))); + DEBUG_PRINT_RAW (TRACE_TABLES, ("%p S:%p O:%p", ThisNode, ThisNode->Child, ThisNode->Object)); + + + if (!ThisNode->Object) + { + /* No attached object, we are done */ + + DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); + return (AE_OK); + } + + switch (Type) + { + + case ACPI_TYPE_METHOD: + + /* Name is a Method and its AML offset/length are set */ + + DEBUG_PRINT_RAW (TRACE_TABLES, (" M:%p-%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.Pcode, + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.PcodeLength)); + + break; + + + case ACPI_TYPE_NUMBER: + + DEBUG_PRINT_RAW (TRACE_TABLES, (" N:%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Number.Value)); + break; + + + case ACPI_TYPE_STRING: + + DEBUG_PRINT_RAW (TRACE_TABLES, (" S:%p-%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Pointer, + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Length)); + break; + + + case ACPI_TYPE_BUFFER: + + DEBUG_PRINT_RAW (TRACE_TABLES, (" B:%p-%X\n", + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Pointer, + ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Length)); + break; + + + default: + + DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); + break; + } + + /* If debug turned off, done */ + + if (!(AcpiDbgLevel & TRACE_VALUES)) + { + return (AE_OK); + } + + + /* If there is an attached object, display it */ + + Value = ThisNode->Object; + + /* Dump attached objects */ + + while (Value) + { + ObjType = INTERNAL_TYPE_INVALID; + + /* Decode the type of attached object and dump the contents */ + + DEBUG_PRINT_RAW (TRACE_TABLES, (" Attached Object %p: ", Value)); + + if (AcpiTbSystemTablePointer (Value)) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to AML Code)\n")); + BytesToDump = 16; + } + + else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to Node)\n")); + BytesToDump = sizeof (ACPI_NAMESPACE_NODE); + } + + + else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_INTERNAL)) + { + ObjDesc = (ACPI_OPERAND_OBJECT *) Value; + ObjType = ObjDesc->Common.Type; + + if (ObjType > INTERNAL_TYPE_MAX) + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type 0x%X [UNKNOWN])\n", ObjType)); + BytesToDump = 32; + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type 0x%X [%s])\n", + ObjType, AcpiCmGetTypeName (ObjType))); + BytesToDump = sizeof (ACPI_OPERAND_OBJECT); + } + } + + else + { + DEBUG_PRINT_RAW (TRACE_TABLES, ("(String or Buffer - not descriptor)\n", Value)); + BytesToDump = 16; + } + + DUMP_BUFFER (Value, BytesToDump); + + /* If value is NOT an internal object, we are done */ + + if ((AcpiTbSystemTablePointer (Value)) || + (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED))) + { + goto Cleanup; + } + + /* + * Valid object, get the pointer to next level, if any + */ + switch (ObjType) + { + case ACPI_TYPE_STRING: + Value = (UINT8 *) ObjDesc->String.Pointer; + break; + + case ACPI_TYPE_BUFFER: + Value = (UINT8 *) ObjDesc->Buffer.Pointer; + break; + + case ACPI_TYPE_PACKAGE: + Value = (UINT8 *) ObjDesc->Package.Elements; + break; + + case ACPI_TYPE_METHOD: + Value = (UINT8 *) ObjDesc->Method.Pcode; + break; + + case ACPI_TYPE_FIELD_UNIT: + Value = (UINT8 *) ObjDesc->FieldUnit.Container; + break; + + case INTERNAL_TYPE_DEF_FIELD: + Value = (UINT8 *) ObjDesc->Field.Container; + break; + + case INTERNAL_TYPE_BANK_FIELD: + Value = (UINT8 *) ObjDesc->BankField.Container; + break; + + case INTERNAL_TYPE_INDEX_FIELD: + Value = (UINT8 *) ObjDesc->IndexField.Index; + break; + + default: + goto Cleanup; + } + + ObjType = INTERNAL_TYPE_INVALID; /* Terminate loop after next pass */ + } + +Cleanup: + DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); + return (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpObjects + * + * PARAMETERS: Type - Object type to be dumped + * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX + * for an effectively unlimited depth. + * OwnerId - Dump only objects owned by this ID. Use + * ACPI_UINT32_MAX to match all owners. + * StartHandle - Where in namespace to start/end search + * + * DESCRIPTION: Dump typed objects within the loaded namespace. + * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. + * + ***************************************************************************/ + +void +AcpiNsDumpObjects ( + OBJECT_TYPE_INTERNAL Type, + UINT32 MaxDepth, + UINT32 OwnerId, + ACPI_HANDLE StartHandle) +{ + ACPI_WALK_INFO Info; + + + Info.DebugLevel = TRACE_TABLES; + Info.OwnerId = OwnerId; + + AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject, + (void *) &Info, NULL); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpOneDevice + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * + * DESCRIPTION: Dump a single Node that represents a device + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_INFO Info; + ACPI_STATUS Status; + UINT32 i; + + + Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); + + Status = AcpiGetObjectInfo (ObjHandle, &Info); + if (ACPI_SUCCESS (Status)) + { + for (i = 0; i < Level; i++) + { + DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); + } + + DEBUG_PRINT_RAW (TRACE_TABLES, (" HID: %.8X, ADR: %.8X, Status: %x\n", + Info.HardwareId, Info.Address, Info.CurrentStatus)); + } + + return (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpRootDevices + * + * PARAMETERS: None + * + * DESCRIPTION: Dump all objects of type "device" + * + ***************************************************************************/ + +void +AcpiNsDumpRootDevices (void) +{ + ACPI_HANDLE SysBusHandle; + + + /* Only dump the table if tracing is enabled */ + + if (!(TRACE_TABLES & AcpiDbgLevel)) + { + return; + } + + AcpiGetHandle (0, NS_SYSTEM_BUS, &SysBusHandle); + + DEBUG_PRINT (TRACE_TABLES, ("Display of all devices in the namespace:\n")); + AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, NS_WALK_NO_UNLOCK, + AcpiNsDumpOneDevice, NULL, NULL); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpTables + * + * PARAMETERS: SearchBase - Root of subtree to be dumped, or + * NS_ALL to dump the entire namespace + * MaxDepth - Maximum depth of dump. Use INT_MAX + * for an effectively unlimited depth. + * + * DESCRIPTION: Dump the name space, or a portion of it. + * + ***************************************************************************/ + +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth) +{ + ACPI_HANDLE SearchHandle = SearchBase; + + + FUNCTION_TRACE ("NsDumpTables"); + + + if (!AcpiGbl_RootNode) + { + /* + * If the name space has not been initialized, + * there is nothing to dump. + */ + DEBUG_PRINT (TRACE_TABLES, ("NsDumpTables: name space not initialized!\n")); + return_VOID; + } + + if (NS_ALL == SearchBase) + { + /* entire namespace */ + + SearchHandle = AcpiGbl_RootNode; + DEBUG_PRINT (TRACE_TABLES, ("\\\n")); + } + + + AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SearchHandle); + return_VOID; +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsDumpEntry + * + * PARAMETERS: Handle - Node to be dumped + * DebugLevel - Output level + * + * DESCRIPTION: Dump a single Node + * + ***************************************************************************/ + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel) +{ + ACPI_WALK_INFO Info; + + + FUNCTION_TRACE_PTR ("NsDumpEntry", Handle); + + Info.DebugLevel = DebugLevel; + Info.OwnerId = ACPI_UINT32_MAX; + + AcpiNsDumpOneObject (Handle, 1, &Info, NULL); + + DEBUG_PRINT (TRACE_EXEC, ("leave AcpiNsDumpEntry %p\n", Handle)); + return_VOID; +} + +#endif + diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c new file mode 100644 index 0000000..e7a587f --- /dev/null +++ b/sys/contrib/dev/acpica/nseval.c @@ -0,0 +1,670 @@ +/******************************************************************************* + * + * Module Name: nseval - Object evaluation interfaces -- includes control + * method lookup and execution. + * $Revision: 79 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSEVAL_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nseval") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluateRelative + * + * PARAMETERS: Handle - The relative containing object + * *Pathname - Name of method to execute, If NULL, the + * handle is the object to execute + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Find and execute the requested method using the handle as a + * scope + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluateRelative ( + ACPI_NAMESPACE_NODE *Handle, + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_NAMESPACE_NODE *PrefixNode; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + NATIVE_CHAR *InternalPath = NULL; + ACPI_GENERIC_STATE ScopeInfo; + + + FUNCTION_TRACE ("NsEvaluateRelative"); + + + /* + * Must have a valid object handle + */ + if (!Handle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Build an internal name string for the method */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the prefix handle and Node */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + PrefixNode = AcpiNsConvertHandleToEntry (Handle); + if (!PrefixNode) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* Lookup the name in the namespace */ + + ScopeInfo.Scope.Node = PrefixNode; + Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, + IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + &Node); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateRelative: Object [%s] not found [%.4X]\n", + Pathname, AcpiCmFormatException (Status))); + goto Cleanup; + } + + /* + * Now that we have a handle to the object, we can attempt + * to evaluate it. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateRelative: %s [%p] Value %p\n", + Pathname, Node, Node->Object)); + + Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateRelative: *** Completed eval of object %s ***\n", + Pathname)); + +Cleanup: + + /* Cleanup */ + + AcpiCmFree (InternalPath); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluateByName + * + * PARAMETERS: Pathname - Fully qualified pathname to the object + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * + * RETURN: Status + * + * DESCRIPTION: Find and execute the requested method passing the given + * parameters + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluateByName ( + NATIVE_CHAR *Pathname, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + NATIVE_CHAR *InternalPath = NULL; + + + FUNCTION_TRACE ("NsEvaluateByName"); + + + /* Build an internal name string for the method */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Lookup the name in the namespace */ + + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, + IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + &Node); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateByName: Object at [%s] was not found, status=%.4X\n", + Pathname, Status)); + goto Cleanup; + } + + /* + * Now that we have a handle to the object, we can attempt + * to evaluate it. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateByName: %s [%p] Value %p\n", + Pathname, Node, Node->Object)); + + Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + + DEBUG_PRINT (ACPI_INFO, + ("NsEvaluateByName: *** Completed eval of object %s ***\n", + Pathname)); + + +Cleanup: + + /* Cleanup */ + + if (InternalPath) + { + AcpiCmFree (InternalPath); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluateByHandle + * + * PARAMETERS: Handle - Method Node to execute + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Execute the requested method passing the given parameters + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluateByHandle ( + ACPI_NAMESPACE_NODE *Handle, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *LocalReturnObject; + + + FUNCTION_TRACE ("NsEvaluateByHandle"); + + + /* Check if namespace has been initialized */ + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + /* Parameter Validation */ + + if (!Handle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ReturnObject) + { + /* Initialize the return value to an invalid object */ + + *ReturnObject = NULL; + } + + /* Get the prefix handle and Node */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* + * Two major cases here: + * 1) The object is an actual control method -- execute it. + * 2) The object is not a method -- just return it's current + * value + * + * In both cases, the namespace is unlocked by the + * AcpiNs* procedure + */ + if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD) + { + /* + * Case 1) We have an actual control method to execute + */ + Status = AcpiNsExecuteControlMethod (Node, Params, + &LocalReturnObject); + } + + else + { + /* + * Case 2) Object is NOT a method, just return its + * current value + */ + Status = AcpiNsGetObjectValue (Node, &LocalReturnObject); + } + + + /* + * Check if there is a return value on the stack that must + * be dealt with + */ + if (Status == AE_CTRL_RETURN_VALUE) + { + /* + * If the Method returned a value and the caller + * provided a place to store a returned value, Copy + * the returned value to the object descriptor provided + * by the caller. + */ + if (ReturnObject) + { + /* + * Valid return object, copy the pointer to + * the returned object + */ + *ReturnObject = LocalReturnObject; + } + + + /* Map AE_RETURN_VALUE to AE_OK, we are done with it */ + + if (Status == AE_CTRL_RETURN_VALUE) + { + Status = AE_OK; + } + } + + /* + * Namespace was unlocked by the handling AcpiNs* function, + * so we just return + */ + return_ACPI_STATUS (Status); + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecuteControlMethod + * + * PARAMETERS: MethodNode - The object/method + * **Params - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * **ReturnObjDesc - List of result objects to be returned + * from the method. + * + * RETURN: Status + * + * DESCRIPTION: Execute the requested method passing the given parameters + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsExecuteControlMethod ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("NsExecuteControlMethod"); + + + /* Verify that there is a method associated with this object */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) MethodNode); + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("Control method is undefined (nil value)\n")); + return_ACPI_STATUS (AE_ERROR); + } + + + DEBUG_PRINT (ACPI_INFO, ("Control method at Offset %x Length %lx]\n", + ObjDesc->Method.Pcode + 1, + ObjDesc->Method.PcodeLength - 1)); + + DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing", + TRACE_NAMES, _COMPONENT); + + DEBUG_PRINT (TRACE_NAMES, + ("At offset %8XH\n", ObjDesc->Method.Pcode + 1)); + + + /* + * Unlock the namespace before execution. This allows namespace access + * via the external Acpi* interfaces while a method is being executed. + * However, any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of the + * namespace that is being deleted. + */ + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * Excecute the method via the interpreter + */ + Status = AcpiAmlExecuteMethod (MethodNode, Params, ReturnObjDesc); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetObjectValue + * + * PARAMETERS: Node - The object + * + * RETURN: Status + * + * DESCRIPTION: Return the current value of the object + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetObjectValue ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *ValDesc; + + + FUNCTION_TRACE ("NsGetObjectValue"); + + + /* + * We take the value from certain objects directly + */ + + if ((Node->Type == ACPI_TYPE_PROCESSOR) || + (Node->Type == ACPI_TYPE_POWER)) + { + /* + * Create a Reference object to contain the object + */ + ObjDesc = AcpiCmCreateInternalObject (Node->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* + * Get the attached object + */ + + ValDesc = AcpiNsGetAttachedObject (Node); + if (!ValDesc) + { + Status = AE_NULL_OBJECT; + goto UnlockAndExit; + } + + /* + * Just copy from the original to the return object + * + * TBD: [Future] - need a low-level object copy that handles + * the reference count automatically. (Don't want to copy it) + */ + + MEMCPY (ObjDesc, ValDesc, sizeof (ACPI_OPERAND_OBJECT)); + ObjDesc->Common.ReferenceCount = 1; + } + + + /* + * Other objects require a reference object wrapper which we + * then attempt to resolve. + */ + else + { + /* Create an Reference object to contain the object */ + + ObjDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Construct a descriptor pointing to the name */ + + ObjDesc->Reference.OpCode = (UINT8) AML_NAME_OP; + ObjDesc->Reference.Object = (void *) Node; + + /* + * Use AcpiAmlResolveToValue() to get the associated value. + * The call to AcpiAmlResolveToValue causes + * ObjDesc (allocated above) to always be deleted. + * + * NOTE: we can get away with passing in NULL for a walk state + * because ObjDesc is guaranteed to not be a reference to either + * a method local or a method argument + * + * Even though we do not technically need to use the interpreter + * for this, we must enter it because we could hit an opregion. + * The opregion access code assumes it is in the interpreter. + */ + + AcpiAmlEnterInterpreter(); + + Status = AcpiAmlResolveToValue (&ObjDesc, NULL); + + AcpiAmlExitInterpreter(); + } + + /* + * If AcpiAmlResolveToValue() succeeded, the return value was + * placed in ObjDesc. + */ + + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_RETURN_VALUE; + + *ReturnObjDesc = ObjDesc; + DEBUG_PRINT (ACPI_INFO, + ("NsGetObjectValue: Returning obj %p\n", *ReturnObjDesc)); + } + + +UnlockAndExit: + + /* Unlock the namespace */ + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/nsinit.c b/sys/contrib/dev/acpica/nsinit.c new file mode 100644 index 0000000..6be2d04 --- /dev/null +++ b/sys/contrib/dev/acpica/nsinit.c @@ -0,0 +1,514 @@ +/****************************************************************************** + * + * Module Name: nsinit - namespace initialization + * $Revision: 4 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFINIT_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acdispat.h" + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsinit") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + + + FUNCTION_TRACE ("NsInitializeObjects"); + + + DEBUG_PRINT (TRACE_DISPATCH, + ("NsInitializeObjects: **** Starting initialization of namespace objects ****\n")); + DEBUG_PRINT_RAW (ACPI_OK, ("Completing Region and Field initialization:")); + + + Info.FieldCount = 0; + Info.FieldInit = 0; + Info.OpRegionCount = 0; + Info.OpRegionInit = 0; + Info.ObjectCount = 0; + + + /* Walk entire namespace from the supplied root */ + + Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiNsInitOneObject, + &Info, NULL); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsInitializeObjects: WalkNamespace failed! %x\n", Status)); + } + + DEBUG_PRINT_RAW (ACPI_OK, + ("\n%d/%d Regions, %d/%d Fields initialized (%d nodes total)\n", + Info.OpRegionInit, Info.OpRegionCount, Info.FieldInit, Info.FieldCount, Info.ObjectCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("NsInitializeObjects: %d Control Methods found\n", Info.MethodCount)); + DEBUG_PRINT (TRACE_DISPATCH, + ("NsInitializeObjects: %d 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. + * + * Also: Install PCI config space handler for all PCI root bridges. + * A PCI root bridge is found by searching for devices containing + * a HID with the value EISAID("PNP0A03") + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeDevices ( + UINT32 Flags) +{ + ACPI_STATUS Status; + ACPI_DEVICE_WALK_INFO Info; + + + FUNCTION_TRACE ("NsInitializeDevices"); + + + Info.Flags = Flags; + Info.DeviceCount = 0; + Info.Num_STA = 0; + Info.Num_INI = 0; + Info.Num_HID = 0; + Info.Num_PCI = 0; + + + DEBUG_PRINT_RAW (ACPI_OK, ("Executing device _INI methods:")); + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + FALSE, AcpiNsInitOneDevice, &Info, NULL); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsInitializeDevices: WalkNamespace failed! %x\n", Status)); + } + + + DEBUG_PRINT_RAW (ACPI_OK, + ("\n%d Devices found: %d _STA, %d _INI, %d _HID, %d PCIRoot\n", + Info.DeviceCount, Info.Num_STA, Info.Num_INI, + Info.Num_HID, Info.Num_PCI)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneObject + * + * PARAMETERS: ObjHandle - Node + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Op Regions + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + OBJECT_TYPE_INTERNAL Type; + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OPERAND_OBJECT *ObjDesc; + + + Info->ObjectCount++; + + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + ObjDesc = Node->Object; + if (!ObjDesc) + { + return (AE_OK); + } + + switch (Type) + { + + case ACPI_TYPE_REGION: + + Info->OpRegionCount++; + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + break; + } + + Info->OpRegionInit++; + Status = AcpiDsGetRegionArguments (ObjDesc); + DEBUG_PRINT_RAW (ACPI_OK, (".")); + break; + + + case ACPI_TYPE_FIELD_UNIT: + + Info->FieldCount++; + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + break; + } + + Info->FieldInit++; + Status = AcpiDsGetFieldUnitArguments (ObjDesc); + DEBUG_PRINT_RAW (ACPI_OK, (".")); + + 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: AcpiNsInitOneDevice + * + * PARAMETERS: The usual "I'm a namespace callback" stuff + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: This is called once per device soon after ACPI is enabled + * to initialize each device. It determines if the device is + * present, and if so, calls _INI. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RetObj = NULL; + ACPI_NAMESPACE_NODE *Node; + UINT32 Flags; + ACPI_DEVICE_WALK_INFO *Info = (ACPI_DEVICE_WALK_INFO *) Context; + + + FUNCTION_TRACE ("AcpiNsInitOneDevice"); + + + DEBUG_PRINT_RAW (ACPI_OK, (".")); + Info->DeviceCount++; + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (ObjHandle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * Run _STA to determine if we can run _INI on the device. + */ + + Status = AcpiCmExecute_STA (Node, &Flags); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Info->Num_STA++; + + if (!(Flags & 0x01)) + { + /* don't look at children of a not present device */ + return_ACPI_STATUS(AE_CTRL_DEPTH); + } + + /* + * The device is present. Run _INI. + */ + + Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); + if (AE_NOT_FOUND == Status) + { + /* No _INI means device requires no initialization */ + } + + else if (ACPI_FAILURE (Status)) + { +#ifdef ACPI_DEBUG + NATIVE_CHAR *ScopeName = AcpiNsGetTablePathname (ObjHandle); + + DEBUG_PRINT (ACPI_ERROR, ("%s._INI failed: %s\n", + ScopeName, AcpiCmFormatException (Status))); + + AcpiCmFree (ScopeName); +#endif + return_ACPI_STATUS (Status); + } + + else + { + Info->Num_INI++; + } + + + /* + * Examine the HID of the device. _HID can be an executable + * control method -- it simply has to return a string or number + * containing the HID. + */ + + if (RetObj) + { + AcpiCmRemoveReference (RetObj); + } + + RetObj = NULL; + Status = AcpiNsEvaluateRelative (ObjHandle, "_HID", NULL, &RetObj); + if (AE_NOT_FOUND == Status) + { + /* No _HID --> Can't be a PCI root bridge */ + + return_ACPI_STATUS (AE_OK); + } + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Info->Num_HID++; + + + /* + * Found an _HID object. + * Check for a PCI Root Bridge. We need to install the PCI_CONFIG space + * handler on all PCI Root Bridges found within the namespace + * + * A PCI Root Bridge has an HID with the value EISAID("PNP0A03") + * The HID can be either a number or a string. + */ + + switch (RetObj->Common.Type) + { + case ACPI_TYPE_NUMBER: + + if (RetObj->Number.Value != PCI_ROOT_HID_VALUE) + { + goto Cleanup; + } + + break; + + case ACPI_TYPE_STRING: + + if (STRNCMP (RetObj->String.Pointer, PCI_ROOT_HID_STRING, + sizeof (PCI_ROOT_HID_STRING))) + { + goto Cleanup; + } + + break; + + default: + + goto Cleanup; + } + + + /* + * We found a valid PCI_ROOT_HID. + * The parent of the HID entry is the PCI device; Install the default PCI + * handler for this PCI device. + */ + + Info->Num_PCI++; + + if (!(Info->Flags & ACPI_NO_PCI_INIT)) + { + Status = AcpiInstallAddressSpaceHandler (ObjHandle, + ADDRESS_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + } + +Cleanup: + + if (RetObj) + { + AcpiCmRemoveReference (RetObj); + } + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/nsload.c b/sys/contrib/dev/acpica/nsload.c new file mode 100644 index 0000000..e006ccf --- /dev/null +++ b/sys/contrib/dev/acpica/nsload.c @@ -0,0 +1,712 @@ +/****************************************************************************** + * + * Module Name: nsload - namespace loading/expanding/contracting procedures + * $Revision: 31 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSLOAD_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acdebug.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsload") + + +/****************************************************************************** + * + * FUNCTION: AcpiLoadNamespace + * + * PARAMETERS: DisplayAmlDuringLoad + * + * 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; + + + FUNCTION_TRACE ("AcpiLoadNameSpace"); + + + /* There must be at least a DSDT installed */ + + if (AcpiGbl_DSDT == NULL) + { + DEBUG_PRINT (ACPI_ERROR, ("DSDT is not in memory\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + + /* + * Load the namespace. The DSDT is required, + * but the SSDT and PSDT tables are optional. + */ + + Status = AcpiNsLoadTableByType (ACPI_TABLE_DSDT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ignore exceptions from these */ + + AcpiNsLoadTableByType (ACPI_TABLE_SSDT); + AcpiNsLoadTableByType (ACPI_TABLE_PSDT); + + + DEBUG_PRINT_RAW (ACPI_OK, + ("ACPI Namespace successfully loaded at root 0x%p\n", + AcpiGbl_RootNode)); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsOneParsePass + * + * PARAMETERS: + * + * RETURN: Status + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; + ACPI_PARSE_OBJECT *ParseRoot; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("NsOneCompleteParse"); + + + switch (PassNumber) + { + case 1: + DescendingCallback = AcpiDsLoad1BeginOp; + AscendingCallback = AcpiDsLoad1EndOp; + break; + + case 2: + DescendingCallback = AcpiDsLoad2BeginOp; + AscendingCallback = AcpiDsLoad2EndOp; + break; + + case 3: + DescendingCallback = AcpiDsExecBeginOp; + AscendingCallback = AcpiDsExecEndOp; + break; + + default: + return (AE_BAD_PARAMETER); + } + + /* Create and init a Root Node */ + + ParseRoot = AcpiPsAllocOp (AML_SCOPE_OP); + if (!ParseRoot) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ((ACPI_PARSE2_OBJECT *) ParseRoot)->Name = ACPI_ROOT_NAME; + + + /* Pass 1: Parse everything except control method bodies */ + + DEBUG_PRINT (TRACE_PARSE, + ("NsParseTable: *PARSE* pass %d parse\n", PassNumber)); + + Status = AcpiPsParseAml (ParseRoot, + TableDesc->AmlPointer, + TableDesc->AmlLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + NULL, NULL, NULL, + DescendingCallback, + AscendingCallback); + + AcpiPsDeleteParseTree (ParseRoot); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsParseTable + * + * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse + * StartNode - Where to enter the table into the namespace + * + * RETURN: Status + * + * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsParseTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("NsParseTable"); + + + /* + * AML Parse, pass 1 + * + * In this pass, we load most of the namespace. Control methods + * are not parsed until later. A parse tree is not created. Instead, + * each Parser Op subtree is deleted when it is finished. This saves + * a great deal of memory, and allows a small cache of parse objects + * to service the entire parse. The second pass of the parse then + * performs another complete parse of the AML.. + */ + + Status = AcpiNsOneCompleteParse (1, TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* + * AML Parse, pass 2 + * + * In this pass, we resolve forward references and other things + * that could not be completed during the first pass. + * Another complete parse of the AML is performed, but the + * overhead of this is compensated for by the fact that the + * parse objects are all cached. + */ + + Status = AcpiNsOneCompleteParse (2, TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* TBD: no longer needed, remove */ + + AcpiGbl_ParsedNamespaceRoot = NULL; + + + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiNsLoadTable + * + * PARAMETERS: *PcodeAddr - Address of pcode block + * PcodeLength - Length of pcode block + * + * RETURN: Status + * + * DESCRIPTION: Load one ACPI table into the namespace + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsLoadTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("NsLoadTable"); + + + if (!TableDesc->AmlPointer) + { + DEBUG_PRINT (ACPI_ERROR, ("NsLoadTable: Null AML pointer\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: AML block at %p\n", TableDesc->AmlPointer)); + + + if (!TableDesc->AmlLength) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsLoadTable: Zero-length AML block\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* + * 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! + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: **** Loading table into namespace ****\n")); + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiNsParseTable (TableDesc, Node->Child); + AcpiCmReleaseMutex (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. + */ + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: **** Begin Table Method Parsing and Object Initialization ****\n")); + + Status = AcpiDsInitializeObjects (TableDesc, Node); + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTable: **** Completed Table Method Parsing and Object Initialization ****\n")); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsLoadTableByType + * + * PARAMETERS: TableType - Id of the table type to load + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables + * of the given type are loaded. The mechanism allows this + * routine to be called repeatedly. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiNsLoadTableByType ( + ACPI_TABLE_TYPE TableType) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *TablePtr; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE ("NsLoadTableByType"); + + + AcpiCmAcquireMutex (ACPI_MTX_TABLES); + + + /* + * Table types supported are: + * DSDT (one), SSDT/PSDT (multiple) + */ + + switch (TableType) + { + + case ACPI_TABLE_DSDT: + + DEBUG_PRINT (ACPI_INFO, ("NsLoadTableByType: Loading DSDT\n")); + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_DSDT]; + + /* If table already loaded into namespace, just return */ + + if (TableDesc->LoadedIntoNamespace) + { + goto UnlockAndExit; + } + + TableDesc->TableId = TABLE_ID_DSDT; + + /* Now load the single DSDT */ + + Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode); + if (ACPI_SUCCESS (Status)) + { + TableDesc->LoadedIntoNamespace = TRUE; + } + + break; + + + case ACPI_TABLE_SSDT: + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTableByType: Loading %d SSDTs\n", + AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count)); + + /* + * Traverse list of SSDT tables + */ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_SSDT]; + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count; i++) + { + TablePtr = TableDesc->Pointer; + + /* + * Only attempt to load table if it is not + * already loaded! + */ + + if (!TableDesc->LoadedIntoNamespace) + { + Status = AcpiNsLoadTable (TableDesc, + AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + break; + } + + TableDesc->LoadedIntoNamespace = TRUE; + } + + TableDesc = TableDesc->Next; + } + + break; + + + case ACPI_TABLE_PSDT: + + DEBUG_PRINT (ACPI_INFO, + ("NsLoadTableByType: Loading %d PSDTs\n", + AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count)); + + /* + * Traverse list of PSDT tables + */ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_PSDT]; + + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count; i++) + { + TablePtr = TableDesc->Pointer; + + /* Only attempt to load table if it is not already loaded! */ + + if (!TableDesc->LoadedIntoNamespace) + { + Status = AcpiNsLoadTable (TableDesc, + AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + break; + } + + TableDesc->LoadedIntoNamespace = TRUE; + } + + TableDesc = TableDesc->Next; + } + + break; + + + default: + Status = AE_SUPPORT; + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_TABLES); + + return_ACPI_STATUS (Status); + +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsDeleteSubtree + * + * PARAMETERS: StartHandle - Handle in namespace where search begins + * + * RETURNS Status + * + * DESCRIPTION: Walks the namespace starting at the given handle and deletes + * all objects, entries, and scopes in the entire subtree. + * + * TBD: [Investigate] What if any part of this subtree is in use? + * (i.e. on one of the object stacks?) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle) +{ + ACPI_STATUS Status; + ACPI_HANDLE ChildHandle; + ACPI_HANDLE ParentHandle; + ACPI_HANDLE NextChildHandle; + ACPI_HANDLE Dummy; + UINT32 Level; + + + FUNCTION_TRACE ("NsDeleteSubtree"); + + + ParentHandle = StartHandle; + ChildHandle = 0; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + + while (Level > 0) + { + /* Attempt to get the next object in this scope */ + + Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, + ChildHandle, + &NextChildHandle); + + ChildHandle = NextChildHandle; + + + /* Did we get a new object? */ + + if (ACPI_SUCCESS (Status)) + { + /* Check if this object has any children */ + + if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, + ChildHandle, 0, + &Dummy))) + { + /* + * There is at least one child of this object, + * visit the object + */ + + Level++; + ParentHandle = ChildHandle; + ChildHandle = 0; + } + } + + else + { + /* + * No more children in this object, go back up to + * the object's parent + */ + Level--; + + /* Delete all children now */ + + AcpiNsDeleteChildren (ChildHandle); + + ChildHandle = ParentHandle; + AcpiGetParent (ParentHandle, &ParentHandle); + } + } + + /* Now delete the starting object, and we are done */ + + AcpiNsDeleteNode (ChildHandle); + + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsUnloadNameSpace + * + * PARAMETERS: Handle - Root of namespace subtree to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Shrinks the namespace, typically in response to an undocking + * event. Deletes an entire subtree starting from (and + * including) the given handle. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle) +{ + ACPI_STATUS Status; + + + 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); +} + + diff --git a/sys/contrib/dev/acpica/nsnames.c b/sys/contrib/dev/acpica/nsnames.c new file mode 100644 index 0000000..795c811 --- /dev/null +++ b/sys/contrib/dev/acpica/nsnames.c @@ -0,0 +1,334 @@ +/******************************************************************************* + * + * Module Name: nsnames - Name manipulation and search + * $Revision: 49 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSNAMES_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsnames") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetTablePathname + * + * PARAMETERS: Node - Scope whose name is needed + * + * RETURN: Pointer to storage containing the fully qualified name of + * the scope, in Label format (all segments strung together + * with no separators) + * + * DESCRIPTION: Used for debug printing in AcpiNsSearchTable(). + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiNsGetTablePathname ( + ACPI_NAMESPACE_NODE *Node) +{ + NATIVE_CHAR *NameBuffer; + UINT32 Size; + ACPI_NAME Name; + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE_PTR ("AcpiNsGetTablePathname", Node); + + + if (!AcpiGbl_RootNode || !Node) + { + /* + * If the name space has not been initialized, + * this function should not have been called. + */ + return_PTR (NULL); + } + + ChildNode = Node->Child; + + + /* Calculate required buffer size based on depth below root */ + + Size = 1; + ParentNode = ChildNode; + while (ParentNode) + { + ParentNode = AcpiNsGetParentObject (ParentNode); + if (ParentNode) + { + Size += ACPI_NAME_SIZE; + } + } + + + /* Allocate a buffer to be returned to caller */ + + NameBuffer = AcpiCmCallocate (Size + 1); + if (!NameBuffer) + { + REPORT_ERROR (("NsGetTablePathname: allocation failure\n")); + return_PTR (NULL); + } + + + /* Store terminator byte, then build name backwards */ + + NameBuffer[Size] = '\0'; + while ((Size > ACPI_NAME_SIZE) && + AcpiNsGetParentObject (ChildNode)) + { + Size -= ACPI_NAME_SIZE; + Name = AcpiNsFindParentName (ChildNode); + + /* Put the name into the buffer */ + + MOVE_UNALIGNED32_TO_32 ((NameBuffer + Size), &Name); + ChildNode = AcpiNsGetParentObject (ChildNode); + } + + NameBuffer[--Size] = AML_ROOT_PREFIX; + + if (Size != 0) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsGetTablePathname: Bad pointer returned; size = %d\n", Size)); + } + + return_PTR (NameBuffer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsHandleToPathname + * + * PARAMETERS: TargetHandle - Handle of named object whose name is + * to be found + * BufSize - Size of the buffer provided + * UserBuffer - 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 + * + * MUTEX: Locks Namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + UINT32 *BufSize, + NATIVE_CHAR *UserBuffer) +{ + ACPI_STATUS Status = AE_OK; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *NextNode; + UINT32 PathLength; + UINT32 Size; + UINT32 UserBufSize; + ACPI_NAME Name; + + FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle); + + + if (!AcpiGbl_RootNode || !TargetHandle) + { + /* + * If the name space has not been initialized, + * this function should not have been called. + */ + + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + Node = AcpiNsConvertHandleToEntry (TargetHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Compute length of pathname as 5 * number of name segments. + * Go back up the parent tree to the root + */ + for (Size = 0, NextNode = Node; + AcpiNsGetParentObject (NextNode); + NextNode = AcpiNsGetParentObject (NextNode)) + { + Size += PATH_SEGMENT_LENGTH; + } + + /* Set return length to the required path length */ + + PathLength = Size + 1; + UserBufSize = *BufSize; + *BufSize = PathLength; + + /* Check if the user buffer is sufficiently large */ + + if (PathLength > UserBufSize) + { + Status = AE_BUFFER_OVERFLOW; + goto Exit; + } + + /* Store null terminator */ + + UserBuffer[Size] = 0; + Size -= ACPI_NAME_SIZE; + + /* Put the original ACPI name at the end of the path */ + + MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size), + &Node->Name); + + UserBuffer[--Size] = PATH_SEPARATOR; + + /* Build name backwards, putting "." between segments */ + + while ((Size > ACPI_NAME_SIZE) && Node) + { + Size -= ACPI_NAME_SIZE; + Name = AcpiNsFindParentName (Node); + MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size), &Name); + + UserBuffer[--Size] = PATH_SEPARATOR; + Node = AcpiNsGetParentObject (Node); + } + + /* + * Overlay the "." preceding the first segment with + * the root name "\" + */ + + UserBuffer[Size] = '\\'; + + DEBUG_PRINT (TRACE_EXEC, + ("NsHandleToPathname: Len=%d, %s \n", + PathLength, UserBuffer)); + +Exit: + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/nsobject.c b/sys/contrib/dev/acpica/nsobject.c new file mode 100644 index 0000000..6dd5fe3 --- /dev/null +++ b/sys/contrib/dev/acpica/nsobject.c @@ -0,0 +1,523 @@ +/******************************************************************************* + * + * Module Name: nsobject - Utilities for objects attached to namespace + * table entries + * $Revision: 46 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSOBJECT_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "actables.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsobject") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachObject + * + * PARAMETERS: Node - Parent Node + * Object - Object to be attached + * Type - Type of object, or ACPI_TYPE_ANY if not + * known + * + * DESCRIPTION: Record the given object as the value associated with the + * name whose ACPI_HANDLE is passed. If Object is NULL + * and Type is ACPI_TYPE_ANY, set the name as having no value. + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + OBJECT_TYPE_INTERNAL Type) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *PreviousObjDesc; + OBJECT_TYPE_INTERNAL ObjType = ACPI_TYPE_ANY; + UINT8 Flags; + UINT16 Opcode; + + + FUNCTION_TRACE ("NsAttachObject"); + + + /* + * Parameter validation + */ + + if (!AcpiGbl_RootNode) + { + /* Name space not initialized */ + + REPORT_ERROR (("NsAttachObject: Namespace not initialized\n")); + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + if (!Node) + { + /* Invalid handle */ + + REPORT_ERROR (("NsAttachObject: Null NamedObj handle\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!Object && (ACPI_TYPE_ANY != Type)) + { + /* Null object */ + + REPORT_ERROR (("NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!VALID_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED)) + { + /* Not a name handle */ + + REPORT_ERROR (("NsAttachObject: Invalid handle\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check if this object is already attached */ + + if (Node->Object == Object) + { + DEBUG_PRINT (TRACE_EXEC, + ("NsAttachObject: Obj %p already installed in NameObj %p\n", + Object, Node)); + + return_ACPI_STATUS (AE_OK); + } + + + /* Get the current flags field of the Node */ + + Flags = Node->Flags; + Flags &= ~ANOBJ_AML_ATTACHMENT; + + + /* If null object, we will just install it */ + + if (!Object) + { + ObjDesc = NULL; + ObjType = ACPI_TYPE_ANY; + } + + /* + * If the object is an Node with an attached object, + * we will use that (attached) object + */ + + else if (VALID_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; + ObjType = ((ACPI_NAMESPACE_NODE *) Object)->Type; + + /* + * Copy appropriate flags + */ + + if (((ACPI_NAMESPACE_NODE *) Object)->Flags & ANOBJ_AML_ATTACHMENT) + { + Flags |= ANOBJ_AML_ATTACHMENT; + } + } + + + /* + * Otherwise, we will use the parameter object, but we must type + * it first + */ + + else + { + ObjDesc = (ACPI_OPERAND_OBJECT *) Object; + + + /* If a valid type (non-ANY) was given, just use it */ + + if (ACPI_TYPE_ANY != Type) + { + ObjType = Type; + } + + + /* + * Type is TYPE_Any, we must try to determinte the + * actual type of the object + */ + + /* + * Check if value points into the AML code + */ + else if (AcpiTbSystemTablePointer (Object)) + { + /* + * Object points into the AML stream. + * Set a flag bit in the Node to indicate this + */ + + Flags |= ANOBJ_AML_ATTACHMENT; + + /* + * The next byte (perhaps the next two bytes) + * will be the AML opcode + */ + + MOVE_UNALIGNED16_TO_16 (&Opcode, Object); + + /* Check for a recognized OpCode */ + + switch ((UINT8) Opcode) + { + + case AML_OP_PREFIX: + + if (Opcode != AML_REVISION_OP) + { + /* + * OpPrefix is unrecognized unless part + * of RevisionOp + */ + + break; + } + + /* Else fall through to set type as Number */ + + + case AML_ZERO_OP: case AML_ONES_OP: case AML_ONE_OP: + case AML_BYTE_OP: case AML_WORD_OP: case AML_DWORD_OP: + + ObjType = ACPI_TYPE_NUMBER; + break; + + + case AML_STRING_OP: + + ObjType = ACPI_TYPE_STRING; + break; + + + case AML_BUFFER_OP: + + ObjType = ACPI_TYPE_BUFFER; + break; + + + case AML_MUTEX_OP: + + ObjType = ACPI_TYPE_MUTEX; + break; + + + case AML_PACKAGE_OP: + + ObjType = ACPI_TYPE_PACKAGE; + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("AML Opcode/Type [%x] not supported in attach\n", + (UINT8) Opcode)); + + return_ACPI_STATUS (AE_TYPE); + break; + } + } + + else + { + /* + * Cannot figure out the type -- set to DefAny which + * will print as an error in the name table dump + */ + + if (GetDebugLevel () > 0) + { + DUMP_PATHNAME (Node, + "NsAttachObject confused: setting bogus type for ", + ACPI_INFO, _COMPONENT); + + if (AcpiTbSystemTablePointer (Object)) + { + DEBUG_PRINT (ACPI_INFO, + ("AML-stream code %02x\n", *(UINT8 *) Object)); + } + + else if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_NAMED)) + { + DUMP_PATHNAME (Object, + "name ", ACPI_INFO, + _COMPONENT); + } + + else + { + DUMP_PATHNAME (Object, "object ", + ACPI_INFO, _COMPONENT); + DUMP_STACK_ENTRY (Object); + } + } + + ObjType = INTERNAL_TYPE_DEF_ANY; + } + } + + + DEBUG_PRINT (TRACE_EXEC, + ("NsAttachObject: Installing obj %p into NameObj %p [%4.4s]\n", + ObjDesc, Node, &Node->Name)); + + + /* + * Must increment the new value's reference count + * (if it is an internal object) + */ + + AcpiCmAddReference (ObjDesc); + + /* Save the existing object (if any) for deletion later */ + + PreviousObjDesc = Node->Object; + + /* Install the object and set the type, flags */ + + Node->Object = ObjDesc; + Node->Type = (UINT8) ObjType; + Node->Flags |= Flags; + + + /* + * Delete an existing attached object. + */ + + if (PreviousObjDesc) + { + /* One for the attach to the Node */ + + AcpiCmRemoveReference (PreviousObjDesc); + + /* Now delete */ + + AcpiCmRemoveReference (PreviousObjDesc); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachObject + * + * PARAMETERS: Node - An object whose Value will be deleted + * + * RETURN: None. + * + * DESCRIPTION: Delete the Value associated with a namespace object. If the + * Value is an allocated object, it is freed. Otherwise, the + * field is simply cleared. + * + ******************************************************************************/ + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + FUNCTION_TRACE ("NsDetachObject"); + + ObjDesc = Node->Object; + if (!ObjDesc) + { + return_VOID; + } + + /* Clear the entry in all cases */ + + Node->Object = NULL; + + /* Found a valid value */ + + DEBUG_PRINT (ACPI_INFO, + ("NsDetachObject: Object=%p Value=%p Name %4.4s\n", + Node, ObjDesc, &Node->Name)); + + /* + * Not every value is an object allocated via AcpiCmCallocate, + * - must check + */ + + if (!AcpiTbSystemTablePointer (ObjDesc)) + { + /* Attempt to delete the object (and all subobjects) */ + + AcpiCmRemoveReference (ObjDesc); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedObject + * + * PARAMETERS: Handle - Parent Node to be examined + * + * RETURN: Current value of the object field from the Node whose + * handle is passed + * + ******************************************************************************/ + +void * +AcpiNsGetAttachedObject ( + ACPI_HANDLE Handle) +{ + FUNCTION_TRACE_PTR ("NsGetAttachedObject", Handle); + + + if (!Handle) + { + /* handle invalid */ + + REPORT_WARNING (("NsGetAttachedObject: Null handle\n")); + return_PTR (NULL); + } + + return_PTR (((ACPI_NAMESPACE_NODE *) Handle)->Object); +} + + diff --git a/sys/contrib/dev/acpica/nssearch.c b/sys/contrib/dev/acpica/nssearch.c new file mode 100644 index 0000000..e8e26af --- /dev/null +++ b/sys/contrib/dev/acpica/nssearch.c @@ -0,0 +1,505 @@ +/******************************************************************************* + * + * Module Name: nssearch - Namespace search + * $Revision: 58 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSSEARCH_C__ + +#include "acpi.h" +#include "amlcode.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nssearch") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchNode + * + * PARAMETERS: *TargetName - Ascii ACPI name to search for + * *Node - Starting table where search will begin + * Type - Object type to match + * **ReturnNode - Where the matched Named obj is returned + * + * RETURN: Status + * + * DESCRIPTION: Search a single namespace table. Performs a simple search, + * does not add entries or search parents. + * + * + * Named object lists are built (and subsequently dumped) in the + * order in which the names are encountered during the namespace load; + * + * All namespace searching is linear in this implementation, but + * could be easily modified to support any improved search + * algorithm. However, the linear search was chosen for simplicity + * and because the trees are small and the other interpreter + * execution overhead is relatively high. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchNode ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_NAMESPACE_NODE *NextNode; + + + FUNCTION_TRACE ("NsSearchNode"); + + { + DEBUG_EXEC (NATIVE_CHAR *ScopeName = AcpiNsGetTablePathname (Node)); + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: Searching %s [%p]\n", + ScopeName, Node)); + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: For %4.4s (type 0x%X)\n", + &TargetName, Type)); + DEBUG_EXEC (AcpiCmFree (ScopeName)); + } + + + /* + * Search for name in this table, which is to say that we must search + * for the name among the children of this object + */ + + NextNode = Node->Child; + while (NextNode) + { + /* Check for match against the name */ + + if (NextNode->Name == TargetName) + { + /* + * Found matching entry. Capture type if + * appropriate before returning the entry. + */ + + /* + * The DefFieldDefn and BankFieldDefn cases + * are actually looking up the Region in which + * the field will be defined + */ + + if ((INTERNAL_TYPE_DEF_FIELD_DEFN == Type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) + { + Type = ACPI_TYPE_REGION; + } + + /* + * Scope, DefAny, and IndexFieldDefn are bogus + * "types" which do not actually have anything + * to do with the type of the name being looked + * up. For any other value of Type, if the type + * stored in the entry is Any (i.e. unknown), + * save the actual type. + */ + + if (Type != INTERNAL_TYPE_SCOPE && + Type != INTERNAL_TYPE_DEF_ANY && + Type != INTERNAL_TYPE_INDEX_FIELD_DEFN && + NextNode->Type == ACPI_TYPE_ANY) + { + NextNode->Type = (UINT8) Type; + } + + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: Name %4.4s (actual type 0x%X) found at %p\n", + &TargetName, NextNode->Type, NextNode)); + + *ReturnNode = NextNode; + return_ACPI_STATUS (AE_OK); + } + + + /* + * The last entry in the list points back to the parent, + * so a flag is used to indicate the end-of-list + */ + if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + { + /* Searched entire list, we are done */ + + break; + } + + /* Didn't match name, move on to the next peer object */ + + NextNode = NextNode->Peer; + } + + + /* Searched entire table, not found */ + + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchNode: Name %4.4s (type 0x%X) not found at %p\n", + &TargetName, Type, NextNode)); + + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchParentTree + * + * PARAMETERS: *TargetName - Ascii ACPI name to search for + * *Node - Starting table where search will begin + * Type - Object type to match + * **ReturnNode - Where the matched Named Obj is returned + * + * RETURN: Status + * + * DESCRIPTION: Called when a name has not been found in the current namespace + * table. Before adding it or giving up, ACPI scope rules require + * 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) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE ("NsSearchParentTree"); + + + ParentNode = AcpiNsGetParentObject (Node); + + /* + * If there is no parent (at the root) or type is "local", we won't be + * searching the parent tree. + */ + if ((AcpiNsLocal (Type)) || + (!ParentNode)) + { + if (!ParentNode) + { + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchParentTree: [%4.4s] has no parent\n", + &TargetName)); + } + + if (AcpiNsLocal (Type)) + { + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchParentTree: [%4.4s] (type 0x%X) is local (no search)\n", + &TargetName, Type)); + } + + return_ACPI_STATUS (AE_NOT_FOUND); + } + + + /* Search the parent tree */ + + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchParentTree: Searching parent for %4.4s\n", + &TargetName)); + + /* + * Search parents until found the target or we have backed up to + * the root + */ + + while (ParentNode) + { + /* Search parent scope */ + /* TBD: [Investigate] Why ACPI_TYPE_ANY? */ + + Status = AcpiNsSearchNode (TargetName, ParentNode, + ACPI_TYPE_ANY, ReturnNode); + + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Not found here, go up another level + * (until we reach the root) + */ + + ParentNode = AcpiNsGetParentObject (ParentNode); + } + + + /* Not found in parent tree */ + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchAndEnter + * + * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) + * WalkState - Current state of the walk + * *Node - Starting table where search will begin + * InterpreterMode - Add names only in MODE_LoadPassX. + * Otherwise,search only. + * Type - Object type to match + * Flags - Flags describing the search restrictions + * **ReturnNode - Where the Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Search for a name segment in a single name table, + * optionally adding it if it is not found. If the passed + * Type is not Any and the type previously stored in the + * entry was Any (i.e. unknown), update the stored type. + * + * In IMODE_EXECUTE, search only. + * In other modes, search and add if not found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 TargetName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + OPERATING_MODE InterpreterMode, + OBJECT_TYPE_INTERNAL Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *NewNode; + + + FUNCTION_TRACE ("NsSearchAndEnter"); + + + /* Parameter validation */ + + if (!Node || !TargetName || !ReturnNode) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsSearchAndEnter: Null param: Table %p Name %p Return %p\n", + Node, TargetName, ReturnNode)); + + REPORT_ERROR (("NsSearchAndEnter: bad (null) parameter\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Name must consist of printable characters */ + + if (!AcpiCmValidAcpiName (TargetName)) + { + DEBUG_PRINT (ACPI_ERROR, + ("NsSearchAndEnter: *** Bad character in name: %08lx *** \n", + TargetName)); + + REPORT_ERROR (("NsSearchAndEnter: Bad character in ACPI Name\n")); + return_ACPI_STATUS (AE_BAD_CHARACTER); + } + + + /* Try to find the name in the table specified by the caller */ + + *ReturnNode = ENTRY_NOT_FOUND; + Status = AcpiNsSearchNode (TargetName, Node, + Type, ReturnNode); + if (Status != AE_NOT_FOUND) + { + /* + * Either found it or there was an error + * -- finished either way + */ + return_ACPI_STATUS (Status); + } + + + /* + * Not found in the table. 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 != IMODE_LOAD_PASS1) && + (Flags & NS_SEARCH_PARENT)) + { + /* + * Not found in table - search parent tree according + * to ACPI specification + */ + + Status = AcpiNsSearchParentTree (TargetName, Node, + Type, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + /* + * In execute mode, just search, never add names. Exit now. + */ + if (InterpreterMode == IMODE_EXECUTE) + { + DEBUG_PRINT (TRACE_NAMES, + ("NsSearchAndEnter: %4.4s Not found in %p [Not adding]\n", + &TargetName, Node)); + + return_ACPI_STATUS (AE_NOT_FOUND); + } + + + /* Create the new named object */ + + NewNode = AcpiNsCreateNode (TargetName); + if (!NewNode) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Install the new object into the parent's list of children */ + + AcpiNsInstallNode (WalkState, Node, NewNode, Type); + *ReturnNode = NewNode; + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/nsutils.c b/sys/contrib/dev/acpica/nsutils.c new file mode 100644 index 0000000..1a259b1 --- /dev/null +++ b/sys/contrib/dev/acpica/nsutils.c @@ -0,0 +1,1001 @@ +/****************************************************************************** + * + * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing + * parents and siblings and Scope manipulation + * $Revision: 71 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSUTILS_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" +#include "actables.h" + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsutils") + + +/**************************************************************************** + * + * FUNCTION: AcpiNsValidRootPrefix + * + * PARAMETERS: Prefix - Character to be checked + * + * RETURN: TRUE if a valid prefix + * + * DESCRIPTION: Check if a character is a valid ACPI Root prefix + * + ***************************************************************************/ + +BOOLEAN +AcpiNsValidRootPrefix ( + NATIVE_CHAR Prefix) +{ + + return ((BOOLEAN) (Prefix == '\\')); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsValidPathSeparator + * + * PARAMETERS: Sep - Character to be checked + * + * RETURN: TRUE if a valid path separator + * + * DESCRIPTION: Check if a character is a valid ACPI path separator + * + ***************************************************************************/ + +BOOLEAN +AcpiNsValidPathSeparator ( + NATIVE_CHAR Sep) +{ + + return ((BOOLEAN) (Sep == '.')); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsGetType + * + * PARAMETERS: Handle - Parent Node to be examined + * + * RETURN: Type field from Node whose handle is passed + * + ***************************************************************************/ + +OBJECT_TYPE_INTERNAL +AcpiNsGetType ( + ACPI_HANDLE handle) +{ + FUNCTION_TRACE ("NsGetType"); + + + if (!handle) + { + REPORT_WARNING (("NsGetType: Null handle\n")); + return_VALUE (ACPI_TYPE_ANY); + } + + return_VALUE (((ACPI_NAMESPACE_NODE *) handle)->Type); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsLocal + * + * PARAMETERS: Type - A namespace object type + * + * RETURN: LOCAL if names must be found locally in objects of the + * passed type, 0 if enclosing scopes should be searched + * + ***************************************************************************/ + +UINT32 +AcpiNsLocal ( + OBJECT_TYPE_INTERNAL Type) +{ + FUNCTION_TRACE ("NsLocal"); + + + if (!AcpiCmValidObjectType (Type)) + { + /* Type code out of range */ + + REPORT_WARNING (("NsLocal: Invalid Object Type\n")); + return_VALUE (NSP_NORMAL); + } + + return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & NSP_LOCAL); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsInternalizeName + * + * PARAMETERS: *ExternalName - External representation of name + * **Converted Name - Where to return the resulting + * internal represention of the name + * + * RETURN: Status + * + * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") + * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsInternalizeName ( + NATIVE_CHAR *ExternalName, + NATIVE_CHAR **ConvertedName) +{ + NATIVE_CHAR *Result = NULL; + NATIVE_CHAR *InternalName; + UINT32 NumSegments; + BOOLEAN FullyQualified = FALSE; + UINT32 i; + + + FUNCTION_TRACE ("NsInternalizeName"); + + + if ((!ExternalName) || + (*ExternalName == 0) || + (!ConvertedName)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* + * 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 (ExternalName[0])) + { + FullyQualified = TRUE; + ExternalName++; + } + + + /* + * 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. + */ + + NumSegments = 1; + for (i = 0; ExternalName[i]; i++) + { + if (AcpiNsValidPathSeparator (ExternalName[i])) + { + NumSegments++; + } + } + + + /* We need a segment to store the internal version of the name */ + + InternalName = AcpiCmCallocate ((ACPI_NAME_SIZE * NumSegments) + 4); + if (!InternalName) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + /* Setup the correct prefixes, counts, and pointers */ + + if (FullyQualified) + { + InternalName[0] = '\\'; + InternalName[1] = AML_MULTI_NAME_PREFIX_OP; + InternalName[2] = (char) NumSegments; + Result = &InternalName[3]; + } + else + { + InternalName[0] = AML_MULTI_NAME_PREFIX_OP; + InternalName[1] = (char) NumSegments; + Result = &InternalName[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 INT8 to uppercase and save it */ + + Result[i] = (char) TOUPPER (*ExternalName); + ExternalName++; + } + + } + + /* Now we must have a path separator, or the pathname is bad */ + + if (!AcpiNsValidPathSeparator (*ExternalName) && + (*ExternalName != 0)) + { + AcpiCmFree (InternalName); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Move on the next segment */ + + ExternalName++; + Result += ACPI_NAME_SIZE; + } + + + /* Return the completed name */ + + /* Terminate the string! */ + *Result = 0; + *ConvertedName = InternalName; + + + if (FullyQualified) + { + DEBUG_PRINT (TRACE_EXEC, + ("NsInternalizeName: returning [%p] (abs) \"\\%s\"\n", + InternalName, &InternalName[3])); + } + else + { + DEBUG_PRINT (TRACE_EXEC, + ("NsInternalizeName: returning [%p] (rel) \"%s\"\n", + InternalName, &InternalName[2])); + } + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsExternalizeName + * + * PARAMETERS: *InternalName - Internal representation of name + * **ConvertedName - Where to return the resulting + * external representation of name + * + * RETURN: Status + * + * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * to its external form (e.g. "\_PR_.CPU0") + * + ****************************************************************************/ + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName) +{ + UINT32 PrefixLength = 0; + UINT32 NamesIndex = 0; + UINT32 NamesCount = 0; + UINT32 i = 0; + UINT32 j = 0; + + + FUNCTION_TRACE ("NsExternalizeName"); + + + if (!InternalNameLength || + !InternalName || + !ConvertedNameLength || + !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; + } + } + + if (i == InternalNameLength) + { + PrefixLength = i; + } + + break; + } + + /* + * Check for object names. Note that there could be 0-255 of these + * 4-byte elements. + */ + if (PrefixLength < InternalNameLength) + { + switch (InternalName[PrefixLength]) + { + + /* 4-byte names */ + + case AML_MULTI_NAME_PREFIX_OP: + NamesIndex = PrefixLength + 2; + NamesCount = (UINT32) InternalName[PrefixLength + 1]; + break; + + + /* two 4-byte names */ + + case AML_DUAL_NAME_PREFIX: + NamesIndex = PrefixLength + 1; + NamesCount = 2; + break; + + + /* NullName */ + + case 0: + NamesIndex = 0; + NamesCount = 0; + break; + + + /* one 4-byte name */ + + default: + NamesIndex = PrefixLength; + NamesCount = 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. + */ + *ConvertedNameLength = PrefixLength + (4 * NamesCount) + + ((NamesCount > 0) ? (NamesCount - 1) : 0) + 1; + + /* + * Check to see if we're still in bounds. If not, there's a problem + * with InternalName (invalid format). + */ + if (*ConvertedNameLength > InternalNameLength) + { + REPORT_ERROR (("NsExternalizeName: Invalid internal name\n")); + return_ACPI_STATUS (AE_BAD_PATHNAME); + } + + /* + * Build ConvertedName... + */ + + (*ConvertedName) = AcpiCmCallocate (*ConvertedNameLength); + if (!(*ConvertedName)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + j = 0; + + for (i = 0; i < PrefixLength; i++) + { + (*ConvertedName)[j++] = InternalName[i]; + } + + if (NamesCount > 0) + { + for (i = 0; i < NamesCount; i++) + { + if (i > 0) + { + (*ConvertedName)[j++] = '.'; + } + + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsConvertHandleToEntry + * + * PARAMETERS: Handle - Handle to be converted to an Node + * + * RETURN: A Name table entry pointer + * + * DESCRIPTION: Convert a namespace handle to a real Node + * + ****************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsConvertHandleToEntry ( + ACPI_HANDLE Handle) +{ + + /* + * Simple implementation for now; + * TBD: [Future] Real integer handles allow for more verification + * and keep all pointers within this subsystem! + */ + + if (!Handle) + { + return (NULL); + } + + if (Handle == ACPI_ROOT_OBJECT) + { + return (AcpiGbl_RootNode); + } + + + /* We can at least attempt to verify the handle */ + + if (!VALID_DESCRIPTOR_TYPE (Handle, ACPI_DESC_TYPE_NAMED)) + { + return (NULL); + } + + return ((ACPI_NAMESPACE_NODE *) Handle); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsConvertEntryToHandle + * + * PARAMETERS: Node - Node to be converted to a Handle + * + * RETURN: An USER ACPI_HANDLE + * + * DESCRIPTION: Convert a real Node to a namespace handle + * + ****************************************************************************/ + +ACPI_HANDLE +AcpiNsConvertEntryToHandle ( + ACPI_NAMESPACE_NODE *Node) +{ + + + /* + * Simple implementation for now; + * TBD: [Future] Real integer handles allow for more verification + * and keep all pointers within this subsystem! + */ + + return ((ACPI_HANDLE) Node); + + +/* --------------------------------------------------- + + if (!Node) + { + return (NULL); + } + + if (Node == AcpiGbl_RootNode) + { + return (ACPI_ROOT_OBJECT); + } + + + return ((ACPI_HANDLE) Node); +------------------------------------------------------*/ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiNsTerminate (void) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *ThisNode; + + + FUNCTION_TRACE ("NsTerminate"); + + + ThisNode = AcpiGbl_RootNode; + + /* + * 1) Free the entire namespace -- all objects, tables, and stacks + */ + /* + * Delete all objects linked to the root + * (additional table descriptors) + */ + + AcpiNsDeleteNamespaceSubtree (ThisNode); + + /* Detach any object(s) attached to the root */ + + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + if (ObjDesc) + { + AcpiNsDetachObject (ThisNode); + AcpiCmRemoveReference (ObjDesc); + } + + AcpiNsDeleteChildren (ThisNode); + + DEBUG_PRINT (ACPI_INFO, ("NsTerminate: Namespace freed\n")); + + + /* + * 2) Now we can delete the ACPI tables + */ + + AcpiTbDeleteAcpiTables (); + + DEBUG_PRINT (ACPI_INFO, ("NsTerminate: ACPI Tables freed\n")); + + return_VOID; +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsOpensScope + * + * PARAMETERS: Type - A valid namespace type + * + * RETURN: NEWSCOPE if the passed type "opens a name scope" according + * to the ACPI specification, else 0 + * + ***************************************************************************/ + +UINT32 +AcpiNsOpensScope ( + OBJECT_TYPE_INTERNAL Type) +{ + FUNCTION_TRACE_U32 ("NsOpensScope", Type); + + + if (!AcpiCmValidObjectType (Type)) + { + /* type code out of range */ + + REPORT_WARNING (("NsOpensScope: Invalid Object Type\n")); + return_VALUE (NSP_NORMAL); + } + + return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & NSP_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. + * StartNode - Root of subtree to be searched, or NS_ALL for the + * root of the name space. If Name is fully + * qualified (first INT8 is '\'), the passed value + * of Scope will not be accessed. + * 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 ( + NATIVE_CHAR *Pathname, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_GENERIC_STATE ScopeInfo; + ACPI_STATUS Status; + NATIVE_CHAR *InternalPath = NULL; + + + FUNCTION_TRACE_PTR ("NsGetNte", Pathname); + + + ScopeInfo.Scope.Node = StartNode; + + /* Ensure that the namespace has been initialized */ + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + if (!Pathname) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Convert path to internal representation */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* NS_ALL means start from the root */ + + if (NS_ALL == ScopeInfo.Scope.Node) + { + ScopeInfo.Scope.Node = AcpiGbl_RootNode; + } + + else + { + ScopeInfo.Scope.Node = StartNode; + if (!ScopeInfo.Scope.Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* Lookup the name in the namespace */ + + Status = AcpiNsLookup (&ScopeInfo, InternalPath, + ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + NULL, ReturnNode); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_INFO, ("NsGetNte: %s, %s\n", + InternalPath, AcpiCmFormatException (Status))); + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Cleanup */ + + AcpiCmFree (InternalPath); + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsFindParentName + * + * PARAMETERS: *ChildNode - Named Obj whose name is to be found + * + * RETURN: The ACPI name + * + * DESCRIPTION: Search for the given obj in its parent scope and return the + * name segment, or "????" if the parent name can't be found + * (which "should not happen"). + * + ***************************************************************************/ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *ParentNode; + + + FUNCTION_TRACE ("FindParentName"); + + + if (ChildNode) + { + /* Valid entry. Get the parent Node */ + + ParentNode = AcpiNsGetParentObject (ChildNode); + if (ParentNode) + { + DEBUG_PRINT (TRACE_EXEC, + ("Parent of %p [%4.4s] is %p [%4.4s]\n", + ChildNode, &ChildNode->Name, ParentNode, + &ParentNode->Name)); + + if (ParentNode->Name) + { + return_VALUE (ParentNode->Name); + } + } + + DEBUG_PRINT (TRACE_EXEC, + ("FindParentName: unable to find parent of %p (%4.4s)\n", + ChildNode, &ChildNode->Name)); + } + + + return_VALUE (ACPI_UNKNOWN_NAME); +} + + +#ifdef ACPI_DEBUG + +/**************************************************************************** + * + * FUNCTION: AcpiNsExistDownstreamSibling + * + * PARAMETERS: *Node - pointer to first Node to examine + * + * RETURN: TRUE if sibling is found, FALSE otherwise + * + * DESCRIPTION: Searches remainder of scope being processed to determine + * whether there is a downstream sibling to the current + * object. This function is used to determine what type of + * line drawing character to use when displaying namespace + * trees. + * + ***************************************************************************/ + +BOOLEAN +AcpiNsExistDownstreamSibling ( + ACPI_NAMESPACE_NODE *Node) +{ + + if (!Node) + { + return (FALSE); + } + + if (Node->Name) + { + return (TRUE); + } + + return (FALSE); +} + +#endif /* ACPI_DEBUG */ + + +/**************************************************************************** + * + * FUNCTION: AcpiNsGetParentObject + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Parent entry of the given entry + * + * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. + * + ***************************************************************************/ + + +ACPI_NAMESPACE_NODE * +AcpiNsGetParentObject ( + ACPI_NAMESPACE_NODE *Node) +{ + + + /* + * Walk to the end of this peer list. + * The last entry is marked with a flag and the peer + * pointer is really a pointer back to the parent. + * This saves putting a parent back pointer in each and + * every named object! + */ + + while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) + { + Node = Node->Peer; + } + + + return (Node->Peer); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiNsGetNextValidObject + * + * PARAMETERS: Node - Current table entry + * + * RETURN: Next valid object in the table. NULL if no more valid + * objects + * + * DESCRIPTION: Find the next valid object within a name table. + * Useful for implementing NULL-end-of-list loops. + * + ***************************************************************************/ + + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextValidObject ( + ACPI_NAMESPACE_NODE *Node) +{ + + /* If we are at the end of this peer list, return NULL */ + + if (Node->Flags & ANOBJ_END_OF_PEER_LIST) + { + return NULL; + } + + /* Otherwise just return the next peer */ + + return (Node->Peer); +} + + diff --git a/sys/contrib/dev/acpica/nswalk.c b/sys/contrib/dev/acpica/nswalk.c new file mode 100644 index 0000000..9b37c32 --- /dev/null +++ b/sys/contrib/dev/acpica/nswalk.c @@ -0,0 +1,384 @@ +/****************************************************************************** + * + * Module Name: nswalk - Functions for walking the APCI namespace + * $Revision: 17 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSWALK_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nswalk") + + +/**************************************************************************** + * + * 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 + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * 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_NAMESPACE_NODE * +AcpiNsGetNextObject ( + OBJECT_TYPE_INTERNAL Type, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *NextNode = NULL; + + + if (!ChildNode) + { + + /* It's really the parent's _scope_ that we want */ + + if (ParentNode->Child) + { + NextNode = ParentNode->Child; + } + } + + else + { + /* Start search at the NEXT object */ + + NextNode = AcpiNsGetNextValidObject (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 object -- 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 object */ + + NextNode = AcpiNsGetNextValidObject (NextNode); + } + + + /* Not found */ + + return (NULL); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiNsWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartNode - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * UnlockBeforeCallback- Whether to unlock the NS before invoking + * the callback routine + * UserFunction - Called when an object of "Type" is found + * Context - Passed to user function + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object that matches + * the type parameter is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the User Function can be tailored + * to each task, whether it is a print function, a compare + * function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsWalkNamespace ( + OBJECT_TYPE_INTERNAL Type, + ACPI_HANDLE StartNode, + UINT32 MaxDepth, + BOOLEAN UnlockBeforeCallback, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *ParentNode; + OBJECT_TYPE_INTERNAL ChildType; + UINT32 Level; + + + FUNCTION_TRACE ("NsWalkNamespace"); + + /* Special case for the namespace Root Node */ + + if (StartNode == ACPI_ROOT_OBJECT) + { + StartNode = AcpiGbl_RootNode; + } + + + /* Null child means "get first object" */ + + ParentNode = StartNode; + ChildNode = 0; + ChildType = ACPI_TYPE_ANY; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up to where we + * started. When Level is zero, the loop is done because we have + * bubbled up to (and passed) the original parent handle (StartEntry) + */ + + while (Level > 0) + { + /* + * Get the next typed object in this scope. Null returned + * if not found + */ + + Status = AE_OK; + ChildNode = AcpiNsGetNextObject (ACPI_TYPE_ANY, + ParentNode, + ChildNode); + + if (ChildNode) + { + /* + * Found an object, Get the type if we are not + * searching for ANY + */ + + if (Type != ACPI_TYPE_ANY) + { + ChildType = ChildNode->Type; + } + + if (ChildType == Type) + { + /* + * Found a matching object, invoke the user + * callback function + */ + + if (UnlockBeforeCallback) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + Status = UserFunction (ChildNode, Level, + Context, ReturnValue); + + if (UnlockBeforeCallback) + { + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + } + + 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); + break; + + default: + /* All others are valid exceptions */ + return_ACPI_STATUS (Status); + break; + } + } + + /* + * Depth first search: + * Attempt to go down another level in the namespace + * if we are allowed to. Don't go any further if we + * have reached the caller specified maximum depth + * or if the user function has specified that the + * maximum depth has been reached. + */ + + if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) + { + if (AcpiNsGetNextObject (ACPI_TYPE_ANY, + ChildNode, 0)) + { + /* + * There is at least one child of this + * object, visit the object + */ + Level++; + ParentNode = ChildNode; + ChildNode = 0; + } + } + } + + else + { + /* + * No more children in this object (AcpiNsGetNextObject + * failed), go back upwards in the namespace tree to + * the object's parent. + */ + Level--; + ChildNode = ParentNode; + ParentNode = AcpiNsGetParentObject (ParentNode); + } + } + + /* Complete walk, not terminated by user function */ + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/nsxfname.c b/sys/contrib/dev/acpica/nsxfname.c new file mode 100644 index 0000000..7133b9f --- /dev/null +++ b/sys/contrib/dev/acpica/nsxfname.c @@ -0,0 +1,410 @@ +/****************************************************************************** + * + * Module Name: nsxfname - Public interfaces to the ACPI subsystem + * ACPI Namespace oriented interfaces + * $Revision: 71 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __NSXFNAME_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acevents.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsxfname") + + +/**************************************************************************** + * + * FUNCTION: AcpiGetHandle + * + * PARAMETERS: Parent - Object to search under (search scope). + * PathName - Pointer to an asciiz string containing the + * name + * RetHandle - Where the return handle is placed + * + * RETURN: Status + * + * DESCRIPTION: This routine will search for a caller specified name in the + * name space. The caller can restrict the search region by + * specifying a non NULL parent. The parent value is itself a + * namespace handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *PrefixNode = NULL; + + + if (!RetHandle || !Pathname) + { + return (AE_BAD_PARAMETER); + } + + if (Parent) + { + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (Parent); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + PrefixNode = Node->Child; + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + } + + /* Special case for root, since we can't search for it */ + /* TBD: [Investigate] Check for both forward and backslash?? */ + + if (STRCMP (Pathname, NS_ROOT_PATH) == 0) + { + *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode); + return (AE_OK); + } + + /* + * Find the Node and convert to the user format + */ + Node = NULL; + Status = AcpiNsGetNode (Pathname, PrefixNode, &Node); + + *RetHandle = NULL; + if(ACPI_SUCCESS(Status)) + { + *RetHandle = AcpiNsConvertEntryToHandle (Node); + } + + return (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiGetPathname + * + * PARAMETERS: Handle - Handle to be converted to a pathname + * NameType - Full pathname or single segment + * RetPathPtr - 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 *RetPathPtr) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + /* Buffer pointer must be valid always */ + + if (!RetPathPtr || (NameType > ACPI_NAME_TYPE_MAX)) + { + return (AE_BAD_PARAMETER); + } + + /* Allow length to be zero and ignore the pointer */ + + if ((RetPathPtr->Length) && + (!RetPathPtr->Pointer)) + { + return (AE_BAD_PARAMETER); + } + + if (NameType == ACPI_FULL_PATHNAME) + { + /* Get the full pathname (From the namespace root) */ + + Status = AcpiNsHandleToPathname (Handle, &RetPathPtr->Length, + RetPathPtr->Pointer); + return (Status); + } + + /* + * Wants the single segment ACPI name. + * Validate handle and convert to an Node + */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Check if name will fit in buffer */ + + if (RetPathPtr->Length < PATH_SEGMENT_LENGTH) + { + RetPathPtr->Length = PATH_SEGMENT_LENGTH; + Status = AE_BUFFER_OVERFLOW; + goto UnlockAndExit; + } + + /* Just copy the ACPI name from the Node and zero terminate it */ + + STRNCPY (RetPathPtr->Pointer, (NATIVE_CHAR *) &Node->Name, + ACPI_NAME_SIZE); + ((NATIVE_CHAR *) RetPathPtr->Pointer) [ACPI_NAME_SIZE] = 0; + Status = AE_OK; + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiGetObjectInfo + * + * PARAMETERS: Handle - Object Handle + * Info - Where the info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns information about an object as gleaned from the + * namespace node and possibly by running several standard + * control methods (Such as in the case of a device.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO *Info) +{ + DEVICE_ID Hid; + DEVICE_ID Uid; + ACPI_STATUS Status; + UINT32 DeviceStatus = 0; + ACPI_INTEGER Address = 0; + ACPI_NAMESPACE_NODE *Node; + + + /* Parameter validation */ + + if (!Handle || !Info) + { + return (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + Info->Type = Node->Type; + Info->Name = Node->Name; + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * If not a device, we are all done. + */ + if (Info->Type != ACPI_TYPE_DEVICE) + { + return (AE_OK); + } + + + /* + * Get extra info for ACPI devices only. Run the + * _HID, _UID, _STA, and _ADR methods. Note: none + * of these methods are required, so they may or may + * not be present. The Info->Valid bits are used + * to indicate which methods ran successfully. + */ + + Info->Valid = 0; + + /* Execute the _HID method and save the result */ + + Status = AcpiCmExecute_HID (Node, &Hid); + if (ACPI_SUCCESS (Status)) + { + STRNCPY (Info->HardwareId, Hid.Buffer, sizeof(Info->HardwareId)); + + Info->Valid |= ACPI_VALID_HID; + } + + /* Execute the _UID method and save the result */ + + Status = AcpiCmExecute_UID (Node, &Uid); + if (ACPI_SUCCESS (Status)) + { + STRCPY (Info->UniqueId, Uid.Buffer); + + Info->Valid |= ACPI_VALID_UID; + } + + /* + * Execute the _STA method and save the result + * _STA is not always present + */ + + Status = AcpiCmExecute_STA (Node, &DeviceStatus); + if (ACPI_SUCCESS (Status)) + { + Info->CurrentStatus = DeviceStatus; + Info->Valid |= ACPI_VALID_STA; + } + + /* + * Execute the _ADR method and save result if successful + * _ADR is not always present + */ + + Status = AcpiCmEvaluateNumericObject (METHOD_NAME__ADR, + Node, &Address); + + if (ACPI_SUCCESS (Status)) + { + Info->Address = Address; + Info->Valid |= ACPI_VALID_ADR; + } + + return (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/nsxfobj.c b/sys/contrib/dev/acpica/nsxfobj.c new file mode 100644 index 0000000..8092758 --- /dev/null +++ b/sys/contrib/dev/acpica/nsxfobj.c @@ -0,0 +1,853 @@ +/******************************************************************************* + * + * Module Name: nsxfobj - Public interfaces to the ACPI subsystem + * ACPI Object oriented interfaces + * $Revision: 74 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __NSXFOBJ_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsxfobj") + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObject + * + * PARAMETERS: Handle - Object handle (optional) + * *Pathname - Object pathname (optional) + * **Params - List of parameters to pass to + * method, terminated by NULL. + * Params itself may be NULL + * if no parameters are being + * passed. + * *ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Find and 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 *ParamObjects, + ACPI_BUFFER *ReturnBuffer) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **ParamPtr = NULL; + ACPI_OPERAND_OBJECT *ReturnObj = NULL; + ACPI_OPERAND_OBJECT *ObjectPtr = NULL; + UINT32 BufferSpaceNeeded; + UINT32 UserBufferLength; + UINT32 Count; + UINT32 i; + UINT32 ParamLength; + UINT32 ObjectLength; + + + FUNCTION_TRACE ("AcpiEvaluateObject"); + + + /* + * If there are parameters to be passed to the object + * (which must be a control method), the external objects + * must be converted to internal objects + */ + + if (ParamObjects && ParamObjects->Count) + { + /* + * Allocate a new parameter block for the internal objects + * Add 1 to count to allow for null terminated internal list + */ + + Count = ParamObjects->Count; + ParamLength = (Count + 1) * sizeof (void *); + ObjectLength = Count * sizeof (ACPI_OPERAND_OBJECT); + + ParamPtr = AcpiCmCallocate (ParamLength + /* Parameter List part */ + ObjectLength); /* Actual objects */ + if (!ParamPtr) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjectPtr = (ACPI_OPERAND_OBJECT *) ((UINT8 *) ParamPtr + + ParamLength); + + /* + * Init the param array of pointers and NULL terminate + * the list + */ + + for (i = 0; i < Count; i++) + { + ParamPtr[i] = &ObjectPtr[i]; + AcpiCmInitStaticObject (&ObjectPtr[i]); + } + ParamPtr[Count] = NULL; + + /* + * Convert each external object in the list to an + * internal object + */ + for (i = 0; i < Count; i++) + { + Status = + AcpiCmBuildInternalObject (&ParamObjects->Pointer[i], + ParamPtr[i]); + + if (ACPI_FAILURE (Status)) + { + AcpiCmDeleteInternalObjectList (ParamPtr); + return_ACPI_STATUS (Status); + } + } + } + + + /* + * Three major cases: + * 1) Fully qualified pathname + * 2) No handle, not fully qualified pathname (error) + * 3) Valid handle + */ + + if ((Pathname) && + (AcpiNsValidRootPrefix (Pathname[0]))) + { + /* + * The path is fully qualified, just evaluate by name + */ + Status = AcpiNsEvaluateByName (Pathname, ParamPtr, &ReturnObj); + } + + 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) + { + DEBUG_PRINT (ACPI_ERROR, + ("AcpiEvaluateObject: Both Handle and Pathname are NULL\n")); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("AcpiEvaluateObject: Handle is NULL and Pathname is relative\n")); + } + + Status = AE_BAD_PARAMETER; + } + + else + { + /* + * We get here if we have a handle -- and if we have a + * pathname it is relative. The handle will be validated + * in the lower procedures + */ + + if (!Pathname) + { + /* + * The null pathname case means the handle is for + * the actual object to be evaluated + */ + Status = AcpiNsEvaluateByHandle (Handle, ParamPtr, &ReturnObj); + } + + else + { + /* + * Both a Handle and a relative Pathname + */ + Status = AcpiNsEvaluateRelative (Handle, Pathname, ParamPtr, + &ReturnObj); + } + } + + + /* + * If we are expecting a return value, and all went well above, + * copy the return value to an external object. + */ + + if (ReturnBuffer) + { + UserBufferLength = ReturnBuffer->Length; + ReturnBuffer->Length = 0; + + if (ReturnObj) + { + if (VALID_DESCRIPTOR_TYPE (ReturnObj, ACPI_DESC_TYPE_NAMED)) + { + /* + * If we got an Node as a return object, + * this means 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; + ReturnObj = NULL; /* No need to delete an Node */ + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Find out how large a buffer is needed + * to contain the returned object + */ + Status = AcpiCmGetObjectSize (ReturnObj, + &BufferSpaceNeeded); + if (ACPI_SUCCESS (Status)) + { + /* + * Check if there is enough room in the + * caller's buffer + */ + + if (UserBufferLength < BufferSpaceNeeded) + { + /* + * Caller's buffer is too small, can't + * give him partial results fail the call + * but return the buffer size needed + */ + + DEBUG_PRINT (ACPI_INFO, + ("AcpiEvaluateObject: Needed buffer size %d, received %d\n", + BufferSpaceNeeded, UserBufferLength)); + + ReturnBuffer->Length = BufferSpaceNeeded; + Status = AE_BUFFER_OVERFLOW; + } + + else + { + /* + * We have enough space for the object, build it + */ + Status = AcpiCmBuildExternalObject (ReturnObj, + ReturnBuffer); + ReturnBuffer->Length = BufferSpaceNeeded; + } + } + } + } + } + + + /* Delete the return and parameter objects */ + + if (ReturnObj) + { + /* + * Delete the internal return object. (Or at least + * decrement the reference count by one) + */ + AcpiCmRemoveReference (ReturnObj); + } + + /* + * Free the input parameter list (if we created one), + */ + + if (ParamPtr) + { + /* Free the allocated parameter block */ + + AcpiCmDeleteInternalObjectList (ParamPtr); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetNextObject + * + * PARAMETERS: Type - Type of object to be searched for + * Parent - Parent object whose children we are getting + * LastChild - Previous child that was found. + * The NEXT child will be returned + * RetHandle - Where handle to the next object is placed + * + * RETURN: Status + * + * DESCRIPTION: Return the next peer object within the namespace. If Handle is + * valid, Scope is ignored. Otherwise, the first object within + * Scope is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status = AE_OK; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode = NULL; + ACPI_NAMESPACE_NODE *ChildNode = NULL; + + + /* Parameter validation */ + + if (Type > ACPI_TYPE_MAX) + { + return (AE_BAD_PARAMETER); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* If null handle, use the parent */ + + if (!Child) + { + /* Start search at the beginning of the specified scope */ + + ParentNode = AcpiNsConvertHandleToEntry (Parent); + if (!ParentNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* Non-null handle, ignore the parent */ + + else + { + /* Convert and validate the handle */ + + ChildNode = AcpiNsConvertHandleToEntry (Child); + if (!ChildNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + + /* Internal function does the real work */ + + Node = AcpiNsGetNextObject ((OBJECT_TYPE_INTERNAL) Type, + ParentNode, ChildNode); + if (!Node) + { + Status = AE_NOT_FOUND; + goto UnlockAndExit; + } + + if (RetHandle) + { + *RetHandle = AcpiNsConvertEntryToHandle (Node); + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + + +/******************************************************************************* + * + * 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; + + + /* 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); + } + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the handle */ + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + *RetType = Node->Type; + + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetParent + * + * PARAMETERS: Handle - Handle of object whose parent is desired + * RetHandle - Where the parent handle will be placed + * + * RETURN: Status + * + * DESCRIPTION: Returns a handle to the parent of the object represented by + * Handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Handle, + ACPI_HANDLE *RetHandle) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status = AE_OK; + + + /* No trace macro, too verbose */ + + + if (!RetHandle) + { + return (AE_BAD_PARAMETER); + } + + /* Special case for the predefined Root Node (no parent) */ + + if (Handle == ACPI_ROOT_OBJECT) + { + return (AE_NULL_ENTRY); + } + + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + /* Convert and validate the handle */ + + Node = AcpiNsConvertHandleToEntry (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + + /* Get the parent entry */ + + *RetHandle = + AcpiNsConvertEntryToHandle (AcpiNsGetParentObject (Node)); + + /* Return exeption if parent is null */ + + if (!AcpiNsGetParentObject (Node)) + { + Status = AE_NULL_ENTRY; + } + + +UnlockAndExit: + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartObject - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * UserFunction - Called when an object of "Type" is found + * Context - Passed to user function + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object that matches + * the type parameter is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the User Function can be tailored + * to each task, whether it is a print function, a compare + * function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiWalkNamespace"); + + + /* Parameter validation */ + + if ((Type > ACPI_TYPE_MAX) || + (!MaxDepth) || + (!UserFunction)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Lock the namespace around the walk. + * The namespace will be unlocked/locked around each call + * to the user function - since this function + * must be allowed to make Acpi calls itself. + */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiNsWalkNamespace ((OBJECT_TYPE_INTERNAL) Type, + StartObject, MaxDepth, + NS_WALK_UNLOCK, + UserFunction, Context, + ReturnValue); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetDeviceCallback + * + * PARAMETERS: Callback from AcpiGetDevice + * + * RETURN: Status + * + * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- + * present devices, or if they specified a HID, it filters based + * on that. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsGetDeviceCallback ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + UINT32 Flags; + DEVICE_ID DeviceId; + ACPI_GET_DEVICES_INFO *Info; + + + Info = Context; + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + + Node = AcpiNsConvertHandleToEntry (ObjHandle); + if (!Node) + { + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + /* + * Run _STA to determine if device is present + */ + + Status = AcpiCmExecute_STA (Node, &Flags); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!(Flags & 0x01)) + { + /* don't return at the device or children of the device if not there */ + + return (AE_CTRL_DEPTH); + } + + /* + * Filter based on device HID + */ + if (Info->Hid != NULL) + { + Status = AcpiCmExecute_HID (Node, &DeviceId); + + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + + else if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (STRNCMP (DeviceId.Buffer, Info->Hid, sizeof (DeviceId.Buffer)) != 0) + { + return (AE_OK); + } + } + + Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetDevices + * + * PARAMETERS: HID - HID to search for. Can be NULL. + * UserFunction - Called when a matching object is found + * Context - Passed to user function + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object that matches + * the type parameter is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * This is a wrapper for WalkNamespace, but the callback performs + * additional filtering. Please see AcpiGetDeviceCallback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetDevices ( + NATIVE_CHAR *HID, + WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_GET_DEVICES_INFO Info; + + + FUNCTION_TRACE ("AcpiGetDevices"); + + + /* Parameter validation */ + + if (!UserFunction) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * We're going to call their callback from OUR callback, so we need + * to know what it is, and their context parameter. + */ + Info.Context = Context; + Info.UserFunction = UserFunction; + Info.Hid = HID; + + /* + * Lock the namespace around the walk. + * The namespace will be unlocked/locked around each call + * to the user function - since this function + * must be allowed to make Acpi calls itself. + */ + + AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, + ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + NS_WALK_UNLOCK, + AcpiNsGetDeviceCallback, &Info, + ReturnValue); + + AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); + + return_ACPI_STATUS (Status); +} \ No newline at end of file diff --git a/sys/contrib/dev/acpica/psargs.c b/sys/contrib/dev/acpica/psargs.c new file mode 100644 index 0000000..6b203ff --- /dev/null +++ b/sys/contrib/dev/acpica/psargs.c @@ -0,0 +1,950 @@ +/****************************************************************************** + * + * Module Name: psargs - Parse AML opcode arguments + * $Revision: 35 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSARGS_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psargs") + + +UINT32 +AcpiPsPkgLengthEncodingSize ( + UINT32 FirstByte) +{ + + /* + * Bits 6-7 contain the number of bytes + * in the encoded package length (-1) + */ + + return ((FirstByte >> 6) + 1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageLength + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Decoded package length. On completion, the AML pointer points + * past the length byte or bytes. + * + * DESCRIPTION: Decode and return a package length field + * + ******************************************************************************/ + +UINT32 +xxxAcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 EncodingLength; + UINT32 PackageLength = 0; + UINT8 *AmlPtr = ParserState->Aml; + + + FUNCTION_TRACE ("PsGetNextPackageLength"); + + + EncodingLength = AcpiPsPkgLengthEncodingSize ((UINT32) GET8 (AmlPtr)); + + + switch (EncodingLength) + { + case 1: /* 1-byte encoding (bits 0-5) */ + + PackageLength = ((UINT32) GET8 (AmlPtr) & 0x3f); + break; + + + case 2: /* 2-byte encoding (next byte + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + + + case 3: /* 3-byte encoding (next 2 bytes + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 2)) << 12) | + (((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + + + case 4: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + + PackageLength = ((((UINT32) GET8 (AmlPtr + 3)) << 20) | + (((UINT32) GET8 (AmlPtr + 2)) << 12) | + (((UINT32) GET8 (AmlPtr + 1)) << 4) | + (((UINT32) GET8 (AmlPtr)) & 0x0f)); + break; + } + + ParserState->Aml += EncodingLength; + + return_VALUE (PackageLength); +} + +UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 EncodedLength; + UINT32 Length = 0; + + + FUNCTION_TRACE ("PsGetNextPackageLength"); + + + EncodedLength = (UINT32) GET8 (ParserState->Aml); + ParserState->Aml++; + + + switch (EncodedLength >> 6) /* bits 6-7 contain encoding scheme */ + { + case 0: /* 1-byte encoding (bits 0-5) */ + + Length = (EncodedLength & 0x3f); + break; + + + case 1: /* 2-byte encoding (next byte + bits 0-3) */ + + Length = (GET8 (ParserState->Aml) << 4) | (EncodedLength & 0xf); + ParserState->Aml++; + break; + + + case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ + + Length = ( (GET8 (ParserState->Aml + 1) << 12) + | (GET8 (ParserState->Aml) << 4) + | (EncodedLength & 0xf)); + ParserState->Aml += 2; + break; + + + case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + + Length = ( (GET8 (ParserState->Aml + 2) << 20) + | (GET8 (ParserState->Aml + 1) << 12) + | (GET8 (ParserState->Aml) << 4) + | (EncodedLength & 0xf)); + ParserState->Aml += 3; + break; + } + + return_VALUE (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageEnd + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to end-of-package +1 + * + * DESCRIPTION: Get next package length and return a pointer past the end of + * the package. Consumes the package length field + * + ******************************************************************************/ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + NATIVE_UINT Length; + + + FUNCTION_TRACE ("PsGetNextPackageEnd"); + + + Length = (NATIVE_UINT) AcpiPsGetNextPackageLength (ParserState); + + return_PTR (Start + Length); /* end of package */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamestring + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to the start of the name string (pointer points into + * the AML. + * + * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name + * prefix characters. Set parser state to point past the string. + * (Name is consumed from the AML.) + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT8 *End = ParserState->Aml; + UINT32 Length; + + + FUNCTION_TRACE ("PsGetNextNamestring"); + + + /* Handle multiple prefix characters */ + + while (AcpiPsIsPrefixChar (GET8 (End))) + { + /* include prefix '\\' or '^' */ + + End++; + } + + /* Decode the path */ + + switch (GET8 (End)) + { + case 0: + + /* NullName */ + + if (End == Start) + { + Start = NULL; + } + End++; + break; + + + case AML_DUAL_NAME_PREFIX: + + /* two name segments */ + + End += 9; + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + /* multiple name segments */ + + Length = (UINT32) GET8 (End + 1) * 4; + End += 2 + Length; + break; + + + default: + + /* single name segment */ + /* assert (AcpiPsIsLead (GET8 (End))); */ + + End += 4; + break; + } + + ParserState->Aml = (UINT8*) End; + + return_PTR ((NATIVE_CHAR *) Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamepath + * + * PARAMETERS: ParserState - Current parser state object + * Arg - Where the namepath will be stored + * ArgCount - If the namepath points to a control method + * the method's argument is returned here. + * MethodCall - Whether the namepath can be the start + * of a method call + * + * RETURN: None + * + * DESCRIPTION: Get next name (if method call, push appropriate # args). Names + * are looked up in either the parsed or 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. + * + ******************************************************************************/ + + +#ifdef PARSER_ONLY + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall) +{ + NATIVE_CHAR *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Count; + + + FUNCTION_TRACE ("PsGetNextNamepath"); + + + Path = AcpiPsGetNextNamestring (ParserState); + if (!Path || !MethodCall) + { + /* Null name case, create a null namepath object */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + return_VOID; + } + + + if (AcpiGbl_ParsedNamespaceRoot) + { + /* + * Lookup the name in the parsed namespace + */ + + Op = NULL; + if (MethodCall) + { + Op = AcpiPsFind (AcpiPsGetParentScope (ParserState), + Path, AML_METHOD_OP, 0); + } + + if (Op) + { + if (Op->Opcode == AML_METHOD_OP) + { + /* + * The name refers to a control method, so this namepath is a + * method invocation. We need to 1) Get the number of arguments + * associated with this method, and 2) Change the NAMEPATH + * object into a METHODCALL object. + */ + + Count = AcpiPsGetArg (Op, 0); + if (Count && Count->Opcode == AML_BYTE_OP) + { + NameOp = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (NameOp) + { + /* Change arg into a METHOD CALL and attach the name */ + + AcpiPsInitOp (Arg, AML_METHODCALL_OP); + + NameOp->Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Node = (ACPI_NAMESPACE_NODE *) Op; + AcpiPsAppendArg (Arg, NameOp); + + *ArgCount = Count->Value.Integer & + METHOD_FLAGS_ARG_COUNT; + } + } + + return_VOID; + } + + /* + * Else this is normal named object reference. + * Just init the NAMEPATH object with the pathname. + * (See code below) + */ + } + } + + + /* + * Either we didn't find the object in the namespace, or the object is + * something other than a control method. Just initialize the Op with the + * pathname + */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + + + return_VOID; +} + + +#else + + +void +AcpiPsGetNextNamepath ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + UINT32 *ArgCount, + BOOLEAN MethodCall) +{ + NATIVE_CHAR *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE ScopeInfo; + + + FUNCTION_TRACE ("PsGetNextNamepath"); + + + Path = AcpiPsGetNextNamestring (ParserState); + if (!Path || !MethodCall) + { + /* Null name case, create a null namepath object */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + return_VOID; + } + + + if (MethodCall) + { + /* + * Lookup the name in the internal namespace + */ + ScopeInfo.Scope.Node = NULL; + Node = ParserState->StartNode; + if (Node) + { + ScopeInfo.Scope.Node = Node; + } + + /* + * Lookup object. We don't want to add anything new to the namespace + * here, however. So we use MODE_EXECUTE. Allow searching of the + * parent tree, but don't open a new scope -- we just want to lookup the + * object (MUST BE mode EXECUTE to perform upsearch) + */ + + Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, + &Node); + if (ACPI_SUCCESS (Status)) + { + if (Node->Type == ACPI_TYPE_METHOD) + { + MethodNode = Node; + DEBUG_PRINT (TRACE_PARSE, + ("PsGetNextNamepath: method - %p Path=%p\n", + MethodNode, Path)); + + NameOp = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (NameOp) + { + /* Change arg into a METHOD CALL and attach name to it */ + + AcpiPsInitOp (Arg, AML_METHODCALL_OP); + + NameOp->Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Node = MethodNode; + AcpiPsAppendArg (Arg, NameOp); + + *ArgCount = ((ACPI_OPERAND_OBJECT *) MethodNode->Object)->Method.ParamCount; + } + + return_VOID; + } + + /* + * Else this is normal named object reference. + * Just init the NAMEPATH object with the pathname. + * (See code below) + */ + } + } + + /* + * Either we didn't find the object in the namespace, or the object is + * something other than a control method. Just initialize the Op with the + * pathname + */ + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = Path; + + + return_VOID; +} + +#endif + +/******************************************************************************* + * + * 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) +{ + + + FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); + + + switch (ArgType) + { + + case ARGP_BYTEDATA: + + AcpiPsInitOp (Arg, AML_BYTE_OP); + Arg->Value.Integer = (UINT32) GET8 (ParserState->Aml); + ParserState->Aml++; + break; + + + case ARGP_WORDDATA: + + AcpiPsInitOp (Arg, AML_WORD_OP); + + /* Get 2 bytes from the AML stream */ + + MOVE_UNALIGNED16_TO_32 (&Arg->Value.Integer, ParserState->Aml); + ParserState->Aml += 2; + break; + + + case ARGP_DWORDDATA: + + AcpiPsInitOp (Arg, AML_DWORD_OP); + + /* Get 4 bytes from the AML stream */ + + MOVE_UNALIGNED32_TO_32 (&Arg->Value.Integer, ParserState->Aml); + ParserState->Aml += 4; + break; + + + case ARGP_CHARLIST: + + AcpiPsInitOp (Arg, AML_STRING_OP); + Arg->Value.String = (char*) ParserState->Aml; + + while (GET8 (ParserState->Aml) != '\0') + { + ParserState->Aml++; + } + ParserState->Aml++; + break; + + + case ARGP_NAME: + case ARGP_NAMESTRING: + + AcpiPsInitOp (Arg, AML_NAMEPATH_OP); + Arg->Value.Name = AcpiPsGetNextNamestring (ParserState); + break; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextField + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: A newly allocated FIELD op + * + * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_PTRDIFF AmlOffset = ParserState->Aml - + ParserState->AmlStart; + ACPI_PARSE_OBJECT *Field; + UINT16 Opcode; + UINT32 Name; + + + FUNCTION_TRACE ("PsGetNextField"); + + + /* determine field type */ + + switch (GET8 (ParserState->Aml)) + { + + default: + + Opcode = AML_NAMEDFIELD_OP; + break; + + + case 0x00: + + Opcode = AML_RESERVEDFIELD_OP; + ParserState->Aml++; + break; + + + case 0x01: + + Opcode = AML_ACCESSFIELD_OP; + ParserState->Aml++; + break; + } + + + /* Allocate a new field op */ + + Field = AcpiPsAllocOp (Opcode); + if (Field) + { + Field->AmlOffset = AmlOffset; + + /* Decode the field type */ + + switch (Opcode) + { + case AML_NAMEDFIELD_OP: + + /* Get the 4-character name */ + + MOVE_UNALIGNED32_TO_32 (&Name, ParserState->Aml); + AcpiPsSetName (Field, Name); + ParserState->Aml += 4; + + /* Get the length which is encoded as a package length */ + + Field->Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_RESERVEDFIELD_OP: + + /* Get the length which is encoded as a package length */ + + Field->Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_ACCESSFIELD_OP: + + /* Get AccessType and AccessAtrib and merge into the field Op */ + + Field->Value.Integer = ((GET8 (ParserState->Aml) << 8) | + GET8 (ParserState->Aml)); + ParserState->Aml += 2; + break; + } + } + + return_PTR (Field); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextArg + * + * PARAMETERS: ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * ArgCount - If the argument points to a control method + * the method's argument is returned here. + * + * RETURN: An op object containing the next argument. + * + * DESCRIPTION: Get next argument (including complex list arguments that require + * pushing the parser stack) + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetNextArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + UINT32 *ArgCount) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE_OBJECT *Prev = NULL; + ACPI_PARSE_OBJECT *Field; + UINT32 Subop; + + + 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) + { + 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) + { + break; + } + + if (Prev) + { + Prev->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_BYTELIST_OP); + if (Arg) + { + /* fill in bytelist data */ + + Arg->Value.Size = (ParserState->PkgEnd - ParserState->Aml); + ((ACPI_PARSE2_OBJECT *) Arg)->Data = ParserState->Aml; + } + + /* skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_TARGET: + case ARGP_SUPERNAME: + { + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + AcpiPsIsPrefixChar (Subop)) + { + /* NullName or NameString */ + + Arg = AcpiPsAllocOp (AML_NAMEPATH_OP); + if (Arg) + { + AcpiPsGetNextNamepath (ParserState, Arg, ArgCount, 0); + } + } + + else + { + /* single complex argument, nothing returned */ + + *ArgCount = 1; + } + } + break; + + + case ARGP_DATAOBJ: + case ARGP_TERMARG: + + /* single complex argument, nothing returned */ + + *ArgCount = 1; + break; + + + case ARGP_DATAOBJLIST: + case ARGP_TERMLIST: + case ARGP_OBJLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* non-empty list of variable arguments, nothing returned */ + + *ArgCount = ACPI_VAR_ARGS; + } + break; + } + + return_PTR (Arg); +} diff --git a/sys/contrib/dev/acpica/psfind.c b/sys/contrib/dev/acpica/psfind.c new file mode 100644 index 0000000..a0a9236 --- /dev/null +++ b/sys/contrib/dev/acpica/psfind.c @@ -0,0 +1,459 @@ + +/****************************************************************************** + * + * Module Name: psfind - Parse tree search routine + * $Revision: 17 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __PSFIND_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psfind") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetParent + * + * PARAMETERS: Op - Get the parent of this Op + * + * RETURN: The Parent op. + * + * DESCRIPTION: Get op's parent + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsGetParent ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Parent = Op; + + + /* Traverse the tree upward (to root if necessary) */ + + while (Parent) + { + switch (Parent->Opcode) + { + case AML_SCOPE_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_DEVICE_OP: + case AML_POWER_RES_OP: + case AML_THERMAL_ZONE_OP: + + return (Parent->Parent); + } + + Parent = Parent->Parent; + } + + return (Parent); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFindName + * + * PARAMETERS: Scope - Scope to search + * Name - ACPI name to search for + * Opcode - Opcode to search for + * + * RETURN: Op containing the name + * + * DESCRIPTION: Find name segment from a list of acpi_ops. Searches a single + * scope, no more. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsFindName ( + ACPI_PARSE_OBJECT *Scope, + UINT32 Name, + UINT32 Opcode) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *Field; + + + /* search scope level for matching name segment */ + + Op = AcpiPsGetChild (Scope); + + while (Op) + { + + if (AcpiPsIsFieldOp (Op->Opcode)) + { + /* Field, search named fields */ + + Field = AcpiPsGetChild (Op); + while (Field) + { + if (AcpiPsIsNamedOp (Field->Opcode) && + AcpiPsGetName (Field) == Name && + (!Opcode || Field->Opcode == Opcode)) + { + return (Field); + } + + Field = Field->Next; + } + } + + else if (AcpiPsIsCreateFieldOp (Op->Opcode)) + { + if (Op->Opcode == AML_CREATE_FIELD_OP) + { + Field = AcpiPsGetArg (Op, 3); + } + + else + { + /* CreateXXXField, check name */ + + Field = AcpiPsGetArg (Op, 2); + } + + if ((Field) && + (Field->Value.String) && + (!STRNCMP (Field->Value.String, (char *) &Name, ACPI_NAME_SIZE))) + { + return (Op); + } + } + + else if ((AcpiPsIsNamedOp (Op->Opcode)) && + (AcpiPsGetName (Op) == Name) && + (!Opcode || Op->Opcode == Opcode || Opcode == AML_SCOPE_OP)) + { + break; + } + + Op = Op->Next; + } + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFind + * + * PARAMETERS: Scope - Where to begin the search + * Path - ACPI Path to the named object + * Opcode - Opcode associated with the object + * Create - if TRUE, create the object if not found. + * + * RETURN: Op if found, NULL otherwise. + * + * DESCRIPTION: Find object within scope + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR *Path, + UINT16 Opcode, + UINT32 Create) +{ + UINT32 SegCount; + UINT32 Name; + UINT32 NameOp; + ACPI_PARSE_OBJECT *Op = NULL; + BOOLEAN Unprefixed = TRUE; + + + FUNCTION_TRACE_PTR ("PsFind", Scope); + + + if (!Scope || !Path) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Null path (%p) or scope (%p)!\n", Path, Scope)); + return_VALUE (NULL); + } + + + AcpiGbl_PsFindCount++; + + + /* Handle all prefixes in the name path */ + + while (AcpiPsIsPrefixChar (GET8 (Path))) + { + switch (GET8 (Path)) + { + + case '\\': + + /* Could just use a global for "root scope" here */ + + while (Scope->Parent) + { + Scope = Scope->Parent; + } + + /* get first object within the scope */ + /* TBD: [Investigate] OR - set next in root scope to point to the same value as arg */ + + /* Scope = Scope->Value.Arg; */ + + break; + + + case '^': + + /* Go up to the next valid scoping Op (method, scope, etc.) */ + + if (AcpiPsGetParent (Scope)) + { + Scope = AcpiPsGetParent (Scope); + } + + break; + } + + Unprefixed = FALSE; + Path++; + } + + /* get name segment count */ + + switch (GET8 (Path)) + { + case '\0': + SegCount = 0; + + /* Null name case */ + + if (Unprefixed) + { + Op = NULL; + } + else + { + Op = Scope; + } + + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Null path, returning current root scope Op=%p\n", Op)); + return_PTR (Op); + break; + + case AML_DUAL_NAME_PREFIX: + SegCount = 2; + Path++; + break; + + case AML_MULTI_NAME_PREFIX_OP: + SegCount = GET8 (Path + 1); + Path += 2; + break; + + default: + SegCount = 1; + break; + } + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Search scope %p Segs=%d Opcode=%4.4X Create=%d\n", Scope, SegCount, Opcode, Create)); + + /* match each name segment */ + + while (Scope && SegCount) + { + MOVE_UNALIGNED32_TO_32 (&Name, Path); + Path += 4; + SegCount --; + + if (SegCount) + { + NameOp = 0; + } + else + { + NameOp = Opcode; + } + + Op = AcpiPsFindName (Scope, Name, NameOp); + if (Op) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Found! Op=%p Opcode=%4.4X\n", &Name, Op, Op->Opcode)); + } + + if (!Op) + { + if (Create) + { + /* Create a new Scope level */ + + if (SegCount) + { + Op = AcpiPsAllocOp (AML_SCOPE_OP); + } + else + { + Op = AcpiPsAllocOp (Opcode); + } + + if (Op) + { + AcpiPsSetName (Op, Name); + AcpiPsAppendArg (Scope, Op); + + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Not found, created Op=%p Opcode=%4.4X\n", &Name, Op, Opcode)); + } + } + + else if (Unprefixed) + { + /* Search higher scopes for unprefixed name */ + + while (!Op && Scope->Parent) + { + Scope = Scope->Parent; + Op = AcpiPsFindName (Scope, Name, Opcode); + if (Op) + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Found in parent tree! Op=%p Opcode=%4.4X\n", &Name, Op, Op->Opcode)); + } + + else + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: [%4.4s] Not found in parent=%p\n", &Name, Scope)); + } + } + } + + else + { + DEBUG_PRINT (TRACE_PARSE, ("PsFind: Segment [%4.4s] Not Found in scope %p!\n", &Name, Scope)); + } + } + + Unprefixed = FALSE; + Scope = Op; + } + + return_PTR (Op); +} + + diff --git a/sys/contrib/dev/acpica/psopcode.c b/sys/contrib/dev/acpica/psopcode.c new file mode 100644 index 0000000..8035f6a --- /dev/null +++ b/sys/contrib/dev/acpica/psopcode.c @@ -0,0 +1,704 @@ +/****************************************************************************** + * + * Module Name: psopcode - Parser opcode information table + * $Revision: 20 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT PARSER + MODULE_NAME ("psopcode") + + +UINT8 AcpiGbl_AmlShortOpInfoIndex[]; +UINT8 AcpiGbl_AmlLongOpInfoIndex[]; + +#define _UNK 0x6B +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D +#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ + +#define MAX_EXTENDED_OPCODE 0x87 +#define NUM_EXTENDED_OPCODE MAX_EXTENDED_OPCODE + 1 +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE MAX_INTERNAL_OPCODE + 1 + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeInfo + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the info about the opcode. NULL if the opcode was + * not found in the table. + * + * DESCRIPTION: Find AML opcode description based on the opcode. + * NOTE: This procedure must ALWAYS return a valid pointer! + * + ******************************************************************************/ + +ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *OpInfo; + UINT8 UpperOpcode; + UINT8 LowerOpcode; + + + /* Split the 16-bit opcode into separate bytes */ + + UpperOpcode = (UINT8) (Opcode >> 8); + LowerOpcode = (UINT8) Opcode; + + /* Default is "unknown opcode" */ + + OpInfo = &AcpiGbl_AmlOpInfo [_UNK]; + + + /* + * Detect normal 8-bit opcode or extended 16-bit opcode + */ + + switch (UpperOpcode) + { + case 0: + + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ + + OpInfo = &AcpiGbl_AmlOpInfo [AcpiGbl_AmlShortOpInfoIndex [LowerOpcode]]; + break; + + + case AML_EXTOP: + + /* Extended (16-bit, prefix+opcode) opcode */ + + if (LowerOpcode <= MAX_EXTENDED_OPCODE) + { + OpInfo = &AcpiGbl_AmlOpInfo [AcpiGbl_AmlLongOpInfoIndex [LowerOpcode]]; + } + break; + + + case AML_LNOT_OP: + + /* This case is for the bogus opcodes LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL */ + /* TBD: [Investigate] remove this case? */ + + DEBUG_PRINT (ACPI_ERROR, ("PsGetOpcodeInfo: Bad multi-byte opcode=%X\n", + Opcode)); + + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, ("PsGetOpcodeInfo: Unknown extended opcode=%X\n", + Opcode)); + + break; + } + + + /* Get the Op info pointer for this opcode */ + + return (OpInfo); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeName + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the name of the opcode (ASCII String) + * Note: Never returns NULL. + * + * DESCRIPTION: Translate an opcode into a human-readable string + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiPsGetOpcodeName ( + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *Op; + + + Op = AcpiPsGetOpcodeInfo (Opcode); + + /* Always guaranteed to return a valid pointer */ + + DEBUG_ONLY_MEMBERS (return Op->Name); + return ("AE_NOT_CONFIGURED"); +} + + +/******************************************************************************* + * + * NAME: AcpiGbl_AmlOpInfo + * + * DESCRIPTION: Opcode table. Each entry contains + * The name is a simple ascii string, the operand specifier is an + * ascii string with one letter per operand. The letter specifies + * the operand type. + * + ******************************************************************************/ + + +/* + * Flags byte: 0-4 (5 bits) = Opcode Type + * 5 (1 bit) = Has arguments flag + * 6-7 (2 bits) = Reserved + */ +#define AML_NO_ARGS 0 +#define AML_HAS_ARGS ACPI_OP_ARGS_MASK + +/* + * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed + * into a 32-bit number and stored in the master opcode table at the end of this file. + */ + +#define ARGP_ZERO_OP ARG_NONE +#define ARGP_ONE_OP ARG_NONE +#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) +#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) +#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) +#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) +#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) +#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) +#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) +#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) +#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) +#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) +#define ARGP_LOCAL0 ARG_NONE +#define ARGP_LOCAL1 ARG_NONE +#define ARGP_LOCAL2 ARG_NONE +#define ARGP_LOCAL3 ARG_NONE +#define ARGP_LOCAL4 ARG_NONE +#define ARGP_LOCAL5 ARG_NONE +#define ARGP_LOCAL6 ARG_NONE +#define ARGP_LOCAL7 ARG_NONE +#define ARGP_ARG0 ARG_NONE +#define ARGP_ARG1 ARG_NONE +#define ARGP_ARG2 ARG_NONE +#define ARGP_ARG3 ARG_NONE +#define ARGP_ARG4 ARG_NONE +#define ARGP_ARG5 ARG_NONE +#define ARGP_ARG6 ARG_NONE +#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) +#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) +#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_NOOP_OP ARG_NONE +#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_BREAK_OP ARG_NONE +#define ARGP_BREAK_POINT_OP ARG_NONE +#define ARGP_ONES_OP ARG_NONE +#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) +#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) +#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) +#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REVISION_OP ARG_NONE +#define ARGP_DEBUG_OP ARG_NONE +#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) +#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DEF_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) +#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) +#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) + + +/* + * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed + * into a 32-bit number and stored in the master opcode table at the end of this file. + * + * (Used by AcpiAmlPrepOperands procedure) + */ + +#define ARGI_ZERO_OP ARG_NONE +#define ARGI_ONE_OP ARG_NONE +#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE +#define ARGI_NAME_OP ARGI_INVALID_OPCODE +#define ARGI_BYTE_OP ARGI_INVALID_OPCODE +#define ARGI_WORD_OP ARGI_INVALID_OPCODE +#define ARGI_DWORD_OP ARGI_INVALID_OPCODE +#define ARGI_STRING_OP ARGI_INVALID_OPCODE +#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE +#define ARGI_BUFFER_OP ARGI_INVALID_OPCODE +#define ARGI_PACKAGE_OP ARGI_INVALID_OPCODE +#define ARGI_METHOD_OP ARGI_INVALID_OPCODE +#define ARGI_LOCAL0 ARG_NONE +#define ARGI_LOCAL1 ARG_NONE +#define ARGI_LOCAL2 ARG_NONE +#define ARGI_LOCAL3 ARG_NONE +#define ARGI_LOCAL4 ARG_NONE +#define ARGI_LOCAL5 ARG_NONE +#define ARGI_LOCAL6 ARG_NONE +#define ARGI_LOCAL7 ARG_NONE +#define ARGI_ARG0 ARG_NONE +#define ARGI_ARG1 ARG_NONE +#define ARGI_ARG2 ARG_NONE +#define ARGI_ARG3 ARG_NONE +#define ARGI_ARG4 ARG_NONE +#define ARGI_ARG5 ARG_NONE +#define ARGI_ARG6 ARG_NONE +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_TARGETREF) +#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_ADD_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_TARGETREF) +#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF, ARGI_TARGETREF) +#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REFERENCE) +#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_REFERENCE, ARGI_NUMBER) +#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) +#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) +#define ARGI_LAND_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LOR_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_IF_OP ARGI_INVALID_OPCODE +#define ARGI_ELSE_OP ARGI_INVALID_OPCODE +#define ARGI_WHILE_OP ARGI_INVALID_OPCODE +#define ARGI_NOOP_OP ARG_NONE +#define ARGI_RETURN_OP ARGI_INVALID_OPCODE +#define ARGI_BREAK_OP ARG_NONE +#define ARGI_BREAK_POINT_OP ARG_NONE +#define ARGI_ONES_OP ARG_NONE +#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE +#define ARGI_EVENT_OP ARGI_INVALID_OPCODE +#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_REFERENCE, ARGI_TARGETREF) +#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_NUMBER, ARGI_NUMBER, ARGI_REFERENCE) +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION, ARGI_TARGETREF) +#define ARGI_STALL_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_NUMBER) +#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_NUMBER) +#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_NUMBER) +#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) +#define ARGI_REVISION_OP ARG_NONE +#define ARGI_DEBUG_OP ARG_NONE +#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER) +#define ARGI_REGION_OP ARGI_INVALID_OPCODE +#define ARGI_DEF_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE +#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE +#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE +#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE +#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE +#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE +#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE +#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE + + +/* + * Master Opcode information table. A summary of everything we know about each opcode, all in one place. + */ + + +ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[] = +{ +/* Index Opcode Type Class Has Arguments? Name Parser Args Interpreter Args */ + +/* 00 */ /* AML_ZERO_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "ZeroOp", ARGP_ZERO_OP, ARGI_ZERO_OP), +/* 01 */ /* AML_ONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "OneOp", ARGP_ONE_OP, ARGI_ONE_OP), +/* 02 */ /* AML_ALIAS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP), +/* 03 */ /* AML_NAME_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Name", ARGP_NAME_OP, ARGI_NAME_OP), +/* 04 */ /* AML_BYTE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP), +/* 05 */ /* AML_WORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "WordConst", ARGP_WORD_OP, ARGI_WORD_OP), +/* 06 */ /* AML_DWORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP), +/* 07 */ /* AML_STRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "String", ARGP_STRING_OP, ARGI_STRING_OP), +/* 08 */ /* AML_SCOPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP), +/* 09 */ /* AML_BUFFER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP), +/* 0A */ /* AML_PACKAGE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP), +/* 0B */ /* AML_METHOD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Method", ARGP_METHOD_OP, ARGI_METHOD_OP), +/* 0C */ /* AML_LOCAL0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local0", ARGP_LOCAL0, ARGI_LOCAL0), +/* 0D */ /* AML_LOCAL1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local1", ARGP_LOCAL1, ARGI_LOCAL1), +/* 0E */ /* AML_LOCAL2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local2", ARGP_LOCAL2, ARGI_LOCAL2), +/* 0F */ /* AML_LOCAL3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local3", ARGP_LOCAL3, ARGI_LOCAL3), +/* 10 */ /* AML_LOCAL4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local4", ARGP_LOCAL4, ARGI_LOCAL4), +/* 11 */ /* AML_LOCAL5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local5", ARGP_LOCAL5, ARGI_LOCAL5), +/* 12 */ /* AML_LOCAL6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local6", ARGP_LOCAL6, ARGI_LOCAL6), +/* 13 */ /* AML_LOCAL7 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local7", ARGP_LOCAL7, ARGI_LOCAL7), +/* 14 */ /* AML_ARG0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg0", ARGP_ARG0, ARGI_ARG0), +/* 15 */ /* AML_ARG1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg1", ARGP_ARG1, ARGI_ARG1), +/* 16 */ /* AML_ARG2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg2", ARGP_ARG2, ARGI_ARG2), +/* 17 */ /* AML_ARG3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg3", ARGP_ARG3, ARGI_ARG3), +/* 18 */ /* AML_ARG4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg4", ARGP_ARG4, ARGI_ARG4), +/* 19 */ /* AML_ARG5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg5", ARGP_ARG5, ARGI_ARG5), +/* 1A */ /* AML_ARG6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg6", ARGP_ARG6, ARGI_ARG6), +/* 1B */ /* AML_STORE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "Store", ARGP_STORE_OP, ARGI_STORE_OP), +/* 1C */ /* AML_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP), +/* 1D */ /* AML_ADD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Add", ARGP_ADD_OP, ARGI_ADD_OP), +/* 1E */ /* AML_CONCAT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Concat", ARGP_CONCAT_OP, ARGI_CONCAT_OP), +/* 1F */ /* AML_SUBTRACT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP), +/* 20 */ /* AML_INCREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP), +/* 21 */ /* AML_DECREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP), +/* 22 */ /* AML_MULTIPLY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP), +/* 23 */ /* AML_DIVIDE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP), +/* 24 */ /* AML_SHIFT_LEFT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP), +/* 25 */ /* AML_SHIFT_RIGHT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP), +/* 26 */ /* AML_BIT_AND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP), +/* 27 */ /* AML_BIT_NAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP), +/* 28 */ /* AML_BIT_OR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP), +/* 29 */ /* AML_BIT_NOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP), +/* 2A */ /* AML_BIT_XOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2R| AML_HAS_ARGS, "XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP), +/* 2B */ /* AML_BIT_NOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP), +/* 2C */ /* AML_FIND_SET_LEFT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP), +/* 2D */ /* AML_FIND_SET_RIGHT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP, ARGI_FIND_SET_RIGHT_BIT_OP), +/* 2E */ /* AML_DEREF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP), +/* 2F */ /* AML_NOTIFY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC1| AML_HAS_ARGS, "Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP), +/* 30 */ /* AML_SIZE_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP), +/* 31 */ /* AML_INDEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_INDEX| AML_HAS_ARGS, "Index", ARGP_INDEX_OP, ARGI_INDEX_OP), +/* 32 */ /* AML_MATCH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MATCH| AML_HAS_ARGS, "Match", ARGP_MATCH_OP, ARGI_MATCH_OP), +/* 33 */ /* AML_DWORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateDWordField", ARGP_DWORD_FIELD_OP, ARGI_DWORD_FIELD_OP), +/* 34 */ /* AML_WORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateWordField", ARGP_WORD_FIELD_OP, ARGI_WORD_FIELD_OP), +/* 35 */ /* AML_BYTE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateByteField", ARGP_BYTE_FIELD_OP, ARGI_BYTE_FIELD_OP), +/* 36 */ /* AML_BIT_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateBitField", ARGP_BIT_FIELD_OP, ARGI_BIT_FIELD_OP), +/* 37 */ /* AML_TYPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP), +/* 38 */ /* AML_LAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LAnd", ARGP_LAND_OP, ARGI_LAND_OP), +/* 39 */ /* AML_LOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LOr", ARGP_LOR_OP, ARGI_LOR_OP), +/* 3A */ /* AML_LNOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "LNot", ARGP_LNOT_OP, ARGI_LNOT_OP), +/* 3B */ /* AML_LEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP), +/* 3C */ /* AML_LGREATER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP), +/* 3D */ /* AML_LLESS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LLess", ARGP_LLESS_OP, ARGI_LLESS_OP), +/* 3E */ /* AML_IF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "If", ARGP_IF_OP, ARGI_IF_OP), +/* 3F */ /* AML_ELSE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Else", ARGP_ELSE_OP, ARGI_ELSE_OP), +/* 40 */ /* AML_WHILE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "While", ARGP_WHILE_OP, ARGI_WHILE_OP), +/* 41 */ /* AML_NOOP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Noop", ARGP_NOOP_OP, ARGI_NOOP_OP), +/* 42 */ /* AML_RETURN_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Return", ARGP_RETURN_OP, ARGI_RETURN_OP), +/* 43 */ /* AML_BREAK_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Break", ARGP_BREAK_OP, ARGI_BREAK_OP), +/* 44 */ /* AML_BREAK_POINT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP), +/* 45 */ /* AML_ONES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "OnesOp", ARGP_ONES_OP, ARGI_ONES_OP), + +/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ + +/* 46 */ /* AML_MUTEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP), +/* 47 */ /* AML_EVENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_NO_ARGS, "Event", ARGP_EVENT_OP, ARGI_EVENT_OP), +/* 48 */ /* AML_COND_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP), +/* 49 */ /* AML_CREATE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP), +/* 4A */ /* AML_LOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Load", ARGP_LOAD_OP, ARGI_LOAD_OP), +/* 4B */ /* AML_STALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Stall", ARGP_STALL_OP, ARGI_STALL_OP), +/* 4C */ /* AML_SLEEP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP), +/* 4D */ /* AML_ACQUIRE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2S| AML_HAS_ARGS, "Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP), +/* 4E */ /* AML_SIGNAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP), +/* 4F */ /* AML_WAIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2S| AML_HAS_ARGS, "Wait", ARGP_WAIT_OP, ARGI_WAIT_OP), +/* 50 */ /* AML_RESET_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Reset", ARGP_RESET_OP, ARGI_RESET_OP), +/* 51 */ /* AML_RELEASE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP), +/* 52 */ /* AML_FROM_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP), +/* 53 */ /* AML_TO_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2R| AML_HAS_ARGS, "ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP), +/* 54 */ /* AML_UNLOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP), +/* 55 */ /* AML_REVISION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Revision", ARGP_REVISION_OP, ARGI_REVISION_OP), +/* 56 */ /* AML_DEBUG_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP), +/* 57 */ /* AML_FATAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_FATAL| AML_HAS_ARGS, "Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP), +/* 58 */ /* AML_REGION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "OpRegion", ARGP_REGION_OP, ARGI_REGION_OP), +/* 59 */ /* AML_DEF_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Field", ARGP_DEF_FIELD_OP, ARGI_DEF_FIELD_OP), +/* 5A */ /* AML_DEVICE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP), +/* 5B */ /* AML_PROCESSOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP), +/* 5C */ /* AML_POWER_RES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "PowerRes", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP), +/* 5D */ /* AML_THERMAL_ZONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP), +/* 5E */ /* AML_INDEX_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP), +/* 5F */ /* AML_BANK_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP), + +/* Internal opcodes that map to invalid AML opcodes */ + +/* 60 */ /* AML_LNOTEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP), +/* 61 */ /* AML_LLESSEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP), +/* 62 */ /* AML_LGREATEREQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP), +/* 63 */ /* AML_NAMEPATH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "NamePath", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP), +/* 64 */ /* AML_METHODCALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_CALL| AML_HAS_ARGS, "MethodCall", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP), +/* 65 */ /* AML_BYTELIST_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "ByteList", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP), +/* 66 */ /* AML_RESERVEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "ReservedField", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP), +/* 67 */ /* AML_NAMEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "NamedField", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP), +/* 68 */ /* AML_ACCESSFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "AccessField", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP), +/* 69 */ /* AML_STATICSTRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP), +/* 6A */ /* AML_RETURN_VALUE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RETURN| AML_HAS_ARGS, "[Return Value]", ARG_NONE, ARG_NONE), +/* 6B */ /* UNKNOWN OPCODES */ OP_INFO_ENTRY (ACPI_OP_TYPE_UNKNOWN | OPTYPE_BOGUS| AML_HAS_ARGS, "UNKNOWN_OP!", ARG_NONE, ARG_NONE), +/* 6C */ /* ASCII CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_ASCII | OPTYPE_BOGUS| AML_HAS_ARGS, "ASCII_ONLY!", ARG_NONE, ARG_NONE), +/* 6D */ /* PREFIX CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_PREFIX | OPTYPE_BOGUS| AML_HAS_ARGS, "PREFIX_ONLY!", ARG_NONE, ARG_NONE), +}; + +/* + * This table is directly indexed by the opcodes, and returns an + * index into the table above + */ + +UINT8 AcpiGbl_AmlShortOpInfoIndex[256] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, +/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, _UNK, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, _UNK, 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, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, +/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, +/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, +/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, +/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, +/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, _UNK, _UNK, 0x2f, 0x30, +/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, _UNK, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, _UNK, _UNK, +/* 0x98 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 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, +}; + + +UINT8 AcpiGbl_AmlLongOpInfoIndex[NUM_EXTENDED_OPCODE] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 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, _UNK, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +}; + + +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ + + diff --git a/sys/contrib/dev/acpica/psparse.c b/sys/contrib/dev/acpica/psparse.c new file mode 100644 index 0000000..4951b7a --- /dev/null +++ b/sys/contrib/dev/acpica/psparse.c @@ -0,0 +1,1506 @@ +/****************************************************************************** + * + * Module Name: psparse - Parser top level AML parse routines + * $Revision: 60 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in AcpiGbl_AmlOpInfo[] + */ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psparse") + + +UINT32 AcpiGbl_Depth = 0; +extern UINT32 AcpiGbl_ScopeDepth; + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteCompletedOp + * + * PARAMETERS: State - Walk state + * Op - Completed op + * + * RETURN: AE_OK + * + * DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during + * AcpiPsDeleteParse tree to delete Op objects when all sub-objects + * have been visited (and deleted.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsDeleteCompletedOp ( + ACPI_WALK_STATE *State, + ACPI_PARSE_OBJECT *Op) +{ + + AcpiPsFreeOp (Op); + return (AE_OK); +} + + +#ifndef PARSER_ONLY +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseTree + * + * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete + * + * RETURN: None + * + * DESCRIPTION: Delete a portion of or an entire parse tree. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *SubtreeRoot) +{ + ACPI_WALK_STATE *WalkState; + ACPI_WALK_LIST WalkList; + + + FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot); + + + if (!SubtreeRoot) + { + return_VOID; + } + + /* Create and initialize a new walk list */ + + WalkList.WalkState = NULL; + WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, &WalkList); + if (!WalkState) + { + return_VOID; + } + + WalkState->ParserState = NULL; + WalkState->ParseFlags = 0; + WalkState->DescendingCallback = NULL; + WalkState->AscendingCallback = NULL; + + + WalkState->Origin = SubtreeRoot; + WalkState->NextOp = SubtreeRoot; + + + /* Head downward in the tree */ + + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Visit all nodes in the subtree */ + + while (WalkState->NextOp) + { + AcpiPsGetNextWalkOp (WalkState, WalkState->NextOp, + AcpiPsDeleteCompletedOp); + } + + /* We are done with this walk */ + + AcpiDsDeleteWalkState (WalkState); + + return_VOID; +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode) +{ + + /* Extended (2-byte) opcode if > 255 */ + + if (Opcode > 0x00FF) + { + return (2); + } + + /* Otherwise, just a single byte opcode */ + + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: ParserState - A parser state object + * + * RETURN: Status + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml; + UINT16 Opcode; + + + Aml = ParserState->Aml; + Opcode = (UINT16) GET8 (Aml); + + Aml++; + + + /* + * Original code special cased LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL. + * These opcodes are no longer recognized. Instead, they are broken into + * two opcodes. + * + * + * if (Opcode == AML_EXTOP + * || (Opcode == AML_LNOT + * && (GET8 (AcpiAml) == AML_LEQUAL + * || GET8 (AcpiAml) == AML_LGREATER + * || GET8 (AcpiAml) == AML_LLESS))) + * + * extended Opcode, !=, <=, or >= + */ + + if (Opcode == AML_EXTOP) + { + /* Extended opcode */ + + Opcode = (UINT16) ((Opcode << 8) | GET8 (Aml)); + Aml++; + } + + /* don't convert bare name to a namepath */ + + return (Opcode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateState + * + * PARAMETERS: AcpiAml - AcpiAml code pointer + * AcpiAmlSize - Length of AML code + * + * RETURN: A new parser state object + * + * DESCRIPTION: Create and initialize a new parser state object + * + ******************************************************************************/ + +ACPI_PARSE_STATE * +AcpiPsCreateState ( + UINT8 *Aml, + UINT32 AmlSize) +{ + ACPI_PARSE_STATE *ParserState; + + + FUNCTION_TRACE ("PsCreateState"); + + + ParserState = AcpiCmCallocate (sizeof (ACPI_PARSE_STATE)); + if (!ParserState) + { + return_VALUE (NULL); + } + + ParserState->Aml = Aml; + ParserState->AmlEnd = Aml + AmlSize; + ParserState->PkgEnd = ParserState->AmlEnd; + ParserState->AmlStart = Aml; + + + return_PTR (ParserState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFindObject + * + * PARAMETERS: Opcode - Current opcode + * ParserState - Current state + * WalkState - Current state + * *Op - Where found/new op is returned + * + * RETURN: Status + * + * DESCRIPTION: Find a named object. Two versions - one to search the parse + * tree (for parser-only applications such as acpidump), another + * to search the ACPI internal namespace (the parse tree may no + * longer exist) + * + ******************************************************************************/ + +#ifdef PARSER_ONLY + +ACPI_STATUS +AcpiPsFindObject ( + UINT16 Opcode, + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + NATIVE_CHAR *Path; + + + /* We are only interested in opcodes that have an associated name */ + + if (!AcpiPsIsNamedOp (Opcode)) + { + *OutOp = Op; + return (AE_OK); + } + + /* Find the name in the parse tree */ + + Path = AcpiPsGetNextNamestring (WalkState->ParserState); + + *OutOp = AcpiPsFind (AcpiPsGetParentScope (WalkState->ParserState), + Path, Opcode, 1); + + if (!(*OutOp)) + { + return (AE_NOT_FOUND); + } + + return (AE_OK); +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteThisOp + * + * PARAMETERS: WalkState - Current State + * Op - Op to complete + * + * RETURN: TRUE if Op and subtree was deleted + * + * DESCRIPTION: Perform any cleanup at the completion of an Op. + * + ******************************************************************************/ + +BOOLEAN +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ +#ifndef PARSER_ONLY + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + ACPI_OPCODE_INFO *OpInfo; + ACPI_OPCODE_INFO *ParentInfo; + UINT32 OpcodeClass; + ACPI_PARSE_OBJECT *ReplacementOp = NULL; + + + FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op); + + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + OpcodeClass = ACPI_GET_OP_CLASS (OpInfo); + + + /* Delete this op and the subtree below it if asked to */ + + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && + (OpcodeClass != OPTYPE_CONSTANT) && + (OpcodeClass != OPTYPE_LITERAL) && + (OpcodeClass != OPTYPE_LOCAL_VARIABLE) && + (OpcodeClass != OPTYPE_METHOD_ARGUMENT) && + (OpcodeClass != OPTYPE_DATA_TERM) && + (Op->Opcode != AML_NAMEPATH_OP)) + { + /* Make sure that we only delete this subtree */ + + if (Op->Parent) + { + /* + * Check if we need to replace the operator and its subtree + * with a return value op + */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode); + + switch (ACPI_GET_OP_CLASS (ParentInfo)) + { + case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ + case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ + break; + + default: + ReplacementOp = AcpiPsAllocOp (AML_RETURN_VALUE_OP); + if (!ReplacementOp) + { + return_VALUE (FALSE); + } + } + + /* We must unlink this op from the parent tree */ + + Prev = Op->Parent->Value.Arg; + if (Prev == Op) + { + /* This op is the first in the list */ + + if (ReplacementOp) + { + ReplacementOp->Parent = Op->Parent; + ReplacementOp->Value.Arg = NULL; + Op->Parent->Value.Arg = ReplacementOp; + ReplacementOp->Next = Op->Next; + } + else + { + Op->Parent->Value.Arg = Op->Next; + } + } + + /* Search the parent list */ + + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + + Next = Prev->Next; + if (Next == Op) + { + if (ReplacementOp) + { + ReplacementOp->Parent = Op->Parent; + ReplacementOp->Value.Arg = NULL; + Prev->Next = ReplacementOp; + ReplacementOp->Next = Op->Next; + Next = NULL; + } + else + { + Prev->Next = Op->Next; + Next = NULL; + } + } + + Prev = Next; + } + + } + + /* Now we can actually delete the subtree rooted at op */ + + AcpiPsDeleteParseTree (Op); + + return_VALUE (TRUE); + } + + return_VALUE (FALSE); + +#else + return (FALSE); +#endif +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsNextParseState + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + + +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; + UINT8 *Start; + UINT32 PackageLength; + + + 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_PENDING: + + /* + * Predicate of a WHILE was true and the loop just completed an + * execution. Go back to the start of the loop and reevaluate the + * predicate. + */ +/* WalkState->ControlState->Common.State = + CONTROL_PREDICATE_EXECUTING;*/ + + /* TBD: How to handle a break within a while. */ + /* This code attempts it */ + + ParserState->Aml = WalkState->AmlLastWhile; + break; + + + case AE_CTRL_TRUE: + /* + * Predicate of an IF was true, and we are at the matching ELSE. + * Just close out this package + * + * Note: ParserState->Aml is modified by the package length procedure + * TBD: [Investigate] perhaps it shouldn't, too much trouble + */ + Start = ParserState->Aml; + PackageLength = AcpiPsGetNextPackageLength (ParserState); + ParserState->Aml = Start + PackageLength; + 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->Value.Arg)->Node; + + /* Will return value (if any) be used by the caller? */ + + WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState); + break; + + + default: + Status = CallbackStatus; + if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) + { + Status = AE_OK; + } + break; + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_OPCODE_INFO *OpInfo; + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE2_OBJECT *DeferredOp; + UINT32 ArgCount; /* push for fixed or var args */ + UINT32 ArgTypes = 0; + ACPI_PTRDIFF AmlOffset; + UINT16 Opcode; + ACPI_PARSE_OBJECT PreOp; + ACPI_PARSE_STATE *ParserState; + + + + FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); + + + ParserState = WalkState->ParserState; + + if (WalkState->WalkType & 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->Opcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Opcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + CONTROL_PREDICATE_EXECUTING)) + { + + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + + Status = AcpiDsGetPredicateValue (WalkState, NULL, TRUE); + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op)); + } + + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + ArgTypes = WalkState->PrevArgTypes; + } + } + + /* + * Iterative parsing loop, while there is more aml to process: + */ + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + if (!Op) + { + /* Get the next opcode from the AML stream */ + + AmlOffset = ParserState->Aml - ParserState->AmlStart; + Opcode = AcpiPsPeekOpcode (ParserState); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + switch (ACPI_GET_OP_TYPE (OpInfo)) + { + case ACPI_OP_TYPE_OPCODE: + + /* Found opcode info, this is a normal opcode */ + + ParserState->Aml += AcpiPsGetOpcodeSize (Opcode); + ArgTypes = OpInfo->ParseArgs; + break; + + case ACPI_OP_TYPE_ASCII: + case ACPI_OP_TYPE_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + + Opcode = AML_NAMEPATH_OP; + ArgTypes = ARGP_NAMESTRING; + break; + + case ACPI_OP_TYPE_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + DEBUG_PRINT (ACPI_ERROR, + ("ParseLoop: Found unknown opcode 0x%lX at AML offset 0x%X, ignoring\n", + Opcode, AmlOffset)); + + DUMP_BUFFER (ParserState->Aml, 128); + + /* Assume one-byte bad opcode */ + + ParserState->Aml++; + continue; + } + + + /* Create Op structure and append to parent's argument list */ + + if (AcpiPsIsNamedOp (Opcode)) + { + PreOp.Value.Arg = NULL; + PreOp.Opcode = Opcode; + + while (GET_CURRENT_ARG_TYPE (ArgTypes) != ARGP_NAME) + { + Arg = AcpiPsGetNextArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), + &ArgCount); + AcpiPsAppendArg (&PreOp, Arg); + INCREMENT_ARG_LIST (ArgTypes); + } + + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (ArgTypes); + + if (WalkState->DescendingCallback != NULL) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + Status = WalkState->DescendingCallback (Opcode, NULL, WalkState, &Op); + if (Op == NULL) + { + continue; + } + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + } + + AcpiPsAppendArg (Op, PreOp.Value.Arg); + AcpiGbl_Depth++; + + + if (Op->Opcode == AML_REGION_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Backup to beginning of OpRegion declaration (2 for + * Opcode, 4 for name) + * + * BodyLength is unknown until we parse the body + */ + + DeferredOp->Data = ParserState->Aml - 6; + DeferredOp->Length = 0; + } + } + } + + + else + { + /* Not a named opcode, just allocate Op and append to parent */ + + Op = AcpiPsAllocOp (Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + + if ((Op->Opcode == AML_CREATE_FIELD_OP) || + (Op->Opcode == AML_BIT_FIELD_OP) || + (Op->Opcode == AML_BYTE_FIELD_OP) || + (Op->Opcode == AML_WORD_FIELD_OP) || + (Op->Opcode == AML_DWORD_FIELD_OP)) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + DeferredOp = (ACPI_PARSE2_OBJECT *) Op; + + DeferredOp->Data = ParserState->Aml -1; + DeferredOp->Length = 0; + } + + AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op); + + if ((WalkState->DescendingCallback != NULL)) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + Status = WalkState->DescendingCallback (Opcode, Op, WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + } + } + + Op->AmlOffset = AmlOffset; + + if (OpInfo) + { + DEBUG_PRINT (TRACE_PARSE, + ("ParseLoop: Op=%p Opcode=%4.4lX Aml %p Oft=%5.5lX\n", + Op, Op->Opcode, ParserState->Aml, Op->AmlOffset)); + } + } + + + /* Start ArgCount at zero because we don't know if there are any args yet */ + + ArgCount = 0; + + + if (ArgTypes) /* Are there any arguments that must be processed? */ + { + /* get arguments */ + + switch (Op->Opcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* fill in constant or string argument directly */ + + AcpiPsGetNextSimpleArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), Op); + break; + + case AML_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + AcpiPsGetNextNamepath (ParserState, Op, &ArgCount, 1); + ArgTypes = 0; + break; + + + default: + + /* Op is not a constant or string, append each argument */ + + while (GET_CURRENT_ARG_TYPE (ArgTypes) && !ArgCount) + { + AmlOffset = ParserState->Aml - ParserState->AmlStart; + Arg = AcpiPsGetNextArg (ParserState, + GET_CURRENT_ARG_TYPE (ArgTypes), + &ArgCount); + if (Arg) + { + Arg->AmlOffset = AmlOffset; + AcpiPsAppendArg (Op, Arg); + } + + INCREMENT_ARG_LIST (ArgTypes); + } + + + /* For a method, save the length and address of the body */ + + if (Op->Opcode == AML_METHOD_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + */ + + DeferredOp->Data = ParserState->Aml; + DeferredOp->Length = ParserState->PkgEnd - + ParserState->Aml; + + /* + * Skip body of method. For OpRegions, we must continue + * parsing because the opregion is not a standalone + * package (We don't know where the end is). + */ + ParserState->Aml = ParserState->PkgEnd; + ArgCount = 0; + } + } + + break; + } + } + + + /* + * Zero ArgCount means that all arguments for this op have been processed + */ + if (!ArgCount) + { + /* completed Op, prepare for next */ + + if (AcpiPsIsNamedOp (Op->Opcode)) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Opcode == AML_REGION_OP) + { + DeferredOp = AcpiPsToExtendedOp (Op); + if (DeferredOp) + { + /* + * 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. + */ + + DeferredOp->Length = ParserState->Aml - + DeferredOp->Data; + } + } + } + + if ((Op->Opcode == AML_CREATE_FIELD_OP) || + (Op->Opcode == AML_BIT_FIELD_OP) || + (Op->Opcode == AML_BYTE_FIELD_OP) || + (Op->Opcode == AML_WORD_FIELD_OP) || + (Op->Opcode == AML_DWORD_FIELD_OP)) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + * -4 for the name (last) -- TBD: namestring: may be longer + * than 4? + */ + DeferredOp = (ACPI_PARSE2_OBJECT *) Op; + + DeferredOp->Length = ParserState->Aml - DeferredOp->Data; + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + } + + +CloseThisOp: + + /* + * Finished one argument of the containing scope + */ + ParserState->Scope->ParseScope.ArgCount--; + + /* Close this Op (may result in parse subtree deletion) */ + + if (AcpiPsCompleteThisOp (WalkState, Op)) + { + Op = NULL; + } + + + if (Status == AE_CTRL_TRANSFER) + { + /* + * We are about to transfer to a called method. + */ + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = ArgTypes; + return_ACPI_STATUS (Status); + } + + else if (Status == AE_CTRL_END) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + AcpiPsCompleteThisOp (WalkState, Op); + Op = NULL; + Status = AE_OK; + } + + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + if (Op == NULL) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + } + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = ArgTypes; + + /* + * TEMP: + */ + + return_ACPI_STATUS (Status); + } + + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op)); + } + + else + { + Op = NULL; + } + + } + + + /* ArgCount is non-zero */ + + else + { + /* complex argument, push Op and prepare for argument */ + + AcpiPsPushScope (ParserState, Op, ArgTypes, ArgCount); + Op = NULL; + } + + } /* while ParserState->Aml */ + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several AML blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsParseLoop: Package complete at Op %p\n", Op)); + do + { + if (Op) + { + if (WalkState->AscendingCallback != NULL) + { + Status = WalkState->AscendingCallback (WalkState, Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + AcpiPsCompleteThisOp (WalkState, Op); + return_ACPI_STATUS (Status); + } + } + + AcpiPsCompleteThisOp (WalkState, Op); + } + + AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseAml + * + * PARAMETERS: StartScope - The starting point of the parse. Becomes the + * root of the parsed op tree. + * Aml - Pointer to the raw AML code to parse + * AmlSize - Length of the AML to parse + * + * RETURN: Status + * + * DESCRIPTION: Parse raw AML and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_PARSE_OBJECT *StartScope, + UINT8 *Aml, + UINT32 AmlSize, + UINT32 ParseFlags, + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_STATUS Status; + ACPI_PARSE_STATE *ParserState; + ACPI_WALK_STATE *WalkState; + ACPI_WALK_LIST WalkList; + ACPI_NAMESPACE_NODE *Node = NULL; + ACPI_WALK_LIST *PrevWalkList = AcpiGbl_CurrentWalkList; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_OPERAND_OBJECT *MthDesc = NULL; + ACPI_NAMESPACE_NODE *StartNode; + + + FUNCTION_TRACE ("PsParseAml"); + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: Entered with Scope=%p Aml=%p size=%lX\n", + StartScope, Aml, AmlSize)); + + + /* Create and initialize a new parser state */ + + ParserState = AcpiPsCreateState (Aml, AmlSize); + if (!ParserState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiPsInitScope (ParserState, StartScope); + + if (MethodNode) + { + MthDesc = AcpiNsGetAttachedObject (MethodNode); + } + + /* Create and initialize a new walk list */ + + WalkList.WalkState = NULL; + + WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, ParserState->StartOp, MthDesc, &WalkList); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + WalkState->MethodNode = MethodNode; + WalkState->ParserState = ParserState; + WalkState->ParseFlags = ParseFlags; + WalkState->DescendingCallback = DescendingCallback; + WalkState->AscendingCallback = AscendingCallback; + + /* TBD: [Restructure] TEMP until we pass WalkState to the interpreter + */ + AcpiGbl_CurrentWalkList = &WalkList; + + + if (MethodNode) + { + StartNode = MethodNode; + ParserState->StartNode = MethodNode; + WalkState->WalkType = WALK_METHOD; + + if (StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } + /* Init arguments if this is a control method */ + /* TBD: [Restructure] add walkstate as a param */ + + AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState); + } + + else + { + /* Setup the current scope */ + + Node = ParserState->StartOp->Node; + if (Node) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (Node, Node->Type, + WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + } + } + + + Status = AE_OK; + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsParseAml: State=%p\n", + WalkState)); + + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + Status = AcpiPsParseLoop (WalkState); + } + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: Completed one call to walk loop, State=%p\n", + WalkState)); + + if (Status == AE_CTRL_TRANSFER) + { + /* + * A method call was detected. + * Transfer control to the called control method + */ + + Status = AcpiDsCallControlMethod (&WalkList, WalkState, NULL); + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + continue; + } + + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + } + + /* We are done with this walk, move on to the parent if any */ + + + WalkState = AcpiDsPopWalkState (&WalkList); + + /* Extract return value before we delete WalkState */ + + ReturnDesc = WalkState->ReturnDesc; + + DEBUG_PRINT (TRACE_PARSE, + ("PsParseAml: ReturnValue=%p, State=%p\n", + WalkState->ReturnDesc, WalkState)); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method, + * there's lots of cleanup to do + */ + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) + { + AcpiDsTerminateControlMethod (WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiPsCleanupScope (WalkState->ParserState); + AcpiCmFree (WalkState->ParserState); + AcpiDsDeleteWalkState (WalkState); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + if (WalkState && + ACPI_SUCCESS (Status)) + { + /* There is another walk state, restart it */ + + /* + * If the method returned value is not used by the parent, + * The object is deleted + */ + + AcpiDsRestartControlMethod (WalkState, ReturnDesc); + WalkState->WalkType |= WALK_METHOD_RESTART; + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + + else if (CallerReturnDesc) + { + *CallerReturnDesc = ReturnDesc; /* NULL if no return value */ + } + + else if (ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiCmRemoveReference (ReturnDesc); + } + } + + + /* Normal exit */ + + AcpiGbl_CurrentWalkList = PrevWalkList; + return_ACPI_STATUS (Status); + + +Cleanup: + + /* Cleanup */ + + AcpiDsDeleteWalkState (WalkState); + AcpiPsCleanupScope (ParserState); + AcpiCmFree (ParserState); + + AcpiGbl_CurrentWalkList = PrevWalkList; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/psscope.c b/sys/contrib/dev/acpica/psscope.c new file mode 100644 index 0000000..47b61dc --- /dev/null +++ b/sys/contrib/dev/acpica/psscope.c @@ -0,0 +1,375 @@ +/****************************************************************************** + * + * Module Name: psscope - Parser scope stack management routines + * $Revision: 21 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" + +#define _COMPONENT PARSER + 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; + + + FUNCTION_TRACE_PTR ("PsInitScope", RootOp); + + + Scope = AcpiCmCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + 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; + + + FUNCTION_TRACE_PTR ("PsPushScope", Op); + + + Scope = AcpiCmCreateGenericState (); + if (!Scope) + { + return (AE_NO_MEMORY); + } + + + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + + /* Push onto scope stack */ + + AcpiCmPushGenericState (&ParserState->Scope, Scope); + + + if (ArgCount == ACPI_VAR_ARGS) + { + /* multiple arguments */ + + Scope->ParseScope.ArgEnd = ParserState->PkgEnd; + } + + else + { + /* single argument */ + + Scope->ParseScope.ArgEnd = ACPI_MAX_AML; + } + + 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; + + + FUNCTION_TRACE ("PsPopScope"); + + /* + * Only pop the scope if there is in fact a next scope + */ + if (Scope->Common.Next) + { + Scope = AcpiCmPopGenericState (&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 */ + + AcpiCmDeleteGenericState (Scope); + } + + else + { + /* empty parse stack, prepare to fetch next opcode */ + + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; + } + + + DEBUG_PRINT (TRACE_PARSE, + ("PsPopScope: Popped Op %p Args %d\n", *Op, *ArgCount)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCleanupScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Status + * + * DESCRIPTION: Destroy available list, remaining stack levels, and return + * root scope + * + ******************************************************************************/ + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_GENERIC_STATE *Scope; + + FUNCTION_TRACE_PTR ("PsCleanupScope", ParserState); + + + if (!ParserState) + { + return; + } + + + /* Delete anything on the scope stack */ + + while (ParserState->Scope) + { + Scope = AcpiCmPopGenericState (&ParserState->Scope); + AcpiCmDeleteGenericState (Scope); + } + + return_VOID; +} + diff --git a/sys/contrib/dev/acpica/pstree.c b/sys/contrib/dev/acpica/pstree.c new file mode 100644 index 0000000..adb5c62 --- /dev/null +++ b/sys/contrib/dev/acpica/pstree.c @@ -0,0 +1,518 @@ +/****************************************************************************** + * + * Module Name: pstree - Parser op tree manipulation/traversal/search + * $Revision: 23 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __PSTREE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("pstree") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArg + * + * PARAMETERS: Op - Get an argument for this op + * Argn - Nth argument to get + * + * RETURN: The argument (as an Op object). NULL if argument does not exist + * + * DESCRIPTION: Get the specified op's argument. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetArg ( + ACPI_PARSE_OBJECT *Op, + UINT32 Argn) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_OPCODE_INFO *OpInfo; + + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Invalid opcode or ASCII character */ + + return (NULL); + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(ACPI_GET_OP_ARGS (OpInfo))) + { + /* Has no linked argument objects */ + + return (NULL); + } + + /* Get the requested argument object */ + + Arg = Op->Value.Arg; + while (Arg && Argn) + { + Argn--; + Arg = Arg->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; + ACPI_OPCODE_INFO *OpInfo; + + + if (!Op) + { + return; + } + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode); + if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) + { + /* Invalid opcode */ + + return; + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(ACPI_GET_OP_ARGS (OpInfo))) + { + /* Has no linked argument objects */ + + return; + } + + + /* Append the argument to the linked argument list */ + + if (Op->Value.Arg) + { + /* Append to existing argument list */ + + PrevArg = Op->Value.Arg; + while (PrevArg->Next) + { + PrevArg = PrevArg->Next; + } + PrevArg->Next = Arg; + } + + else + { + /* No argument list, this will be the first argument */ + + Op->Value.Arg = Arg; + } + + + /* Set the parent in this arg and any args linked after it */ + + while (Arg) + { + Arg->Parent = Op; + Arg = Arg->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + switch (Op->Opcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_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_DEF_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; + + } + + return (Child); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetDepthNext + * + * PARAMETERS: Origin - Root of subtree to search + * Op - Last (previous) Op that was found + * + * RETURN: Next Op found in the search. + * + * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) + * Return NULL when reaching "origin" or when walking up from root + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *Arg; + + + if (!Op) + { + return (NULL); + } + + /* look for an argument or child */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + return (Next); + } + + /* look for a sibling */ + + Next = Op->Next; + if (Next) + { + return (Next); + } + + /* look for a sibling of parent */ + + Parent = Op->Parent; + + while (Parent) + { + Arg = AcpiPsGetArg (Parent, 0); + while (Arg && (Arg != Origin) && (Arg != Op)) + { + Arg = Arg->Next; + } + + if (Arg == Origin) + { + /* reached parent of origin, end search */ + + return (NULL); + } + + if (Parent->Next) + { + /* found sibling of parent */ + return (Parent->Next); + } + + Op = Parent; + Parent = Parent->Parent; + } + + return (Next); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFetchPrefix + * + * PARAMETERS: Scope - Op to fetch prefix for + * Path - A namestring containing the prefix + * io - Direction flag + * + * RETURN: Op referenced by the prefix + * + * DESCRIPTION: Fetch and handle path prefix ('\\' or '^') + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsFetchPrefix ( + ACPI_PARSE_OBJECT *Scope, + NATIVE_CHAR **Path, + UINT32 io) +{ + UINT32 prefix = io ? GET8 (*Path):**Path; + + + switch (prefix) + { + case '\\': + case '/': + + /* go to the root */ + + *Path += 1; + while (Scope->Parent) + { + Scope = Scope->Parent; + } + break; + + + case '^': + + /* go up one level */ + + *Path += 1; + Scope = Scope->Parent; + break; + } + + if (Scope && !Scope->Parent) + { + /* searching from the root, start with its children */ + + Scope = AcpiPsGetChild (Scope); + } + + return (Scope); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFetchName + * + * PARAMETERS: Path - A string containing the name segment + * io - Direction flag + * + * RETURN: The 4-INT8 ASCII ACPI Name as a UINT32 + * + * DESCRIPTION: Fetch ACPI name segment (dot-delimited) + * + ******************************************************************************/ + +UINT32 +AcpiPsFetchName ( + NATIVE_CHAR **Path, + UINT32 io) +{ + UINT32 Name = 0; + NATIVE_CHAR *nm; + UINT32 i; + NATIVE_CHAR ch; + + + if (io) + { + /* Get the name from the path pointer */ + + MOVE_UNALIGNED32_TO_32 (&Name, *Path); + *Path += 4; + } + + else + { + if (**Path == '.') + { + *Path += 1; + } + + nm = (NATIVE_CHAR *) &Name; + for (i = 0; i < 4; i++) + { + ch = **Path; + if (ch && ch != '.') + { + *nm = ch; + *Path += 1; + } + + else + { + *nm = '_'; + } + nm++; + } + } + + return (Name); +} + + diff --git a/sys/contrib/dev/acpica/psutils.c b/sys/contrib/dev/acpica/psutils.c new file mode 100644 index 0000000..0467ff8 --- /dev/null +++ b/sys/contrib/dev/acpica/psutils.c @@ -0,0 +1,683 @@ +/****************************************************************************** + * + * Module Name: psutils - Parser miscellaneous utilities (Parser only) + * $Revision: 30 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psutils") + + +#define PARSEOP_GENERIC 0x01 +#define PARSEOP_NAMED 0x02 +#define PARSEOP_DEFERRED 0x03 +#define PARSEOP_BYTELIST 0x04 +#define PARSEOP_IN_CACHE 0x80 + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitOp + * + * PARAMETERS: Op - A newly allocated Op object + * Opcode - Opcode to store in the Op + * + * RETURN: Status + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode + * + ******************************************************************************/ + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode) +{ + ACPI_OPCODE_INFO *AmlOp; + + + Op->DataType = ACPI_DESC_TYPE_PARSER; + Op->Opcode = Opcode; + + AmlOp = AcpiPsGetOpcodeInfo (Opcode); + + DEBUG_ONLY_MEMBERS (STRNCPY (Op->OpName, AmlOp->Name, + sizeof (Op->OpName))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAllocOp + * + * PARAMETERS: Opcode - Opcode that will be stored in the new Op + * + * RETURN: Pointer to the new Op. + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode. A cache of opcodes is available for the pure + * GENERIC_OP, since this is by far the most commonly used. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsAllocOp ( + UINT16 Opcode) +{ + ACPI_PARSE_OBJECT *Op = NULL; + UINT32 Size; + UINT8 Flags; + + + /* Allocate the minimum required size object */ + + if (AcpiPsIsDeferredOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_DEFERRED; + } + + else if (AcpiPsIsNamedOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_NAMED; + } + + else if (AcpiPsIsBytelistOp (Opcode)) + { + Size = sizeof (ACPI_PARSE2_OBJECT); + Flags = PARSEOP_BYTELIST; + } + + else + { + Size = sizeof (ACPI_PARSE_OBJECT); + Flags = PARSEOP_GENERIC; + } + + + if (Size == sizeof (ACPI_PARSE_OBJECT)) + { + /* + * The generic op is by far the most common (16 to 1), and therefore + * the op cache is implemented with this type. + * + * Check if there is an Op already available in the cache + */ + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ParseCacheRequests++; + if (AcpiGbl_ParseCache) + { + /* Extract an op from the front of the cache list */ + + AcpiGbl_ParseCacheDepth--; + AcpiGbl_ParseCacheHits++; + + Op = AcpiGbl_ParseCache; + AcpiGbl_ParseCache = Op->Next; + + if (Op->DataType == 0xFF) + { + DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op)); + } + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT)); + + DEBUG_PRINT (TRACE_PARSE, + ("PsAllocOp: Op %p from Parse Cache\n", Op)); + } + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* + * The generic op is by far the most common (16 to 1), and therefore + * the op cache is implemented with this type. + * + * Check if there is an Op already available in the cache + */ + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ExtParseCacheRequests++; + if (AcpiGbl_ExtParseCache) + { + /* Extract an op from the front of the cache list */ + + AcpiGbl_ExtParseCacheDepth--; + AcpiGbl_ExtParseCacheHits++; + + Op = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache; + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op->Next; + + if (Op->DataType == 0xFF) + { + DEBUG_PRINT (ACPI_ERROR, ("Op %p deleted while in cache!\n", Op)); + } + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT)); + + DEBUG_PRINT (TRACE_PARSE, + ("PsAllocOp: Op %p from ExtParse Cache\n", Op)); + } + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + + /* Allocate a new Op if necessary */ + + if (!Op) + { + Op = AcpiCmCallocate (Size); + } + + /* Initialize the Op */ + if (Op) + { + AcpiPsInitOp (Op, Opcode); + Op->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) +{ + + + if (Op->Opcode == AML_RETURN_VALUE_OP) + { + DEBUG_PRINT (ACPI_INFO, ("Free retval op: %p\n", Op)); + } + + if (Op->Flags == PARSEOP_GENERIC) + { + /* Is the cache full? */ + + if (AcpiGbl_ParseCacheDepth < MAX_PARSE_CACHE_DEPTH) + { + /* Put a GENERIC_OP back into the cache */ + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE_OBJECT)); + Op->Flags = PARSEOP_IN_CACHE; + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ParseCacheDepth++; + + Op->Next = AcpiGbl_ParseCache; + AcpiGbl_ParseCache = Op; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return; + } + } + + else + { + /* Is the cache full? */ + + if (AcpiGbl_ExtParseCacheDepth < MAX_EXTPARSE_CACHE_DEPTH) + { + /* Put a GENERIC_OP back into the cache */ + + /* Clear the previously used Op */ + + MEMSET (Op, 0, sizeof (ACPI_PARSE2_OBJECT)); + Op->Flags = PARSEOP_IN_CACHE; + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + AcpiGbl_ExtParseCacheDepth++; + + Op->Next = (ACPI_PARSE_OBJECT *) AcpiGbl_ExtParseCache; + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Op; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return; + } + } + + + /* + * Not a GENERIC OP, or the cache is full, just free the Op + */ + + AcpiCmFree (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseCache + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Free all objects that are on the parse cache list. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseCache ( + void) +{ + ACPI_PARSE_OBJECT *Next; + + + FUNCTION_TRACE ("PsDeleteParseCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_ParseCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ParseCache->Next; + AcpiCmFree (AcpiGbl_ParseCache); + AcpiGbl_ParseCache = Next; + AcpiGbl_ParseCacheDepth--; + } + + /* Traverse the global cache list */ + + while (AcpiGbl_ExtParseCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ExtParseCache->Next; + AcpiCmFree (AcpiGbl_ExtParseCache); + AcpiGbl_ExtParseCache = (ACPI_PARSE2_OBJECT *) Next; + AcpiGbl_ExtParseCacheDepth--; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: Utility functions + * + * DESCRIPTION: Low level functions + * + * TBD: [Restructure] + * 1) Some of these functions should be macros + * 2) Some can be simplified + * + ******************************************************************************/ + + +/* + * 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 == '^')); +} + + +BOOLEAN +AcpiPsIsNamespaceObjectOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_DEF_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_NAMEDFIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_METHODCALL_OP || + Opcode == AML_NAMEPATH_OP)); +} + +BOOLEAN +AcpiPsIsNamespaceOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_DEF_FIELD_OP || + Opcode == AML_INDEX_FIELD_OP || + Opcode == AML_BANK_FIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_NAMEDFIELD_OP)); +} + + +/* + * Is opcode for a named object Op? + * (Includes all named object opcodes) + * + * TBD: [Restructure] Need a better way than this brute force approach! + */ +BOOLEAN +AcpiPsIsNodeOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_NAMEDFIELD_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + + + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_METHODCALL_OP || + Opcode == AML_NAMEPATH_OP)); +} + + +/* + * Is opcode for a named Op? + */ +BOOLEAN +AcpiPsIsNamedOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_SCOPE_OP || + Opcode == AML_DEVICE_OP || + Opcode == AML_THERMAL_ZONE_OP || + Opcode == AML_METHOD_OP || + Opcode == AML_POWER_RES_OP || + Opcode == AML_PROCESSOR_OP || + Opcode == AML_NAME_OP || + Opcode == AML_ALIAS_OP || + Opcode == AML_MUTEX_OP || + Opcode == AML_EVENT_OP || + Opcode == AML_REGION_OP || + Opcode == AML_NAMEDFIELD_OP)); +} + + +BOOLEAN +AcpiPsIsDeferredOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_METHOD_OP || + Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP || + Opcode == AML_REGION_OP)); +} + + +/* + * Is opcode for a bytelist? + */ +BOOLEAN +AcpiPsIsBytelistOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) (Opcode == AML_BYTELIST_OP)); +} + + +/* + * Is opcode for a Field, IndexField, or BankField + */ +BOOLEAN +AcpiPsIsFieldOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_CREATE_FIELD_OP + || Opcode == AML_DEF_FIELD_OP + || Opcode == AML_INDEX_FIELD_OP + || Opcode == AML_BANK_FIELD_OP)); +} + + +/* + * Is field creation op + */ +BOOLEAN +AcpiPsIsCreateFieldOp ( + UINT16 Opcode) +{ + return ((BOOLEAN) + (Opcode == AML_CREATE_FIELD_OP || + Opcode == AML_BIT_FIELD_OP || + Opcode == AML_BYTE_FIELD_OP || + Opcode == AML_WORD_FIELD_OP || + Opcode == AML_DWORD_FIELD_OP)); +} + + +/* + * Cast an acpi_op to an acpi_extended_op if possible + */ + +/* TBD: This is very inefficient, fix */ +ACPI_PARSE2_OBJECT * +AcpiPsToExtendedOp ( + ACPI_PARSE_OBJECT *Op) +{ + return ((AcpiPsIsDeferredOp (Op->Opcode) || AcpiPsIsNamedOp (Op->Opcode) || AcpiPsIsBytelistOp (Op->Opcode)) + ? ( (ACPI_PARSE2_OBJECT *) Op) : NULL); +} + + +/* + * Get op's name (4-byte name segment) or 0 if unnamed + */ +UINT32 +AcpiPsGetName ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op); + + return (Named ? Named->Name : 0); +} + + +/* + * Set op's name + */ +void +AcpiPsSetName ( + ACPI_PARSE_OBJECT *Op, + UINT32 name) +{ + ACPI_PARSE2_OBJECT *Named = AcpiPsToExtendedOp (Op); + + if (Named) + { + Named->Name = name; + } +} + diff --git a/sys/contrib/dev/acpica/pswalk.c b/sys/contrib/dev/acpica/pswalk.c new file mode 100644 index 0000000..176a54d --- /dev/null +++ b/sys/contrib/dev/acpica/pswalk.c @@ -0,0 +1,727 @@ +/****************************************************************************** + * + * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * $Revision: 47 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "amlcode.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT PARSER + MODULE_NAME ("pswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextWalkOp + * + * PARAMETERS: WalkState - Current state of the walk + * Op - Current Op to be walked + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Get the next Op in a walk of the parse tree. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *GrandParent; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("PsGetNextWalkOp", Op); + + + /* Check for a argument only if we are descending in the tree */ + + if (WalkState->NextOpInfo != NEXT_OP_UPWARD) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (AE_OK); + } + + + /* + * No more children, this Op is complete. Save Next and Parent + * in case the Op object gets deleted by the callback routine + */ + + Next = Op->Next; + Parent = Op->Parent; + + Status = AscendingCallback (WalkState, Op); + + switch (Status) + { + case AE_CTRL_TERMINATE: + + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + WalkState->PrevOp = WalkState->Origin; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); + 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. + */ + + Next = Parent->Next; + Status = AE_OK; + + /* + * If there is a sibling to the parent, we must close out the + * parent now, because we are going to continue to go downward (to + * the sibling) in the parse tree. + */ + if (Next) + { + Status = AscendingCallback (WalkState, Parent); + + /* The parent sibling will be next */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Continue downward */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Drop into the loop below because we are moving upwards in + * the tree + */ + + break; + + + default: + /* + * If we are back to the starting point, the walk is complete. + */ + if (Op == WalkState->Origin) + { + /* Reached the point of origin, the walk is complete */ + + WalkState->PrevOp = Op; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (Status); + } + + /* + * Check for a sibling to the current op. A sibling means + * we are still going "downward" in the tree. + */ + + if (Next) + { + /* There is a sibling, it will be next */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + /* Continue downward */ + + return_ACPI_STATUS (Status); + } + + /* + * No sibling, but check status. + * Abort on error from callback routine + */ + if (ACPI_FAILURE (Status)) + { + /* Next op will be the parent */ + + WalkState->PrevOp = Op; + WalkState->NextOp = Parent; + WalkState->NextOpInfo = NEXT_OP_UPWARD; + + return_ACPI_STATUS (Status); + } + + /* + * Drop into the loop below because we are moving upwards in + * the tree + */ + + break; + } + } + + else + { + /* + * We are resuming a walk, and we were (are) going upward in the tree. + * So, we want to drop into the parent loop below. + */ + + Parent = Op; + } + + + /* + * Look for a sibling of the current Op's parent + * Continue moving up the tree until we find a node that has not been + * visited, or we get back to where we started. + */ + while (Parent) + { + /* We are moving up the tree, therefore this parent Op is complete */ + + GrandParent = Parent->Parent; + Next = Parent->Next; + + Status = AscendingCallback (WalkState, Parent); + + + switch (Status) + { + 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. + */ + + Parent = GrandParent; + Next = GrandParent->Next; + GrandParent = GrandParent->Parent; + + Status = AscendingCallback (WalkState, Parent); + + /* Now continue to the next node in the tree */ + + break; + + + case AE_CTRL_TRUE: + + /* + * Predicate of a WHILE was true and the loop just completed an + * execution. Go back to the start of the loop and reevaluate the + * predicate. + */ + + Op = WalkState->ControlState->Control.PredicateOp; + + WalkState->ControlState->Common.State = CONTROL_PREDICATE_EXECUTING; + + /* + * AcpiEvaluate the predicate again (next) + * Because we will traverse WHILE tree again + */ + + WalkState->PrevOp = Op->Parent; + WalkState->NextOp = Op; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (AE_OK); + break; + + + case AE_CTRL_TERMINATE: + + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + WalkState->PrevOp = WalkState->Origin; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); + break; + } + + + /* + * If we are back to the starting point, the walk is complete. + */ + if (Parent == WalkState->Origin) + { + /* Reached the point of origin, the walk is complete */ + + WalkState->PrevOp = Parent; + WalkState->NextOp = NULL; + + return_ACPI_STATUS (Status); + } + + + /* + * If there is a sibling to this parent (it is not the starting point + * Op), then we will visit it. + */ + if (Next) + { + /* found sibling of parent */ + + WalkState->PrevOp = Parent; + WalkState->NextOp = Next; + WalkState->NextOpInfo = NEXT_OP_DOWNWARD; + + return_ACPI_STATUS (Status); + } + + /* + * No sibling, check for an error from closing the parent + * (Also, AE_PENDING if a method call was encountered) + */ + if (ACPI_FAILURE (Status)) + { + WalkState->PrevOp = Parent; + WalkState->NextOp = GrandParent; + WalkState->NextOpInfo = NEXT_OP_UPWARD; + + return_ACPI_STATUS (Status); + } + + /* No siblings, no errors, just move up one more level in the tree */ + + Op = Parent; + Parent = GrandParent; + WalkState->PrevOp = Op; + } + + + /* Got all the way to the top of the tree, we must be done! */ + /* However, the code should have terminated in the loop above */ + + WalkState->NextOp = NULL; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsWalkLoop + * + * PARAMETERS: WalkList - State of the walk + * StartOp - Starting Op of the subtree to be walked + * DescendingCallback - Procedure called when a new Op is + * encountered + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Perform a walk of the parsed AML tree. Begins and terminates at + * the StartOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsWalkLoop ( + ACPI_WALK_LIST *WalkList, + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_STATUS Status = AE_OK; + ACPI_WALK_STATE *WalkState; + ACPI_PARSE_OBJECT *Op = StartOp; + + + FUNCTION_TRACE_PTR ("PsWalkLoop", StartOp); + + + WalkState = AcpiDsGetCurrentWalkState (WalkList); + + + /* Walk entire subtree, visiting all nodes depth-first */ + + while (Op) + { + if (WalkState->NextOpInfo != NEXT_OP_UPWARD) + { + Status = DescendingCallback (Op->Opcode, Op, WalkState, NULL); + } + + /* + * A TRUE exception means that an ELSE was detected, but the IF + * predicate evaluated TRUE. + */ + if (Status == AE_CTRL_TRUE) + { + /* + * Ignore the entire ELSE block by moving on to the the next opcode. + * And we do that by simply going up in the tree (either to the next + * sibling or to the parent) from here. + */ + + WalkState->NextOpInfo = NEXT_OP_UPWARD; + } + + /* Get the next node (op) in the depth-first walk */ + + Status = AcpiPsGetNextWalkOp (WalkState, Op, AscendingCallback); + + /* + * A PENDING exception means that a control method invocation has been + * detected + */ + + if (Status == AE_CTRL_PENDING) + { + /* Transfer control to the called control method */ + + Status = AcpiDsCallControlMethod (WalkList, WalkState, Op); + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + + WalkState = AcpiDsGetCurrentWalkState (WalkList); + } + + /* Abort the walk on any exception */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Op = WalkState->NextOp; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsWalkParsedAml + * + * PARAMETERS: StartOp - Starting Op of the subtree to be walked + * EndOp - Where to terminate the walk + * DescendingCallback - Procedure called when a new Op is + * encountered + * AscendingCallback - Procedure called when Op is complete + * + * RETURN: Status + * + * DESCRIPTION: Top level interface to walk the parsed AML tree. Handles + * preemption of executing control methods. + * + * NOTE: The EndOp is usually only different from the StartOp if + * we don't want to visit the StartOp during the tree descent. + * + ******************************************************************************/ + +ACPI_STATUS +mmmmAcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_STATUS Status; + ACPI_WALK_LIST WalkList; + ACPI_WALK_LIST *PrevWalkList; + + + FUNCTION_TRACE_PTR ("PsWalkParsedAml", StartOp); + + + /* Parameter Validation */ + + if (!StartOp || !EndOp) + { + return (AE_BAD_PARAMETER); + } + + /* Initialize a new walk list */ + + WalkList.WalkState = NULL; + + WalkState = AcpiDsCreateWalkState (OwnerId, EndOp, MthDesc, &WalkList); + if (!WalkState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* TBD: [Restructure] TEMP until we pass WalkState to the interpreter + */ + PrevWalkList = AcpiGbl_CurrentWalkList; + AcpiGbl_CurrentWalkList = &WalkList; + + if (StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } + + if (MthDesc) + { + /* Init arguments if this is a control method */ + /* TBD: [Restructure] add walkstate as a param */ + + AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState); + } + + Op = StartOp; + Status = AE_OK; + + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + + DEBUG_PRINT (TRACE_PARSE, ("PsWalkParsedAml: Op=%p EndOp=%p State=%p\n", + Op, EndOp, WalkState)); + + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + Status = AcpiPsWalkLoop (&WalkList, Op, DescendingCallback, + AscendingCallback); + } + + DEBUG_PRINT (TRACE_PARSE, + ("PsWalkParsedAml: Completed one call to walk loop, State=%p\n", + WalkState)); + + /* We are done with this walk, move on to the parent if any */ + + BREAKPOINT3; + + WalkState = AcpiDsPopWalkState (&WalkList); + + /* Extract return value before we delete WalkState */ + + ReturnDesc = WalkState->ReturnDesc; + + DEBUG_PRINT (TRACE_PARSE, + ("PsWalkParsedAml: ReturnValue=%p, State=%p\n", + WalkState->ReturnDesc, WalkState)); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method, + * there's lots of cleanup to do + */ + + if (WalkState->MethodDesc) + { + AcpiDsTerminateControlMethod (WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiDsDeleteWalkState (WalkState); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (&WalkList); + if (WalkState && + ACPI_SUCCESS (Status)) + { + /* There is another walk state, restart it */ + + /* + * If the method returned value is not used by the parent, + * The object is deleted + */ + + AcpiDsRestartControlMethod (WalkState, ReturnDesc); + + /* Get the next Op to process */ + + Op = WalkState->NextOp; + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + + else if (CallerReturnDesc) + { + *CallerReturnDesc = ReturnDesc; /* NULL if no return value */ + } + + else if (ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiCmRemoveReference (ReturnDesc); + } + } + + + AcpiGbl_CurrentWalkList = PrevWalkList; + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/psxface.c b/sys/contrib/dev/acpica/psxface.c new file mode 100644 index 0000000..2f65a41 --- /dev/null +++ b/sys/contrib/dev/acpica/psxface.c @@ -0,0 +1,270 @@ +/****************************************************************************** + * + * Module Name: psxface - Parser external interfaces + * $Revision: 37 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PSXFACE_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT PARSER + MODULE_NAME ("psxface") + + +/***************************************************************************** + * + * FUNCTION: AcpiPsxExecute + * + * PARAMETERS: MethodNode - A method object containing both the AML + * address and length. + * **Params - List of parameters to pass to method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * **ReturnObjDesc - Return object from execution of the + * method. + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ****************************************************************************/ + +ACPI_STATUS +AcpiPsxExecute ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **ReturnObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 i; + ACPI_PARSE_OBJECT *Op; + + + FUNCTION_TRACE ("PsxExecute"); + + + /* Validate the Node and get the attached object */ + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Params) + { + /* + * The caller "owns" the parameters, so give each one an extra + * reference + */ + + for (i = 0; Params[i]; i++) + { + AcpiCmAddReference (Params[i]); + } + } + + /* + * Perform the first pass parse of the method to enter any + * named objects that it creates into the namespace + */ + + DEBUG_PRINT (ACPI_INFO, + ("PsxExecute: **** Begin Method Execution **** Entry=%p obj=%p\n", + MethodNode, ObjDesc)); + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + MethodNode, Params, ReturnObjDesc, + AcpiDsLoad1BeginOp, AcpiDsLoad1EndOp); + AcpiPsDeleteParseTree (Op); + + /* Create and init a Root Node */ + + Op = AcpiPsAllocOp (AML_SCOPE_OP); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * The walk of the parse tree is where we actually execute the method + */ + Status = AcpiPsParseAml (Op, ObjDesc->Method.Pcode, + ObjDesc->Method.PcodeLength, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + MethodNode, Params, ReturnObjDesc, + AcpiDsExecBeginOp, AcpiDsExecEndOp); + AcpiPsDeleteParseTree (Op); + + if (Params) + { + /* Take away the extra reference that we gave the parameters above */ + + for (i = 0; Params[i]; i++) + { + AcpiCmUpdateObjectReference (Params[i], REF_DECREMENT); + } + } + + + /* + * Normal exit is with Status == AE_RETURN_VALUE when a ReturnOp has been + * executed, or with Status == AE_PENDING at end of AML block (end of + * Method code) + */ + + if (*ReturnObjDesc) + { + DEBUG_PRINT (ACPI_INFO, ("Method returned ObjDesc=%X\n", + *ReturnObjDesc)); + DUMP_STACK_ENTRY (*ReturnObjDesc); + + Status = AE_CTRL_RETURN_VALUE; + } + + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/rsaddr.c b/sys/contrib/dev/acpica/rsaddr.c new file mode 100644 index 0000000..478441c --- /dev/null +++ b/sys/contrib/dev/acpica/rsaddr.c @@ -0,0 +1,922 @@ +/******************************************************************************* + * + * Module Name: rsaddr - AcpiRsAddress16Resource + * AcpiRsAddress16Stream + * AcpiRsAddress32Resource + * AcpiRsAddress32Stream + * $Revision: 11 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSADDR_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsaddr") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress16Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress16Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16; + UINT8 Temp8; + UINT32 Index; + UINT32 StructSize = sizeof(ADDRESS16_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsAddress16Resource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = Address16; + + OutputStruct->Length = StructSize; + + /* + * Get the Resource Type (Byte3) + */ + Buffer += 2; + Temp8 = *Buffer; + + /* Values 0-2 are valid */ + if (Temp8 > 2) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03; + + /* + * Get the General Flags (Byte4) + */ + Buffer += 1; + Temp8 = *Buffer; + + /* + * Producer / Consumer + */ + OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01; + + /* + * Decode + */ + OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01; + + /* + * Min Address Fixed + */ + OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01; + + /* + * Max Address Fixed + */ + OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01; + + /* + * Get the Type Specific Flags (Byte5) + */ + Buffer += 1; + Temp8 = *Buffer; + + if (MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType) + { + OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute = + (UINT16) (Temp8 & 0x01); + OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute = + (UINT16) ((Temp8 >> 1) & 0x0F); + } + + else + { + if (IO_RANGE == OutputStruct->Data.Address16.ResourceType) + { + OutputStruct->Data.Address16.Attribute.Io.RangeAttribute = + (UINT16) (Temp8 & 0x03); + } + + else + { + /* BUS_NUMBER_RANGE == Address32Data->ResourceType */ + /* Nothing needs to be filled in */ + } + } + + /* + * Get Granularity (Bytes 6-7) + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.Granularity, + Buffer); + + /* + * Get MinAddressRange (Bytes 8-9) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MinAddressRange, + Buffer); + + /* + * Get MaxAddressRange (Bytes 10-11) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 + (&OutputStruct->Data.Address16.MaxAddressRange, + Buffer); + + /* + * Get AddressTranslationOffset (Bytes 12-13) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 + (&OutputStruct->Data.Address16.AddressTranslationOffset, + Buffer); + + /* + * Get AddressLength (Bytes 14-15) + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 + (&OutputStruct->Data.Address16.AddressLength, + Buffer); + + /* + * Resource Source Index (if present) + */ + Buffer += 2; + + /* + * This will leave us pointing to the Resource Source Index + * If it is present, then save it off and calculate the + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. + */ + if (*BytesConsumed > 16) + { + /* Dereference the Index */ + + Temp8 = *Buffer; + OutputStruct->Data.Address16.ResourceSourceIndex = + (UINT32) Temp8; + + /* Point to the String */ + + Buffer += 1; + + /* Copy the string into the buffer */ + + Index = 0; + + while (0x00 != *Buffer) + { + OutputStruct->Data.Address16.ResourceSource[Index] = + *Buffer; + + Buffer += 1; + Index += 1; + } + + /* + * Add the terminating null + */ + OutputStruct->Data.Address16.ResourceSource[Index] = 0x00; + + OutputStruct->Data.Address16.ResourceSourceStringLength = + Index + 1; + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundry. + */ + Temp8 = (UINT8) (Index + 1); + StructSize += ROUND_UP_TO_32BITS (Temp8); + OutputStruct->Length = StructSize; + } + else + { + OutputStruct->Data.Address16.ResourceSourceIndex = 0x00; + OutputStruct->Data.Address16.ResourceSourceStringLength = 0; + OutputStruct->Data.Address16.ResourceSource[0] = 0x00; + } + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress16Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress16Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT8 *LengthField; + UINT8 Temp8; + NATIVE_CHAR *TempPointer = NULL; + UINT32 ActualBytes; + + + FUNCTION_TRACE ("RsAddress16Stream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x88; + Buffer += 1; + + /* + * Save a pointer to the Length field - to be filled in later + */ + LengthField = Buffer; + Buffer += 2; + + /* + * Set the Resource Type (Memory, Io, BusNumber) + */ + Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the general flags + */ + Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01); + + Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1; + Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2; + Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the type specific flags + */ + Temp8 = 0; + + if (MEMORY_RANGE == LinkedList->Data.Address16.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute & + 0x01); + + Temp8 |= + (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute & + 0x0F) << 1; + } + + else if (IO_RANGE == LinkedList->Data.Address16.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address16.Attribute.Io.RangeAttribute & + 0x03); + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the address space granularity + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.Granularity); + Buffer += 2; + + /* + * Set the address range minimum + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.MinAddressRange); + Buffer += 2; + + /* + * Set the address range maximum + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.MaxAddressRange); + Buffer += 2; + + /* + * Set the address translation offset + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.AddressTranslationOffset); + Buffer += 2; + + /* + * Set the address length + */ + MOVE_UNALIGNED16_TO_16 (Buffer, + &LinkedList->Data.Address16.AddressLength); + Buffer += 2; + + /* + * Resource Source Index and Resource Source are optional + */ + if (0 != LinkedList->Data.Address16.ResourceSourceStringLength) + { + Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSourceIndex; + + *Buffer = Temp8; + Buffer += 1; + + TempPointer = (NATIVE_CHAR *) Buffer; + + /* + * Copy the string + */ + STRCPY (TempPointer, LinkedList->Data.Address16.ResourceSource); + + /* + * Buffer needs to be set to the length of the sting + one for the + * terminating null + */ + Buffer += (STRLEN (LinkedList->Data.Address16.ResourceSource) + 1); + } + + /* + * Return the number of bytes consumed in this operation + */ + ActualBytes = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + *BytesConsumed = ActualBytes; + + /* + * Set the length field to the number of bytes consumed + * minus the header size (3 bytes) + */ + ActualBytes -= 3; + MOVE_UNALIGNED16_TO_16 (LengthField, &ActualBytes); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress32Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer; + RESOURCE *OutputStruct; + UINT16 Temp16; + UINT8 Temp8; + UINT32 StructSize; + UINT32 Index; + + + FUNCTION_TRACE ("RsAddress32Resource"); + + Buffer = ByteStreamBuffer; + + OutputStruct = (RESOURCE *) *OutputBuffer; + + StructSize = sizeof (ADDRESS32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = Address32; + + /* + * Get the Resource Type (Byte3) + */ + Buffer += 2; + Temp8 = *Buffer; + + /* Values 0-2 are valid */ + if(Temp8 > 2) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03; + + /* + * Get the General Flags (Byte4) + */ + Buffer += 1; + Temp8 = *Buffer; + + /* + * Producer / Consumer + */ + OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01; + + /* + * Decode + */ + OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01; + + /* + * Min Address Fixed + */ + OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01; + + /* + * Max Address Fixed + */ + OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01; + + /* + * Get the Type Specific Flags (Byte5) + */ + Buffer += 1; + Temp8 = *Buffer; + + if (MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType) + { + OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute = + (UINT16) (Temp8 & 0x01); + + OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute = + (UINT16) ((Temp8 >> 1) & 0x0F); + } + + else + { + if (IO_RANGE == OutputStruct->Data.Address32.ResourceType) + { + OutputStruct->Data.Address32.Attribute.Io.RangeAttribute = + (UINT16) (Temp8 & 0x03); + } + + else + { + /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */ + /* Nothing needs to be filled in */ + } + } + + /* + * Get Granularity (Bytes 6-9) + */ + Buffer += 1; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.Granularity, + Buffer); + + /* + * Get MinAddressRange (Bytes 10-13) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange, + Buffer); + + /* + * Get MaxAddressRange (Bytes 14-17) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange, + Buffer); + + /* + * Get AddressTranslationOffset (Bytes 18-21) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 + (&OutputStruct->Data.Address32.AddressTranslationOffset, + Buffer); + + /* + * Get AddressLength (Bytes 22-25) + */ + Buffer += 4; + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressLength, + Buffer); + + /* + * Resource Source Index (if present) + */ + Buffer += 4; + + /* + * This will leave us pointing to the Resource Source Index + * If it is present, then save it off and calculate the + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. + */ + if (*BytesConsumed > 26) + { + /* Dereference the Index */ + + Temp8 = *Buffer; + OutputStruct->Data.Address32.ResourceSourceIndex = (UINT32)Temp8; + + /* Point to the String */ + + Buffer += 1; + + /* Copy the string into the buffer */ + + Index = 0; + + while (0x00 != *Buffer) + { + OutputStruct->Data.Address32.ResourceSource[Index] = *Buffer; + Buffer += 1; + Index += 1; + } + + /* + * Add the terminating null + */ + OutputStruct->Data.Address32.ResourceSource[Index] = 0x00; + + OutputStruct->Data.Address32.ResourceSourceStringLength = Index + 1; + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundry. + */ + Temp8 = (UINT8) (Index + 1); + StructSize += ROUND_UP_TO_32BITS (Temp8); + } + + else + { + OutputStruct->Data.Address32.ResourceSourceIndex = 0x00; + OutputStruct->Data.Address32.ResourceSourceStringLength = 0; + OutputStruct->Data.Address32.ResourceSource[0] = 0x00; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsAddress32Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsAddress32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer; + UINT16 *LengthField; + UINT8 Temp8; + NATIVE_CHAR *TempPointer; + + + FUNCTION_TRACE ("RsAddress32Stream"); + + Buffer = *OutputBuffer; + + /* + * The descriptor field is static + */ + *Buffer = 0x87; + Buffer += 1; + + /* + * Set a pointer to the Length field - to be filled in later + */ + + LengthField = (UINT16 *)Buffer; + Buffer += 2; + + /* + * Set the Resource Type (Memory, Io, BusNumber) + */ + Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03); + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the general flags + */ + Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01); + Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1; + Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2; + Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the type specific flags + */ + Temp8 = 0; + + if(MEMORY_RANGE == LinkedList->Data.Address32.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute & + 0x01); + + Temp8 |= + (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute & + 0x0F) << 1; + } + + else if (IO_RANGE == LinkedList->Data.Address32.ResourceType) + { + Temp8 = (UINT8) + (LinkedList->Data.Address32.Attribute.Io.RangeAttribute & + 0x03); + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the address space granularity + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.Granularity); + Buffer += 4; + + /* + * Set the address range minimum + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.MinAddressRange); + Buffer += 4; + + /* + * Set the address range maximum + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.MaxAddressRange); + Buffer += 4; + + /* + * Set the address translation offset + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.AddressTranslationOffset); + Buffer += 4; + + /* + * Set the address length + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.Address32.AddressLength); + Buffer += 4; + + /* + * Resource Source Index and Resource Source are optional + */ + if (0 != LinkedList->Data.Address32.ResourceSourceStringLength) + { + Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSourceIndex; + + *Buffer = Temp8; + Buffer += 1; + + TempPointer = (NATIVE_CHAR *) Buffer; + + /* + * Copy the string + */ + STRCPY (TempPointer, LinkedList->Data.Address32.ResourceSource); + + /* + * Buffer needs to be set to the length of the sting + one for the + * terminating null + */ + Buffer += (STRLEN (LinkedList->Data.Address32.ResourceSource) + 1); + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + /* + * Set the length field to the number of bytes consumed + * minus the header size (3 bytes) + */ + *LengthField = (UINT16) (*BytesConsumed - 3); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/rscalc.c b/sys/contrib/dev/acpica/rscalc.c new file mode 100644 index 0000000..5911adf --- /dev/null +++ b/sys/contrib/dev/acpica/rscalc.c @@ -0,0 +1,986 @@ +/******************************************************************************* + * + * Module Name: rscalc - AcpiRsCalculateByteStreamLength + * AcpiRsCalculateListLength + * $Revision: 11 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSCALC_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rscalc") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCalculateByteStreamLength + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * SizeNeeded - UINT32 pointer of the size buffer needed + * to properly return the parsed data + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource byte stream and parses it once, calculating + * the size buffer needed to hold the linked list that conveys + * the resource data. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCalculateByteStreamLength ( + RESOURCE *LinkedList, + UINT32 *SizeNeeded) +{ + UINT32 ByteStreamSizeNeeded = 0; + UINT32 SegmentSize; + EXTENDED_IRQ_RESOURCE *ExIrq = NULL; + BOOLEAN Done = FALSE; + + + FUNCTION_TRACE ("RsCalculateByteStreamLength"); + + + while (!Done) + { + + /* + * Init the variable that will hold the size to add to the + * total. + */ + SegmentSize = 0; + + switch (LinkedList->Id) + { + case Irq: + /* + * IRQ Resource + */ + /* + * For an IRQ Resource, Byte 3, although optional, will + * always be created - it holds IRQ information. + */ + SegmentSize = 4; + break; + + case Dma: + /* + * DMA Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 3; + break; + + case StartDependentFunctions: + /* + * Start Dependent Functions Resource + */ + /* + * For a StartDependentFunctions Resource, Byte 1, + * although optional, will always be created. + */ + SegmentSize = 2; + break; + + case EndDependentFunctions: + /* + * End Dependent Functions Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 1; + break; + + case Io: + /* + * IO Port Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 8; + break; + + case FixedIo: + /* + * Fixed IO Port Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 4; + break; + + case VendorSpecific: + /* + * Vendor Defined Resource + */ + /* + * For a Vendor Specific resource, if the Length is + * between 1 and 7 it will be created as a Small + * Resource data type, otherwise it is a Large + * Resource data type. + */ + if(LinkedList->Data.VendorSpecific.Length > 7) + { + SegmentSize = 3; + } + else + { + SegmentSize = 1; + } + SegmentSize += + LinkedList->Data.VendorSpecific.Length; + break; + + case EndTag: + /* + * End Tag + */ + /* + * For this resource the size is static + */ + SegmentSize = 2; + Done = TRUE; + break; + + case Memory24: + /* + * 24-Bit Memory Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 12; + break; + + case Memory32: + /* + * 32-Bit Memory Range Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 20; + break; + + case FixedMemory32: + /* + * 32-Bit Fixed Memory Resource + */ + /* + * For this resource the size is static + */ + SegmentSize = 12; + break; + + case Address16: + /* + * 16-Bit Address Resource + */ + /* + * The base size of this byte stream is 16. If a + * Resource Source string is not NULL, add 1 for + * the Index + the length of the null terminated + * string Resource Source + 1 for the null. + */ + SegmentSize = 16; + + if(NULL != LinkedList->Data.Address16.ResourceSource) + { + SegmentSize += (1 + + LinkedList->Data.Address16.ResourceSourceStringLength); + } + break; + + case Address32: + /* + * 32-Bit Address Resource + */ + /* + * The base size of this byte stream is 26. If a Resource + * Source string is not NULL, add 1 for the Index + the + * length of the null terminated string Resource Source + + * 1 for the null. + */ + SegmentSize = 26; + + if(NULL != LinkedList->Data.Address16.ResourceSource) + { + SegmentSize += (1 + + LinkedList->Data.Address16.ResourceSourceStringLength); + } + break; + + case ExtendedIrq: + /* + * Extended IRQ Resource + */ + /* + * The base size of this byte stream is 9. This is for an + * Interrupt table length of 1. For each additional + * interrupt, add 4. + * If a Resource Source string is not NULL, add 1 for the + * Index + the length of the null terminated string + * Resource Source + 1 for the null. + */ + SegmentSize = 9; + + SegmentSize += + (LinkedList->Data.ExtendedIrq.NumberOfInterrupts - + 1) * 4; + + if(NULL != ExIrq->ResourceSource) + { + SegmentSize += (1 + + LinkedList->Data.ExtendedIrq.ResourceSourceStringLength); + } + break; + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + + } /* switch (LinkedList->Id) */ + + /* + * Update the total + */ + ByteStreamSizeNeeded += SegmentSize; + + /* + * Point to the next object + */ + LinkedList = (RESOURCE *) ((NATIVE_UINT) LinkedList + + (NATIVE_UINT) LinkedList->Length); + } + + /* + * This is the data the caller needs + */ + *SizeNeeded = ByteStreamSizeNeeded; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCalculateListLength + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream + * ByteStreamBufferLength - Size of ByteStreamBuffer + * SizeNeeded - UINT32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource byte stream and parses it once, calculating + * the size buffer needed to hold the linked list that conveys + * the resource data. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCalculateListLength ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT32 *SizeNeeded) +{ + UINT32 BufferSize = 0; + UINT32 BytesParsed = 0; + UINT8 NumberOfInterrupts = 0; + UINT8 NumberOfChannels = 0; + UINT8 ResourceType; + UINT32 StructureSize; + UINT32 BytesConsumed; + UINT8 *Buffer; + UINT8 Temp8; + UINT16 Temp16; + UINT8 Index; + UINT8 AdditionalBytes; + + + FUNCTION_TRACE ("RsCalculateListLength"); + + + while (BytesParsed < ByteStreamBufferLength) + { + /* + * Look at the next byte in the stream + */ + ResourceType = *ByteStreamBuffer; + + /* + * See if this is a small or large resource + */ + if(ResourceType & 0x80) + { + /* + * Large Resource Type + */ + switch (ResourceType) + { + case MEMORY_RANGE_24: + /* + * 24-Bit Memory Resource + */ + BytesConsumed = 12; + + StructureSize = sizeof (MEMORY24_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + case LARGE_VENDOR_DEFINED: + /* + * Vendor Defined Resource + */ + Buffer = ByteStreamBuffer; + ++Buffer; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + BytesConsumed = Temp16 + 3; + + /* + * Ensure a 32-bit boundary for the structure + */ + Temp16 = (UINT16) ROUND_UP_TO_32BITS (Temp16); + + StructureSize = sizeof (VENDOR_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp16 * sizeof (UINT8)); + break; + + case MEMORY_RANGE_32: + /* + * 32-Bit Memory Range Resource + */ + + BytesConsumed = 20; + + StructureSize = sizeof (MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + case FIXED_MEMORY_RANGE_32: + /* + * 32-Bit Fixed Memory Resource + */ + BytesConsumed = 12; + + StructureSize = sizeof(FIXED_MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + case DWORD_ADDRESS_SPACE: + /* + * 32-Bit Address Resource + */ + Buffer = ByteStreamBuffer; + + ++Buffer; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + BytesConsumed = Temp16 + 3; + + /* + * Resource Source Index and Resource Source are + * optional elements. Check the length of the + * Bytestream. If it is greater than 23, that + * means that an Index exists and is followed by + * a null termininated string. Therefore, set + * the temp variable to the length minus the minimum + * byte stream length plus the byte for the Index to + * determine the size of the NULL terminiated string. + */ + if (23 < Temp16) + { + Temp8 = (UINT8) (Temp16 - 24); + } + else + { + Temp8 = 0; + } + + /* + * Ensure a 32-bit boundary for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + + StructureSize = sizeof (ADDRESS32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp8 * sizeof (UINT8)); + break; + + case WORD_ADDRESS_SPACE: + /* + * 16-Bit Address Resource + */ + Buffer = ByteStreamBuffer; + + ++Buffer; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + BytesConsumed = Temp16 + 3; + + /* + * Resource Source Index and Resource Source are + * optional elements. Check the length of the + * Bytestream. If it is greater than 13, that + * means that an Index exists and is followed by + * a null termininated string. Therefore, set + * the temp variable to the length minus the minimum + * byte stream length plus the byte for the Index to + * determine the size of the NULL terminiated string. + */ + if (13 < Temp16) + { + Temp8 = (UINT8) (Temp16 - 14); + } + else + { + Temp8 = 0; + } + + /* + * Ensure a 32-bit boundry for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + + StructureSize = sizeof (ADDRESS16_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp8 * sizeof (UINT8)); + break; + + case EXTENDED_IRQ: + /* + * Extended IRQ + */ + Buffer = ByteStreamBuffer; + + ++Buffer; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + BytesConsumed = Temp16 + 3; + + /* + * Point past the length field and the + * Interrupt vector flags to save off the + * Interrupt table length to the Temp8 variable. + */ + Buffer += 3; + Temp8 = *Buffer; + + /* + * To compensate for multiple interrupt numbers, + * Add 4 bytes for each additional interrupts + * greater than 1 + */ + AdditionalBytes = (UINT8) ((Temp8 - 1) * 4); + + /* + * Resource Source Index and Resource Source are + * optional elements. Check the length of the + * Bytestream. If it is greater than 9, that + * means that an Index exists and is followed by + * a null termininated string. Therefore, set + * the temp variable to the length minus the minimum + * byte stream length plus the byte for the Index to + * determine the size of the NULL terminiated string. + */ + if (9 + AdditionalBytes < Temp16) + { + Temp8 = (UINT8) (Temp16 - (9 + AdditionalBytes)); + } + + else + { + Temp8 = 0; + } + + /* + * Ensure a 32-bit boundry for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + + StructureSize = sizeof (EXTENDED_IRQ_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (AdditionalBytes * sizeof (UINT8)) + + (Temp8 * sizeof (UINT8)); + + break; + +/* TBD: [Future] 64-bit not currently supported */ +/* + case 0x8A: + break; +*/ + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + } + } + + else + { + /* + * Small Resource Type + * Only bits 7:3 are valid + */ + ResourceType >>= 3; + + switch (ResourceType) + { + case IRQ_FORMAT: + /* + * IRQ Resource + */ + /* + * Determine if it there are two or three + * trailing bytes + */ + Buffer = ByteStreamBuffer; + Temp8 = *Buffer; + + if(Temp8 & 0x01) + { + BytesConsumed = 4; + } + + else + { + BytesConsumed = 3; + } + + /* + * Point past the descriptor + */ + ++Buffer; + + /* + * Look at the number of bits set + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + for (Index = 0; Index < 16; Index++) + { + if (Temp16 & 0x1) + { + ++NumberOfInterrupts; + } + + Temp16 >>= 1; + } + + StructureSize = sizeof (IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (NumberOfInterrupts * sizeof (UINT32)); + break; + + + case DMA_FORMAT: + + /* + * DMA Resource + */ + Buffer = ByteStreamBuffer; + + BytesConsumed = 3; + + /* + * Point past the descriptor + */ + ++Buffer; + + /* + * Look at the number of bits set + */ + Temp8 = *Buffer; + + for(Index = 0; Index < 8; Index++) + { + if(Temp8 & 0x1) + { + ++NumberOfChannels; + } + + Temp8 >>= 1; + } + + StructureSize = sizeof (DMA_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (NumberOfChannels * sizeof (UINT32)); + break; + + + case START_DEPENDENT_TAG: + + /* + * Start Dependent Functions Resource + */ + /* + * Determine if it there are two or three trailing bytes + */ + Buffer = ByteStreamBuffer; + Temp8 = *Buffer; + + if(Temp8 & 0x01) + { + BytesConsumed = 2; + } + else + { + BytesConsumed = 1; + } + + + StructureSize = + sizeof (START_DEPENDENT_FUNCTIONS_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + + case END_DEPENDENT_TAG: + + /* + * End Dependent Functions Resource + */ + BytesConsumed = 1; + StructureSize = RESOURCE_LENGTH; + break; + + + case IO_PORT_DESCRIPTOR: + /* + * IO Port Resource + */ + BytesConsumed = 8; + StructureSize = sizeof (IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + + case FIXED_LOCATION_IO_DESCRIPTOR: + + /* + * Fixed IO Port Resource + */ + BytesConsumed = 4; + StructureSize = sizeof (FIXED_IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + break; + + + case SMALL_VENDOR_DEFINED: + + /* + * Vendor Specific Resource + */ + Buffer = ByteStreamBuffer; + + Temp8 = *Buffer; + Temp8 = (UINT8) (Temp8 & 0x7); + BytesConsumed = Temp8 + 1; + + /* + * Ensure a 32-bit boundry for the structure + */ + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + StructureSize = sizeof (VENDOR_RESOURCE) + + RESOURCE_LENGTH_NO_DATA + + (Temp8 * sizeof (UINT8)); + break; + + + case END_TAG: + + /* + * End Tag + */ + BytesConsumed = 2; + StructureSize = RESOURCE_LENGTH; + break; + + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + + } /* switch */ + + } /* if(ResourceType & 0x80) */ + + /* + * Update the return value and counter + */ + BufferSize += StructureSize; + BytesParsed += BytesConsumed; + + /* + * Set the byte stream to point to the next resource + */ + ByteStreamBuffer += BytesConsumed; + + } + + /* + * This is the data the caller needs + */ + *SizeNeeded = BufferSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCalculatePciRoutingTableLength + * + * PARAMETERS: PackageObject - Pointer to the package object + * BufferSizeNeeded - UINT32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status AE_OK + * + * DESCRIPTION: Given a package representing a PCI routing table, this + * calculates the size of the corresponding linked list of + * descriptions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCalculatePciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + UINT32 *BufferSizeNeeded) +{ + UINT32 NumberOfElements; + UINT32 TempSizeNeeded; + ACPI_OPERAND_OBJECT **TopObjectList; + UINT32 Index; + ACPI_OPERAND_OBJECT *PackageElement; + ACPI_OPERAND_OBJECT **SubObjectList; + BOOLEAN NameFound; + UINT32 TableIndex; + + + FUNCTION_TRACE ("AcpiRsCalculatePciRoutingTableLength"); + + + 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. + * + * NOTE: The NumberOfElements is incremented by one to add an end + * table structure that is essentially a structure of zeros. + */ + TempSizeNeeded = (NumberOfElements + 1) * + (sizeof (PCI_ROUTING_TABLE) - 1); + + /* + * But each PRT_ENTRY structure has a pointer to a string and + * the size of that string must be found. + */ + TopObjectList = PackageObject->Package.Elements; + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* + * Dereference the sub-package + */ + PackageElement = *TopObjectList; + + /* + * The SubObjectList will now point to an array of the + * four IRQ elements: Address, Pin, Source and SourceIndex + */ + SubObjectList = PackageElement->Package.Elements; + + /* + * Scan the IrqTableElements for the Source Name String + */ + NameFound = FALSE; + + for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) + { + if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + { + NameFound = TRUE; + } + + else + { + /* + * Look at the next element + */ + SubObjectList++; + } + } + + /* + * Was a String type found? + */ + if (TRUE == NameFound) + { + /* + * The length String.Length field includes the + * terminating NULL + */ + TempSizeNeeded += (*SubObjectList)->String.Length; + } + + else + { + /* + * If no name was found, then this is a NULL, which is + * translated as a UINT32 zero. + */ + TempSizeNeeded += sizeof(UINT32); + } + + /* + * Point to the next ACPI_OPERAND_OBJECT + */ + TopObjectList++; + } + + /* Align the count before returning it */ + + *BufferSizeNeeded = ROUND_UP_TO_32BITS (TempSizeNeeded); + + return_ACPI_STATUS (AE_OK); +} \ No newline at end of file diff --git a/sys/contrib/dev/acpica/rscreate.c b/sys/contrib/dev/acpica/rscreate.c new file mode 100644 index 0000000..07f3f51 --- /dev/null +++ b/sys/contrib/dev/acpica/rscreate.c @@ -0,0 +1,548 @@ +/******************************************************************************* + * + * Module Name: rscreate - AcpiRsCreateResourceList + * AcpiRsCreatePciRoutingTable + * AcpiRsCreateByteStream + * $Revision: 19 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSCREATE_C__ + +#include "acpi.h" +#include "acresrc.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rscreate") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateResourceList + * + * PARAMETERS: + * ByteStreamBuffer - Pointer to the resource byte stream + * OutputBuffer - Pointer to the user's buffer + * OutputBufferLength - Pointer to the size of OutputBuffer + * + * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code + * If OutputBuffer is not large enough, OutputBufferLength + * indicates how large OutputBuffer should be, else it + * indicates how may UINT8 elements of OutputBuffer are valid. + * + * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method + * execution and parses the stream to create a linked list + * of device resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *ByteStreamBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength) +{ + + ACPI_STATUS Status; + UINT8 *ByteStreamStart = NULL; + UINT32 ListSizeNeeded = 0; + UINT32 ByteStreamBufferLength = 0; + + + FUNCTION_TRACE ("RsCreateResourceList"); + + + DEBUG_PRINT (VERBOSE_INFO, ("RsCreateResourceList: ByteStreamBuffer = %p\n", + ByteStreamBuffer)); + + /* + * Params already validated, so we don't re-validate here + */ + + ByteStreamBufferLength = ByteStreamBuffer->Buffer.Length; + ByteStreamStart = ByteStreamBuffer->Buffer.Pointer; + + /* + * Pass the ByteStreamBuffer into a module that can calculate + * the buffer size needed for the linked list + */ + Status = AcpiRsCalculateListLength (ByteStreamStart, + ByteStreamBufferLength, + &ListSizeNeeded); + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreateResourceList: Status=%d ListSizeNeeded=%d\n", + Status, ListSizeNeeded)); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * If the linked list will fit into the available buffer + * call to fill in the list + */ + + if (ListSizeNeeded <= *OutputBufferLength) + { + /* + * Zero out the return buffer before proceeding + */ + MEMSET (OutputBuffer, 0x00, *OutputBufferLength); + + Status = AcpiRsByteStreamToList (ByteStreamStart, + ByteStreamBufferLength, + &OutputBuffer); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (VERBOSE_INFO, ("RsByteStreamToList: OutputBuffer = %p\n", + OutputBuffer)); + } + + else + { + *OutputBufferLength = ListSizeNeeded; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + *OutputBufferLength = ListSizeNeeded; + return_ACPI_STATUS (AE_OK); + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreatePciRoutingTable + * + * PARAMETERS: + * PackageObject - Pointer to an ACPI_OPERAND_OBJECT + * package + * OutputBuffer - Pointer to the user's buffer + * OutputBufferLength - Size of OutputBuffer + * + * 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 OutputBufferLength will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a + * linked list of PCI interrupt descriptions + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength) +{ + UINT8 *Buffer = OutputBuffer; + ACPI_OPERAND_OBJECT **TopObjectList = NULL; + ACPI_OPERAND_OBJECT **SubObjectList = NULL; + ACPI_OPERAND_OBJECT *PackageElement = NULL; + UINT32 BufferSizeNeeded = 0; + UINT32 NumberOfElements = 0; + UINT32 Index = 0; + PCI_ROUTING_TABLE *UserPrt = NULL; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("RsCreatePciRoutingTable"); + + + /* + * Params already validated, so we don't re-validate here + */ + + Status = AcpiRsCalculatePciRoutingTableLength(PackageObject, + &BufferSizeNeeded); + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreatePciRoutingTable: BufferSizeNeeded = %d\n", + BufferSizeNeeded)); + + /* + * If the data will fit into the available buffer + * call to fill in the list + */ + if (BufferSizeNeeded <= *OutputBufferLength) + { + /* + * Zero out the return buffer before proceeding + */ + MEMSET (OutputBuffer, 0x00, *OutputBufferLength); + + /* + * Loop through the ACPI_INTERNAL_OBJECTS - Each object should + * contain a UINT32 Address, a UINT8 Pin, a Name and a UINT8 + * SourceIndex. + */ + TopObjectList = PackageObject->Package.Elements; + NumberOfElements = PackageObject->Package.Count; + UserPrt = (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; + Buffer = ROUND_PTR_UP_TO_4 (Buffer, UINT8); + UserPrt = (PCI_ROUTING_TABLE *) Buffer; + + /* + * Fill in the Length field with the information we + * have at this point. + * The minus one is to subtract the size of the + * UINT8 Source[1] member because it is added below. + */ + UserPrt->Length = (sizeof (PCI_ROUTING_TABLE) - 1); + + /* + * Dereference the sub-package + */ + PackageElement = *TopObjectList; + + /* + * The SubObjectList will now point to an array of + * the four IRQ elements: Address, Pin, Source and + * SourceIndex + */ + SubObjectList = PackageElement->Package.Elements; + + /* + * Dereference the Address + */ + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + UserPrt->Data.Address = + (*SubObjectList)->Number.Value; + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Dereference the Pin + */ + SubObjectList++; + + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + UserPrt->Data.Pin = + (UINT32) (*SubObjectList)->Number.Value; + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Dereference the Source Name + */ + SubObjectList++; + + if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) + { + STRCPY (UserPrt->Data.Source, + (*SubObjectList)->String.Pointer); + + /* + * Add to the Length field the length of the string + */ + UserPrt->Length += (*SubObjectList)->String.Length; + } + + else + { + /* + * If this is a number, then the Source Name + * is NULL, since the entire buffer was zeroed + * out, we can leave this alone. + */ + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + /* + * Add to the Length field the length of + * the UINT32 NULL + */ + UserPrt->Length += sizeof (UINT32); + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* Now align the current length */ + + UserPrt->Length = ROUND_UP_TO_32BITS (UserPrt->Length); + + /* + * Dereference the Source Index + */ + SubObjectList++; + + if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) + { + UserPrt->Data.SourceIndex = + (UINT32) (*SubObjectList)->Number.Value; + } + + else + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Point to the next ACPI_OPERAND_OBJECT + */ + TopObjectList++; + } + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreatePciRoutingTable: OutputBuffer = %p\n", + OutputBuffer)); + } + + else + { + *OutputBufferLength = BufferSizeNeeded; + + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + /* + * Report the amount of buffer used + */ + *OutputBufferLength = BufferSizeNeeded; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateByteStream + * + * PARAMETERS: + * LinkedListBuffer - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's buffer + * OutputBufferLength - Size of OutputBuffer + * + * 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 OutputBufferLength will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the linked list of device resources and + * creates a bytestream to be used as input for the + * _SRS control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateByteStream ( + RESOURCE *LinkedListBuffer, + UINT8 *OutputBuffer, + UINT32 *OutputBufferLength) +{ + ACPI_STATUS Status; + UINT32 ByteStreamSizeNeeded = 0; + + + FUNCTION_TRACE ("RsCreateByteStream"); + + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreateByteStream: LinkedListBuffer = %p\n", + LinkedListBuffer)); + + /* + * Params already validated, so we don't re-validate here + * + * Pass the LinkedListBuffer into a module that can calculate + * the buffer size needed for the byte stream. + */ + Status = AcpiRsCalculateByteStreamLength (LinkedListBuffer, + &ByteStreamSizeNeeded); + + DEBUG_PRINT (VERBOSE_INFO, + ("RsCreateByteStream: ByteStreamSizeNeeded=%d, %s\n", + ByteStreamSizeNeeded, + AcpiCmFormatException (Status))); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * If the linked list will fit into the available buffer + * call to fill in the list + */ + + if (ByteStreamSizeNeeded <= *OutputBufferLength) + { + /* + * Zero out the return buffer before proceeding + */ + MEMSET (OutputBuffer, 0x00, *OutputBufferLength); + + Status = AcpiRsListToByteStream (LinkedListBuffer, + ByteStreamSizeNeeded, + &OutputBuffer); + + /* + * Exit with the error passed back + */ + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + DEBUG_PRINT (VERBOSE_INFO, + ("RsListToByteStream: OutputBuffer = %p\n", + OutputBuffer)); + } + else + { + *OutputBufferLength = ByteStreamSizeNeeded; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/rsdump.c b/sys/contrib/dev/acpica/rsdump.c new file mode 100644 index 0000000..8df18fb --- /dev/null +++ b/sys/contrib/dev/acpica/rsdump.c @@ -0,0 +1,1044 @@ +/******************************************************************************* + * + * Module Name: rsdump - Functions do dump out the resource structures. + * $Revision: 11 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSDUMP_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsdump") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIrq + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpIrq ( + RESOURCE_DATA *Data) +{ + IRQ_RESOURCE *IrqData = (IRQ_RESOURCE*) Data; + UINT8 Index = 0; + + + AcpiOsPrintf ("\tIRQ Resource\n"); + + AcpiOsPrintf ("\t\t%s Triggered\n", + LEVEL_SENSITIVE == IrqData->EdgeLevel ? + "Level" : "Edge"); + + AcpiOsPrintf ("\t\tActive %s\n", + ACTIVE_LOW == IrqData->ActiveHighLow ? + "Low" : "High"); + + AcpiOsPrintf ("\t\t%s\n", + SHARED == IrqData->SharedExclusive ? + "Shared" : "Exclusive"); + + AcpiOsPrintf ("\t\t%d Interrupts ( ", + IrqData->NumberOfInterrupts); + + for (Index = 0; Index < IrqData->NumberOfInterrupts; Index++) + { + AcpiOsPrintf ("%d ", IrqData->Interrupts[Index]); + } + + AcpiOsPrintf (")\n"); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpDma + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpDma ( + RESOURCE_DATA *Data) +{ + DMA_RESOURCE *DmaData = (DMA_RESOURCE*) Data; + UINT8 Index = 0; + + + AcpiOsPrintf ("\tDMA Resource\n"); + + switch (DmaData->Type) + { + case COMPATIBILITY: + AcpiOsPrintf ("\t\tCompatibility mode\n"); + break; + + case TYPE_A: + AcpiOsPrintf ("\t\tType A\n"); + break; + + case TYPE_B: + AcpiOsPrintf ("\t\tType B\n"); + break; + + case TYPE_F: + AcpiOsPrintf ("\t\tType F\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid DMA type\n"); + break; + } + + AcpiOsPrintf ("\t\t%sBus Master\n", + BUS_MASTER == DmaData->BusMaster ? + "" : "Not a "); + + switch (DmaData->Transfer) + { + case TRANSFER_8: + AcpiOsPrintf ("\t\t8-bit only transfer\n"); + break; + + case TRANSFER_8_16: + AcpiOsPrintf ("\t\t8 and 16-bit transfer\n"); + break; + + case TRANSFER_16: + AcpiOsPrintf ("\t\t16 bit only transfer\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid transfer preference\n"); + break; + } + + AcpiOsPrintf ("\t\tNumber of Channels: %d ( ", + DmaData->NumberOfChannels); + + for (Index = 0; Index < DmaData->NumberOfChannels; Index++) + { + AcpiOsPrintf ("%d ", DmaData->Channels[Index]); + } + + AcpiOsPrintf (")\n"); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpStartDependentFunctions + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpStartDependentFunctions ( + RESOURCE_DATA *Data) +{ + START_DEPENDENT_FUNCTIONS_RESOURCE *SdfData = + (START_DEPENDENT_FUNCTIONS_RESOURCE*) Data; + + + AcpiOsPrintf ("\tStart Dependent Functions Resource\n"); + + switch (SdfData->CompatibilityPriority) + { + case GOOD_CONFIGURATION: + AcpiOsPrintf ("\t\tGood configuration\n"); + break; + + case ACCEPTABLE_CONFIGURATION: + AcpiOsPrintf ("\t\tAcceptable configuration\n"); + break; + + case SUB_OPTIMAL_CONFIGURATION: + AcpiOsPrintf ("\t\tSub-optimal configuration\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid compatibility priority\n"); + break; + } + + switch(SdfData->PerformanceRobustness) + { + case GOOD_CONFIGURATION: + AcpiOsPrintf ("\t\tGood configuration\n"); + break; + + case ACCEPTABLE_CONFIGURATION: + AcpiOsPrintf ("\t\tAcceptable configuration\n"); + break; + + case SUB_OPTIMAL_CONFIGURATION: + AcpiOsPrintf ("\t\tSub-optimal configuration\n"); + break; + + default: + AcpiOsPrintf ("\t\tInvalid performance " + "robustness preference\n"); + break; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIo + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpIo ( + RESOURCE_DATA *Data) +{ + IO_RESOURCE *IoData = (IO_RESOURCE*) Data; + + + AcpiOsPrintf ("\tIo Resource\n"); + + AcpiOsPrintf ("\t\t%d bit decode\n", + DECODE_16 == IoData->IoDecode ? 16 : 10); + + AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n", + IoData->MinBaseAddress); + + AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n", + IoData->MaxBaseAddress); + + AcpiOsPrintf ("\t\tAlignment: 0x%08x\n", + IoData->Alignment); + + AcpiOsPrintf ("\t\tRange Length: 0x%08x\n", + IoData->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpFixedIo + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpFixedIo ( + RESOURCE_DATA *Data) +{ + FIXED_IO_RESOURCE *FixedIoData = (FIXED_IO_RESOURCE*) Data; + + + AcpiOsPrintf ("\tFixed Io Resource\n"); + AcpiOsPrintf ("\t\tRange base address: 0x%08x", + FixedIoData->BaseAddress); + + AcpiOsPrintf ("\t\tRange length: 0x%08x", + FixedIoData->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpVendorSpecific + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpVendorSpecific ( + RESOURCE_DATA *Data) +{ + VENDOR_RESOURCE *VendorData = (VENDOR_RESOURCE*) Data; + UINT16 Index = 0; + + + AcpiOsPrintf ("\tVendor Specific Resource\n"); + + AcpiOsPrintf ("\t\tLength: 0x%08x\n", VendorData->Length); + + for (Index = 0; Index < VendorData->Length; Index++) + { + AcpiOsPrintf ("\t\tByte %d: 0x%08x\n", + Index, VendorData->Reserved[Index]); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpMemory24 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpMemory24 ( + RESOURCE_DATA *Data) +{ + MEMORY24_RESOURCE *Memory24Data = (MEMORY24_RESOURCE*) Data; + + + AcpiOsPrintf ("\t24-Bit Memory Range Resource\n"); + + AcpiOsPrintf ("\t\tRead%s\n", + READ_WRITE_MEMORY == + Memory24Data->ReadWriteAttribute ? + "/Write" : " only"); + + AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n", + Memory24Data->MinBaseAddress); + + AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n", + Memory24Data->MaxBaseAddress); + + AcpiOsPrintf ("\t\tAlignment: 0x%08x\n", + Memory24Data->Alignment); + + AcpiOsPrintf ("\t\tRange length: 0x%08x\n", + Memory24Data->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpMemory32 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpMemory32 ( + RESOURCE_DATA *Data) +{ + MEMORY32_RESOURCE *Memory32Data = (MEMORY32_RESOURCE*) Data; + + + AcpiOsPrintf ("\t32-Bit Memory Range Resource\n"); + + AcpiOsPrintf ("\t\tRead%s\n", + READ_WRITE_MEMORY == + Memory32Data->ReadWriteAttribute ? + "/Write" : " only"); + + AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n", + Memory32Data->MinBaseAddress); + + AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n", + Memory32Data->MaxBaseAddress); + + AcpiOsPrintf ("\t\tAlignment: 0x%08x\n", + Memory32Data->Alignment); + + AcpiOsPrintf ("\t\tRange length: 0x%08x\n", + Memory32Data->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpFixedMemory32 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpFixedMemory32 ( + RESOURCE_DATA *Data) +{ + FIXED_MEMORY32_RESOURCE *FixedMemory32Data = (FIXED_MEMORY32_RESOURCE*) Data; + + + AcpiOsPrintf ("\t32-Bit Fixed Location Memory Range Resource\n"); + + AcpiOsPrintf ("\t\tRead%s\n", + READ_WRITE_MEMORY == + FixedMemory32Data->ReadWriteAttribute ? + "/Write" : " Only"); + + AcpiOsPrintf ("\t\tRange base address: 0x%08x\n", + FixedMemory32Data->RangeBaseAddress); + + AcpiOsPrintf ("\t\tRange length: 0x%08x\n", + FixedMemory32Data->RangeLength); + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpAddress16 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpAddress16 ( + RESOURCE_DATA *Data) +{ + ADDRESS16_RESOURCE *Address16Data = (ADDRESS16_RESOURCE*) Data; + + + AcpiOsPrintf ("\t16-Bit Address Space Resource\n"); + AcpiOsPrintf ("\t\tResource Type: "); + + switch (Address16Data->ResourceType) + { + case MEMORY_RANGE: + + AcpiOsPrintf ("Memory Range\n"); + + switch (Address16Data->Attribute.Memory.CacheAttribute) + { + case NON_CACHEABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Noncacheable memory\n"); + break; + + case CACHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Cacheable memory\n"); + break; + + case WRITE_COMBINING_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Write-combining memory\n"); + break; + + case PREFETCHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Prefetchable memory\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid cache attribute\n"); + break; + } + + AcpiOsPrintf ("\t\tType Specific: Read%s\n", + READ_WRITE_MEMORY == + Address16Data->Attribute.Memory.ReadWriteAttribute ? + "/Write" : " Only"); + break; + + case IO_RANGE: + + AcpiOsPrintf ("I/O Range\n"); + + switch (Address16Data->Attribute.Io.RangeAttribute) + { + case NON_ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "Non-ISA Io Addresses\n"); + break; + + case ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "ISA Io Addresses\n"); + break; + + case ENTIRE_RANGE: + AcpiOsPrintf ("\t\tType Specific: " + "ISA and non-ISA Io Addresses\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid range attribute\n"); + break; + } + break; + + case BUS_NUMBER_RANGE: + + AcpiOsPrintf ("Bus Number Range\n"); + break; + + default: + + AcpiOsPrintf ("Invalid resource type. Exiting.\n"); + return; + } + + AcpiOsPrintf ("\t\tResource %s\n", + CONSUMER == Address16Data->ProducerConsumer ? + "Consumer" : "Producer"); + + AcpiOsPrintf ("\t\t%s decode\n", + SUB_DECODE == Address16Data->Decode ? + "Subtractive" : "Positive"); + + AcpiOsPrintf ("\t\tMin address is %s fixed\n", + ADDRESS_FIXED == Address16Data->MinAddressFixed ? + "" : "not"); + + AcpiOsPrintf ("\t\tMax address is %s fixed\n", + ADDRESS_FIXED == Address16Data->MaxAddressFixed ? + "" : "not"); + + AcpiOsPrintf ("\t\tGranularity: 0x%08x\n", + Address16Data->Granularity); + + AcpiOsPrintf ("\t\tAddress range min: 0x%08x\n", + Address16Data->MinAddressRange); + + AcpiOsPrintf ("\t\tAddress range max: 0x%08x\n", + Address16Data->MaxAddressRange); + + AcpiOsPrintf ("\t\tAddress translation offset: 0x%08x\n", + Address16Data->AddressTranslationOffset); + + AcpiOsPrintf ("\t\tAddress Length: 0x%08x\n", + Address16Data->AddressLength); + + if (0xFF != Address16Data->ResourceSourceIndex) + { + AcpiOsPrintf ("\t\tResource Source Index: %d\n", + Address16Data->ResourceSourceIndex); + AcpiOsPrintf ("\t\tResource Source: %s\n", + Address16Data->ResourceSource); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpAddress32 + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpAddress32 ( + RESOURCE_DATA *Data) +{ + ADDRESS32_RESOURCE *Address32Data = (ADDRESS32_RESOURCE*) Data; + + + AcpiOsPrintf ("\t32-Bit Address Space Resource\n"); + + switch (Address32Data->ResourceType) + { + case MEMORY_RANGE: + + AcpiOsPrintf ("\t\tResource Type: Memory Range\n"); + + switch (Address32Data->Attribute.Memory.CacheAttribute) + { + case NON_CACHEABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Noncacheable memory\n"); + break; + + case CACHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Cacheable memory\n"); + break; + + case WRITE_COMBINING_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Write-combining memory\n"); + break; + + case PREFETCHABLE_MEMORY: + AcpiOsPrintf ("\t\tType Specific: " + "Prefetchable memory\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid cache attribute\n"); + break; + } + + AcpiOsPrintf ("\t\tType Specific: Read%s\n", + READ_WRITE_MEMORY == + Address32Data->Attribute.Memory.ReadWriteAttribute ? + "/Write" : " Only"); + break; + + case IO_RANGE: + + AcpiOsPrintf ("\t\tResource Type: Io Range\n"); + + switch (Address32Data->Attribute.Io.RangeAttribute) + { + case NON_ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "Non-ISA Io Addresses\n"); + break; + + case ISA_ONLY_RANGES: + AcpiOsPrintf ("\t\tType Specific: " + "ISA Io Addresses\n"); + break; + + case ENTIRE_RANGE: + AcpiOsPrintf ("\t\tType Specific: " + "ISA and non-ISA Io Addresses\n"); + break; + + default: + AcpiOsPrintf ("\t\tType Specific: " + "Invalid Range attribute"); + break; + } + break; + + case BUS_NUMBER_RANGE: + + AcpiOsPrintf ("\t\tResource Type: Bus Number Range\n"); + break; + + default: + + AcpiOsPrintf ("\t\tInvalid Resource Type..exiting.\n"); + return; + } + + AcpiOsPrintf ("\t\tResource %s\n", + CONSUMER == Address32Data->ProducerConsumer ? + "Consumer" : "Producer"); + + AcpiOsPrintf ("\t\t%s decode\n", + SUB_DECODE == Address32Data->Decode ? + "Subtractive" : "Positive"); + + AcpiOsPrintf ("\t\tMin address is %s fixed\n", + ADDRESS_FIXED == Address32Data->MinAddressFixed ? + "" : "not "); + + AcpiOsPrintf ("\t\tMax address is %s fixed\n", + ADDRESS_FIXED == Address32Data->MaxAddressFixed ? + "" : "not "); + + AcpiOsPrintf ("\t\tGranularity: 0x%08x\n", + Address32Data->Granularity); + + AcpiOsPrintf ("\t\tAddress range min: 0x%08x\n", + Address32Data->MinAddressRange); + + AcpiOsPrintf ("\t\tAddress range max: 0x%08x\n", + Address32Data->MaxAddressRange); + + AcpiOsPrintf ("\t\tAddress translation offset: 0x%08x\n", + Address32Data->AddressTranslationOffset); + + AcpiOsPrintf ("\t\tAddress Length: 0x%08x\n", + Address32Data->AddressLength); + + if(0xFF != Address32Data->ResourceSourceIndex) + { + AcpiOsPrintf ("\t\tResource Source Index: %d\n", + Address32Data->ResourceSourceIndex); + AcpiOsPrintf ("\t\tResource Source: %s\n", + Address32Data->ResourceSource); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpExtendedIrq + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Prints out the various members of the Data structure type. + * + ******************************************************************************/ + +void +AcpiRsDumpExtendedIrq ( + RESOURCE_DATA *Data) +{ + EXTENDED_IRQ_RESOURCE *ExtIrqData = (EXTENDED_IRQ_RESOURCE*) Data; + UINT8 Index = 0; + + + AcpiOsPrintf ("\tExtended IRQ Resource\n"); + + AcpiOsPrintf ("\t\tResource %s\n", + CONSUMER == ExtIrqData->ProducerConsumer ? + "Consumer" : "Producer"); + + AcpiOsPrintf ("\t\t%s\n", + LEVEL_SENSITIVE == ExtIrqData->EdgeLevel ? + "Level" : "Edge"); + + AcpiOsPrintf ("\t\tActive %s\n", + ACTIVE_LOW == ExtIrqData->ActiveHighLow ? + "low" : "high"); + + AcpiOsPrintf ("\t\t%s\n", + SHARED == ExtIrqData->SharedExclusive ? + "Shared" : "Exclusive"); + + AcpiOsPrintf ("\t\tInterrupts : %d ( ", + ExtIrqData->NumberOfInterrupts); + + for (Index = 0; Index < ExtIrqData->NumberOfInterrupts; Index++) + { + AcpiOsPrintf ("%d ", ExtIrqData->Interrupts[Index]); + } + + AcpiOsPrintf (")\n"); + + if(0xFF != ExtIrqData->ResourceSourceIndex) + { + AcpiOsPrintf ("\t\tResource Source Index: %d", + ExtIrqData->ResourceSourceIndex); + AcpiOsPrintf ("\t\tResource Source: %s", + ExtIrqData->ResourceSource); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceList + * + * PARAMETERS: Data - pointer to the resource structure to dump. + * + * RETURN: + * + * DESCRIPTION: Dispatches the structure to the correct dump routine. + * + ******************************************************************************/ + +void +AcpiRsDumpResourceList ( + RESOURCE *Resource) +{ + UINT8 Count = 0; + BOOLEAN Done = FALSE; + + + if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer) + { + while (!Done) + { + AcpiOsPrintf ("\tResource structure %x.\n", Count++); + + switch (Resource->Id) + { + case Irq: + AcpiRsDumpIrq (&Resource->Data); + break; + + case Dma: + AcpiRsDumpDma (&Resource->Data); + break; + + case StartDependentFunctions: + AcpiRsDumpStartDependentFunctions (&Resource->Data); + break; + + case EndDependentFunctions: + AcpiOsPrintf ("\tEndDependentFunctions Resource\n"); + /* AcpiRsDumpEndDependentFunctions (Resource->Data);*/ + break; + + case Io: + AcpiRsDumpIo (&Resource->Data); + break; + + case FixedIo: + AcpiRsDumpFixedIo (&Resource->Data); + break; + + case VendorSpecific: + AcpiRsDumpVendorSpecific (&Resource->Data); + break; + + case EndTag: + /*RsDumpEndTag (Resource->Data);*/ + AcpiOsPrintf ("\tEndTag Resource\n"); + Done = TRUE; + break; + + case Memory24: + AcpiRsDumpMemory24 (&Resource->Data); + break; + + case Memory32: + AcpiRsDumpMemory32 (&Resource->Data); + break; + + case FixedMemory32: + AcpiRsDumpFixedMemory32 (&Resource->Data); + break; + + case Address16: + AcpiRsDumpAddress16 (&Resource->Data); + break; + + case Address32: + AcpiRsDumpAddress32 (&Resource->Data); + break; + + case ExtendedIrq: + AcpiRsDumpExtendedIrq (&Resource->Data); + break; + + default: + AcpiOsPrintf ("Invalid resource type\n"); + break; + + } + + Resource = (RESOURCE *) ((NATIVE_UINT) Resource + + (NATIVE_UINT) Resource->Length); + } + } + + return; +} + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIrqList + * + * PARAMETERS: Data - pointer to the routing table to dump. + * + * RETURN: + * + * DESCRIPTION: Dispatches the structures to the correct dump routine. + * + ******************************************************************************/ + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable) +{ + UINT8 *Buffer = RouteTable; + UINT8 Count = 0; + BOOLEAN Done = FALSE; + PCI_ROUTING_TABLE *PrtElement; + + + if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer) + { + PrtElement = (PCI_ROUTING_TABLE *)Buffer; + + while (!Done) + { + AcpiOsPrintf ("\tPCI IRQ Routing Table structure %x.\n", Count++); + + AcpiOsPrintf ("\t\tAddress: 0x%x\n", + PrtElement->Data.Address); + + AcpiOsPrintf ("\t\tPin: 0x%x\n", PrtElement->Data.Pin); + + AcpiOsPrintf ("\t\tSource: %s\n", PrtElement->Data.Source); + + AcpiOsPrintf ("\t\tSourceIndex: 0x%x\n", + PrtElement->Data.SourceIndex); + + Buffer += PrtElement->Length; + + PrtElement = (PCI_ROUTING_TABLE *)Buffer; + + if(0 == PrtElement->Length) + { + Done = TRUE; + } + } + } + + return; +} + diff --git a/sys/contrib/dev/acpica/rsio.c b/sys/contrib/dev/acpica/rsio.c new file mode 100644 index 0000000..0895fcf --- /dev/null +++ b/sys/contrib/dev/acpica/rsio.c @@ -0,0 +1,636 @@ +/******************************************************************************* + * + * Module Name: rsio - AcpiRsIoResource + * AcpiRsFixedIoResource + * AcpiRsIoStream + * AcpiRsFixedIoStream + * AcpiRsDmaResource + * AcpiRsDmaStream + * $Revision: 9 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIO_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsio") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIoResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsIoResource"); + + /* + * The number of bytes consumed are Constant + */ + *BytesConsumed = 8; + + OutputStruct->Id = Io; + + /* + * Check Decode + */ + Buffer += 1; + Temp8 = *Buffer; + + OutputStruct->Data.Io.IoDecode = Temp8 & 0x01; + + /* + * Check MinBase Address + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.Io.MinBaseAddress = Temp16; + + /* + * Check MaxBase Address + */ + Buffer += 2; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.Io.MaxBaseAddress = Temp16; + + /* + * Check Base alignment + */ + Buffer += 2; + Temp8 = *Buffer; + + OutputStruct->Data.Io.Alignment = Temp8; + + /* + * Check RangeLength + */ + Buffer += 1; + Temp8 = *Buffer; + + OutputStruct->Data.Io.RangeLength = Temp8; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedIoResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedIoResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (FIXED_IO_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsFixedIoResource"); + + /* + * The number of bytes consumed are Constant + */ + *BytesConsumed = 4; + + OutputStruct->Id = FixedIo; + + /* + * Check Range Base Address + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.FixedIo.BaseAddress = Temp16; + + /* + * Check RangeLength + */ + Buffer += 2; + Temp8 = *Buffer; + + OutputStruct->Data.FixedIo.RangeLength = Temp8; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIoStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsIoStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x47; + Buffer += 1; + + /* + * Io Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01); + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range minimum base address + */ + Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Range maximum base address + */ + Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the base alignment + */ + Temp8 = (UINT8) LinkedList->Data.Io.Alignment; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the range length + */ + Temp8 = (UINT8) LinkedList->Data.Io.RangeLength; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedIoStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedIoStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsFixedIoStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x4B; + + Buffer += 1; + + /* + * Set the Range base address + */ + Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the range length + */ + Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDmaResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsDmaResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT8 Temp8 = 0; + UINT8 Index; + UINT8 i; + UINT32 StructSize = sizeof(DMA_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsDmaResource"); + + /* + * The number of bytes consumed are Constant + */ + *BytesConsumed = 3; + OutputStruct->Id = Dma; + + /* + * Point to the 8-bits of Byte 1 + */ + Buffer += 1; + Temp8 = *Buffer; + + /* Decode the IRQ bits */ + + for (i = 0, Index = 0; Index < 8; Index++) + { + if ((Temp8 >> Index) & 0x01) + { + OutputStruct->Data.Dma.Channels[i] = Index; + i++; + } + } + OutputStruct->Data.Dma.NumberOfChannels = i; + + + /* + * Calculate the structure size based upon the number of interrupts + */ + StructSize += (OutputStruct->Data.Dma.NumberOfChannels - 1) * 4; + + /* + * Point to Byte 2 + */ + Buffer += 1; + Temp8 = *Buffer; + + /* + * Check for transfer preference (Bits[1:0]) + */ + OutputStruct->Data.Dma.Transfer = Temp8 & 0x03; + + if (0x03 == OutputStruct->Data.Dma.Transfer) + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* + * Get bus master preference (Bit[2]) + */ + OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01; + + /* + * Get channel speed support (Bits[6:5]) + */ + OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDmaStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsDmaStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + + + FUNCTION_TRACE ("RsDmaStream"); + + + /* + * The descriptor field is static + */ + *Buffer = 0x2A; + Buffer += 1; + Temp8 = 0; + + /* + * Loop through all of the Channels and set the mask bits + */ + for (Index = 0; + Index < LinkedList->Data.Dma.NumberOfChannels; + Index++) + { + Temp16 = (UINT16) LinkedList->Data.Dma.Channels[Index]; + Temp8 |= 0x1 << Temp16; + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the DMA Info + */ + Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5); + Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2); + Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03); + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/rsirq.c b/sys/contrib/dev/acpica/rsirq.c new file mode 100644 index 0000000..7f16c4d --- /dev/null +++ b/sys/contrib/dev/acpica/rsirq.c @@ -0,0 +1,683 @@ +/******************************************************************************* + * + * Module Name: rsirq - AcpiRsIrqResource, + * AcpiRsIrqStream + * AcpiRsExtendedIrqResource + * AcpiRsExtendedIrqStream + * $Revision: 10 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIRQ_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsirq") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIrqResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + UINT8 i; + UINT32 StructSize = sizeof (IRQ_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsIrqResource"); + + /* + * The number of bytes consumed are contained in the descriptor + * (Bits:0-1) + */ + Temp8 = *Buffer; + *BytesConsumed = (Temp8 & 0x03) + 1; + OutputStruct->Id = Irq; + + /* + * Point to the 16-bits of Bytes 1 and 2 + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + OutputStruct->Data.Irq.NumberOfInterrupts = 0; + + /* Decode the IRQ bits */ + + for (i = 0, Index = 0; Index < 16; Index++) + { + if((Temp16 >> Index) & 0x01) + { + OutputStruct->Data.Irq.Interrupts[i] = Index; + i++; + } + } + OutputStruct->Data.Irq.NumberOfInterrupts = i; + + /* + * Calculate the structure size based upon the number of interrupts + */ + StructSize += (OutputStruct->Data.Irq.NumberOfInterrupts - 1) * 4; + + /* + * Point to Byte 3 if it is used + */ + if (4 == *BytesConsumed) + { + Buffer += 2; + Temp8 = *Buffer; + + /* + * Check for HE, LL or HL + */ + if (Temp8 & 0x01) + { + OutputStruct->Data.Irq.EdgeLevel = EDGE_SENSITIVE; + OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_HIGH; + } + + else + { + if (Temp8 & 0x8) + { + OutputStruct->Data.Irq.EdgeLevel = LEVEL_SENSITIVE; + OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_LOW; + } + + else + { + /* + * Only _LL and _HE polarity/trigger interrupts + * are allowed (ACPI spec v1.0b ection 6.4.2.1), + * so an error will occur if we reach this point + */ + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* + * Check for sharable + */ + OutputStruct->Data.Irq.SharedExclusive = (Temp8 >> 3) & 0x01; + } + + else + { + /* + * Assume Edge Sensitive, Active High, Non-Sharable + * per ACPI Specification + */ + OutputStruct->Data.Irq.EdgeLevel = EDGE_SENSITIVE; + OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_HIGH; + OutputStruct->Data.Irq.SharedExclusive = EXCLUSIVE; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsIrqStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + BOOLEAN IRQInfoByteNeeded; + + + FUNCTION_TRACE ("RsIrqStream"); + + + /* + * The descriptor field is set based upon whether a third byte is + * needed to contain the IRQ Information. + */ + if (EDGE_SENSITIVE == LinkedList->Data.Irq.EdgeLevel && + ACTIVE_HIGH == LinkedList->Data.Irq.ActiveHighLow && + EXCLUSIVE == LinkedList->Data.Irq.SharedExclusive) + { + *Buffer = 0x22; + IRQInfoByteNeeded = FALSE; + } + else + { + *Buffer = 0x23; + IRQInfoByteNeeded = TRUE; + } + + Buffer += 1; + Temp16 = 0; + + /* + * Loop through all of the interrupts and set the mask bits + */ + for(Index = 0; + Index < LinkedList->Data.Irq.NumberOfInterrupts; + Index++) + { + Temp8 = (UINT8) LinkedList->Data.Irq.Interrupts[Index]; + Temp16 |= 0x1 << Temp8; + } + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the IRQ Info byte if needed. + */ + if (IRQInfoByteNeeded) + { + Temp8 = 0; + Temp8 = (UINT8) ((LinkedList->Data.Irq.SharedExclusive & + 0x01) << 4); + + if (LEVEL_SENSITIVE == LinkedList->Data.Irq.EdgeLevel && + ACTIVE_LOW == LinkedList->Data.Irq.ActiveHighLow) + { + Temp8 |= 0x08; + } + + else + { + Temp8 |= 0x01; + } + + *Buffer = Temp8; + Buffer += 1; + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsExtendedIrqResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsExtendedIrqResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + UINT32 StructSize = sizeof (EXTENDED_IRQ_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsExtendedIrqResource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + *BytesConsumed = Temp16 + 3; + OutputStruct->Id = ExtendedIrq; + + /* + * Point to the Byte3 + */ + Buffer += 2; + Temp8 = *Buffer; + + OutputStruct->Data.ExtendedIrq.ProducerConsumer = Temp8 & 0x01; + + /* + * Check for HE, LL or HL + */ + if(Temp8 & 0x02) + { + OutputStruct->Data.ExtendedIrq.EdgeLevel = EDGE_SENSITIVE; + OutputStruct->Data.ExtendedIrq.ActiveHighLow = ACTIVE_HIGH; + } + + else + { + if(Temp8 & 0x4) + { + OutputStruct->Data.ExtendedIrq.EdgeLevel = LEVEL_SENSITIVE; + OutputStruct->Data.ExtendedIrq.ActiveHighLow = ACTIVE_LOW; + } + + else + { + /* + * Only _LL and _HE polarity/trigger interrupts + * are allowed (ACPI spec v1.0b ection 6.4.2.1), + * so an error will occur if we reach this point + */ + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* + * Check for sharable + */ + OutputStruct->Data.ExtendedIrq.SharedExclusive = + (Temp8 >> 3) & 0x01; + + /* + * Point to Byte4 (IRQ Table length) + */ + Buffer += 1; + Temp8 = *Buffer; + + OutputStruct->Data.ExtendedIrq.NumberOfInterrupts = Temp8; + + /* + * Add any additional structure size to properly calculate + * the next pointer at the end of this function + */ + StructSize += (Temp8 - 1) * 4; + + /* + * Point to Byte5 (First IRQ Number) + */ + Buffer += 1; + + /* + * Cycle through every IRQ in the table + */ + for (Index = 0; Index < Temp8; Index++) + { + OutputStruct->Data.ExtendedIrq.Interrupts[Index] = + (UINT32)*Buffer; + + /* Point to the next IRQ */ + + Buffer += 4; + } + + /* + * This will leave us pointing to the Resource Source Index + * If it is present, then save it off and calculate the + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. + */ + if (*BytesConsumed > + (UINT32)(OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * + 4) + 5) + { + /* Dereference the Index */ + + Temp8 = *Buffer; + OutputStruct->Data.ExtendedIrq.ResourceSourceIndex = + (UINT32)Temp8; + + /* Point to the String */ + + Buffer += 1; + + /* Copy the string into the buffer */ + + Index = 0; + + while (0x00 != *Buffer) + { + OutputStruct->Data.ExtendedIrq.ResourceSource[Index] = + *Buffer; + + Buffer += 1; + Index += 1; + } + + /* + * Add the terminating null + */ + OutputStruct->Data.ExtendedIrq.ResourceSource[Index] = 0x00; + OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength = + Index + 1; + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundry. + */ + Temp8 = (UINT8) (Index + 1); + Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + } + + else + { + OutputStruct->Data.ExtendedIrq.ResourceSourceIndex = 0x00; + OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength = 0; + OutputStruct->Data.ExtendedIrq.ResourceSource[0] = 0x00; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsExtendedIrqStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsExtendedIrqStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 *LengthField; + UINT8 Temp8 = 0; + UINT8 Index; + NATIVE_CHAR *TempPointer = NULL; + + + FUNCTION_TRACE ("RsExtendedIrqStream"); + + + /* + * The descriptor field is static + */ + *Buffer = 0x89; + Buffer += 1; + + /* + * Set a pointer to the Length field - to be filled in later + */ + + LengthField = (UINT16 *)Buffer; + Buffer += 2; + + /* + * Set the Interrupt vector flags + */ + Temp8 = (UINT8)(LinkedList->Data.ExtendedIrq.ProducerConsumer & 0x01); + + Temp8 |= ((LinkedList->Data.ExtendedIrq.SharedExclusive & 0x01) << 3); + + if (LEVEL_SENSITIVE == LinkedList->Data.ExtendedIrq.EdgeLevel && + ACTIVE_LOW == LinkedList->Data.ExtendedIrq.ActiveHighLow) + { + Temp8 |= 0x04; + } + else + { + Temp8 |= 0x02; + } + + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Interrupt table length + */ + Temp8 = (UINT8) LinkedList->Data.ExtendedIrq.NumberOfInterrupts; + + *Buffer = Temp8; + Buffer += 1; + + for (Index = 0; + Index < LinkedList->Data.ExtendedIrq.NumberOfInterrupts; + Index++) + { + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.ExtendedIrq.Interrupts[Index]); + Buffer += 4; + } + + /* + * Resource Source Index and Resource Source are optional + */ + if (0 != LinkedList->Data.ExtendedIrq.ResourceSourceStringLength) + { + *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSourceIndex; + Buffer += 1; + + TempPointer = (NATIVE_CHAR *) Buffer; + + /* + * Copy the string + */ + STRCPY (TempPointer, LinkedList->Data.ExtendedIrq.ResourceSource); + + /* + * Buffer needs to be set to the length of the sting + one for the + * terminating null + */ + Buffer += (STRLEN (LinkedList->Data.ExtendedIrq.ResourceSource) + 1); + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + /* + * Set the length field to the number of bytes consumed + * minus the header size (3 bytes) + */ + *LengthField = (UINT16) (*BytesConsumed - 3); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/rslist.c b/sys/contrib/dev/acpica/rslist.c new file mode 100644 index 0000000..463cee3 --- /dev/null +++ b/sys/contrib/dev/acpica/rslist.c @@ -0,0 +1,606 @@ +/******************************************************************************* + * + * Module Name: rslist - AcpiRsByteStreamToList + * AcpiListToByteStream + * $Revision: 8 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSLIST_C__ + +#include "acpi.h" +#include "acresrc.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rslist") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsByteStreamToList + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream + * ByteStreamBufferLength - Length of ByteStreamBuffer + * OutputBuffer - Pointer to the buffer that will + * contain the output structures + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource byte stream and parses it, creating a + * linked list of resources in the caller's output buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsByteStreamToList ( + UINT8 *ByteStreamBuffer, + UINT32 ByteStreamBufferLength, + UINT8 **OutputBuffer) +{ + ACPI_STATUS Status; + UINT32 BytesParsed = 0; + UINT8 ResourceType = 0; + UINT32 BytesConsumed = 0; + UINT8 **Buffer = OutputBuffer; + UINT32 StructureSize = 0; + BOOLEAN EndTagProcessed = FALSE; + + + FUNCTION_TRACE ("RsByteStreamToList"); + + + while (BytesParsed < ByteStreamBufferLength && + FALSE == EndTagProcessed) + { + /* + * Look at the next byte in the stream + */ + ResourceType = *ByteStreamBuffer; + + /* + * See if this is a small or large resource + */ + if(ResourceType & 0x80) + { + /* + * Large Resource Type + */ + switch (ResourceType) + { + case MEMORY_RANGE_24: + /* + * 24-Bit Memory Resource + */ + Status = AcpiRsMemory24Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case LARGE_VENDOR_DEFINED: + /* + * Vendor Defined Resource + */ + Status = AcpiRsVendorResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case MEMORY_RANGE_32: + /* + * 32-Bit Memory Range Resource + */ + Status = AcpiRsMemory32RangeResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case FIXED_MEMORY_RANGE_32: + /* + * 32-Bit Fixed Memory Resource + */ + Status = AcpiRsFixedMemory32Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case DWORD_ADDRESS_SPACE: + /* + * 32-Bit Address Resource + */ + Status = AcpiRsAddress32Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case WORD_ADDRESS_SPACE: + /* + * 16-Bit Address Resource + */ + Status = AcpiRsAddress16Resource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case EXTENDED_IRQ: + /* + * Extended IRQ + */ + Status = AcpiRsExtendedIrqResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + +/* TBD: [Future] 64-bit not currently supported */ +/* + case 0x8A: + break; +*/ + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + } + } + + else + { + /* + * Small Resource Type + * Only bits 7:3 are valid + */ + ResourceType >>= 3; + + switch(ResourceType) + { + case IRQ_FORMAT: + /* + * IRQ Resource + */ + Status = AcpiRsIrqResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case DMA_FORMAT: + /* + * DMA Resource + */ + Status = AcpiRsDmaResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case START_DEPENDENT_TAG: + /* + * Start Dependent Functions Resource + */ + Status = AcpiRsStartDependentFunctionsResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case END_DEPENDENT_TAG: + /* + * End Dependent Functions Resource + */ + Status = AcpiRsEndDependentFunctionsResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case IO_PORT_DESCRIPTOR: + /* + * IO Port Resource + */ + Status = AcpiRsIoResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case FIXED_LOCATION_IO_DESCRIPTOR: + /* + * Fixed IO Port Resource + */ + Status = AcpiRsFixedIoResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case SMALL_VENDOR_DEFINED: + /* + * Vendor Specific Resource + */ + Status = AcpiRsVendorResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + + break; + + case END_TAG: + /* + * End Tag + */ + Status = AcpiRsEndTagResource(ByteStreamBuffer, + &BytesConsumed, + Buffer, + &StructureSize); + EndTagProcessed = TRUE; + + break; + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_AML_ERROR); + break; + + } /* switch */ + } /* end else */ + + /* + * Update the return value and counter + */ + BytesParsed += BytesConsumed; + + /* + * Set the byte stream to point to the next resource + */ + ByteStreamBuffer += BytesConsumed; + + /* + * Set the Buffer to the next structure + */ + *Buffer += StructureSize; + + } /* end while */ + + /* + * Check the reason for exiting the while loop + */ + if (!(ByteStreamBufferLength == BytesParsed) || + (TRUE != EndTagProcessed)) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsListToByteStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * ByteSteamSizeNeeded - Calculated size of the byte stream + * needed from calling + * AcpiRsCalculateByteStreamLength() + * The size of the OutputBuffer is + * guaranteed to be >= + * ByteStreamSizeNeeded + * OutputBuffer - Pointer to the buffer that will + * contain the byte stream + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Takes the resource linked list and parses it, creating a + * byte stream of resources in the caller's output buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsListToByteStream ( + RESOURCE *LinkedList, + UINT32 ByteStreamSizeNeeded, + UINT8 **OutputBuffer) +{ + ACPI_STATUS Status; + UINT8 *Buffer = *OutputBuffer; + UINT32 BytesConsumed = 0; + BOOLEAN Done = FALSE; + + + FUNCTION_TRACE ("RsListToByteStream"); + + while (!Done) + { + switch (LinkedList->Id) + { + case Irq: + /* + * IRQ Resource + */ + Status = AcpiRsIrqStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Dma: + /* + * DMA Resource + */ + Status = AcpiRsDmaStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case StartDependentFunctions: + /* + * Start Dependent Functions Resource + */ + Status = AcpiRsStartDependentFunctionsStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case EndDependentFunctions: + /* + * End Dependent Functions Resource + */ + Status = AcpiRsEndDependentFunctionsStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Io: + /* + * IO Port Resource + */ + Status = AcpiRsIoStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case FixedIo: + /* + * Fixed IO Port Resource + */ + Status = AcpiRsFixedIoStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case VendorSpecific: + /* + * Vendor Defined Resource + */ + Status = AcpiRsVendorStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case EndTag: + /* + * End Tag + */ + Status = AcpiRsEndTagStream (LinkedList, + &Buffer, + &BytesConsumed); + + /* + * An End Tag indicates the end of the Resource Template + */ + Done = TRUE; + break; + + case Memory24: + /* + * 24-Bit Memory Resource + */ + Status = AcpiRsMemory24Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Memory32: + /* + * 32-Bit Memory Range Resource + */ + Status = AcpiRsMemory32RangeStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case FixedMemory32: + /* + * 32-Bit Fixed Memory Resource + */ + Status = AcpiRsFixedMemory32Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Address16: + /* + * 16-Bit Address Descriptor Resource + */ + Status = AcpiRsAddress16Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case Address32: + /* + * 32-Bit Address Descriptor Resource + */ + Status = AcpiRsAddress32Stream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + case ExtendedIrq: + /* + * Extended IRQ Resource + */ + Status = AcpiRsExtendedIrqStream (LinkedList, + &Buffer, + &BytesConsumed); + break; + + default: + /* + * If we get here, everything is out of sync, + * so exit with an error + */ + return_ACPI_STATUS (AE_BAD_DATA); + break; + + } /* switch (LinkedList->Id) */ + + /* + * Set the Buffer to point to the open byte + */ + Buffer += BytesConsumed; + + /* + * Point to the next object + */ + LinkedList = (RESOURCE *) ((NATIVE_UINT) LinkedList + + (NATIVE_UINT) LinkedList->Length); + } + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/rsmemory.c b/sys/contrib/dev/acpica/rsmemory.c new file mode 100644 index 0000000..bc1ab29 --- /dev/null +++ b/sys/contrib/dev/acpica/rsmemory.c @@ -0,0 +1,660 @@ +/******************************************************************************* + * + * Module Name: rsmem24 - AcpiRsMemory24Resource + * AcpiRsMemory24Stream + * AcpiRsMemory32RangeResource + * AcpiRsFixedMemory32Resource + * AcpiRsMemory32RangeStream + * AcpiRsFixedMemory32Stream + * $Revision: 9 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMEMORY_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsmemory") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory24Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory24Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (MEMORY24_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsMemory24Resource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + *BytesConsumed = Temp16 + 3; + OutputStruct->Id = Memory24; + + /* + * Check Byte 3 the Read/Write bit + */ + Temp8 = *Buffer; + Buffer += 1; + OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01; + + /* + * Get MinBaseAddress (Bytes 4-5) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + OutputStruct->Data.Memory24.MinBaseAddress = Temp16; + + /* + * Get MaxBaseAddress (Bytes 6-7) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + OutputStruct->Data.Memory24.MaxBaseAddress = Temp16; + + /* + * Get Alignment (Bytes 8-9) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + OutputStruct->Data.Memory24.Alignment = Temp16; + + /* + * Get RangeLength (Bytes 10-11) + */ + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + OutputStruct->Data.Memory24.RangeLength = Temp16; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory24Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory24Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsMemory24Stream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x81; + Buffer += 1; + + /* + * The length field is static + */ + Temp16 = 0x09; + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range minimum base address + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress); + Buffer += 2; + + /* + * Set the Range maximum base address + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress); + Buffer += 2; + + /* + * Set the base alignment + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment); + Buffer += 2; + + /* + * Set the range length + */ + MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength); + Buffer += 2; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory32RangeResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory32RangeResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsMemory32RangeResource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + Buffer += 2; + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = Memory32; + + /* + * Point to the place in the output buffer where the data portion will + * begin. + * 1. Set the RESOURCE_DATA * Data to point to it's own address, then + * 2. Set the pointer to the next address. + * + * NOTE: OutputStruct->Data is cast to UINT8, otherwise, this addition adds + * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8) + */ + + /* + * Check Byte 3 the Read/Write bit + */ + Temp8 = *Buffer; + Buffer += 1; + + OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01; + + /* + * Get MinBaseAddress (Bytes 4-7) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress, + Buffer); + Buffer += 4; + + /* + * Get MaxBaseAddress (Bytes 8-11) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress, + Buffer); + Buffer += 4; + + /* + * Get Alignment (Bytes 12-15) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer); + Buffer += 4; + + /* + * Get RangeLength (Bytes 16-19) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer); + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedMemory32Resource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedMemory32Resource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT32 StructSize = sizeof (FIXED_MEMORY32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsFixedMemory32Resource"); + + /* + * Point past the Descriptor to get the number of bytes consumed + */ + Buffer += 1; + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + Buffer += 2; + *BytesConsumed = Temp16 + 3; + + OutputStruct->Id = FixedMemory32; + + /* + * Check Byte 3 the Read/Write bit + */ + Temp8 = *Buffer; + Buffer += 1; + OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01; + + /* + * Get RangeBaseAddress (Bytes 4-7) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress, + Buffer); + Buffer += 4; + + /* + * Get RangeLength (Bytes 8-11) + */ + MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength, + Buffer); + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMemory32RangeStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsMemory32RangeStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsMemory32RangeStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x85; + Buffer += 1; + + /* + * The length field is static + */ + Temp16 = 0x11; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range minimum base address + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress); + Buffer += 4; + + /* + * Set the Range maximum base address + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress); + Buffer += 4; + + /* + * Set the base alignment + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment); + Buffer += 4; + + /* + * Set the range length + */ + MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength); + Buffer += 4; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsFixedMemory32Stream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsFixedMemory32Stream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsFixedMemory32Stream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x86; + Buffer += 1; + + /* + * The length field is static + */ + Temp16 = 0x09; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + + /* + * Set the Information Byte + */ + Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01); + *Buffer = Temp8; + Buffer += 1; + + /* + * Set the Range base address + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.FixedMemory32.RangeBaseAddress); + Buffer += 4; + + /* + * Set the range length + */ + MOVE_UNALIGNED32_TO_32 (Buffer, + &LinkedList->Data.FixedMemory32.RangeLength); + Buffer += 4; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/rsmisc.c b/sys/contrib/dev/acpica/rsmisc.c new file mode 100644 index 0000000..23170e6 --- /dev/null +++ b/sys/contrib/dev/acpica/rsmisc.c @@ -0,0 +1,725 @@ +/******************************************************************************* + * + * Module Name: rsmisc - AcpiRsEndTagResource + * AcpiRsEndTagStream + * AcpiRsVendorResource + * AcpiRsVendorStream + * AcpiRsStartDependentFunctionsResource + * AcpiRsEndDependentFunctionsResource + * AcpiRsStartDependentFunctionsStream + * AcpiRsEndDependentFunctionsStream + * $Revision: 9 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSMISC_C__ + +#include "acpi.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsmisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndTagResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndTagResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT32 StructSize = RESOURCE_LENGTH; + + + FUNCTION_TRACE ("RsEndTagResource"); + + /* + * The number of bytes consumed is static + */ + *BytesConsumed = 2; + + /* + * Fill out the structure + */ + OutputStruct->Id = EndTag; + + /* + * Set the Length parameter + */ + OutputStruct->Length = 0; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndTagStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndTagStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsEndTagStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x79; + Buffer += 1; + + /* + * Set the Checksum - zero means that the resource data is treated as if + * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) + */ + Temp8 = 0; + + *Buffer = Temp8; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsVendorResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsVendorResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + UINT32 StructSize = sizeof (VENDOR_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsVendorResource"); + + /* + * Dereference the Descriptor to find if this is a large or small item. + */ + Temp8 = *Buffer; + + if (Temp8 & 0x80) + { + /* + * Large Item + */ + /* Point to the length field */ + + Buffer += 1; + + /* Dereference */ + + MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); + + /* Calculate bytes consumed */ + + *BytesConsumed = Temp16 + 3; + + /* Point to the first vendor byte */ + + Buffer += 2; + } + + else + { + /* + * Small Item + */ + + /* Dereference the size */ + + Temp16 = (UINT8)(*Buffer & 0x07); + + /* Calculate bytes consumed */ + + *BytesConsumed = Temp16 + 1; + + /* Point to the first vendor byte */ + + Buffer += 1; + } + + OutputStruct->Id = VendorSpecific; + OutputStruct->Data.VendorSpecific.Length = Temp16; + + for (Index = 0; Index < Temp16; Index++) + { + OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer; + Buffer += 1; + } + + /* + * In order for the StructSize to fall on a 32-bit boundry, + * calculate the length of the vendor string and expand the + * StructSize to the next 32-bit boundry. + */ + StructSize += ROUND_UP_TO_32BITS (Temp16); + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsVendorStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsVendorStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT16 Temp16 = 0; + UINT8 Temp8 = 0; + UINT8 Index; + + + FUNCTION_TRACE ("RsVendorStream"); + + /* + * Dereference the length to find if this is a large or small item. + */ + + if(LinkedList->Data.VendorSpecific.Length > 7) + { + /* + * Large Item + */ + /* + * Set the descriptor field and length bytes + */ + *Buffer = 0x84; + Buffer += 1; + + Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length; + + MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16); + Buffer += 2; + } + + else + { + /* + * Small Item + */ + + /* + * Set the descriptor field + */ + Temp8 = 0x70; + Temp8 |= LinkedList->Data.VendorSpecific.Length; + + *Buffer = Temp8; + Buffer += 1; + } + + /* + * Loop through all of the Vendor Specific fields + */ + for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++) + { + Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index]; + + *Buffer = Temp8; + Buffer += 1; + } + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStartDependentFunctionsResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsStartDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + UINT8 *Buffer = ByteStreamBuffer; + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT8 Temp8 = 0; + UINT32 StructSize = + sizeof(START_DEPENDENT_FUNCTIONS_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + + + FUNCTION_TRACE ("RsStartDependentFunctionsResource"); + + /* + * The number of bytes consumed are contained in the descriptor (Bits:0-1) + */ + Temp8 = *Buffer; + + *BytesConsumed = (Temp8 & 0x01) + 1; + + OutputStruct->Id = StartDependentFunctions; + + /* + * Point to Byte 1 if it is used + */ + if (2 == *BytesConsumed) + { + Buffer += 1; + Temp8 = *Buffer; + + /* + * Check Compatibility priority + */ + OutputStruct->Data.StartDependentFunctions.CompatibilityPriority = + Temp8 & 0x03; + + if (3 == OutputStruct->Data.StartDependentFunctions.CompatibilityPriority) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + /* + * Check Performance/Robustness preference + */ + OutputStruct->Data.StartDependentFunctions.PerformanceRobustness = + (Temp8 >> 2) & 0x03; + + if (3 == OutputStruct->Data.StartDependentFunctions.PerformanceRobustness) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + } + + else + { + OutputStruct->Data.StartDependentFunctions.CompatibilityPriority = + ACCEPTABLE_CONFIGURATION; + + OutputStruct->Data.StartDependentFunctions.PerformanceRobustness = + ACCEPTABLE_CONFIGURATION; + } + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndDependentFunctionsResource + * + * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte + * stream + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes consumed from + * the ByteStreamBuffer + * OutputBuffer - Pointer to the user's return buffer + * StructureSize - UINT32 pointer that is filled with + * the number of bytes in the filled + * in structure + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the resource byte stream and fill out the appropriate + * structure pointed to by the OutputBuffer. Return the + * number of bytes consumed from the byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndDependentFunctionsResource ( + UINT8 *ByteStreamBuffer, + UINT32 *BytesConsumed, + UINT8 **OutputBuffer, + UINT32 *StructureSize) +{ + RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + UINT32 StructSize = RESOURCE_LENGTH; + + + FUNCTION_TRACE ("RsEndDependentFunctionsResource"); + + /* + * The number of bytes consumed is static + */ + *BytesConsumed = 1; + + /* + * Fill out the structure + */ + OutputStruct->Id = EndDependentFunctions; + + /* + * Set the Length parameter + */ + OutputStruct->Length = StructSize; + + /* + * Return the final size of the structure + */ + *StructureSize = StructSize; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStartDependentFunctionsStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsStartDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed) +{ + UINT8 *Buffer = *OutputBuffer; + UINT8 Temp8 = 0; + + + FUNCTION_TRACE ("RsStartDependentFunctionsStream"); + + /* + * The descriptor field is set based upon whether a byte is needed + * to contain Priority data. + */ + if (ACCEPTABLE_CONFIGURATION == + LinkedList->Data.StartDependentFunctions.CompatibilityPriority && + ACCEPTABLE_CONFIGURATION == + LinkedList->Data.StartDependentFunctions.PerformanceRobustness) + { + *Buffer = 0x30; + } + else + { + *Buffer = 0x31; + Buffer += 1; + + /* + * Set the Priority Byte Definition + */ + Temp8 = 0; + Temp8 = (UINT8) + ((LinkedList->Data.StartDependentFunctions.PerformanceRobustness & + 0x03) << 2); + Temp8 |= + (LinkedList->Data.StartDependentFunctions.CompatibilityPriority & + 0x03); + + *Buffer = Temp8; + } + + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEndDependentFunctionsStream + * + * PARAMETERS: LinkedList - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's return buffer + * BytesConsumed - UINT32 pointer that is filled with + * the number of bytes of the + * OutputBuffer used + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code + * + * DESCRIPTION: Take the linked list resource structure and fills in the + * the appropriate bytes in a byte stream + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsEndDependentFunctionsStream ( + RESOURCE *LinkedList, + UINT8 **OutputBuffer, + UINT32 *BytesConsumed + ) +{ + UINT8 *Buffer = *OutputBuffer; + + + FUNCTION_TRACE ("RsEndDependentFunctionsStream"); + + /* + * The descriptor field is static + */ + *Buffer = 0x38; + Buffer += 1; + + /* + * Return the number of bytes consumed in this operation + */ + *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - + (NATIVE_UINT) *OutputBuffer); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/rsutils.c b/sys/contrib/dev/acpica/rsutils.c new file mode 100644 index 0000000..3ec5fa6 --- /dev/null +++ b/sys/contrib/dev/acpica/rsutils.c @@ -0,0 +1,511 @@ +/******************************************************************************* + * + * Module Name: rsutils - Utilities for the resource manager + * $Revision: 12 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSUTILS_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acresrc.h" + + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrtMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * RetBuffer - a pointer to a buffer structure for the + * results + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get the _PRT value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *RetObj; + ACPI_STATUS Status; + UINT32 BufferSpaceNeeded; + + + FUNCTION_TRACE ("RsGetPrtMethodData"); + + + /* already validated params, so we won't repeat here */ + + BufferSpaceNeeded = RetBuffer->Length; + + /* + * Execute the method, no parameters + */ + Status = AcpiNsEvaluateRelative (Handle, "_PRT", NULL, &RetObj); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!RetObj) + { + /* Return object is required */ + + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _PRT\n")); + return_ACPI_STATUS (AE_TYPE); + } + + + /* + * The return object will be a package, so check the + * parameters. If the return object is not a package, + * then the underlying AML code is corrupt or improperly + * written. + */ + if (ACPI_TYPE_PACKAGE != RetObj->Common.Type) + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreatePciRoutingTable (RetObj, + RetBuffer->Pointer, + &BufferSpaceNeeded); + + /* + * Tell the user how much of the buffer we have used or is needed + * and return the final status. + */ + RetBuffer->Length = BufferSpaceNeeded; + + + /* On exit, we must delete the object returned by evaluateObject */ + +Cleanup: + + AcpiCmRemoveReference (RetObj); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetCrsMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * RetBuffer - a pointer to a buffer structure for the + * results + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get the _CRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *RetObj; + ACPI_STATUS Status; + UINT32 BufferSpaceNeeded = RetBuffer->Length; + + + FUNCTION_TRACE ("RsGetCrsMethodData"); + + + /* already validated params, so we won't repeat here */ + + /* + * Execute the method, no parameters + */ + Status = AcpiNsEvaluateRelative (Handle, "_CRS", NULL, &RetObj); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!RetObj) + { + /* Return object is required */ + + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _CRS\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* + * The return object will be a buffer, but check the + * parameters. If the return object is not a buffer, + * then the underlying AML code is corrupt or improperly + * written. + */ + if (ACPI_TYPE_BUFFER != RetObj->Common.Type) + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (RetObj, + RetBuffer->Pointer, + &BufferSpaceNeeded); + + + if (ACPI_SUCCESS (Status)) + { + DUMP_RESOURCE_LIST(RetBuffer->Pointer); + } + + /* + * Tell the user how much of the buffer we have used or is needed + * and return the final status. + */ + RetBuffer->Length = BufferSpaceNeeded; + + + /* On exit, we must delete the object returned by evaluateObject */ + +Cleanup: + + AcpiCmRemoveReference (RetObj); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrsMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * RetBuffer - a pointer to a buffer structure for the + * results + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get the _PRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *RetObj; + ACPI_STATUS Status; + UINT32 BufferSpaceNeeded = RetBuffer->Length; + + + FUNCTION_TRACE ("RsGetPrsMethodData"); + + + /* already validated params, so we won't repeat here */ + + /* + * Execute the method, no parameters + */ + Status = AcpiNsEvaluateRelative (Handle, "_PRS", NULL, &RetObj); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!RetObj) + { + /* Return object is required */ + + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _PRS\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* + * The return object will be a buffer, but check the + * parameters. If the return object is not a buffer, + * then the underlying AML code is corrupt or improperly + * written.. + */ + if (ACPI_TYPE_BUFFER != RetObj->Common.Type) + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (RetObj, + RetBuffer->Pointer, + &BufferSpaceNeeded); + + /* + * Tell the user how much of the buffer we have used or is needed + * and return the final status. + */ + RetBuffer->Length = BufferSpaceNeeded; + + + /* On exit, we must delete the object returned by evaluateObject */ + +Cleanup: + + AcpiCmRemoveReference (RetObj); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetSrsMethodData + * + * PARAMETERS: Handle - a handle to the containing object + * InBuffer - a pointer to a buffer structure of the + * parameter + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to set the _SRS of an object contained + * in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *InBuffer) +{ + ACPI_OPERAND_OBJECT *Params[2]; + ACPI_OPERAND_OBJECT ParamObj; + ACPI_STATUS Status; + UINT8 *ByteStream = NULL; + UINT32 BufferSizeNeeded = 0; + + + FUNCTION_TRACE ("RsSetSrsMethodData"); + + + /* already validated params, so we won't repeat here */ + + /* + * 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. + */ + BufferSizeNeeded = 0; + + /* + * First call is to get the buffer size needed + */ + Status = AcpiRsCreateByteStream (InBuffer->Pointer, + ByteStream, + &BufferSizeNeeded); + /* + * We expect a return of AE_BUFFER_OVERFLOW + * if not, exit with the error + */ + if (AE_BUFFER_OVERFLOW != Status) + { + return_ACPI_STATUS (Status); + } + + /* + * Allocate the buffer needed + */ + ByteStream = AcpiCmCallocate(BufferSizeNeeded); + if (NULL == ByteStream) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Now call to convert the linked list into a byte stream + */ + Status = AcpiRsCreateByteStream (InBuffer->Pointer, + ByteStream, + &BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Init the param object + */ + AcpiCmInitStaticObject (&ParamObj); + + /* + * Method requires one parameter. Set it up + */ + Params [0] = &ParamObj; + Params [1] = NULL; + + /* + * Set up the parameter object + */ + ParamObj.Common.Type = ACPI_TYPE_BUFFER; + ParamObj.Buffer.Length = BufferSizeNeeded; + ParamObj.Buffer.Pointer = ByteStream; + + /* + * Execute the method, no return value + */ + Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL); + + /* + * Clean up and return the status from AcpiNsEvaluateRelative + */ + +Cleanup: + + AcpiCmFree (ByteStream); + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/rsxface.c b/sys/contrib/dev/acpica/rsxface.c new file mode 100644 index 0000000..c3dc221 --- /dev/null +++ b/sys/contrib/dev/acpica/rsxface.c @@ -0,0 +1,326 @@ +/******************************************************************************* + * + * Module Name: rsxface - Public interfaces to the ACPI subsystem + * $Revision: 8 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __RSXFACE_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acresrc.h" + +#define _COMPONENT RESOURCE_MANAGER + MODULE_NAME ("rsxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiGetIrqRoutingTable + * + * PARAMETERS: DeviceHandle - a handle to the Bus device we are querying + * RetBuffer - a pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiGetIrqRoutingTable "); + + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!DeviceHandle) || + (!RetBuffer) || + ((!RetBuffer->Pointer) && (RetBuffer->Length))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetCurrentResources + * + * PARAMETERS: DeviceHandle - a handle to the device object for the + * device we are querying + * RetBuffer - a pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiGetCurrentResources"); + + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!DeviceHandle) || + (!RetBuffer) || + ((RetBuffer->Length) && (!RetBuffer->Pointer))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetPossibleResources + * + * PARAMETERS: DeviceHandle - a handle to the device object for the + * device we are querying + * RetBuffer - a pointer to a buffer to receive the + * resources for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiGetPossibleResources"); + + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!DeviceHandle) || + (!RetBuffer) || + ((RetBuffer->Length) && (!RetBuffer->Pointer))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiSetCurrentResources + * + * PARAMETERS: DeviceHandle - a handle to the device object for the + * device we are changing the resources of + * InBuffer - a pointer to a buffer containing the + * resources to be set for the device + * + * RETURN: Status - the status of the call + * + * 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; + + + FUNCTION_TRACE ("AcpiSetCurrentResources"); + + /* + * Must have a valid handle and buffer + */ + if ((!DeviceHandle) || + (!InBuffer) || + (!InBuffer->Pointer) || + (!InBuffer->Length)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer); + + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/tbget.c b/sys/contrib/dev/acpica/tbget.c new file mode 100644 index 0000000..b8b307f --- /dev/null +++ b/sys/contrib/dev/acpica/tbget.c @@ -0,0 +1,733 @@ +/****************************************************************************** + * + * Module Name: tbget - ACPI Table get* routines + * $Revision: 26 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBGET_C__ + +#include "acpi.h" +#include "achware.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbget") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTablePtr + * + * PARAMETERS: TableType - one of the defined table types + * Instance - Which table of this type + * TablePtrLoc - pointer to location to place the pointer for + * return + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the pointer to an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTablePtr ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER **TablePtrLoc) +{ + ACPI_TABLE_DESC *TableDesc; + UINT32 i; + + + FUNCTION_TRACE ("TbGetTablePtr"); + + + if (!AcpiGbl_DSDT) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + if (TableType > ACPI_TABLE_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* + * For all table types (Single/Multiple), the first + * instance is always in the list head. + */ + + if (Instance == 1) + { + /* + * Just pluck the pointer out of the global table! + * Will be null if no table is present + */ + + *TablePtrLoc = AcpiGbl_AcpiTables[TableType].Pointer; + return_ACPI_STATUS (AE_OK); + } + + + /* + * Check for instance out of range + */ + if (Instance > AcpiGbl_AcpiTables[TableType].Count) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Walk the list to get the desired table + * Since the if (Instance == 1) check above checked for the + * first table, setting TableDesc equal to the .Next member + * is actually pointing to the second table. Therefore, we + * need to walk from the 2nd table until we reach the Instance + * that the user is looking for and return its table pointer. + */ + TableDesc = AcpiGbl_AcpiTables[TableType].Next; + for (i = 2; i < Instance; i++) + { + TableDesc = TableDesc->Next; + } + + /* We are now pointing to the requested table's descriptor */ + + *TablePtrLoc = TableDesc->Pointer; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTable + * + * PARAMETERS: PhysicalAddress - Physical address of table to retrieve + * *BufferPtr - If BufferPtr is valid, read data from + * buffer rather than searching memory + * *TableInfo - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Maps the physical address of table into a logical address + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTable ( + void *PhysicalAddress, + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_TABLE_HEADER *TableHeader = NULL; + ACPI_TABLE_HEADER *FullTable = NULL; + UINT32 Size; + UINT8 Allocation; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbGetTable"); + + if (!TableInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + if (BufferPtr) + { + /* + * Getting data from a buffer, not BIOS tables + */ + + TableHeader = BufferPtr; + Status = AcpiTbValidateTableHeader (TableHeader); + if (ACPI_FAILURE (Status)) + { + /* Table failed verification, map all errors to BAD_DATA */ + + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* Allocate buffer for the entire table */ + + FullTable = AcpiCmAllocate (TableHeader->Length); + if (!FullTable) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the entire table (including header) to the local buffer */ + + Size = TableHeader->Length; + MEMCPY (FullTable, BufferPtr, Size); + + /* Save allocation type */ + + Allocation = ACPI_MEM_ALLOCATED; + } + + + /* + * Not reading from a buffer, just map the table's physical memory + * into our address space. + */ + else + { + Size = SIZE_IN_HEADER; + + Status = AcpiTbMapAcpiTable (PhysicalAddress, &Size, + (void **) &FullTable); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Save allocation type */ + + Allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + TableInfo->Pointer = FullTable; + TableInfo->Length = Size; + TableInfo->Allocation = Allocation; + TableInfo->BasePointer = FullTable; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetAllTables + * + * PARAMETERS: NumberOfTables - Number of tables to get + * TablePtr - Input buffer pointer, optional + * + * RETURN: Status + * + * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must + * already be loaded and validated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetAllTables ( + UINT32 NumberOfTables, + ACPI_TABLE_HEADER *TablePtr) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Index; + ACPI_TABLE_DESC TableInfo; + + + FUNCTION_TRACE ("TbGetAllTables"); + + DEBUG_PRINT (ACPI_INFO, ("Number of tables: %d\n", NumberOfTables)); + + + /* + * Loop through all table pointers found in RSDT. + * This will NOT include the FACS and DSDT - we must get + * them after the loop + */ + + for (Index = 0; Index < NumberOfTables; Index++) + { + /* Clear the TableInfo each time */ + + MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); + + /* Get the table via the RSDT */ + + Status = AcpiTbGetTable ((void *) AcpiGbl_RSDT->TableOffsetEntry[Index], + TablePtr, &TableInfo); + + /* Ignore a table that failed verification */ + + if (Status == AE_BAD_DATA) + { + continue; + } + + /* However, abort on serious errors */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Recognize and install the table */ + + Status = AcpiTbInstallTable (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + /* + * Unrecognized or unsupported table, delete it and ignore the + * error. Just get as many tables as we can, later we will + * determine if there are enough tables to continue. + */ + + AcpiTbUninstallTable (&TableInfo); + } + } + + + /* Dump the FACP Header */ + + DEBUG_PRINT (TRACE_TABLES, ("Hex dump of FADT Header:\n")); + DUMP_BUFFER ((UINT8 *) AcpiGbl_FACP, sizeof (ACPI_TABLE_HEADER)); + + /* Dump the entire FACP */ + + DEBUG_PRINT (TRACE_TABLES, + ("Hex dump of FADT (After header), size %d (0x%x)\n", + AcpiGbl_FACP->header.Length, AcpiGbl_FACP->header.Length)); + DUMP_BUFFER ((UINT8 *) (&AcpiGbl_FACP->FirmwareCtrl), AcpiGbl_FACP->header.Length); + + + /* + * Get the minimum set of ACPI tables, namely: + * + * 1) FACP (via RSDT in loop above) + * 2) FACS + * 3) DSDT + * + */ + + + /* + * Get the FACS (must have the FACP first, from loop above) + * AcpiTbGetTableFacs will fail if FACP pointer is not valid + */ + + Status = AcpiTbGetTableFacs (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Install the FACS */ + + Status = AcpiTbInstallTable (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + + /* Get the DSDT (We know that the FACP if valid now) */ + + Status = AcpiTbGetTable ((void *) AcpiGbl_FACP->Dsdt, TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Install the DSDT */ + + Status = AcpiTbInstallTable (TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Dump the DSDT Header */ + + DEBUG_PRINT (TRACE_TABLES, ("Hex dump of DSDT Header:\n")); + DUMP_BUFFER ((UINT8 *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER)); + + /* Dump the entire DSDT */ + + DEBUG_PRINT (TRACE_TABLES, + ("Hex dump of DSDT (After header), size %d (0x%x)\n", + AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length)); + DUMP_BUFFER ((UINT8 *) (AcpiGbl_DSDT + 1), AcpiGbl_DSDT->Length); + + /* + * Initialize the capabilities flags. + * Assumes that platform supports ACPI_MODE since we have tables! + */ + + AcpiGbl_SystemFlags |= AcpiHwGetModeCapabilities (); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbVerifyRsdp + * + * PARAMETERS: NumberOfTables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyRsdp ( + void *RsdpPhysicalAddress) +{ + ACPI_TABLE_DESC TableInfo; + ACPI_STATUS Status; + UINT8 *TablePtr; + + + FUNCTION_TRACE ("AcpiTbVerifyRsdp"); + + + /* + * Obtain access to the RSDP structure + */ + Status = AcpiOsMapMemory (RsdpPhysicalAddress, + sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER), + (void **) &TablePtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The signature and checksum must both be correct + */ + if (STRNCMP ((NATIVE_CHAR *) TablePtr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) + { + /* Nope, BAD Signature */ + + Status = AE_BAD_SIGNATURE; + goto Cleanup; + } + + if (AcpiTbChecksum (TablePtr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) != 0) + { + /* Nope, BAD Checksum */ + + Status = AE_BAD_CHECKSUM; + goto Cleanup; + } + + /* The RSDP supplied is OK */ + + TableInfo.Pointer = (ACPI_TABLE_HEADER *) TablePtr; + TableInfo.Length = sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER); + TableInfo.Allocation = ACPI_MEM_MAPPED; + TableInfo.BasePointer = TablePtr; + + /* Save the table pointers and allocation info */ + + Status = AcpiTbInitTableDescriptor (ACPI_TABLE_RSDP, &TableInfo); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + + /* Save the RSDP in a global for easy access */ + + AcpiGbl_RSDP = (ROOT_SYSTEM_DESCRIPTOR_POINTER *) TableInfo.Pointer; + return_ACPI_STATUS (Status); + + + /* Error exit */ +Cleanup: + + AcpiOsUnmapMemory (TablePtr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetTableRsdt + * + * PARAMETERS: NumberOfTables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetTableRsdt ( + UINT32 *NumberOfTables) +{ + ACPI_TABLE_DESC TableInfo; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiTbGetTableRsdt"); + + + /* + * Get the RSDT from the RSDP + */ + + DEBUG_PRINT (ACPI_INFO, + ("RSDP located at %p, RSDT physical=%p \n", + AcpiGbl_RSDP, AcpiGbl_RSDP->RsdtPhysicalAddress)); + + Status = AcpiTbGetTable ((void *) AcpiGbl_RSDP->RsdtPhysicalAddress, + NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("GetTableRsdt: Could not get the RSDT, %s\n", + AcpiCmFormatException (Status))); + + if (Status == AE_BAD_SIGNATURE) + { + /* Invalid RSDT signature */ + + REPORT_ERROR (("Invalid signature where RSDP indicates RSDT should be located\n")); + + DUMP_BUFFER (AcpiGbl_RSDP, 20); + + DEBUG_PRINT_RAW (ACPI_ERROR, + ("RSDP points to RSDT at %lXh, but RSDT signature is invalid\n", + (void *) AcpiGbl_RSDP->RsdtPhysicalAddress)); + } + + REPORT_ERROR (("Unable to locate the RSDT\n")); + return_ACPI_STATUS (Status); + } + + + /* Always delete the RSDP mapping */ + + AcpiTbDeleteAcpiTable (ACPI_TABLE_RSDP); + + /* Save the table pointers and allocation info */ + + Status = AcpiTbInitTableDescriptor (ACPI_TABLE_RSDT, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiGbl_RSDT = (ROOT_SYSTEM_DESCRIPTION_TABLE *) TableInfo.Pointer; + + + /* Valid RSDT signature, verify the checksum */ + + DEBUG_PRINT (ACPI_INFO, ("RSDT located at %p\n", AcpiGbl_RSDT)); + + Status = AcpiTbVerifyTableChecksum ((ACPI_TABLE_HEADER *) AcpiGbl_RSDT); + + /* + * Determine the number of tables pointed to by the RSDT. + * This is defined by the ACPI Specification to be the number of + * pointers contained within the RSDT. The size of the pointers + * is architecture-dependent. + */ + + *NumberOfTables = ((AcpiGbl_RSDT->header.Length - + sizeof (ACPI_TABLE_HEADER)) / sizeof (void *)); + + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbGetTableFacs + * + * PARAMETERS: *BufferPtr - If BufferPtr is valid, read data from + * buffer rather than searching memory + * *TableInfo - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns a pointer to the FACS as defined in FACP. This + * function assumes the global variable FACP has been + * correctly initialized. The value of FACP->FirmwareCtrl + * into a far pointer which is returned. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbGetTableFacs ( + ACPI_TABLE_HEADER *BufferPtr, + ACPI_TABLE_DESC *TableInfo) +{ + void *TablePtr = NULL; + UINT32 Size; + UINT8 Allocation; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbGetTableFacs"); + + + /* Must have a valid FACP pointer */ + + if (!AcpiGbl_FACP) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + Size = sizeof (FIRMWARE_ACPI_CONTROL_STRUCTURE); + if (BufferPtr) + { + /* + * Getting table from a file -- allocate a buffer and + * read the table. + */ + TablePtr = AcpiCmAllocate (Size); + if(!TablePtr) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MEMCPY (TablePtr, BufferPtr, Size); + + /* Save allocation type */ + + Allocation = ACPI_MEM_ALLOCATED; + } + + else + { + /* Just map the physical memory to our address space */ + + Status = AcpiTbMapAcpiTable ((void *) AcpiGbl_FACP->FirmwareCtrl, + &Size, &TablePtr); + if (ACPI_FAILURE(Status)) + { + return_ACPI_STATUS (Status); + } + + /* Save allocation type */ + + Allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + TableInfo->Pointer = TablePtr; + TableInfo->Length = Size; + TableInfo->Allocation = Allocation; + TableInfo->BasePointer = TablePtr; + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/tbinstal.c b/sys/contrib/dev/acpica/tbinstal.c new file mode 100644 index 0000000..c63464c --- /dev/null +++ b/sys/contrib/dev/acpica/tbinstal.c @@ -0,0 +1,692 @@ +/****************************************************************************** + * + * Module Name: tbinstal - ACPI table installation and removal + * $Revision: 32 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __TBINSTAL_C__ + +#include "acpi.h" +#include "achware.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbinstal") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInstallTable + * + * PARAMETERS: TablePtr - Input buffer pointer, optional + * TableInfo - Return value from AcpiTbGetTable + * + * RETURN: Status + * + * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must + * already be loaded and validated. + * Install the table into the global data structs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInstallTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_STATUS Status; + + FUNCTION_TRACE ("TbInstallTable"); + + + /* + * Check the table signature and make sure it is recognized + * Also checks the header checksum + */ + + Status = AcpiTbRecognizeTable (TablePtr, TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Lock tables while installing */ + + AcpiCmAcquireMutex (ACPI_MTX_TABLES); + + /* Install the table into the global data structure */ + + Status = AcpiTbInitTableDescriptor (TableInfo->Type, TableInfo); + + DEBUG_PRINT (ACPI_INFO, ("%s located at %p\n", + AcpiGbl_AcpiTableData[TableInfo->Type].Name, TableInfo->Pointer)); + + AcpiCmReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbRecognizeTable + * + * PARAMETERS: TablePtr - Input buffer pointer, optional + * TableInfo - Return value from AcpiTbGetTable + * + * RETURN: Status + * + * DESCRIPTION: Check a table signature for a match against known table types + * + * NOTE: All table pointers are validated as follows: + * 1) Table pointer must point to valid physical memory + * 2) Signature must be 4 ASCII chars, even if we don't recognize the + * name + * 3) Table must be readable for length specified in the header + * 4) Table checksum must be valid (with the exception of the FACS + * which has no checksum for some odd reason) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbRecognizeTable ( + ACPI_TABLE_HEADER *TablePtr, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_TABLE_HEADER *TableHeader; + ACPI_STATUS Status; + ACPI_TABLE_TYPE TableType = 0; + UINT32 i; + + + FUNCTION_TRACE ("TbRecognizeTable"); + + + /* Ensure that we have a valid table pointer */ + + TableHeader = (ACPI_TABLE_HEADER *) TableInfo->Pointer; + if (!TableHeader) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Search for a signature match among the known table types + * Start at index one -> Skip the RSDP + */ + + Status = AE_SUPPORT; + for (i = 1; i < NUM_ACPI_TABLES; i++) + { + if (!STRNCMP (TableHeader->Signature, + AcpiGbl_AcpiTableData[i].Signature, + AcpiGbl_AcpiTableData[i].SigLength)) + { + /* + * Found a signature match, get the pertinent info from the + * TableData structure + */ + + TableType = i; + Status = AcpiGbl_AcpiTableData[i].Status; + + DEBUG_PRINT (ACPI_INFO, + ("TbRecognizeTable: Found %4.4s\n", + AcpiGbl_AcpiTableData[i].Signature)); + break; + } + } + + /* Return the table type and length via the info struct */ + + TableInfo->Type = (UINT8) TableType; + TableInfo->Length = TableHeader->Length; + + + /* + * Validate checksum for _most_ tables, + * even the ones whose signature we don't recognize + */ + + if (TableType != ACPI_TABLE_FACS) + { + /* But don't abort if the checksum is wrong */ + /* TBD: [Future] make this a configuration option? */ + + AcpiTbVerifyTableChecksum (TableHeader); + } + + /* + * An AE_SUPPORT means that the table was not recognized. + * We basically ignore this; just print a debug message + */ + + if (Status == AE_SUPPORT) + { + DEBUG_PRINT (ACPI_INFO, + ("Unsupported table %s (Type %d) was found and discarded\n", + AcpiGbl_AcpiTableData[TableType].Name, TableType)); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitTableDescriptor + * + * PARAMETERS: TableType - The type of the table + * TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Install a table into the global data structs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInitTableDescriptor ( + ACPI_TABLE_TYPE TableType, + ACPI_TABLE_DESC *TableInfo) +{ + ACPI_TABLE_DESC *ListHead; + ACPI_TABLE_DESC *TableDesc; + + + FUNCTION_TRACE_U32 ("TbInitTableDescriptor", TableType); + + /* + * Install the table into the global data structure + */ + + ListHead = &AcpiGbl_AcpiTables[TableType]; + TableDesc = ListHead; + + + /* + * Two major types of tables: 1) Only one instance is allowed. This + * includes most ACPI tables such as the DSDT. 2) Multiple instances of + * the table are allowed. This includes SSDT and PSDTs. + */ + + if (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags)) + { + /* + * Only one table allowed, and a table has alread been installed + * at this location, so return an error. + */ + + if (ListHead->Pointer) + { + return_ACPI_STATUS (AE_EXIST); + } + + TableDesc->Count = 1; + } + + + else + { + /* + * Multiple tables allowed for this table type, we must link + * the new table in to the list of tables of this type. + */ + + if (ListHead->Pointer) + { + TableDesc = AcpiCmCallocate (sizeof (ACPI_TABLE_DESC)); + if (!TableDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ListHead->Count++; + + /* Update the original previous */ + + ListHead->Prev->Next = TableDesc; + + /* Update new entry */ + + TableDesc->Prev = ListHead->Prev; + TableDesc->Next = ListHead; + + /* Update list head */ + + ListHead->Prev = TableDesc; + } + + else + { + TableDesc->Count = 1; + } + } + + + /* Common initialization of the table descriptor */ + + TableDesc->Pointer = TableInfo->Pointer; + TableDesc->BasePointer = TableInfo->BasePointer; + TableDesc->Length = TableInfo->Length; + TableDesc->Allocation = TableInfo->Allocation; + TableDesc->AmlPointer = (UINT8 *) (TableDesc->Pointer + 1), + TableDesc->AmlLength = (UINT32) (TableDesc->Length - + (UINT32) sizeof (ACPI_TABLE_HEADER)); + TableDesc->TableId = AcpiCmAllocateOwnerId (OWNER_TYPE_TABLE); + TableDesc->LoadedIntoNamespace = FALSE; + + /* + * Set the appropriate global pointer (if there is one) to point to the + * newly installed table + */ + + if (AcpiGbl_AcpiTableData[TableType].GlobalPtr) + { + *(AcpiGbl_AcpiTableData[TableType].GlobalPtr) = TableInfo->Pointer; + } + + + /* Return Data */ + + TableInfo->TableId = TableDesc->TableId; + TableInfo->InstalledDesc = TableDesc; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteAcpiTables + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all internal ACPI tables + * + ******************************************************************************/ + +void +AcpiTbDeleteAcpiTables (void) +{ + ACPI_TABLE_TYPE Type; + + + /* + * Free memory allocated for ACPI tables + * Memory can either be mapped or allocated + */ + + for (Type = 0; Type < NUM_ACPI_TABLES; Type++) + { + AcpiTbDeleteAcpiTable (Type); + } + +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteAcpiTable + * + * PARAMETERS: Type - The table type to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Delete an internal ACPI table + * Locks the ACPI table mutex + * + ******************************************************************************/ + +void +AcpiTbDeleteAcpiTable ( + ACPI_TABLE_TYPE Type) +{ + FUNCTION_TRACE_U32 ("TbDeleteAcpiTable", Type); + + + if (Type > ACPI_TABLE_MAX) + { + return_VOID; + } + + + AcpiCmAcquireMutex (ACPI_MTX_TABLES); + + /* Free the table */ + + AcpiTbFreeAcpiTablesOfType (&AcpiGbl_AcpiTables[Type]); + + + /* Clear the appropriate "typed" global table pointer */ + + switch (Type) + { + case ACPI_TABLE_RSDP: + AcpiGbl_RSDP = NULL; + break; + + case ACPI_TABLE_APIC: + AcpiGbl_APIC = NULL; + break; + + case ACPI_TABLE_DSDT: + AcpiGbl_DSDT = NULL; + break; + + case ACPI_TABLE_FACP: + AcpiGbl_FACP = NULL; + break; + + case ACPI_TABLE_FACS: + AcpiGbl_FACS = NULL; + break; + + case ACPI_TABLE_PSDT: + break; + + case ACPI_TABLE_RSDT: + AcpiGbl_RSDT = NULL; + break; + + case ACPI_TABLE_SSDT: + break; + + case ACPI_TABLE_SBST: + AcpiGbl_SBST = NULL; + + case ACPI_TABLE_SPIC: + break; + + default: + break; + } + + AcpiCmReleaseMutex (ACPI_MTX_TABLES); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFreeAcpiTablesOfType + * + * PARAMETERS: TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Free the memory associated with an internal ACPI table + * Table mutex should be locked. + * + ******************************************************************************/ + +void +AcpiTbFreeAcpiTablesOfType ( + ACPI_TABLE_DESC *ListHead) +{ + ACPI_TABLE_DESC *TableDesc; + UINT32 Count; + UINT32 i; + + + FUNCTION_TRACE_PTR ("TbFreeAcpiTablesOfType", ListHead); + + + /* Get the head of the list */ + + TableDesc = ListHead; + Count = ListHead->Count; + + /* + * Walk the entire list, deleting both the allocated tables + * and the table descriptors + */ + + for (i = 0; i < Count; i++) + { + TableDesc = AcpiTbUninstallTable (TableDesc); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteSingleTable + * + * PARAMETERS: TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Low-level free for a single ACPI table. Handles cases where + * the table was allocated a buffer or was mapped. + * + ******************************************************************************/ + +void +AcpiTbDeleteSingleTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + if (!TableDesc) + { + return; + } + + if (TableDesc->Pointer) + { + /* Valid table, determine type of memory allocation */ + + switch (TableDesc->Allocation) + { + + case ACPI_MEM_NOT_ALLOCATED: + break; + + + case ACPI_MEM_ALLOCATED: + + AcpiCmFree (TableDesc->BasePointer); + break; + + + case ACPI_MEM_MAPPED: + + AcpiOsUnmapMemory (TableDesc->BasePointer, TableDesc->Length); + break; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbUninstallTable + * + * PARAMETERS: TableInfo - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Free the memory associated with an internal ACPI table that + * is either installed or has never been installed. + * Table mutex should be locked. + * + ******************************************************************************/ + +ACPI_TABLE_DESC * +AcpiTbUninstallTable ( + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_TABLE_DESC *NextDesc; + + + FUNCTION_TRACE_PTR ("TbDeleteSingleTable", TableDesc); + + + if (!TableDesc) + { + return_PTR (NULL); + } + + + /* Unlink the descriptor */ + + if (TableDesc->Prev) + { + TableDesc->Prev->Next = TableDesc->Next; + } + + if (TableDesc->Next) + { + TableDesc->Next->Prev = TableDesc->Prev; + } + + + /* Free the memory allocated for the table itself */ + + AcpiTbDeleteSingleTable (TableDesc); + + + /* Free the table descriptor (Don't delete the list head, tho) */ + + if ((TableDesc->Prev) == (TableDesc->Next)) + { + + NextDesc = NULL; + + /* Clear the list head */ + + TableDesc->Pointer = NULL; + TableDesc->Length = 0; + TableDesc->Count = 0; + + } + + else + { + /* Free the table descriptor */ + + NextDesc = TableDesc->Next; + AcpiCmFree (TableDesc); + } + + + return_PTR (NextDesc); +} + + diff --git a/sys/contrib/dev/acpica/tbutils.c b/sys/contrib/dev/acpica/tbutils.c new file mode 100644 index 0000000..dc942ed --- /dev/null +++ b/sys/contrib/dev/acpica/tbutils.c @@ -0,0 +1,486 @@ +/****************************************************************************** + * + * Module Name: tbutils - Table manipulation utilities + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBUTILS_C__ + +#include "acpi.h" +#include "actables.h" +#include "acinterp.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbHandleToObject + * + * PARAMETERS: TableId - Id for which the function is searching + * TableDesc - Pointer to return the matching table + * descriptor. + * + * RETURN: Search the tables to find one with a matching TableId and + * return a pointer to that table descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **TableDesc) +{ + UINT32 i; + ACPI_TABLE_DESC *ListHead; + + + for (i = 0; i < ACPI_TABLE_MAX; i++) + { + ListHead = &AcpiGbl_AcpiTables[i]; + do + { + if (ListHead->TableId == TableId) + { + *TableDesc = ListHead; + return (AE_OK); + } + + ListHead = ListHead->Next; + + } while (ListHead != &AcpiGbl_AcpiTables[i]); + } + + + DEBUG_PRINT (ACPI_ERROR, ("TableId=0x%X does not exist\n", TableId)); + return (AE_BAD_PARAMETER); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSystemTablePointer + * + * PARAMETERS: *Where - Pointer to be examined + * + * RETURN: TRUE if Where is within the AML stream (in one of the ACPI + * system tables such as the DSDT or an SSDT.) + * FALSE otherwise + * + ******************************************************************************/ + +BOOLEAN +AcpiTbSystemTablePointer ( + void *Where) +{ + UINT32 i; + ACPI_TABLE_DESC *TableDesc; + ACPI_TABLE_HEADER *Table; + + + /* No function trace, called too often! */ + + + /* Ignore null pointer */ + + if (!Where) + { + return (FALSE); + } + + + /* Check for a pointer within the DSDT */ + + if ((AcpiGbl_DSDT) && + (IS_IN_ACPI_TABLE (Where, AcpiGbl_DSDT))) + { + return (TRUE); + } + + + /* Check each of the loaded SSDTs (if any)*/ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_SSDT]; + + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count; i++) + { + Table = TableDesc->Pointer; + + if (IS_IN_ACPI_TABLE (Where, Table)) + { + return (TRUE); + } + + TableDesc = TableDesc->Next; + } + + + /* Check each of the loaded PSDTs (if any)*/ + + TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_PSDT]; + + for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count; i++) + { + Table = TableDesc->Pointer; + + if (IS_IN_ACPI_TABLE (Where, Table)) + { + return (TRUE); + } + + TableDesc = TableDesc->Next; + } + + + /* Pointer does not point into any system table */ + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateTableHeader + * + * PARAMETERS: TableHeader - Logical pointer to the table + * + * RETURN: Status + * + * DESCRIPTION: Check an ACPI table header for validity + * + * NOTE: Table pointers are validated as follows: + * 1) Table pointer must point to valid physical memory + * 2) Signature must be 4 ASCII chars, even if we don't recognize the + * name + * 3) Table must be readable for length specified in the header + * 4) Table checksum must be valid (with the exception of the FACS + * which has no checksum for some odd reason) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbValidateTableHeader ( + ACPI_TABLE_HEADER *TableHeader) +{ + ACPI_NAME Signature; + + + /* Verify that this is a valid address */ + + if (!AcpiOsReadable (TableHeader, sizeof (ACPI_TABLE_HEADER))) + { + DEBUG_PRINT (ACPI_ERROR, + ("Cannot read table header at %p\n", TableHeader)); + return (AE_BAD_ADDRESS); + } + + + /* Ensure that the signature is 4 ASCII characters */ + + MOVE_UNALIGNED32_TO_32 (&Signature, &TableHeader->Signature); + if (!AcpiCmValidAcpiName (Signature)) + { + DEBUG_PRINT (ACPI_ERROR, + ("Table signature at %p [%X] has invalid characters\n", + TableHeader, &Signature)); + + REPORT_WARNING (("Invalid table signature found\n")); + DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_BAD_SIGNATURE); + } + + + /* Validate the table length */ + + if (TableHeader->Length < sizeof (ACPI_TABLE_HEADER)) + { + DEBUG_PRINT (ACPI_ERROR, + ("Invalid length in table header %p name %4.4s\n", + TableHeader, &Signature)); + + REPORT_WARNING (("Invalid table header length found\n")); + DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_BAD_HEADER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbMapAcpiTable + * + * PARAMETERS: PhysicalAddress - Physical address of table to map + * *Size - Size of the table. If zero, the size + * from the table header is used. + * Actual size is returned here. + * **LogicalAddress - Logical address of mapped table + * + * RETURN: Logical address of the mapped table. + * + * DESCRIPTION: Maps the physical address of table into a logical address + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbMapAcpiTable ( + void *PhysicalAddress, + UINT32 *Size, + void **LogicalAddress) +{ + ACPI_TABLE_HEADER *Table; + UINT32 TableSize = *Size; + ACPI_STATUS Status = AE_OK; + + + /* If size is zero, look at the table header to get the actual size */ + + if ((*Size) == 0) + { + /* Get the table header so we can extract the table length */ + + Status = AcpiOsMapMemory (PhysicalAddress, sizeof (ACPI_TABLE_HEADER), + (void **) &Table); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Extract the full table length before we delete the mapping */ + + TableSize = Table->Length; + + /* + * Validate the header and delete the mapping. + * We will create a mapping for the full table below. + */ + + Status = AcpiTbValidateTableHeader (Table); + + /* Always unmap the memory for the header */ + + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + + /* Exit if header invalid */ + + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + + /* Map the physical memory for the correct length */ + + Status = AcpiOsMapMemory (PhysicalAddress, TableSize, (void **) &Table); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DEBUG_PRINT (ACPI_INFO, + ("Mapped memory for ACPI table, length=%d(0x%X) at %p\n", + TableSize, TableSize, Table)); + + *Size = TableSize; + *LogicalAddress = Table; + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbVerifyTableChecksum + * + * PARAMETERS: *TableHeader - ACPI table to verify + * + * RETURN: 8 bit checksum of table + * + * DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct + * table should have a checksum of 0. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyTableChecksum ( + ACPI_TABLE_HEADER *TableHeader) +{ + UINT8 Checksum; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbVerifyTableChecksum"); + + + /* Compute the checksum on the table */ + + Checksum = AcpiTbChecksum (TableHeader, TableHeader->Length); + + /* Return the appropriate exception */ + + if (Checksum) + { + REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n", + Checksum, &TableHeader->Signature)); + + Status = AE_BAD_CHECKSUM; + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbChecksum + * + * PARAMETERS: Buffer - Buffer to checksum + * Length - Size of the buffer + * + * RETURNS 8 bit checksum of buffer + * + * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. + * + ******************************************************************************/ + +UINT8 +AcpiTbChecksum ( + void *Buffer, + UINT32 Length) +{ + UINT8 *limit; + UINT8 *rover; + UINT8 sum = 0; + + + if (Buffer && Length) + { + /* Buffer and Length are valid */ + + limit = (UINT8 *) Buffer + Length; + + for (rover = Buffer; rover < limit; rover++) + { + sum = (UINT8) (sum + *rover); + } + } + + return (sum); +} + + diff --git a/sys/contrib/dev/acpica/tbxface.c b/sys/contrib/dev/acpica/tbxface.c new file mode 100644 index 0000000..b657f6f --- /dev/null +++ b/sys/contrib/dev/acpica/tbxface.c @@ -0,0 +1,506 @@ +/****************************************************************************** + * + * Module Name: tbxface - Public interfaces to the ACPI subsystem + * ACPI table oriented interfaces + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFACE_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiLoadTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: This function is called to load the ACPI tables from the + * provided RSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTables ( + void *RsdpPhysicalAddress) +{ + ACPI_STATUS Status = AE_OK; + UINT32 NumberOfTables = 0; + + + FUNCTION_TRACE ("AcpiLoadTables"); + + + /* Map and validate the RSDP */ + + Status = AcpiTbVerifyRsdp (RsdpPhysicalAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Get the RSDT via the RSDP */ + + Status = AcpiTbGetTableRsdt (&NumberOfTables); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Now get the rest of the tables */ + + Status = AcpiTbGetAllTables (NumberOfTables, NULL); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + DEBUG_PRINT (ACPI_OK, ("ACPI Tables successfully loaded\n")); + + + /* Load the namespace from the tables */ + + Status = AcpiNsLoadNamespace (); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + REPORT_ERROR (("AcpiLoadTables: Could not load tables: %s\n", + AcpiCmFormatException (Status))); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiLoadTable + * + * PARAMETERS: TablePtr - pointer to a buffer containing the entire + * table to be loaded + * + * RETURN: Status + * + * DESCRIPTION: This function is called to load a table from the caller's + * buffer. The buffer must contain an entire ACPI Table including + * a valid header. The header fields will be verified, and if it + * is determined that the table is invalid, the call will fail. + * + * If the call fails an appropriate status will be returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTable ( + ACPI_TABLE_HEADER *TablePtr) +{ + ACPI_STATUS Status; + ACPI_TABLE_DESC TableInfo; + + + FUNCTION_TRACE ("AcpiLoadTable"); + + if (!TablePtr) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Copy the table to a local buffer */ + + Status = AcpiTbGetTable (NULL, TablePtr, &TableInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Install the new table into the local data structures */ + + Status = AcpiTbInstallTable (NULL, &TableInfo); + if (ACPI_FAILURE (Status)) + { + /* Free table allocated by AcpiTbGetTable */ + + AcpiTbDeleteSingleTable (&TableInfo); + return_ACPI_STATUS (Status); + } + + + Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + /* Uninstall table and free the buffer */ + + AcpiTbUninstallTable (TableInfo.InstalledDesc); + return_ACPI_STATUS (Status); + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUnloadTable + * + * PARAMETERS: TableType - Type of table to be unloaded + * + * RETURN: Status + * + * DESCRIPTION: This routine is used to force the unload of a table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUnloadTable ( + ACPI_TABLE_TYPE TableType) +{ + ACPI_TABLE_DESC *ListHead; + + + FUNCTION_TRACE ("AcpiUnloadTable"); + + + /* Parameter validation */ + + if (TableType > ACPI_TABLE_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Find all tables of the requested type */ + + ListHead = &AcpiGbl_AcpiTables[TableType]; + do + { + /* + * Delete all namespace entries owned by this table. Note that these + * entries can appear anywhere in the namespace by virtue of the AML + * "Scope" operator. Thus, we need to track ownership by an ID, not + * simply a position within the hierarchy + */ + + AcpiNsDeleteNamespaceByOwner (ListHead->TableId); + + /* Delete (or unmap) the actual table */ + + AcpiTbDeleteAcpiTable (TableType); + + } while (ListHead != &AcpiGbl_AcpiTables[TableType]); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableHeader + * + * PARAMETERS: TableType - one of the defined table types + * Instance - the non zero instance of the table, allows + * support for multiple tables of the same type + * see AcpiGbl_AcpiTableFlag + * OutTableHeader - pointer to the ACPI_TABLE_HEADER if successful + * + * DESCRIPTION: This function is called to get an ACPI table header. The caller + * supplies an pointer to a data area sufficient to contain an ACPI + * ACPI_TABLE_HEADER structure. + * + * The header contains a length field that can be used to determine + * the size of the buffer needed to contain the entire table. This + * function is not valid for the RSD PTR table since it does not + * have a standard header and is fixed length. + * + * If the operation fails for any reason an appropriate status will + * be returned and the contents of OutTableHeader are undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableHeader ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader) +{ + ACPI_TABLE_HEADER *TblPtr; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiGetTableHeader"); + + if ((Instance == 0) || + (TableType == ACPI_TABLE_RSDP) || + (!OutTableHeader)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check the table type and instance */ + + if ((TableType > ACPI_TABLE_MAX) || + (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && + Instance > 1)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the entire table */ + + Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The function will return a NULL pointer if the table is not loaded + */ + if (TblPtr == NULL) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * Copy the header to the caller's buffer + */ + MEMCPY ((void *) OutTableHeader, (void *) TblPtr, + sizeof (ACPI_TABLE_HEADER)); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTable + * + * PARAMETERS: TableType - one of the defined table types + * Instance - the non zero instance of the table, allows + * support for multiple tables of the same type + * see AcpiGbl_AcpiTableFlag + * RetBuffer - pointer to a structure containing a buffer to + * receive the table + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get an ACPI table. The caller + * supplies an OutBuffer large enough to contain the entire ACPI + * table. The caller should call the AcpiGetTableHeader function + * first to determine the buffer size needed. Upon completion + * the OutBuffer->Length field will indicate the number of bytes + * copied into the OutBuffer->BufPtr buffer. This table will be + * a complete table including the header. + * + * If the operation fails an appropriate status will be returned + * and the contents of OutBuffer are undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTable ( + ACPI_TABLE_TYPE TableType, + UINT32 Instance, + ACPI_BUFFER *RetBuffer) +{ + ACPI_TABLE_HEADER *TblPtr; + ACPI_STATUS Status; + UINT32 RetBufLen; + + + FUNCTION_TRACE ("AcpiGetTable"); + + /* + * If we have a buffer, we must have a length too + */ + if ((Instance == 0) || + (!RetBuffer) || + ((!RetBuffer->Pointer) && (RetBuffer->Length))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check the table type and instance */ + + if ((TableType > ACPI_TABLE_MAX) || + (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && + Instance > 1)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Get a pointer to the entire table */ + + Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * AcpiTbGetTablePtr will return a NULL pointer if the + * table is not loaded. + */ + if (TblPtr == NULL) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * Got a table ptr, assume it's ok and copy it to the user's buffer + */ + if (TableType == ACPI_TABLE_RSDP) + { + /* + * RSD PTR is the only "table" without a header + */ + RetBufLen = sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER); + } + else + { + RetBufLen = TblPtr->Length; + } + + /* + * Verify we have space in the caller's buffer for the table + */ + if (RetBuffer->Length < RetBufLen) + { + RetBuffer->Length = RetBufLen; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + RetBuffer->Length = RetBufLen; + + MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, RetBufLen); + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/tbxfroot.c b/sys/contrib/dev/acpica/tbxfroot.c new file mode 100644 index 0000000..d02a96d --- /dev/null +++ b/sys/contrib/dev/acpica/tbxfroot.c @@ -0,0 +1,319 @@ +/****************************************************************************** + * + * Module Name: tbxfroot - Find the root ACPI table (RSDT) + * $Revision: 28 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBXFROOT_C__ + +#include "acpi.h" +#include "achware.h" +#include "actables.h" + + +#define _COMPONENT TABLE_MANAGER + MODULE_NAME ("tbxfroot") + + +/******************************************************************************* + * + * FUNCTION: AcpiFindRootPointer + * + * PARAMETERS: **RsdpPhysicalAddress - Where to place the RSDP address + * + * RETURN: Status, Physical address of the RSDP + * + * DESCRIPTION: Find the RSDP + * + ******************************************************************************/ + +ACPI_STATUS +AcpiFindRootPointer ( + void **RsdpPhysicalAddress) +{ + ACPI_TABLE_DESC TableInfo; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("AcpiFindRootPointer"); + + + /* Get the RSDP */ + + Status = AcpiTbFindRsdp (&TableInfo); + if (ACPI_FAILURE (Status)) + { + REPORT_WARNING (("RSDP structure not found\n")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + *RsdpPhysicalAddress = TableInfo.Pointer; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbScanMemoryForRsdp + * + * PARAMETERS: StartAddress - Starting pointer for search + * Length - Maximum length to search + * + * RETURN: Pointer to the RSDP if found, otherwise NULL. + * + * DESCRIPTION: Search a block of memory for the RSDP signature + * + ******************************************************************************/ + +UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length) +{ + UINT32 Offset; + UINT8 *MemRover; + + + FUNCTION_TRACE ("TbScanMemoryForRsdp"); + + /* Search from given start addr for the requested length */ + + for (Offset = 0, MemRover = StartAddress; + Offset < Length; + Offset += RSDP_SCAN_STEP, MemRover += RSDP_SCAN_STEP) + { + + /* The signature and checksum must both be correct */ + + if (STRNCMP ((NATIVE_CHAR *) MemRover, + RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && + AcpiTbChecksum (MemRover, + sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) == 0) + { + /* If so, we have found the RSDP */ + + return_PTR (MemRover); + } + } + + /* Searched entire block, no RSDP was found */ + + return_PTR (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFindRsdp + * + * PARAMETERS: *BufferPtr - If == NULL, read data from buffer + * rather than searching memory + * *TableInfo - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor + * pointer structure. If it is found, set *RSDP to point to it. + * + * NOTE: The RSDP must be either in the first 1K of the Extended + * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section + * 5.2.2; assertion #421). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbFindRsdp ( + ACPI_TABLE_DESC *TableInfo) +{ + UINT8 *TablePtr; + UINT8 *MemRover; + UINT8 *PhysAddr; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("TbFindRsdp"); + + + /* + * Search memory for RSDP. First map low physical memory. + */ + + Status = AcpiOsMapMemory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE, + (void **)&TablePtr); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * 1) Search EBDA (low memory) paragraphs + */ + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, LO_RSDP_WINDOW_SIZE); + + /* This mapping is no longer needed */ + + AcpiOsUnmapMemory (TablePtr, LO_RSDP_WINDOW_SIZE); + + if (MemRover) + { + /* Found it, return the physical address */ + + PhysAddr = LO_RSDP_WINDOW_BASE; + PhysAddr += (MemRover - TablePtr); + + TableInfo->Pointer = (ACPI_TABLE_HEADER *) PhysAddr; + + return_ACPI_STATUS (AE_OK); + } + + + /* + * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h + */ + + Status = AcpiOsMapMemory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE, + (void **)&TablePtr); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, HI_RSDP_WINDOW_SIZE); + + /* This mapping is no longer needed */ + + AcpiOsUnmapMemory (TablePtr, HI_RSDP_WINDOW_SIZE); + + if (MemRover) + { + /* Found it, return the physical address */ + + PhysAddr = HI_RSDP_WINDOW_BASE; + PhysAddr += (MemRover - TablePtr); + + TableInfo->Pointer = (ACPI_TABLE_HEADER *) PhysAddr; + + return_ACPI_STATUS (AE_OK); + } + + + /* RSDP signature was not found */ + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + diff --git a/sys/contrib/dev/acpica/utalloc.c b/sys/contrib/dev/acpica/utalloc.c new file mode 100644 index 0000000..bb1e0dd --- /dev/null +++ b/sys/contrib/dev/acpica/utalloc.c @@ -0,0 +1,801 @@ +/****************************************************************************** + * + * Module Name: cmalloc - local memory allocation routines + * $Revision: 76 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMALLOC_C__ + +#include "acpi.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acglobal.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmalloc") + + +#ifdef ACPI_DEBUG +/* + * Most of this code is for tracking memory leaks in the subsystem, and it + * gets compiled out when the ACPI_DEBUG flag is not set. + * Every memory allocation is kept track of in a doubly linked list. Each + * element contains the caller's component, module name, function name, and + * line number. _CmAllocate and _CmCallocate call AcpiCmAddElementToAllocList + * to add an element to the list; deletion occurs in the bosy of _CmFree. + */ + + +/***************************************************************************** + * + * FUNCTION: AcpiCmSearchAllocList + * + * PARAMETERS: Address - Address of allocated memory + * + * RETURN: A list element if found; NULL otherwise. + * + * DESCRIPTION: Searches for an element in the global allocation tracking list. + * + ****************************************************************************/ + +ALLOCATION_INFO * +AcpiCmSearchAllocList ( + void *Address) +{ + ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr; + + + /* Search for the address. */ + + while (Element) + { + if (Element->Address == Address) + { + return (Element); + } + + Element = Element->Next; + } + + return (NULL); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmAddElementToAllocList + * + * PARAMETERS: Address - Address of allocated memory + * Size - Size of the allocation + * AllocType - MEM_MALLOC or MEM_CALLOC + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None. + * + * DESCRIPTION: Inserts an element into the global allocation tracking list. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiCmAddElementToAllocList ( + void *Address, + UINT32 Size, + UINT8 AllocType, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + ALLOCATION_INFO *Element; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("CmAddElementToAllocList", Address); + + + AcpiCmAcquireMutex (ACPI_MTX_MEMORY); + + /* Keep track of the running total of all allocations. */ + + AcpiGbl_CurrentAllocCount++; + AcpiGbl_RunningAllocCount++; + + if (AcpiGbl_MaxConcurrentAllocCount < AcpiGbl_CurrentAllocCount) + { + AcpiGbl_MaxConcurrentAllocCount = AcpiGbl_CurrentAllocCount; + } + + AcpiGbl_CurrentAllocSize += Size; + AcpiGbl_RunningAllocSize += Size; + + if (AcpiGbl_MaxConcurrentAllocSize < AcpiGbl_CurrentAllocSize) + { + AcpiGbl_MaxConcurrentAllocSize = AcpiGbl_CurrentAllocSize; + } + + /* If the head pointer is null, create the first element and fill it in. */ + + if (NULL == AcpiGbl_HeadAllocPtr) + { + AcpiGbl_HeadAllocPtr = + (ALLOCATION_INFO *) AcpiOsCallocate (sizeof (ALLOCATION_INFO)); + + if (!AcpiGbl_HeadAllocPtr) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not allocate memory info block\n")); + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + AcpiGbl_TailAllocPtr = AcpiGbl_HeadAllocPtr; + } + + else + { + AcpiGbl_TailAllocPtr->Next = + (ALLOCATION_INFO *) AcpiOsCallocate (sizeof (ALLOCATION_INFO)); + if (!AcpiGbl_TailAllocPtr->Next) + { + DEBUG_PRINT (ACPI_ERROR, + ("Could not allocate memory info block\n")); + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* error check */ + + AcpiGbl_TailAllocPtr->Next->Previous = AcpiGbl_TailAllocPtr; + AcpiGbl_TailAllocPtr = AcpiGbl_TailAllocPtr->Next; + } + + /* + * Search list for this address to make sure it is not already on the list. + * This will catch several kinds of problems. + */ + + Element = AcpiCmSearchAllocList (Address); + if (Element) + { + REPORT_ERROR (("CmAddElementToAllocList: Address already present in list!\n")); + + DEBUG_PRINT (ACPI_ERROR, ("Element %p Address %p\n", Element, Address)); + + BREAKPOINT3; + } + + /* Fill in the instance data. */ + + AcpiGbl_TailAllocPtr->Address = Address; + AcpiGbl_TailAllocPtr->Size = Size; + AcpiGbl_TailAllocPtr->AllocType = AllocType; + AcpiGbl_TailAllocPtr->Component = Component; + AcpiGbl_TailAllocPtr->Line = Line; + + STRNCPY (AcpiGbl_TailAllocPtr->Module, Module, MAX_MODULE_NAME); + + +UnlockAndExit: + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDeleteElementFromAllocList + * + * PARAMETERS: Address - 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. + * + ****************************************************************************/ + +void +AcpiCmDeleteElementFromAllocList ( + void *Address, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + ALLOCATION_INFO *Element; + UINT32 *DwordPtr; + UINT32 DwordLen; + UINT32 Size; + UINT32 i; + + + FUNCTION_TRACE ("CmDeleteElementFromAllocList"); + + if (NULL == AcpiGbl_HeadAllocPtr) + { + /* Boy we got problems. */ + + _REPORT_ERROR (Module, Line, Component, + ("CmDeleteElementFromAllocList: Empty allocation list, nothing to free!\n")); + + return_VOID; + } + + + AcpiCmAcquireMutex (ACPI_MTX_MEMORY); + + /* Keep track of the amount of memory allocated. */ + + Size = 0; + AcpiGbl_CurrentAllocCount--; + + if (AcpiGbl_HeadAllocPtr == AcpiGbl_TailAllocPtr) + { + if (Address != AcpiGbl_HeadAllocPtr->Address) + { + _REPORT_ERROR (Module, Line, Component, + ("CmDeleteElementFromAllocList: Deleting non-allocated memory\n")); + + goto Cleanup; + } + + Size = AcpiGbl_HeadAllocPtr->Size; + + AcpiOsFree (AcpiGbl_HeadAllocPtr); + AcpiGbl_HeadAllocPtr = NULL; + AcpiGbl_TailAllocPtr = NULL; + + DEBUG_PRINT (TRACE_ALLOCATIONS, + ("_CmFree: Allocation list deleted. There are no outstanding allocations\n")); + + goto Cleanup; + } + + + /* Search list for this address */ + + Element = AcpiCmSearchAllocList (Address); + if (Element) + { + /* cases: head, tail, other */ + + if (Element == AcpiGbl_HeadAllocPtr) + { + Element->Next->Previous = NULL; + AcpiGbl_HeadAllocPtr = Element->Next; + } + + else + { + if (Element == AcpiGbl_TailAllocPtr) + { + Element->Previous->Next = NULL; + AcpiGbl_TailAllocPtr = Element->Previous; + } + + else + { + Element->Previous->Next = Element->Next; + Element->Next->Previous = Element->Previous; + } + } + + + /* Mark the segment as deleted */ + + if (Element->Size >= 4) + { + DwordLen = DIV_4 (Element->Size); + DwordPtr = (UINT32 *) Element->Address; + + for (i = 0; i < DwordLen; i++) + { + DwordPtr[i] = 0x00DEAD00; + } + + /* Set obj type, desc, and ref count fields to all ones */ + + DwordPtr[0] = ACPI_UINT32_MAX; + if (Element->Size >= 8) + { + DwordPtr[1] = ACPI_UINT32_MAX; + } + } + + Size = Element->Size; + + MEMSET (Element, 0xEA, sizeof (ALLOCATION_INFO)); + + + if (Size == sizeof (ACPI_OPERAND_OBJECT)) + { + DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmDelete: Freeing size 0x%X (ACPI_OPERAND_OBJECT)\n", Size)); + } + else + { + DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmDelete: Freeing size 0x%X\n", Size)); + } + + AcpiOsFree (Element); + } + + else + { + _REPORT_ERROR (Module, Line, Component, + ("_CmFree: Entry not found in list\n")); + DEBUG_PRINT (ACPI_ERROR, + ("_CmFree: Entry %p was not found in allocation list\n", + Address)); + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + return_VOID; + } + + +Cleanup: + + AcpiGbl_CurrentAllocSize -= Size; + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDumpAllocationInfo + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: Print some info about the outstanding allocations. + * + ****************************************************************************/ + +void +AcpiCmDumpAllocationInfo ( + void) +{ + FUNCTION_TRACE ("CmDumpAllocationInfo"); + + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current allocations", + AcpiGbl_CurrentAllocCount, + (AcpiGbl_CurrentAllocSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", + AcpiGbl_MaxConcurrentAllocCount, + (AcpiGbl_MaxConcurrentAllocSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Internal objects", + AcpiGbl_CurrentObjectCount, + (AcpiGbl_CurrentObjectSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max internal objects", + AcpiGbl_MaxConcurrentObjectCount, + (AcpiGbl_MaxConcurrentObjectSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Nodes", + AcpiGbl_CurrentNodeCount, + (AcpiGbl_CurrentNodeSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max Nodes", + AcpiGbl_MaxConcurrentNodeCount, + ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)) + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", + AcpiGbl_RunningObjectCount, + (AcpiGbl_RunningObjectSize + 1023) / 1024)); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", + AcpiGbl_RunningAllocCount, + (AcpiGbl_RunningAllocSize + 1023) / 1024)); + + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDumpCurrentAllocations + * + * 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 +AcpiCmDumpCurrentAllocations ( + UINT32 Component, + NATIVE_CHAR *Module) +{ + ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr; + UINT32 i; + + + FUNCTION_TRACE ("CmDumpCurrentAllocations"); + + + if (Element == NULL) + { + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("No outstanding allocations.\n")); + return_VOID; + } + + + /* + * Walk the allocation list. + */ + + AcpiCmAcquireMutex (ACPI_MTX_MEMORY); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("Outstanding allocations:\n")); + + for (i = 1; ; i++) /* Just a counter */ + { + if ((Element->Component & Component) && + ((Module == NULL) || (0 == STRCMP (Module, Element->Module)))) + { + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%p Len %04lX %9.9s-%ld", + Element->Address, Element->Size, Element->Module, + Element->Line)); + + /* Most of the elements will be internal objects. */ + + switch (((ACPI_OPERAND_OBJECT *) + (Element->Address))->Common.DataType) + { + case ACPI_DESC_TYPE_INTERNAL: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" ObjType %s", + AcpiCmGetTypeName (((ACPI_OPERAND_OBJECT *)(Element->Address))->Common.Type))); + break; + + case ACPI_DESC_TYPE_PARSER: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" ParseObj Opcode %04X", + ((ACPI_PARSE_OBJECT *)(Element->Address))->Opcode)); + break; + + case ACPI_DESC_TYPE_NAMED: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" Node %4.4s", + &((ACPI_NAMESPACE_NODE *)(Element->Address))->Name)); + break; + + case ACPI_DESC_TYPE_STATE: + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, + (" StateObj")); + break; + } + + DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES, ("\n")); + } + + if (Element->Next == NULL) + { + break; + } + + Element = Element->Next; + } + + AcpiCmReleaseMutex (ACPI_MTX_MEMORY); + + DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("Total number of unfreed allocations = %d\n", i)); + + return_VOID; +} + +#endif /* Debug routines for memory leak detection */ + + +/***************************************************************************** + * + * FUNCTION: _CmAllocate + * + * 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 * +_CmAllocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + void *Address = NULL; + DEBUG_EXEC (\ + ACPI_STATUS Status) + + + FUNCTION_TRACE_U32 ("_CmAllocate", Size); + + + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + _REPORT_ERROR (Module, Line, Component, + ("CmAllocate: Attempt to allocate zero bytes\n")); + Size = 1; + } + + Address = AcpiOsAllocate (Size); + if (!Address) + { + /* Report allocation error */ + + _REPORT_ERROR (Module, Line, Component, + ("CmAllocate: Could not allocate size 0x%x\n", Size)); + + return_VALUE (NULL); + } + +#ifdef ACPI_DEBUG + Status = AcpiCmAddElementToAllocList (Address, Size, MEM_MALLOC, Component, + Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Address); + return_PTR (NULL); + } + + DEBUG_PRINT (TRACE_ALLOCATIONS, + ("CmAllocate: %p Size 0x%x\n", Address, Size)); +#endif + + return_PTR (Address); +} + + +/***************************************************************************** + * + * FUNCTION: _CmCallocate + * + * 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 * +_CmCallocate ( + UINT32 Size, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + void *Address = NULL; + DEBUG_EXEC (\ + ACPI_STATUS Status) + + + FUNCTION_TRACE_U32 ("_CmCallocate", Size); + + + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + _REPORT_ERROR (Module, Line, Component, + ("CmCallocate: Attempt to allocate zero bytes\n")); + return_VALUE (NULL); + } + + + Address = AcpiOsCallocate (Size); + + if (!Address) + { + /* Report allocation error */ + + _REPORT_ERROR (Module, Line, Component, + ("CmCallocate: Could not allocate size 0x%x\n", Size)); + return_VALUE (NULL); + } + +#ifdef ACPI_DEBUG + Status = AcpiCmAddElementToAllocList (Address, Size, MEM_CALLOC, Component, + Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Address); + return_PTR (NULL); + } +#endif + + DEBUG_PRINT (TRACE_ALLOCATIONS, + ("CmCallocate: %p Size 0x%x\n", Address, Size)); + + return_PTR (Address); +} + + +/***************************************************************************** + * + * FUNCTION: _CmFree + * + * PARAMETERS: Address - 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 Address + * + ****************************************************************************/ + +void +_CmFree ( + void *Address, + UINT32 Component, + NATIVE_CHAR *Module, + UINT32 Line) +{ + FUNCTION_TRACE_PTR ("_CmFree", Address); + + + if (NULL == Address) + { + _REPORT_ERROR (Module, Line, Component, + ("_CmFree: Trying to delete a NULL address\n")); + + return_VOID; + } + +#ifdef ACPI_DEBUG + AcpiCmDeleteElementFromAllocList (Address, Component, Module, Line); +#endif + + AcpiOsFree (Address); + + DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmFree: %p freed\n", Address)); + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/utclib.c b/sys/contrib/dev/acpica/utclib.c new file mode 100644 index 0000000..24e7466 --- /dev/null +++ b/sys/contrib/dev/acpica/utclib.c @@ -0,0 +1,956 @@ +/****************************************************************************** + * + * Module Name: cmclib - Local implementation of C library functions + * $Revision: 26 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMCLIB_C__ + +#include "acpi.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" + +/* + * These implementations of standard C Library routines can optionally be + * used if a C library is not available. In general, they are less efficient + * than an inline or assembly implementation + */ + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmclib") + + +#ifdef _MSC_VER /* disable some level-4 warnings for VC++ */ +#pragma warning(disable:4706) /* warning C4706: assignment within conditional expression */ +#endif + +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +/******************************************************************************* + * + * FUNCTION: strlen + * + * PARAMETERS: String - Null terminated string + * + * RETURN: Length + * + * DESCRIPTION: Returns the length of the input string + * + ******************************************************************************/ + + +NATIVE_UINT +AcpiCmStrlen ( + const NATIVE_CHAR *String) +{ + NATIVE_UINT Length = 0; + + + /* Count the string until a null is encountered */ + + while (*String) + { + Length++; + String++; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: strcpy + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrcpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString) +{ + NATIVE_CHAR *String = DstString; + + + /* Move bytes brute force */ + + while (*SrcString) + { + *String = *SrcString; + + String++; + SrcString++; + } + + /* Null terminate */ + + *String = 0; + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: strncpy + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string, with a maximum length + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrncpy ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count) +{ + NATIVE_CHAR *String = DstString; + + + /* Copy the string */ + + for (String = DstString; + Count && (Count--, (*String++ = *SrcString++)); ) + {;} + + /* Pad with nulls if necessary */ + + while (Count--) + { + *String = 0; + String++; + } + + /* Return original pointer */ + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: strcmp + * + * PARAMETERS: String1 - First string + * String2 - Second string + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings + * + ******************************************************************************/ + +UINT32 +AcpiCmStrcmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2) +{ + + + for ( ; (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + + return ((unsigned char) *String1 - (unsigned char) *String2); +} + + +/******************************************************************************* + * + * FUNCTION: strncmp + * + * PARAMETERS: String1 - First string + * String2 - Second string + * Count - Maximum # of bytes to compare + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings, with a maximum length + * + ******************************************************************************/ + +UINT32 +AcpiCmStrncmp ( + const NATIVE_CHAR *String1, + const NATIVE_CHAR *String2, + NATIVE_UINT Count) +{ + + + for ( ; Count-- && (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((Count == -1) ? 0 : ((unsigned char) *String1 - + (unsigned char) *String2)); +} + + +/******************************************************************************* + * + * FUNCTION: Strcat + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrcat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString) +{ + NATIVE_CHAR *String; + + + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatinate the string */ + + for (--String; (*String++ = *SrcString++); ) + { ; } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: strncat + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string, + * with a maximum count. + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrncat ( + NATIVE_CHAR *DstString, + const NATIVE_CHAR *SrcString, + NATIVE_UINT Count) +{ + NATIVE_CHAR *String; + + + if (Count) + { + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatinate the string */ + + for (--String; (*String++ = *SrcString++) && --Count; ) + { ; } + + /* Null terminate if necessary */ + + if (!Count) + { + *String = 0; + } + } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: memcpy + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +AcpiCmMemcpy ( + void *Dest, + const void *Src, + NATIVE_UINT Count) +{ + NATIVE_CHAR *New = (NATIVE_CHAR *) Dest; + NATIVE_CHAR *Old = (NATIVE_CHAR *) Src; + + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: memset + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +AcpiCmMemset ( + void *Dest, + UINT32 Value, + NATIVE_UINT Count) +{ + NATIVE_CHAR *New = (NATIVE_CHAR *) Dest; + + + while (Count) + { + *New = (char) Value; + New++; + Count--; + } + + return (Dest); +} + + +#define NEGATIVE 1 +#define POSITIVE 0 + + +#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ +#define _ACPI_XS 0x40 /* extra space */ +#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ +#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ +#define _ACPI_DI 0x04 /* '0'-'9' */ +#define _ACPI_LO 0x02 /* 'a'-'z' */ +#define _ACPI_PU 0x10 /* punctuation */ +#define _ACPI_SP 0x08 /* space */ +#define _ACPI_UP 0x01 /* 'A'-'Z' */ +#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +static const UINT8 _acpi_ctype[257] = { + _ACPI_CN, /* 0x0 0. */ + _ACPI_CN, /* 0x1 1. */ + _ACPI_CN, /* 0x2 2. */ + _ACPI_CN, /* 0x3 3. */ + _ACPI_CN, /* 0x4 4. */ + _ACPI_CN, /* 0x5 5. */ + _ACPI_CN, /* 0x6 6. */ + _ACPI_CN, /* 0x7 7. */ + _ACPI_CN, /* 0x8 8. */ + _ACPI_CN|_ACPI_SP, /* 0x9 9. */ + _ACPI_CN|_ACPI_SP, /* 0xA 10. */ + _ACPI_CN|_ACPI_SP, /* 0xB 11. */ + _ACPI_CN|_ACPI_SP, /* 0xC 12. */ + _ACPI_CN|_ACPI_SP, /* 0xD 13. */ + _ACPI_CN, /* 0xE 14. */ + _ACPI_CN, /* 0xF 15. */ + _ACPI_CN, /* 0x10 16. */ + _ACPI_CN, /* 0x11 17. */ + _ACPI_CN, /* 0x12 18. */ + _ACPI_CN, /* 0x13 19. */ + _ACPI_CN, /* 0x14 20. */ + _ACPI_CN, /* 0x15 21. */ + _ACPI_CN, /* 0x16 22. */ + _ACPI_CN, /* 0x17 23. */ + _ACPI_CN, /* 0x18 24. */ + _ACPI_CN, /* 0x19 25. */ + _ACPI_CN, /* 0x1A 26. */ + _ACPI_CN, /* 0x1B 27. */ + _ACPI_CN, /* 0x1C 28. */ + _ACPI_CN, /* 0x1D 29. */ + _ACPI_CN, /* 0x1E 30. */ + _ACPI_CN, /* 0x1F 31. */ + _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ + _ACPI_PU, /* 0x21 33. '!' */ + _ACPI_PU, /* 0x22 34. '"' */ + _ACPI_PU, /* 0x23 35. '#' */ + _ACPI_PU, /* 0x24 36. '$' */ + _ACPI_PU, /* 0x25 37. '%' */ + _ACPI_PU, /* 0x26 38. '&' */ + _ACPI_PU, /* 0x27 39. ''' */ + _ACPI_PU, /* 0x28 40. '(' */ + _ACPI_PU, /* 0x29 41. ')' */ + _ACPI_PU, /* 0x2A 42. '*' */ + _ACPI_PU, /* 0x2B 43. '+' */ + _ACPI_PU, /* 0x2C 44. ',' */ + _ACPI_PU, /* 0x2D 45. '-' */ + _ACPI_PU, /* 0x2E 46. '.' */ + _ACPI_PU, /* 0x2F 47. '/' */ + _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ + _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ + _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ + _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ + _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ + _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ + _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ + _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ + _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ + _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ + _ACPI_PU, /* 0x3A 58. ':' */ + _ACPI_PU, /* 0x3B 59. ';' */ + _ACPI_PU, /* 0x3C 60. '<' */ + _ACPI_PU, /* 0x3D 61. '=' */ + _ACPI_PU, /* 0x3E 62. '>' */ + _ACPI_PU, /* 0x3F 63. '?' */ + _ACPI_PU, /* 0x40 64. '@' */ + _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ + _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ + _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ + _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ + _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ + _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ + _ACPI_UP, /* 0x47 71. 'G' */ + _ACPI_UP, /* 0x48 72. 'H' */ + _ACPI_UP, /* 0x49 73. 'I' */ + _ACPI_UP, /* 0x4A 74. 'J' */ + _ACPI_UP, /* 0x4B 75. 'K' */ + _ACPI_UP, /* 0x4C 76. 'L' */ + _ACPI_UP, /* 0x4D 77. 'M' */ + _ACPI_UP, /* 0x4E 78. 'N' */ + _ACPI_UP, /* 0x4F 79. 'O' */ + _ACPI_UP, /* 0x50 80. 'P' */ + _ACPI_UP, /* 0x51 81. 'Q' */ + _ACPI_UP, /* 0x52 82. 'R' */ + _ACPI_UP, /* 0x53 83. 'S' */ + _ACPI_UP, /* 0x54 84. 'T' */ + _ACPI_UP, /* 0x55 85. 'U' */ + _ACPI_UP, /* 0x56 86. 'V' */ + _ACPI_UP, /* 0x57 87. 'W' */ + _ACPI_UP, /* 0x58 88. 'X' */ + _ACPI_UP, /* 0x59 89. 'Y' */ + _ACPI_UP, /* 0x5A 90. 'Z' */ + _ACPI_PU, /* 0x5B 91. '[' */ + _ACPI_PU, /* 0x5C 92. '\' */ + _ACPI_PU, /* 0x5D 93. ']' */ + _ACPI_PU, /* 0x5E 94. '^' */ + _ACPI_PU, /* 0x5F 95. '_' */ + _ACPI_PU, /* 0x60 96. '`' */ + _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ + _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ + _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ + _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ + _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ + _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ + _ACPI_LO, /* 0x67 103. 'g' */ + _ACPI_LO, /* 0x68 104. 'h' */ + _ACPI_LO, /* 0x69 105. 'i' */ + _ACPI_LO, /* 0x6A 106. 'j' */ + _ACPI_LO, /* 0x6B 107. 'k' */ + _ACPI_LO, /* 0x6C 108. 'l' */ + _ACPI_LO, /* 0x6D 109. 'm' */ + _ACPI_LO, /* 0x6E 110. 'n' */ + _ACPI_LO, /* 0x6F 111. 'o' */ + _ACPI_LO, /* 0x70 112. 'p' */ + _ACPI_LO, /* 0x71 113. 'q' */ + _ACPI_LO, /* 0x72 114. 'r' */ + _ACPI_LO, /* 0x73 115. 's' */ + _ACPI_LO, /* 0x74 116. 't' */ + _ACPI_LO, /* 0x75 117. 'u' */ + _ACPI_LO, /* 0x76 118. 'v' */ + _ACPI_LO, /* 0x77 119. 'w' */ + _ACPI_LO, /* 0x78 120. 'x' */ + _ACPI_LO, /* 0x79 121. 'y' */ + _ACPI_LO, /* 0x7A 122. 'z' */ + _ACPI_PU, /* 0x7B 123. '{' */ + _ACPI_PU, /* 0x7C 124. '|' */ + _ACPI_PU, /* 0x7D 125. '}' */ + _ACPI_PU, /* 0x7E 126. '~' */ + _ACPI_CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + +#define IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) +#define IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) +#define IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) +#define IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) + + +/******************************************************************************* + * + * FUNCTION: AcpiCmToUpper + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +UINT32 +AcpiCmToUpper ( + UINT32 c) +{ + + return (IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmToLower + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +UINT32 +AcpiCmToLower ( + UINT32 c) +{ + + return (IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: strupr + * + * PARAMETERS: SrcString - The source string to convert to + * + * RETURN: SrcString + * + * DESCRIPTION: Convert string to uppercase + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrupr ( + NATIVE_CHAR *SrcString) +{ + NATIVE_CHAR *String; + + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; ) + { + *String = (char) AcpiCmToUpper (*String); + String++; + } + + + return (SrcString); +} + + +/******************************************************************************* + * + * FUNCTION: strstr + * + * PARAMETERS: String1 - + * String2 + * + * RETURN: + * + * DESCRIPTION: Checks if String2 occurs in String1. This is not really a + * full implementation of strstr, only sufficient for command + * matching + * + ******************************************************************************/ + +NATIVE_CHAR * +AcpiCmStrstr ( + NATIVE_CHAR *String1, + NATIVE_CHAR *String2) +{ + NATIVE_CHAR *String; + + + if (AcpiCmStrlen (String2) > AcpiCmStrlen (String1)) + { + return (NULL); + } + + /* Walk entire string, uppercasing the letters */ + + for (String = String1; *String2; ) + { + if (*String2 != *String) + { + return (NULL); + } + + String2++; + String++; + } + + + return (String1); +} + + +/******************************************************************************* + * + * FUNCTION: strtoul + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte is returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. + * + ******************************************************************************/ + +UINT32 +AcpiCmStrtoul ( + const NATIVE_CHAR *String, + NATIVE_CHAR **Terminator, + UINT32 Base) +{ + UINT32 converted = 0; + UINT32 index; + UINT32 sign; + const NATIVE_CHAR *StringStart; + UINT32 ReturnValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* + * Save the value of the pointer to the buffer's first + * character, save the current errno value, and then + * skip over any white space in the buffer: + */ + StringStart = String; + while (IS_SPACE (*String) || *String == '\t') + { + ++String; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*String == '-') + { + sign = NEGATIVE; + ++String; + } + + else if (*String == '+') + { + ++String; + sign = POSITIVE; + } + + else + { + sign = POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (Base == 0) + { + if (*String == '0') + { + if (AcpiCmToLower (*(++String)) == 'x') + { + Base = 16; + ++String; + } + + else + { + Base = 8; + } + } + + else + { + Base = 10; + } + } + + else if (Base < 2 || Base > 36) + { + /* + * The specified Base parameter is not in the domain of + * this function: + */ + goto done; + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (Base == 8 && *String == '0') + { + String++; + } + + if (Base == 16 && + *String == '0' && + AcpiCmToLower (*(++String)) == 'x') + { + String++; + } + + + /* + * Main loop: convert the string to an unsigned long: + */ + while (*String) + { + if (IS_DIGIT (*String)) + { + index = *String - '0'; + } + + else + { + index = AcpiCmToUpper (*String); + if (IS_UPPER (index)) + { + index = index - 'A' + 10; + } + + else + { + goto done; + } + } + + if (index >= Base) + { + goto done; + } + + /* + * Check to see if value is out of range: + */ + + if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) / + (UINT32) Base)) + { + Status = AE_ERROR; + ReturnValue = 0L; /* reset */ + } + + else + { + ReturnValue *= Base; + ReturnValue += index; + converted = 1; + } + + ++String; + } + +done: + /* + * If appropriate, update the caller's pointer to the next + * unconverted character in the buffer. + */ + if (Terminator) + { + if (converted == 0 && ReturnValue == 0L && String != NULL) + { + *Terminator = (NATIVE_CHAR *) StringStart; + } + + else + { + *Terminator = (NATIVE_CHAR *) String; + } + } + + if (Status == AE_ERROR) + { + ReturnValue = ACPI_UINT32_MAX; + } + + /* + * If a minus sign was present, then "the conversion is negated": + */ + if (sign == NEGATIVE) + { + ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + } + + return (ReturnValue); +} + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + diff --git a/sys/contrib/dev/acpica/utcopy.c b/sys/contrib/dev/acpica/utcopy.c new file mode 100644 index 0000000..e7f36c5 --- /dev/null +++ b/sys/contrib/dev/acpica/utcopy.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: cmcopy - Internal to external object translation utilities + * $Revision: 56 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMCOPY_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmcopy") + + +typedef struct Search_st +{ + ACPI_OPERAND_OBJECT *InternalObj; + UINT32 Index; + ACPI_OBJECT *ExternalObj; + +} PKG_SEARCH_INFO; + + +/* Used to traverse nested packages */ + +PKG_SEARCH_INFO Level[MAX_PACKAGE_DEPTH]; + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildExternalSimpleObject + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *Buffer - Where the object is returned + * *SpaceUsed - Where the data length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to place a simple object in a user + * buffer. + * + * The buffer is assumed to have sufficient space for the object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildExternalSimpleObject ( + ACPI_OPERAND_OBJECT *InternalObj, + ACPI_OBJECT *ExternalObj, + UINT8 *DataSpace, + UINT32 *BufferSpaceUsed) +{ + UINT32 Length = 0; + UINT8 *SourcePtr = NULL; + + + FUNCTION_TRACE ("CmBuildExternalSimpleObject"); + + + /* + * Check for NULL object case (could be an uninitialized + * package element + */ + + if (!InternalObj) + { + *BufferSpaceUsed = 0; + return_ACPI_STATUS (AE_OK); + } + + /* Always clear the external object */ + + MEMSET (ExternalObj, 0, sizeof (ACPI_OBJECT)); + + /* + * In general, the external object will be the same type as + * the internal object + */ + + ExternalObj->Type = InternalObj->Common.Type; + + /* However, only a limited number of external types are supported */ + + switch (ExternalObj->Type) + { + + case ACPI_TYPE_STRING: + + Length = InternalObj->String.Length; + ExternalObj->String.Length = InternalObj->String.Length; + ExternalObj->String.Pointer = (NATIVE_CHAR *) DataSpace; + SourcePtr = (UINT8 *) InternalObj->String.Pointer; + break; + + + case ACPI_TYPE_BUFFER: + + Length = InternalObj->Buffer.Length; + ExternalObj->Buffer.Length = InternalObj->Buffer.Length; + ExternalObj->Buffer.Pointer = DataSpace; + SourcePtr = (UINT8 *) InternalObj->Buffer.Pointer; + break; + + + case ACPI_TYPE_NUMBER: + + ExternalObj->Number.Value= InternalObj->Number.Value; + break; + + + case INTERNAL_TYPE_REFERENCE: + + /* + * This is an object reference. We use the object type of "Any" + * to indicate a reference object containing a handle to an ACPI + * named object. + */ + + ExternalObj->Type = ACPI_TYPE_ANY; + ExternalObj->Reference.Handle = InternalObj->Reference.Node; + break; + + + case ACPI_TYPE_PROCESSOR: + + ExternalObj->Processor.ProcId = + InternalObj->Processor.ProcId; + + ExternalObj->Processor.PblkAddress = + InternalObj->Processor.Address; + + ExternalObj->Processor.PblkLength = + InternalObj->Processor.Length; + break; + + case ACPI_TYPE_POWER: + + ExternalObj->PowerResource.SystemLevel = + InternalObj->PowerResource.SystemLevel; + + ExternalObj->PowerResource.ResourceOrder = + InternalObj->PowerResource.ResourceOrder; + break; + + default: + return_ACPI_STATUS (AE_CTRL_RETURN_VALUE); + break; + } + + + /* Copy data if necessary (strings or buffers) */ + + if (Length) + { + /* + * Copy the return data to the caller's buffer + */ + MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length); + } + + + *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildExternalPackageObject + * + * PARAMETERS: *InternalObj - Pointer to the object we are returning + * *Buffer - Where the object is returned + * *SpaceUsed - Where the object length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to place a package object in a user + * buffer. A package object by definition contains other objects. + * + * The buffer is assumed to have sufficient space for the object. + * The caller must have verified the buffer length needed using the + * AcpiCmGetObjectSize function before calling this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildExternalPackageObject ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT8 *Buffer, + UINT32 *SpaceUsed) +{ + UINT8 *FreeSpace; + ACPI_OBJECT *ExternalObj; + UINT32 CurrentDepth = 0; + ACPI_STATUS Status; + UINT32 Length = 0; + UINT32 ThisIndex; + UINT32 ObjectSpace; + ACPI_OPERAND_OBJECT *ThisInternalObj; + ACPI_OBJECT *ThisExternalObj; + PKG_SEARCH_INFO *LevelPtr; + + + FUNCTION_TRACE ("CmBuildExternalPackageObject"); + + + /* + * First package at head of the buffer + */ + ExternalObj = (ACPI_OBJECT *) Buffer; + + /* + * Free space begins right after the first package + */ + FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + + + /* + * Initialize the working variables + */ + + MEMSET ((void *) Level, 0, sizeof (Level)); + + Level[0].InternalObj = InternalObj; + Level[0].ExternalObj = ExternalObj; + Level[0].Index = 0; + LevelPtr = &Level[0]; + CurrentDepth = 0; + + ExternalObj->Type = InternalObj->Common.Type; + ExternalObj->Package.Count = InternalObj->Package.Count; + ExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; + + + /* + * Build an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + + FreeSpace += ExternalObj->Package.Count * + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + + + while (1) + { + ThisIndex = LevelPtr->Index; + ThisInternalObj = + (ACPI_OPERAND_OBJECT *) + LevelPtr->InternalObj->Package.Elements[ThisIndex]; + ThisExternalObj = + (ACPI_OBJECT *) + &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; + + + /* + * Check for + * 1) Null object -- OK, this can happen if package + * element is never initialized + * 2) Not an internal object - can be Node instead + * 3) Any internal object other than a package. + * + * The more complex package case is handled later + */ + + if ((!ThisInternalObj) || + (!VALID_DESCRIPTOR_TYPE ( + ThisInternalObj, ACPI_DESC_TYPE_INTERNAL)) || + (!IS_THIS_OBJECT_TYPE ( + ThisInternalObj, ACPI_TYPE_PACKAGE))) + { + /* + * This is a simple or null object -- get the size + */ + + Status = + AcpiCmBuildExternalSimpleObject (ThisInternalObj, + ThisExternalObj, + FreeSpace, + &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + LevelPtr->Index++; + while (LevelPtr->Index >= + LevelPtr->InternalObj->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 + */ + if (CurrentDepth == 0) + { + /* + * We have handled all of the objects + * in the top level package just add + * the length of the package objects + * and get out + */ + *SpaceUsed = Length; + return_ACPI_STATUS (AE_OK); + } + + /* + * go back up a level and move the index + * past the just completed package object. + */ + CurrentDepth--; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->Index++; + } + } + + + else + { + /* + * This object is a package + * -- we must go one level deeper + */ + if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) + { + /* + * Too many nested levels of packages + * for us to handle + */ + DEBUG_PRINT (ACPI_ERROR, + ("CmBuildPackageObject: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* + * Build the package object + */ + ThisExternalObj->Type = ACPI_TYPE_PACKAGE; + ThisExternalObj->Package.Count = + ThisInternalObj->Package.Count; + ThisExternalObj->Package.Elements = + (ACPI_OBJECT *) FreeSpace; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD ( + ThisExternalObj->Package.Count * + sizeof (ACPI_OBJECT)); + + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + CurrentDepth++; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->InternalObj = ThisInternalObj; + LevelPtr->ExternalObj = ThisExternalObj; + LevelPtr->Index = 0; + } + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildExternalObject + * + * PARAMETERS: *InternalObj - The internal object to be converted + * *BufferPtr - Where the object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to build an API object to be returned to + * the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildExternalObject ( + ACPI_OPERAND_OBJECT *InternalObj, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmBuildExternalObject"); + + + if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE)) + { + /* + * Package objects contain other objects (which can be objects) + * buildpackage does it all + */ + Status = + AcpiCmBuildExternalPackageObject (InternalObj, + RetBuffer->Pointer, + &RetBuffer->Length); + } + + else + { + /* + * Build a simple object (no nested objects) + */ + Status = + AcpiCmBuildExternalSimpleObject (InternalObj, + (ACPI_OBJECT *) RetBuffer->Pointer, + ((UINT8 *) RetBuffer->Pointer + + 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: AcpiCmBuildInternalSimpleObject + * + * PARAMETERS: *ExternalObj - The external object to be converted + * *InternalObj - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function copies an external object to an internal one. + * NOTE: Pointers can be copied, we don't need to copy data. + * (The pointers have to be valid in our address space no matter + * what we do with them!) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildInternalSimpleObject ( + ACPI_OBJECT *ExternalObj, + ACPI_OPERAND_OBJECT *InternalObj) +{ + + FUNCTION_TRACE ("CmBuildInternalSimpleObject"); + + + InternalObj->Common.Type = (UINT8) ExternalObj->Type; + + switch (ExternalObj->Type) + { + + case ACPI_TYPE_STRING: + + InternalObj->String.Length = ExternalObj->String.Length; + InternalObj->String.Pointer = ExternalObj->String.Pointer; + break; + + + case ACPI_TYPE_BUFFER: + + InternalObj->Buffer.Length = ExternalObj->Buffer.Length; + InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer; + break; + + + case ACPI_TYPE_NUMBER: + /* + * Number is included in the object itself + */ + InternalObj->Number.Value = ExternalObj->Number.Value; + break; + + + default: + return_ACPI_STATUS (AE_CTRL_RETURN_VALUE); + break; + } + + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildInternalPackageObject + * + * PARAMETERS: *InternalObj - Pointer to the object we are returning + * *Buffer - Where the object is returned + * *SpaceUsed - Where the length of the object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to place a package object in a user + * buffer. A package object by definition contains other objects. + * + * The buffer is assumed to have sufficient space for the object. + * The caller must have verified the buffer length needed using the + * AcpiCmGetObjectSize function before calling this function. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildInternalPackageObject ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT8 *Buffer, + UINT32 *SpaceUsed) +{ + UINT8 *FreeSpace; + ACPI_OBJECT *ExternalObj; + UINT32 CurrentDepth = 0; + UINT32 Length = 0; + UINT32 ThisIndex; + UINT32 ObjectSpace = 0; + ACPI_OPERAND_OBJECT *ThisInternalObj; + ACPI_OBJECT *ThisExternalObj; + PKG_SEARCH_INFO *LevelPtr; + + + FUNCTION_TRACE ("CmBuildInternalPackageObject"); + + + /* + * First package at head of the buffer + */ + ExternalObj = (ACPI_OBJECT *)Buffer; + + /* + * Free space begins right after the first package + */ + FreeSpace = Buffer + sizeof(ACPI_OBJECT); + + + /* + * Initialize the working variables + */ + + MEMSET ((void *) Level, 0, sizeof(Level)); + + Level[0].InternalObj = InternalObj; + Level[0].ExternalObj = ExternalObj; + LevelPtr = &Level[0]; + CurrentDepth = 0; + + ExternalObj->Type = InternalObj->Common.Type; + ExternalObj->Package.Count = InternalObj->Package.Count; + ExternalObj->Package.Elements = (ACPI_OBJECT *)FreeSpace; + + + /* + * Build an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + + FreeSpace += ExternalObj->Package.Count * sizeof(ACPI_OBJECT); + + + while (1) + { + ThisIndex = LevelPtr->Index; + + ThisInternalObj = (ACPI_OPERAND_OBJECT *) + &LevelPtr->InternalObj->Package.Elements[ThisIndex]; + + ThisExternalObj = (ACPI_OBJECT *) + &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; + + if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE)) + { + /* + * If this object is a package then we go one deeper + */ + if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) + { + /* + * Too many nested levels of packages for us to handle + */ + DEBUG_PRINT (ACPI_ERROR, + ("CmBuildPackageObject: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* + * Build the package object + */ + ThisExternalObj->Type = ACPI_TYPE_PACKAGE; + ThisExternalObj->Package.Count = ThisInternalObj->Package.Count; + ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = ThisExternalObj->Package.Count * + sizeof (ACPI_OBJECT); + + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + CurrentDepth++; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->InternalObj = ThisInternalObj; + LevelPtr->ExternalObj = ThisExternalObj; + LevelPtr->Index = 0; + + } /* if object is a package */ + + else + { + FreeSpace += ObjectSpace; + Length += ObjectSpace; + + LevelPtr->Index++; + while (LevelPtr->Index >= + LevelPtr->InternalObj->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 + */ + if (CurrentDepth == 0) + { + /* + * We have handled all of the objects + * in the top level package just add + * the length of the package objects + * and get out + */ + *SpaceUsed = Length; + return_ACPI_STATUS (AE_OK); + } + + /* + * go back up a level and move the index + * past the just completed package object. + */ + CurrentDepth--; + LevelPtr = &Level[CurrentDepth]; + LevelPtr->Index++; + } + } /* else object is NOT a package */ + } /* while (1) */ +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmBuildInternalObject + * + * PARAMETERS: *InternalObj - The external object to be converted + * *BufferPtr - Where the internal object is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: Converts an external object to an internal object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmBuildInternalObject ( + ACPI_OBJECT *ExternalObj, + ACPI_OPERAND_OBJECT *InternalObj) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmBuildInternalObject"); + + + if (ExternalObj->Type == ACPI_TYPE_PACKAGE) + { + /* + * Package objects contain other objects (which can be objects) + * buildpackage does it all + */ +/* + Status = AcpiCmBuildInternalPackageObject(InternalObj, + RetBuffer->Pointer, + &RetBuffer->Length); +*/ + DEBUG_PRINT (ACPI_ERROR, + ("CmBuildInternalObject: Packages as parameters not implemented!\n")); + + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiCmBuildInternalSimpleObject (ExternalObj, InternalObj); + /* + * build simple does not include the object size in the length + * so we add it in here + */ + } + + return_ACPI_STATUS (Status); +} + diff --git a/sys/contrib/dev/acpica/utdebug.c b/sys/contrib/dev/acpica/utdebug.c new file mode 100644 index 0000000..e9a4f5b --- /dev/null +++ b/sys/contrib/dev/acpica/utdebug.c @@ -0,0 +1,657 @@ +/****************************************************************************** + * + * Module Name: cmdebug - Debug print routines + * $Revision: 60 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMDEBUG_C__ + +#include "acpi.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmdebug") + + +/***************************************************************************** + * + * FUNCTION: Get/Set debug level + * + * DESCRIPTION: Get or set value of the debug flag + * + * These are used to allow user's to get/set the debug level + * + ****************************************************************************/ + + +UINT32 +GetDebugLevel (void) +{ + + return (AcpiDbgLevel); +} + +void +SetDebugLevel ( + UINT32 NewDebugLevel) +{ + + AcpiDbgLevel = NewDebugLevel; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTrace + * + * 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) + * FunctionName - Name of Caller's function + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTrace ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName) +{ + + AcpiGbl_NestingLevel++; + + DebugPrint (ModuleName, LineNumber, ComponentId, + TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s\n", + AcpiGbl_NestingLevel, FunctionName); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTracePtr + * + * 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) + * FunctionName - Name of Caller's function + * Pointer - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTracePtr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + void *Pointer) +{ + + AcpiGbl_NestingLevel++; + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s, 0x%p\n", + AcpiGbl_NestingLevel, FunctionName, Pointer); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTraceStr + * + * 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) + * FunctionName - Name of Caller's function + * String - Additional string to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTraceStr ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_CHAR *String) +{ + + AcpiGbl_NestingLevel++; + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s, %s\n", + AcpiGbl_NestingLevel, FunctionName, String); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionTraceU32 + * + * 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) + * FunctionName - Name of Caller's function + * Integer - Integer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionTraceU32 ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT32 Integer) +{ + + AcpiGbl_NestingLevel++; + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Entered Function: %s, 0x%lX\n", + AcpiGbl_NestingLevel, FunctionName, Integer); +} + + +/***************************************************************************** + * + * FUNCTION: FunctionExit + * + * 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) + * FunctionName - Name of Caller's function + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ****************************************************************************/ + +void +FunctionExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s\n", + AcpiGbl_NestingLevel, FunctionName); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionStatusExit + * + * 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) + * FunctionName - Name of Caller's function + * 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 +FunctionStatusExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + ACPI_STATUS Status) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, + TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s, %s\n", + AcpiGbl_NestingLevel, + FunctionName, + AcpiCmFormatException (Status)); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionValueExit + * + * 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) + * FunctionName - Name of Caller's function + * 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 +FunctionValueExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + NATIVE_UINT Value) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s, 0x%X\n", + AcpiGbl_NestingLevel, FunctionName, Value); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: FunctionPtrExit + * + * 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) + * FunctionName - Name of Caller's function + * 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 +FunctionPtrExit ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + NATIVE_CHAR *FunctionName, + UINT8 *Ptr) +{ + + DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s, 0x%p\n", + AcpiGbl_NestingLevel, FunctionName, Ptr); + + AcpiGbl_NestingLevel--; +} + + +/***************************************************************************** + * + * FUNCTION: DebugPrint + * + * 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) + * PrintLevel - Requested debug print level + * 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 +DebugPrint ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + UINT32 PrintLevel, + NATIVE_CHAR *Format, + ...) +{ + va_list args; + + + /* Both the level and the component must be enabled */ + + if ((PrintLevel & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer)) + { + va_start (args, Format); + + AcpiOsPrintf ("%8s-%04d: ", ModuleName, LineNumber); + AcpiOsVprintf (Format, args); + } +} + + +/***************************************************************************** + * + * FUNCTION: DebugPrintPrefix + * + * 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: None + * + * DESCRIPTION: Print the prefix part of an error message, consisting of the + * module name, and line number + * + ****************************************************************************/ + +void +DebugPrintPrefix ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber) +{ + + + AcpiOsPrintf ("%8s-%04d: ", ModuleName, LineNumber); +} + + +/***************************************************************************** + * + * FUNCTION: DebugPrintRaw + * + * PARAMETERS: Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print error message -- without module/line indentifiers + * + ****************************************************************************/ + +void +DebugPrintRaw ( + NATIVE_CHAR *Format, + ...) +{ + va_list args; + + + va_start (args, Format); + + AcpiOsVprintf (Format, args); + + va_end (args); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ****************************************************************************/ + +void +AcpiCmDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 ComponentId) +{ + UINT32 i = 0; + UINT32 j; + UINT32 Temp32; + UINT8 BufChar; + + + /* Only dump the buffer if tracing is enabled */ + + if (!((TRACE_TABLES & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer))) + { + return; + } + + + /* + * Nasty little dump buffer routine! + */ + while (i < Count) + { + /* Print current offset */ + + AcpiOsPrintf ("%05X ", i); + + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Count) + { + AcpiOsPrintf ("\n"); + return; + } + + /* Make sure that the INT8 doesn't get sign-extended! */ + + switch (Display) + { + /* Default is BYTE display */ + + default: + + AcpiOsPrintf ("%02X ", + *((UINT8 *) &Buffer[i + j])); + j += 1; + break; + + + case DB_WORD_DISPLAY: + + MOVE_UNALIGNED16_TO_32 (&Temp32, + &Buffer[i + j]); + AcpiOsPrintf ("%04X ", Temp32); + j += 2; + break; + + + case DB_DWORD_DISPLAY: + + MOVE_UNALIGNED32_TO_32 (&Temp32, + &Buffer[i + j]); + AcpiOsPrintf ("%08X ", Temp32); + j += 4; + break; + + + case DB_QWORD_DISPLAY: + + MOVE_UNALIGNED32_TO_32 (&Temp32, + &Buffer[i + j]); + AcpiOsPrintf ("%08X", Temp32); + + MOVE_UNALIGNED32_TO_32 (&Temp32, + &Buffer[i + j + 4]); + AcpiOsPrintf ("%08X ", Temp32); + j += 8; + break; + } + } + + + /* + * Print the ASCII equivalent characters + * But watch out for the bad unprintable ones... + */ + + for (j = 0; j < 16; j++) + { + if (i + j >= Count) + { + AcpiOsPrintf ("\n"); + return; + } + + BufChar = Buffer[i + j]; + if ((BufChar > 0x1F && BufChar < 0x2E) || + (BufChar > 0x2F && BufChar < 0x61) || + (BufChar > 0x60 && BufChar < 0x7F)) + { + AcpiOsPrintf ("%c", BufChar); + } + else + { + AcpiOsPrintf ("."); + } + } + + /* Done with that line. */ + + AcpiOsPrintf ("\n"); + i += 16; + } + + return; +} + + diff --git a/sys/contrib/dev/acpica/utdelete.c b/sys/contrib/dev/acpica/utdelete.c new file mode 100644 index 0000000..bce5e2e --- /dev/null +++ b/sys/contrib/dev/acpica/utdelete.c @@ -0,0 +1,806 @@ +/******************************************************************************* + * + * Module Name: cmdelete - object deletion and reference count utilities + * $Revision: 57 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMDELETE_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acparser.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmdelete") + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteInternalObj + * + * PARAMETERS: *Object - Pointer to the list to be deleted + * + * RETURN: None + * + * DESCRIPTION: Low level object deletion, after reference counts have been + * updated (All reference counts, including sub-objects!) + * + ******************************************************************************/ + +void +AcpiCmDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object) +{ + void *ObjPointer = NULL; + ACPI_OPERAND_OBJECT *HandlerDesc; + + + FUNCTION_TRACE_PTR ("CmDeleteInternalObj", 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: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: **** String %p, ptr %p\n", + Object, Object->String.Pointer)); + + /* Free the actual string buffer */ + + ObjPointer = Object->String.Pointer; + break; + + + case ACPI_TYPE_BUFFER: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: **** Buffer %p, ptr %p\n", + Object, Object->Buffer.Pointer)); + + /* Free the actual buffer */ + + ObjPointer = Object->Buffer.Pointer; + break; + + + case ACPI_TYPE_PACKAGE: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: **** Package of count %d\n", + Object->Package.Count)); + + /* + * Elements of the package are not handled here, they are deleted + * separately + */ + + /* Free the (variable length) element pointer array */ + + ObjPointer = Object->Package.Elements; + break; + + + case ACPI_TYPE_MUTEX: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Mutex %p, Semaphore %p\n", + Object, Object->Mutex.Semaphore)); + + AcpiOsDeleteSemaphore (Object->Mutex.Semaphore); + break; + + + case ACPI_TYPE_EVENT: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Event %p, Semaphore %p\n", + Object, Object->Event.Semaphore)); + + AcpiOsDeleteSemaphore (Object->Event.Semaphore); + Object->Event.Semaphore = NULL; + break; + + + case ACPI_TYPE_METHOD: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Method %p\n", Object)); + + /* Delete the method semaphore if it exists */ + + if (Object->Method.Semaphore) + { + AcpiOsDeleteSemaphore (Object->Method.Semaphore); + Object->Method.Semaphore = NULL; + } + + break; + + + case ACPI_TYPE_REGION: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** Region %p\n", + Object)); + + + if (Object->Region.Extra) + { + /* + * Free the RegionContext if and only if the handler is one of the + * default handlers -- and therefore, we created the context object + * locally, it was not created by an external caller. + */ + HandlerDesc = Object->Region.AddrHandler; + if ((HandlerDesc) && + (HandlerDesc->AddrHandler.Hflags == ADDR_HANDLER_DEFAULT_INSTALLED)) + { + ObjPointer = Object->Region.Extra->Extra.RegionContext; + } + + /* Now we can free the Extra object */ + + AcpiCmDeleteObjectDesc (Object->Region.Extra); + } + break; + + + case ACPI_TYPE_FIELD_UNIT: + + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: ***** FieldUnit %p\n", + Object)); + + if (Object->FieldUnit.Extra) + { + AcpiCmDeleteObjectDesc (Object->FieldUnit.Extra); + } + break; + + default: + break; + } + + + /* + * Delete any allocated memory found above + */ + + if (ObjPointer) + { + if (!AcpiTbSystemTablePointer (ObjPointer)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: Deleting Obj Ptr %p \n", ObjPointer)); + + AcpiCmFree (ObjPointer); + } + } + + + /* Only delete the object if it was dynamically allocated */ + + if (Object->Common.Flags & AOPOBJ_STATIC_ALLOCATION) + { + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: Object %p [%s] static allocation, no delete\n", + Object, AcpiCmGetTypeName (Object->Common.Type))); + } + + if (!(Object->Common.Flags & AOPOBJ_STATIC_ALLOCATION)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmDeleteInternalObj: Deleting object %p [%s]\n", + Object, AcpiCmGetTypeName (Object->Common.Type))); + + AcpiCmDeleteObjectDesc (Object); + + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteInternalObjectList + * + * PARAMETERS: *ObjList - Pointer to the list to be deleted + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function deletes an internal object list, including both + * simple objects and package objects + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList) +{ + ACPI_OPERAND_OBJECT **InternalObj; + + + FUNCTION_TRACE ("CmDeleteInternalObjectList"); + + + /* Walk the null-terminated internal list */ + + for (InternalObj = ObjList; *InternalObj; InternalObj++) + { + /* + * Check for a package + * Simple objects are simply stored in the array and do not + * need to be deleted separately. + */ + + if (IS_THIS_OBJECT_TYPE ((*InternalObj), ACPI_TYPE_PACKAGE)) + { + /* Delete the package */ + + /* + * TBD: [Investigate] This might not be the right thing to do, + * depending on how the internal package object was allocated!!! + */ + AcpiCmDeleteInternalObj (*InternalObj); + } + + } + + /* Free the combined parameter pointer list and object array */ + + AcpiCmFree (ObjList); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmUpdateRefCount + * + * 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. + * + ******************************************************************************/ + +void +AcpiCmUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action) +{ + UINT16 Count; + UINT16 NewCount; + + + if (!Object) + { + return; + } + + + Count = Object->Common.ReferenceCount; + NewCount = Count; + + /* + * Reference count action (increment, decrement, or force delete) + */ + + switch (Action) + { + + case REF_INCREMENT: + + NewCount++; + Object->Common.ReferenceCount = NewCount; + + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, [Incremented]\n", + Object, NewCount)); + break; + + + case REF_DECREMENT: + + if (Count < 1) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, can't decrement! (Set to 0)\n", + Object, NewCount)); + + NewCount = 0; + } + + else + { + NewCount--; + + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, [Decremented]\n", + Object, NewCount)); + } + + if (Object->Common.Type == ACPI_TYPE_METHOD) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Method Obj %p Refs=%d, [Decremented]\n", + Object, NewCount)); + } + + Object->Common.ReferenceCount = NewCount; + if (NewCount == 0) + { + AcpiCmDeleteInternalObj (Object); + } + + break; + + + case REF_FORCE_DELETE: + + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateRefCount: Obj %p Refs=%d, Force delete! (Set to 0)\n", + Object, Count)); + + NewCount = 0; + Object->Common.ReferenceCount = NewCount; + AcpiCmDeleteInternalObj (Object); + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("CmUpdateRefCount: Unknown action (%d)\n", Action)); + break; + } + + + /* + * Sanity check the reference count, for debug purposes only. + * (A deleted object will have a huge reference count) + */ + + if (Count > MAX_REFERENCE_COUNT) + { + + DEBUG_PRINT (ACPI_ERROR, + ("CmUpdateRefCount: **** AE_ERROR **** Invalid Reference Count (0x%X) in object %p\n\n", + Count, Object)); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmUpdateObjectReference + * + * 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 +AcpiCmUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_STATUS Status; + UINT32 i; + ACPI_OPERAND_OBJECT *Next; + ACPI_OPERAND_OBJECT *New; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE_PTR ("CmUpdateObjectReference", Object); + + + /* Ignore a null object ptr */ + + if (!Object) + { + return_ACPI_STATUS (AE_OK); + } + + + /* + * Make sure that this isn't a namespace handle or an AML pointer + */ + + if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateObjectReference: Object %p is NS handle\n", + Object)); + return_ACPI_STATUS (AE_OK); + } + + if (AcpiTbSystemTablePointer (Object)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmUpdateObjectReference: **** Object %p is Pcode Ptr\n", + Object)); + return_ACPI_STATUS (AE_OK); + } + + + State = AcpiCmCreateUpdateState (Object, Action); + + while (State) + { + + Object = State->Update.Object; + Action = State->Update.Value; + AcpiCmDeleteGenericState (State); + + /* + * All sub-objects must have their reference count incremented also. + * Different object types have different subobjects. + */ + switch (Object->Common.Type) + { + + case ACPI_TYPE_DEVICE: + + Status = AcpiCmCreateUpdateStateAndPush (Object->Device.AddrHandler, + Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiCmUpdateRefCount (Object->Device.SysHandler, Action); + AcpiCmUpdateRefCount (Object->Device.DrvHandler, Action); + break; + + + case INTERNAL_TYPE_ADDRESS_HANDLER: + + /* Must walk list of address handlers */ + + Next = Object->AddrHandler.Next; + while (Next) + { + New = Next->AddrHandler.Next; + AcpiCmUpdateRefCount (Next, Action); + + Next = New; + } + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * We must update all the sub-objects of the package + * (Each of whom may have their own sub-objects, etc. + */ + for (i = 0; i < Object->Package.Count; i++) + { + /* + * Push each element onto the stack for later processing. + * Note: There can be null elements within the package, + * these are simply ignored + */ + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->Package.Elements[i], Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + break; + + + case ACPI_TYPE_FIELD_UNIT: + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->FieldUnit.Container, Action, &StateList); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case INTERNAL_TYPE_DEF_FIELD: + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->Field.Container, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case INTERNAL_TYPE_BANK_FIELD: + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->BankField.BankSelect, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiCmCreateUpdateStateAndPush ( + Object->BankField.Container, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case ACPI_TYPE_REGION: + + /* TBD: [Investigate] + AcpiCmUpdateRefCount (Object->Region.AddrHandler, Action); + */ +/* + Status = + AcpiCmCreateUpdateStateAndPush (Object->Region.AddrHandler, + Action, &StateList); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } +*/ + break; + + + case INTERNAL_TYPE_REFERENCE: + + break; + } + + + /* + * Now we can update the count in the main object. This can only + * happen after we update the sub-objects in case this causes the + * main object to be deleted. + */ + + AcpiCmUpdateRefCount (Object, Action); + + + /* Move on to the next object to be updated */ + + State = AcpiCmPopGenericState (&StateList); + } + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmAddReference + * + * PARAMETERS: *Object - Object whose reference count is to be + * incremented + * + * RETURN: None + * + * DESCRIPTION: Add one reference to an ACPI object + * + ******************************************************************************/ + +void +AcpiCmAddReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + FUNCTION_TRACE_PTR ("CmAddReference", Object); + + + /* + * Ensure that we have a valid object + */ + + if (!AcpiCmValidInternalObject (Object)) + { + return_VOID; + } + + /* + * We have a valid ACPI internal object, now increment the reference count + */ + + AcpiCmUpdateObjectReference (Object, REF_INCREMENT); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmRemoveReference + * + * PARAMETERS: *Object - Object whose ref count will be decremented + * + * RETURN: None + * + * DESCRIPTION: Decrement the reference count of an ACPI internal object + * + ******************************************************************************/ + +void +AcpiCmRemoveReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + FUNCTION_TRACE_PTR ("CmRemoveReference", Object); + + + /* + * Ensure that we have a valid object + */ + + if (!AcpiCmValidInternalObject (Object)) + { + return_VOID; + } + + DEBUG_PRINT (ACPI_INFO, ("CmRemoveReference: Obj %p Refs=%d\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!) + */ + + AcpiCmUpdateObjectReference (Object, REF_DECREMENT); + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/uteval.c b/sys/contrib/dev/acpica/uteval.c new file mode 100644 index 0000000..81be3df --- /dev/null +++ b/sys/contrib/dev/acpica/uteval.c @@ -0,0 +1,494 @@ +/****************************************************************************** + * + * Module Name: cmeval - Object evaluation + * $Revision: 18 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMEVAL_C__ + +#include "acpi.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmeval") + + +/**************************************************************************** + * + * FUNCTION: AcpiCmEvaluateNumericObject + * + * PARAMETERS: *ObjectName - Object name to be evaluated + * DeviceNode - Node for the device + * *Address - Where the value is returned + * + * RETURN: Status + * + * DESCRIPTION: evaluates a numeric namespace object for a selected device + * and stores results in *Address. + * + * NOTE: Internal function, no parameter validation + * + ***************************************************************************/ + +ACPI_STATUS +AcpiCmEvaluateNumericObject ( + NATIVE_CHAR *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Address) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmEvaluateNumericObject"); + + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, ObjectName, NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + DEBUG_PRINT (ACPI_INFO, + ("%s on %4.4s was not found\n", ObjectName, + &DeviceNode->Name)); + } + else + { + DEBUG_PRINT (ACPI_ERROR, + ("%s on %4.4s failed with status %4.4x\n", ObjectName, + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + return_ACPI_STATUS (Status); + } + + + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, + ("No object was returned from %s\n", ObjectName)); + return_ACPI_STATUS (AE_TYPE); + } + + /* Is the return object of the correct type? */ + + if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from %s was not a number: %d \n", + ObjectName, ObjDesc->Common.Type)); + } + else + { + /* + * Since the structure is a union, setting any field will set all + * of the variables in the union + */ + *Address = ObjDesc->Number.Value; + } + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmExecute_HID + * + * PARAMETERS: DeviceNode - Node for the device + * *Hid - Where the HID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _HID control method that returns the hardware + * ID of the device. + * + * NOTE: Internal function, no parameter validation + * + ***************************************************************************/ + +ACPI_STATUS +AcpiCmExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Hid) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmExecute_HID"); + + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, + METHOD_NAME__HID, NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + DEBUG_PRINT (ACPI_INFO, + ("_HID on %4.4s was not found\n", + &DeviceNode->Name)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("_HID on %4.4s failed with status %4.4x\n", + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + return_ACPI_STATUS (Status); + } + + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _HID\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* + * A _HID can return either a Number (32 bit compressed EISA ID) or + * a string + */ + + if ((ObjDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from _HID was not a number or string: [0x%X] \n", + ObjDesc->Common.Type)); + } + + else + { + if (ObjDesc->Common.Type == ACPI_TYPE_NUMBER) + { + /* Convert the Numeric HID to string */ + + AcpiAmlEisaIdToString ((UINT32) ObjDesc->Number.Value, Hid->Buffer); + } + + else + { + /* Copy the String HID from the returned object */ + + STRNCPY(Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer)); + } + } + + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + + return_ACPI_STATUS (Status); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmExecute_UID + * + * PARAMETERS: DeviceNode - Node for the device + * *Uid - Where the UID is returned + * + * RETURN: Status + * + * DESCRIPTION: Executes the _UID control method that returns the hardware + * ID of the device. + * + * NOTE: Internal function, no parameter validation + * + ***************************************************************************/ + +ACPI_STATUS +AcpiCmExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + DEVICE_ID *Uid) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, + METHOD_NAME__UID, NULL, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + DEBUG_PRINT (ACPI_INFO, + ("_UID on %4.4s was not found\n", + &DeviceNode->Name)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, + ("_UID on %4.4s failed with status %4.4x\n", + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + return (Status); + } + + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _UID\n")); + return (AE_TYPE); + } + + /* + * A _UID can return either a Number (32 bit compressed EISA ID) or + * a string + */ + + if ((ObjDesc->Common.Type != ACPI_TYPE_NUMBER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from _UID was not a number or string: %d \n", + ObjDesc->Common.Type)); + } + + else + { + if (ObjDesc->Common.Type == ACPI_TYPE_NUMBER) + { + /* Convert the Numeric UID to string */ + + AcpiAmlUnsignedIntegerToString (ObjDesc->Number.Value, Uid->Buffer); + } + + else + { + /* Copy the String UID from the returned object */ + + STRNCPY(Uid->Buffer, ObjDesc->String.Pointer, sizeof(Uid->Buffer)); + } + } + + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + + return (Status); +} + +/**************************************************************************** + * + * FUNCTION: AcpiCmExecute_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 +AcpiCmExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *Flags) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmExecute_STA"); + + /* Execute the method */ + + Status = AcpiNsEvaluateRelative (DeviceNode, + METHOD_NAME__STA, NULL, &ObjDesc); + if (AE_NOT_FOUND == Status) + { + DEBUG_PRINT (ACPI_INFO, + ("_STA on %4.4s was not found, assuming present.\n", + &DeviceNode->Name)); + + *Flags = 0x0F; + Status = AE_OK; + } + + else if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, + ("_STA on %4.4s failed with status %s\n", + &DeviceNode->Name, + AcpiCmFormatException (Status))); + } + + else /* success */ + { + /* Did we get a return object? */ + + if (!ObjDesc) + { + DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _STA\n")); + return_ACPI_STATUS (AE_TYPE); + } + + /* Is the return object of the correct type? */ + + if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) + { + Status = AE_TYPE; + DEBUG_PRINT (ACPI_ERROR, + ("Type returned from _STA was not a number: %d \n", + ObjDesc->Common.Type)); + } + + else + { + /* Extract the status flags */ + + *Flags = (UINT32) ObjDesc->Number.Value; + } + + /* On exit, we must delete the return object */ + + AcpiCmRemoveReference (ObjDesc); + } + + return_ACPI_STATUS (Status); +} diff --git a/sys/contrib/dev/acpica/utglobal.c b/sys/contrib/dev/acpica/utglobal.c new file mode 100644 index 0000000..a57bd51 --- /dev/null +++ b/sys/contrib/dev/acpica/utglobal.c @@ -0,0 +1,705 @@ +/****************************************************************************** + * + * Module Name: cmglobal - Global variables for the ACPI subsystem + * $Revision: 104 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMGLOBAL_C__ +#define DEFINE_ACPI_GLOBALS + +#include "acpi.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmglobal") + + +/****************************************************************************** + * + * 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 +UINT32 AcpiDbgLevel = DEBUG_DEFAULT; +#else +UINT32 AcpiDbgLevel = NORMAL_DEFAULT; +#endif + +/* Debug switch - layer (component) mask */ + +UINT32 AcpiDbgLayer = COMPONENT_DEFAULT; +UINT32 AcpiGbl_NestingLevel = 0; + + +/* Debugger globals */ + +BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; +BOOLEAN AcpiGbl_MethodExecuting = FALSE; + +/* System flags */ + +UINT32 AcpiGbl_SystemFlags = 0; +UINT32 AcpiGbl_StartupFlags = 0; + +/* System starts unitialized! */ +BOOLEAN AcpiGbl_Shutdown = TRUE; + + +/****************************************************************************** + * + * Namespace globals + * + ******************************************************************************/ + + +/* + * Names built-in to the interpreter + * + * Initial values are currently supported only for types String and Number. + * To avoid type punning, both are specified as strings in this table. + */ + +PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = +{ + {"_GPE", INTERNAL_TYPE_DEF_ANY}, + {"_PR_", INTERNAL_TYPE_DEF_ANY}, + {"_SB_", INTERNAL_TYPE_DEF_ANY}, + {"_SI_", INTERNAL_TYPE_DEF_ANY}, + {"_TZ_", INTERNAL_TYPE_DEF_ANY}, + {"_REV", ACPI_TYPE_NUMBER, "2"}, + {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, + {"_GL_", ACPI_TYPE_MUTEX, "0"}, + + /* Table terminator */ + + {NULL, ACPI_TYPE_ANY} +}; + + +/* + * Properties of the ACPI Object Types, both internal and external. + * + * Elements of AcpiNsProperties are bit significant + * and the table is indexed by values of ACPI_OBJECT_TYPE + */ + +UINT8 AcpiGbl_NsProperties[] = +{ + NSP_NORMAL, /* 00 Any */ + NSP_NORMAL, /* 01 Number */ + NSP_NORMAL, /* 02 String */ + NSP_NORMAL, /* 03 Buffer */ + NSP_LOCAL, /* 04 Package */ + NSP_NORMAL, /* 05 FieldUnit */ + NSP_NEWSCOPE | NSP_LOCAL, /* 06 Device */ + NSP_LOCAL, /* 07 AcpiEvent */ + NSP_NEWSCOPE | NSP_LOCAL, /* 08 Method */ + NSP_LOCAL, /* 09 Mutex */ + NSP_LOCAL, /* 10 Region */ + NSP_NEWSCOPE | NSP_LOCAL, /* 11 Power */ + NSP_NEWSCOPE | NSP_LOCAL, /* 12 Processor */ + NSP_NEWSCOPE | NSP_LOCAL, /* 13 Thermal */ + NSP_NORMAL, /* 14 BufferField */ + NSP_NORMAL, /* 15 DdbHandle */ + NSP_NORMAL, /* 16 Debug Object */ + NSP_NORMAL, /* 17 DefField */ + NSP_NORMAL, /* 18 BankField */ + NSP_NORMAL, /* 19 IndexField */ + NSP_NORMAL, /* 20 Reference */ + NSP_NORMAL, /* 21 Alias */ + NSP_NORMAL, /* 22 Notify */ + NSP_NORMAL, /* 23 Address Handler */ + NSP_NORMAL, /* 24 DefFieldDefn */ + NSP_NORMAL, /* 25 BankFieldDefn */ + NSP_NORMAL, /* 26 IndexFieldDefn */ + NSP_NORMAL, /* 27 If */ + NSP_NORMAL, /* 28 Else */ + NSP_NORMAL, /* 29 While */ + NSP_NEWSCOPE, /* 30 Scope */ + NSP_LOCAL, /* 31 DefAny */ + NSP_NORMAL, /* 32 Method Arg */ + NSP_NORMAL, /* 33 Method Local */ + NSP_NORMAL, /* 34 Extra */ + NSP_NORMAL /* 35 Invalid */ +}; + + +/****************************************************************************** + * + * Table globals + * + ******************************************************************************/ + + +ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES]; + + +ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES] = +{ + /* Name, Signature, Signature size, How many allowed?, Supported? Global typed pointer */ + + /* RSDP 0 */ {"RSDP", RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL}, + /* APIC 1 */ {APIC_SIG, APIC_SIG, sizeof (APIC_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_APIC}, + /* DSDT 2 */ {DSDT_SIG, DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_DSDT}, + /* FACP 3 */ {FACP_SIG, FACP_SIG, sizeof (FACP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_FACP}, + /* FACS 4 */ {FACS_SIG, FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_FACS}, + /* PSDT 5 */ {PSDT_SIG, PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, + /* RSDT 6 */ {RSDT_SIG, RSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL}, + /* SSDT 7 */ {SSDT_SIG, SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, + /* SBST 8 */ {SBST_SIG, SBST_SIG, sizeof (SBST_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &AcpiGbl_SBST}, + /* SPIC 9 */ {SPIC_SIG, SPIC_SIG, sizeof (SPIC_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL}, + /* BOOT 10 */{BOOT_SIG, BOOT_SIG, sizeof (BOOT_SIG)-1, ACPI_TABLE_SINGLE, AE_SUPPORT, NULL} +}; + + +#ifdef ACPI_DEBUG + +/****************************************************************************** + * + * Strings and procedures used for debug only + * + ******************************************************************************/ + +NATIVE_CHAR *MsgAcpiErrorBreak = "*** Break on ACPI_ERROR ***\n"; + + +/***************************************************************************** + * + * FUNCTION: AcpiCmGetMutexName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a mutex ID into a name string (Debug only) + * + ****************************************************************************/ + +NATIVE_CHAR * +AcpiCmGetMutexName ( + UINT32 MutexId) +{ + + if (MutexId > MAX_MTX) + { + return ("Invalid Mutex ID"); + } + + return (AcpiGbl_MutexNames[MutexId]); +} + + +/* + * Elements of AcpiGbl_NsTypeNames below must match + * one-to-one with values of ACPI_OBJECT_TYPE + * + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when + * stored in a table it really means that we have thus far seen no evidence to + * indicatewhat type is actually going to be stored for this entry. + */ + +static NATIVE_CHAR AcpiGbl_BadType[] = "UNDEFINED"; +#define TYPE_NAME_LENGTH 9 /* Maximum length of each string */ + +static NATIVE_CHAR *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */ +{ + /* 00 */ "Untyped", + /* 01 */ "Number", + /* 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 */ "BufferFld", + /* 15 */ "DdbHandle", + /* 16 */ "DebugObj", + /* 17 */ "DefField", + /* 18 */ "BnkField", + /* 19 */ "IdxField", + /* 20 */ "Reference", + /* 21 */ "Alias", + /* 22 */ "Notify", + /* 23 */ "AddrHndlr", + /* 24 */ "DefFldDfn", + /* 25 */ "BnkFldDfn", + /* 26 */ "IdxFldDfn", + /* 27 */ "If", + /* 28 */ "Else", + /* 29 */ "While", + /* 30 */ "Scope", + /* 31 */ "DefAny", + /* 32 */ "MethodArg", + /* 33 */ "MethodLcl", + /* 34 */ "Extra", + /* 35 */ "Invalid" +}; + + +/***************************************************************************** + * + * FUNCTION: AcpiCmGetTypeName + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Translate a Type ID into a name string (Debug only) + * + ****************************************************************************/ + +NATIVE_CHAR * +AcpiCmGetTypeName ( + UINT32 Type) +{ + + if (Type > INTERNAL_TYPE_INVALID) + { + return (AcpiGbl_BadType); + } + + return (AcpiGbl_NsTypeNames[Type]); +} + +#endif + + +/***************************************************************************** + * + * FUNCTION: AcpiCmValidObjectType + * + * PARAMETERS: None. + * + * RETURN: TRUE if valid object type + * + * DESCRIPTION: Validate an object type + * + ****************************************************************************/ + +BOOLEAN +AcpiCmValidObjectType ( + UINT32 Type) +{ + + if (Type > ACPI_TYPE_MAX) + { + if ((Type < INTERNAL_TYPE_BEGIN) || + (Type > INTERNAL_TYPE_MAX)) + { + return (FALSE); + } + } + + return (TRUE); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmFormatException + * + * PARAMETERS: Status - Acpi status to be formatted + * + * RETURN: Formatted status string + * + * DESCRIPTION: Convert an ACPI exception to a string + * + ****************************************************************************/ + +NATIVE_CHAR * +AcpiCmFormatException ( + ACPI_STATUS Status) +{ + NATIVE_CHAR *Exception = "UNKNOWN_STATUS"; + ACPI_STATUS SubStatus; + + + 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 -1]; + } + break; + + case AE_CODE_ACPI_TABLES: + + if (SubStatus <= AE_CODE_TBL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; + } + break; + + case AE_CODE_AML: + + if (SubStatus <= AE_CODE_AML_MAX) + { + Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; + } + break; + + case AE_CODE_CONTROL: + + if (SubStatus <= AE_CODE_CTRL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; + } + break; + + default: + break; + } + + + return (Exception); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmAllocateOwnerId + * + * PARAMETERS: IdType - Type of ID (method or table) + * + * DESCRIPTION: Allocate a table or method owner id + * + ***************************************************************************/ + +ACPI_OWNER_ID +AcpiCmAllocateOwnerId ( + UINT32 IdType) +{ + ACPI_OWNER_ID OwnerId = 0xFFFF; + + + FUNCTION_TRACE ("CmAllocateOwnerId"); + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + switch (IdType) + { + case OWNER_TYPE_TABLE: + + OwnerId = AcpiGbl_NextTableOwnerId; + AcpiGbl_NextTableOwnerId++; + + if (AcpiGbl_NextTableOwnerId == FIRST_METHOD_ID) + { + AcpiGbl_NextTableOwnerId = FIRST_TABLE_ID; + } + break; + + + case OWNER_TYPE_METHOD: + + OwnerId = AcpiGbl_NextMethodOwnerId; + AcpiGbl_NextMethodOwnerId++; + + if (AcpiGbl_NextMethodOwnerId == FIRST_TABLE_ID) + { + AcpiGbl_NextMethodOwnerId = FIRST_METHOD_ID; + } + break; + } + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + return_VALUE (OwnerId); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiCmInitGlobals + * + * PARAMETERS: none + * + * DESCRIPTION: Init library globals. All globals that require specific + * initialization should be initialized here! + * + ***************************************************************************/ + +void +AcpiCmInitGlobals ( + void) +{ + UINT32 i; + + + FUNCTION_TRACE ("CmInitGlobals"); + + + /* ACPI table structure */ + + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + AcpiGbl_AcpiTables[i].Prev = &AcpiGbl_AcpiTables[i]; + AcpiGbl_AcpiTables[i].Next = &AcpiGbl_AcpiTables[i]; + AcpiGbl_AcpiTables[i].Pointer = NULL; + AcpiGbl_AcpiTables[i].Length = 0; + AcpiGbl_AcpiTables[i].Allocation = ACPI_MEM_NOT_ALLOCATED; + AcpiGbl_AcpiTables[i].Count = 0; + } + + + /* Address Space handler array */ + + for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++) + { + AcpiGbl_AddressSpaces[i].Handler = NULL; + AcpiGbl_AddressSpaces[i].Context = NULL; + } + + /* Mutex locked flags */ + + for (i = 0; i < NUM_MTX; i++) + { + AcpiGbl_AcpiMutexInfo[i].Mutex = NULL; + AcpiGbl_AcpiMutexInfo[i].Locked = FALSE; + AcpiGbl_AcpiMutexInfo[i].UseCount = 0; + } + + /* Global notify handlers */ + + AcpiGbl_SysNotify.Handler = NULL; + AcpiGbl_DrvNotify.Handler = NULL; + + /* Global "typed" ACPI table pointers */ + + AcpiGbl_RSDP = NULL; + AcpiGbl_RSDT = NULL; + AcpiGbl_FACS = NULL; + AcpiGbl_FACP = NULL; + AcpiGbl_APIC = NULL; + AcpiGbl_DSDT = NULL; + AcpiGbl_SBST = NULL; + + + /* Global Lock support */ + + AcpiGbl_GlobalLockAcquired = FALSE; + AcpiGbl_GlobalLockThreadCount = 0; + + /* Miscellaneous variables */ + + AcpiGbl_SystemFlags = 0; + AcpiGbl_StartupFlags = 0; + AcpiGbl_GlobalLockSet = FALSE; + AcpiGbl_RsdpOriginalLocation = 0; + AcpiGbl_WhenToParseMethods = METHOD_PARSE_CONFIGURATION; + AcpiGbl_CmSingleStep = FALSE; + AcpiGbl_DbTerminateThreads = FALSE; + AcpiGbl_Shutdown = FALSE; + AcpiGbl_NsLookupCount = 0; + AcpiGbl_PsFindCount = 0; + AcpiGbl_AcpiHardwarePresent = TRUE; + AcpiGbl_NextTableOwnerId = FIRST_TABLE_ID; + AcpiGbl_NextMethodOwnerId = FIRST_METHOD_ID; + AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; + + /* Cache of small "state" objects */ + + AcpiGbl_GenericStateCache = NULL; + AcpiGbl_GenericStateCacheDepth = 0; + AcpiGbl_StateCacheRequests = 0; + AcpiGbl_StateCacheHits = 0; + + AcpiGbl_ParseCache = NULL; + AcpiGbl_ParseCacheDepth = 0; + AcpiGbl_ParseCacheRequests = 0; + AcpiGbl_ParseCacheHits = 0; + + AcpiGbl_ExtParseCache = NULL; + AcpiGbl_ExtParseCacheDepth = 0; + AcpiGbl_ExtParseCacheRequests = 0; + AcpiGbl_ExtParseCacheHits = 0; + + AcpiGbl_ObjectCache = NULL; + AcpiGbl_ObjectCacheDepth = 0; + AcpiGbl_ObjectCacheRequests = 0; + AcpiGbl_ObjectCacheHits = 0; + + AcpiGbl_WalkStateCache = NULL; + AcpiGbl_WalkStateCacheDepth = 0; + AcpiGbl_WalkStateCacheRequests = 0; + AcpiGbl_WalkStateCacheHits = 0; + + /* Interpreter */ + + AcpiGbl_BufSeq = 0; + AcpiGbl_NodeErr = FALSE; + + /* Parser */ + + AcpiGbl_ParsedNamespaceRoot = NULL; + + /* Hardware oriented */ + + AcpiGbl_Gpe0EnableRegisterSave = NULL; + AcpiGbl_Gpe1EnableRegisterSave = NULL; + AcpiGbl_OriginalMode = SYS_MODE_UNKNOWN; /* original ACPI/legacy mode */ + AcpiGbl_GpeRegisters = NULL; + AcpiGbl_GpeInfo = NULL; + + /* Namespace */ + + AcpiGbl_RootNode = NULL; + + AcpiGbl_RootNodeStruct.Name = ACPI_ROOT_NAME; + AcpiGbl_RootNodeStruct.DataType = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_ANY; + AcpiGbl_RootNodeStruct.Child = NULL; + AcpiGbl_RootNodeStruct.Peer = NULL; + AcpiGbl_RootNodeStruct.Object = NULL; + AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; + + /* Memory allocation metrics - compiled out in non-debug mode. */ + + INITIALIZE_ALLOCATION_METRICS(); + + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/utinit.c b/sys/contrib/dev/acpica/utinit.c new file mode 100644 index 0000000..a00a82b --- /dev/null +++ b/sys/contrib/dev/acpica/utinit.c @@ -0,0 +1,347 @@ +/****************************************************************************** + * + * Module Name: cminit - Common ACPI subsystem initialization + * $Revision: 84 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMINIT_C__ + +#include "acpi.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acparser.h" +#include "acdispat.h" + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cminit") + + +/******************************************************************************* + * + * FUNCTION: AcpiCmFacpRegisterError + * + * PARAMETERS: *RegisterName - Pointer to string identifying register + * Value - Actual register contents value + * AcpiTestSpecSection - TDS section containing assertion + * AcpiAssertion - Assertion number being tested + * + * RETURN: AE_BAD_VALUE + * + * DESCRIPTION: Display failure message and link failure to TDS assertion + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmFacpRegisterError ( + NATIVE_CHAR *RegisterName, + UINT32 Value) +{ + + REPORT_ERROR ( + ("Invalid FACP register value, %s = 0x%X (FACP=0x%X)\n", + RegisterName, Value, AcpiGbl_FACP)); + + + return (AE_BAD_VALUE); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmValidateFacp + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Validate various ACPI registers in the FACP + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmValidateFacp ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + /* + * Verify Fixed ACPI Description Table fields, + * but don't abort on any problems, just display error + */ + + if (AcpiGbl_FACP->Pm1EvtLen < 4) + { + Status = AcpiCmFacpRegisterError ("PM1_EVT_LEN", + (UINT32) AcpiGbl_FACP->Pm1EvtLen); + } + + if (!AcpiGbl_FACP->Pm1CntLen) + { + Status = AcpiCmFacpRegisterError ("PM1_CNT_LEN", + (UINT32) AcpiGbl_FACP->Pm1CntLen); + } + + if (!AcpiGbl_FACP->Pm1aEvtBlk) + { + Status = AcpiCmFacpRegisterError ("PM1a_EVT_BLK", + AcpiGbl_FACP->Pm1aEvtBlk); + } + + if (!AcpiGbl_FACP->Pm1aCntBlk) + { + Status = AcpiCmFacpRegisterError ("PM1a_CNT_BLK", + AcpiGbl_FACP->Pm1aCntBlk); + } + + if (!AcpiGbl_FACP->PmTmrBlk) + { + Status = AcpiCmFacpRegisterError ("PM_TMR_BLK", + AcpiGbl_FACP->PmTmrBlk); + } + + if (AcpiGbl_FACP->Pm2CntBlk && !AcpiGbl_FACP->Pm2CntLen) + { + Status = AcpiCmFacpRegisterError ("PM2_CNT_LEN", + (UINT32) AcpiGbl_FACP->Pm2CntLen); + } + + if (AcpiGbl_FACP->PmTmLen < 4) + { + Status = AcpiCmFacpRegisterError ("PM_TM_LEN", + (UINT32) AcpiGbl_FACP->PmTmLen); + } + + /* length of GPE blocks must be a multiple of 2 */ + + + if (AcpiGbl_FACP->Gpe0Blk && (AcpiGbl_FACP->Gpe0BlkLen & 1)) + { + Status = AcpiCmFacpRegisterError ("GPE0_BLK_LEN", + (UINT32) AcpiGbl_FACP->Gpe0BlkLen); + } + + if (AcpiGbl_FACP->Gpe1Blk && (AcpiGbl_FACP->Gpe1BlkLen & 1)) + { + Status = AcpiCmFacpRegisterError ("GPE1_BLK_LEN", + (UINT32) AcpiGbl_FACP->Gpe1BlkLen); + } + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiCmTerminate (void) +{ + + FUNCTION_TRACE ("CmTerminate"); + + + /* Free global tables, etc. */ + + if (AcpiGbl_Gpe0EnableRegisterSave) + { + AcpiCmFree (AcpiGbl_Gpe0EnableRegisterSave); + } + + if (AcpiGbl_Gpe1EnableRegisterSave) + { + AcpiCmFree (AcpiGbl_Gpe1EnableRegisterSave); + } + + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmSubsystemShutdown + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex + * objects here -- because the AML debugger may be still running. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmSubsystemShutdown (void) +{ + + FUNCTION_TRACE ("CmSubsystemShutdown"); + + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + DEBUG_PRINT (ACPI_ERROR, ("ACPI Subsystem is already terminated\n")); + return_ACPI_STATUS (AE_OK); + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + DEBUG_PRINT (ACPI_INFO, ("Shutting down ACPI Subsystem...\n")); + + + /* Close the Namespace */ + + AcpiNsTerminate (); + + /* Close the AcpiEvent Handling */ + + AcpiEvTerminate (); + + /* Close the globals */ + + AcpiCmTerminate (); + + /* Flush the local cache(s) */ + + AcpiCmDeleteGenericStateCache (); + AcpiCmDeleteObjectCache (); + AcpiDsDeleteWalkStateCache (); + + /* Close the Parser */ + + /* TBD: [Restructure] AcpiPsTerminate () */ + + AcpiPsDeleteParseCache (); + + /* Debug only - display leftover memory allocation, if any */ +#ifdef ENABLE_DEBUGGER + AcpiCmDumpCurrentAllocations (ACPI_UINT32_MAX, NULL); +#endif + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/sys/contrib/dev/acpica/utmisc.c b/sys/contrib/dev/acpica/utmisc.c new file mode 100644 index 0000000..64e08ba --- /dev/null +++ b/sys/contrib/dev/acpica/utmisc.c @@ -0,0 +1,915 @@ +/******************************************************************************* + * + * Module Name: cmutils - common utility procedures + * $Revision: 21 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMUTILS_C__ + +#include "acpi.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acdebug.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiCmValidAcpiName + * + * PARAMETERS: Character - The character to be examined + * + * RETURN: 1 if Character may appear in a name, else 0 + * + * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + ******************************************************************************/ + +BOOLEAN +AcpiCmValidAcpiName ( + UINT32 Name) +{ + NATIVE_CHAR *NamePtr = (NATIVE_CHAR *) &Name; + UINT32 i; + + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!((NamePtr[i] == '_') || + (NamePtr[i] >= 'A' && NamePtr[i] <= 'Z') || + (NamePtr[i] >= '0' && NamePtr[i] <= '9'))) + { + return (FALSE); + } + } + + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmValidAcpiCharacter + * + * PARAMETERS: Character - The character to be examined + * + * RETURN: 1 if Character may appear in a name, else 0 + * + * DESCRIPTION: Check for a printable character + * + ******************************************************************************/ + +BOOLEAN +AcpiCmValidAcpiCharacter ( + NATIVE_CHAR Character) +{ + + return ((BOOLEAN) ((Character == '_') || + (Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9'))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmMutexInitialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmMutexInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + FUNCTION_TRACE ("CmMutexInitialize"); + + + /* + * Create each of the predefined mutex objects + */ + for (i = 0; i < NUM_MTX; i++) + { + Status = AcpiCmCreateMutex (i); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmMutexTerminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. + * + ******************************************************************************/ + +void +AcpiCmMutexTerminate ( + void) +{ + UINT32 i; + + + FUNCTION_TRACE ("CmMutexTerminate"); + + + /* + * Delete each predefined mutex object + */ + for (i = 0; i < NUM_MTX; i++) + { + AcpiCmDeleteMutex (i); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateMutex + * + * PARAMETERS: MutexID - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCreateMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_U32 ("CmCreateMutex", MutexId); + + + if (MutexId > MAX_MTX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + if (!AcpiGbl_AcpiMutexInfo[MutexId].Mutex) + { + Status = AcpiOsCreateSemaphore (1, 1, + &AcpiGbl_AcpiMutexInfo[MutexId].Mutex); + AcpiGbl_AcpiMutexInfo[MutexId].Locked = FALSE; + AcpiGbl_AcpiMutexInfo[MutexId].UseCount = 0; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteMutex + * + * PARAMETERS: MutexID - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + + + FUNCTION_TRACE_U32 ("CmDeleteMutex", MutexId); + + + if (MutexId > MAX_MTX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + Status = AcpiOsDeleteSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex); + + AcpiGbl_AcpiMutexInfo[MutexId].Mutex = NULL; + AcpiGbl_AcpiMutexInfo[MutexId].Locked = FALSE; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmAcquireMutex + * + * PARAMETERS: MutexID - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + + + DEBUG_PRINT (TRACE_MUTEX, + ("Acquiring Mutex [%s]\n", AcpiCmGetMutexName (MutexId))); + + if (MutexId > MAX_MTX) + { + return (AE_BAD_PARAMETER); + } + + + Status = AcpiOsWaitSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex, + 1, WAIT_FOREVER); + + DEBUG_PRINT (TRACE_MUTEX, ("Acquired Mutex [%s] Status %s\n", + AcpiCmGetMutexName (MutexId), AcpiCmFormatException (Status))); + + if (ACPI_SUCCESS (Status)) + { + AcpiGbl_AcpiMutexInfo[MutexId].Locked = TRUE; + AcpiGbl_AcpiMutexInfo[MutexId].UseCount++; + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmReleaseMutex + * + * PARAMETERS: MutexID - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + + + DEBUG_PRINT (TRACE_MUTEX, + ("Releasing Mutex [%s]\n", AcpiCmGetMutexName (MutexId))); + + if (MutexId > MAX_MTX) + { + return (AE_BAD_PARAMETER); + } + + + AcpiGbl_AcpiMutexInfo[MutexId].Locked = FALSE; /* Mark before unlocking */ + + Status = AcpiOsSignalSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex, 1); + + if (ACPI_FAILURE (Status)) + { + DEBUG_PRINT (ACPI_ERROR, ("Error Releasing Mutex [%s], %s\n", + AcpiCmGetMutexName (MutexId), AcpiCmFormatException (Status))); + } + else + { + DEBUG_PRINT (TRACE_MUTEX, ("Released Mutex [%s], %s\n", + AcpiCmGetMutexName (MutexId), AcpiCmFormatException (Status))); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateUpdateStateAndPush + * + * PARAMETERS: *Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: None + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + /* Ignore null objects; these are expected */ + + if (!Object) + { + return (AE_OK); + } + + State = AcpiCmCreateUpdateState (Object, Action); + if (!State) + { + return (AE_NO_MEMORY); + } + + + AcpiCmPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmPushGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * State - State object to push + * + * RETURN: Status + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +AcpiCmPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State) +{ + FUNCTION_TRACE ("CmPushGenericState"); + + /* Push the state object onto the front of the list (stack) */ + + State->Common.Next = *ListHead; + *ListHead = State; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmPopGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * + * RETURN: Status + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmPopGenericState ( + ACPI_GENERIC_STATE **ListHead) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE ("DsPopGenericState"); + + + /* 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: AcpiCmCreateGenericState + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreateGenericState (void) +{ + ACPI_GENERIC_STATE *State; + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + AcpiGbl_StateCacheRequests++; + + /* Check the cache first */ + + if (AcpiGbl_GenericStateCache) + { + /* There is an object available, use it */ + + State = AcpiGbl_GenericStateCache; + AcpiGbl_GenericStateCache = State->Common.Next; + State->Common.Next = NULL; + + AcpiGbl_StateCacheHits++; + AcpiGbl_GenericStateCacheDepth--; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + DEBUG_PRINT (TRACE_EXEC, ("CreateGenState: State %p from cache\n", State)); + } + + else + { + /* The cache is empty, create a new object */ + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + State = AcpiCmCallocate (sizeof (ACPI_GENERIC_STATE)); + } + + /* Initialize */ + + if (State) + { + /* Always zero out the object before init */ + + MEMSET (State, 0, sizeof (ACPI_GENERIC_STATE)); + + State->Common.DataType = ACPI_DESC_TYPE_STATE; + } + + return (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateUpdateState + * + * PARAMETERS: Object - Initial Object to be installed in the + * state + * Action - Update action to be performed + * + * RETURN: Status + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE_PTR ("CmCreateUpdateState", Object); + + + /* Create the generic state object */ + + State = AcpiCmCreateGenericState (); + if (!State) + { + return (NULL); + } + + /* Init fields specific to the update struct */ + + State->Update.Object = Object; + State->Update.Value = Action; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmCreateControlState + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiCmCreateControlState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + FUNCTION_TRACE ("CmCreateControlState"); + + /* Create the generic state object */ + + State = AcpiCmCreateGenericState (); + if (!State) + { + return (NULL); + } + + + /* Init fields specific to the control struct */ + + State->Common.State = CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteGenericState + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Put a state object back into the global state cache. The object + * is not actually freed at this time. + * + ******************************************************************************/ + +void +AcpiCmDeleteGenericState ( + ACPI_GENERIC_STATE *State) +{ + FUNCTION_TRACE ("CmDeleteGenericState"); + + + /* If cache is full, just free this state object */ + + if (AcpiGbl_GenericStateCacheDepth >= MAX_STATE_CACHE_DEPTH) + { + AcpiCmFree (State); + } + + /* Otherwise put this object back into the cache */ + + else + { + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + /* Clear the state */ + + MEMSET (State, 0, sizeof (ACPI_GENERIC_STATE)); + State->Common.DataType = ACPI_DESC_TYPE_STATE; + + /* Put the object at the head of the global cache list */ + + State->Common.Next = AcpiGbl_GenericStateCache; + AcpiGbl_GenericStateCache = State; + AcpiGbl_GenericStateCacheDepth++; + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmDeleteGenericStateCache + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge the global state object cache. Used during subsystem + * termination. + * + ******************************************************************************/ + +void +AcpiCmDeleteGenericStateCache ( + void) +{ + ACPI_GENERIC_STATE *Next; + + + FUNCTION_TRACE ("CmDeleteGenericStateCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_GenericStateCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_GenericStateCache->Common.Next; + AcpiCmFree (AcpiGbl_GenericStateCache); + AcpiGbl_GenericStateCache = Next; + AcpiGbl_GenericStateCacheDepth--; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiCmResolvePackageReferences + * + * PARAMETERS: ObjDesc - The Package object on which to resolve refs + * + * RETURN: Status + * + * DESCRIPTION: Walk through a package and turn internal references into values + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmResolvePackageReferences ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + UINT32 Count; + ACPI_OPERAND_OBJECT *SubObject; + + FUNCTION_TRACE ("AcpiCmResolvePackageReferences"); + + if (ObjDesc->Common.Type != ACPI_TYPE_PACKAGE) + { + /* Must be a package */ + + REPORT_ERROR (("Must resolve Package Refs on a Package\n")); + return_ACPI_STATUS(AE_ERROR); + } + + for (Count = 0; Count < ObjDesc->Package.Count; Count++) + { + SubObject = ObjDesc->Package.Elements[Count]; + + if (SubObject->Common.Type == INTERNAL_TYPE_REFERENCE) + { + if (SubObject->Reference.OpCode == AML_ZERO_OP) + { + SubObject->Common.Type = ACPI_TYPE_NUMBER; + SubObject->Number.Value = 0; + } + else if (SubObject->Reference.OpCode == AML_ONE_OP) + { + SubObject->Common.Type = ACPI_TYPE_NUMBER; + SubObject->Number.Value = 1; + } + else if (SubObject->Reference.OpCode == AML_ONES_OP) + { + SubObject->Common.Type = ACPI_TYPE_NUMBER; + SubObject->Number.Value = ACPI_INTEGER_MAX; + } + } + } + + return_ACPI_STATUS(AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: _ReportError + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: None + * + * DESCRIPTION: Print error message from KD table + * + ******************************************************************************/ + +void +_ReportError ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + + + AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber); +} + + +/******************************************************************************* + * + * FUNCTION: _ReportWarning + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: None + * + * DESCRIPTION: Print warning message from KD table + * + ******************************************************************************/ + +void +_ReportWarning ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + + AcpiOsPrintf ("%8s-%04d: *** Warning: ", ModuleName, LineNumber); +} + + +/******************************************************************************* + * + * FUNCTION: _ReportInfo + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: None + * + * DESCRIPTION: Print information message from KD table + * + ******************************************************************************/ + +void +_ReportInfo ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + + AcpiOsPrintf ("%8s-%04d: *** Info: ", ModuleName, LineNumber); +} + + diff --git a/sys/contrib/dev/acpica/utobject.c b/sys/contrib/dev/acpica/utobject.c new file mode 100644 index 0000000..b8597fb --- /dev/null +++ b/sys/contrib/dev/acpica/utobject.c @@ -0,0 +1,817 @@ +/****************************************************************************** + * + * Module Name: cmobject - ACPI object create/delete/size/cache routines + * $Revision: 30 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __CMOBJECT_C__ + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "amlcode.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmobject") + + +/****************************************************************************** + * + * FUNCTION: _CmCreateInternalObject + * + * PARAMETERS: Address - Address of the memory to deallocate + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * Type - ACPI Type of the new object + * + * RETURN: Object - The new object. Null on failure + * + * DESCRIPTION: Create and initialize a new internal object. + * + * NOTE: + * We always allocate the worst-case object descriptor because these + * objects are cached, and we want them to be one-size-satisifies-any-request. + * This in itself may not be the most memory efficient, but the efficiency + * of the object cache should more than make up for this! + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +_CmCreateInternalObject ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + OBJECT_TYPE_INTERNAL Type) +{ + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE_STR ("CmCreateInternalObject", AcpiCmGetTypeName (Type)); + + + /* Allocate the raw object descriptor */ + + Object = _CmAllocateObjectDesc (ModuleName, LineNumber, ComponentId); + if (!Object) + { + /* Allocation failure */ + + return_VALUE (NULL); + } + + /* Save the object type in the object descriptor */ + + Object->Common.Type = Type; + + /* Init the reference count */ + + Object->Common.ReferenceCount = 1; + + /* Any per-type initialization should go here */ + + + return_PTR (Object); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmValidInternalObject + * + * PARAMETERS: Operand - Object to be validated + * + * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT + * + *****************************************************************************/ + +BOOLEAN +AcpiCmValidInternalObject ( + void *Object) +{ + + /* Check for a null pointer */ + + if (!Object) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Null Object Ptr\n")); + return (FALSE); + } + + /* Check for a pointer within one of the ACPI tables */ + + if (AcpiTbSystemTablePointer (Object)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Object %p is a Pcode Ptr\n", Object)); + return (FALSE); + } + + /* Check the descriptor type field */ + + if (!VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_INTERNAL)) + { + /* Not an ACPI internal object, do some further checking */ + + if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_NAMED)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Obj %p is a named obj, not ACPI obj\n", + Object)); + } + + else if (VALID_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_PARSER)) + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Obj %p is a parser obj, not ACPI obj\n", + Object)); + } + + else + { + DEBUG_PRINT (ACPI_INFO, + ("CmValidInternalObject: **** Obj %p is of unknown type\n", + Object)); + } + + return (FALSE); + } + + + /* The object appears to be a valid ACPI_OPERAND_OBJECT */ + + return (TRUE); +} + + +/***************************************************************************** + * + * FUNCTION: _CmAllocateObjectDesc + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * Message - Error message to use on failure + * + * RETURN: Pointer to newly allocated object descriptor. Null on error + * + * DESCRIPTION: Allocate a new object descriptor. Gracefully handle + * error conditions. + * + ****************************************************************************/ + +void * +_CmAllocateObjectDesc ( + NATIVE_CHAR *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + ACPI_OPERAND_OBJECT *Object; + + + FUNCTION_TRACE ("_AllocateObjectDesc"); + + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + AcpiGbl_ObjectCacheRequests++; + + /* Check the cache first */ + + if (AcpiGbl_ObjectCache) + { + /* There is an object available, use it */ + + Object = AcpiGbl_ObjectCache; + AcpiGbl_ObjectCache = Object->Cache.Next; + Object->Cache.Next = NULL; + + AcpiGbl_ObjectCacheHits++; + AcpiGbl_ObjectCacheDepth--; + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + } + + else + { + /* The cache is empty, create a new object */ + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + + /* Attempt to allocate new descriptor */ + + Object = _CmCallocate (sizeof (ACPI_OPERAND_OBJECT), ComponentId, + ModuleName, LineNumber); + if (!Object) + { + /* Allocation failed */ + + _REPORT_ERROR (ModuleName, LineNumber, ComponentId, + ("Could not allocate an object descriptor\n")); + + return_PTR (NULL); + } + + /* Memory allocation metrics - compiled out in non debug mode. */ + + INCREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); + } + + /* Mark the descriptor type */ + + Object->Common.DataType = ACPI_DESC_TYPE_INTERNAL; + + DEBUG_PRINT (TRACE_ALLOCATIONS, ("AllocateObjectDesc: %p Size 0x%x\n", + Object, sizeof (ACPI_OPERAND_OBJECT))); + + return_PTR (Object); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmDeleteObjectDesc + * + * PARAMETERS: Object - Acpi internal object to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache + * + ****************************************************************************/ + +void +AcpiCmDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object) +{ + + FUNCTION_TRACE_PTR ("AcpiCmDeleteObjectDesc", Object); + + + /* Make sure that the object isn't already in the cache */ + + if (Object->Common.DataType == (ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT)) + { + DEBUG_PRINT (ACPI_ERROR, + ("CmDeleteObjectDesc: Obj %p is already in the object cache\n", + Object)); + return_VOID; + } + + /* Object must be an ACPI_OPERAND_OBJECT */ + + if (Object->Common.DataType != ACPI_DESC_TYPE_INTERNAL) + { + DEBUG_PRINT (ACPI_ERROR, + ("CmDeleteObjectDesc: Obj %p is not an ACPI object\n", Object)); + return_VOID; + } + + + /* If cache is full, just free this object */ + + if (AcpiGbl_ObjectCacheDepth >= MAX_OBJECT_CACHE_DEPTH) + { + /* + * Memory allocation metrics. Call the macro here since we only + * care about dynamically allocated objects. + */ + DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); + + AcpiCmFree (Object); + return_VOID; + } + + AcpiCmAcquireMutex (ACPI_MTX_CACHES); + + /* Clear the entire object. This is important! */ + + MEMSET (Object, 0, sizeof (ACPI_OPERAND_OBJECT)); + Object->Common.DataType = ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT; + + /* Put the object at the head of the global cache list */ + + Object->Cache.Next = AcpiGbl_ObjectCache; + AcpiGbl_ObjectCache = Object; + AcpiGbl_ObjectCacheDepth++; + + + AcpiCmReleaseMutex (ACPI_MTX_CACHES); + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmDeleteObjectCache + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge the global state object cache. Used during subsystem + * termination. + * + ******************************************************************************/ + +void +AcpiCmDeleteObjectCache ( + void) +{ + ACPI_OPERAND_OBJECT *Next; + + + FUNCTION_TRACE ("CmDeleteObjectCache"); + + + /* Traverse the global cache list */ + + while (AcpiGbl_ObjectCache) + { + /* Delete one cached state object */ + + Next = AcpiGbl_ObjectCache->Cache.Next; + AcpiGbl_ObjectCache->Cache.Next = NULL; + + /* + * Memory allocation metrics. Call the macro here since we only + * care about dynamically allocated objects. + */ + DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); + + AcpiCmFree (AcpiGbl_ObjectCache); + AcpiGbl_ObjectCache = Next; + AcpiGbl_ObjectCacheDepth--; + } + + return_VOID; +} + + +/***************************************************************************** + * + * FUNCTION: AcpiCmInitStaticObject + * + * PARAMETERS: ObjDesc - Pointer to a "static" object - on stack + * or in the data segment. + * + * RETURN: None. + * + * DESCRIPTION: Initialize a static object. Sets flags to disallow dynamic + * deletion of the object. + * + ****************************************************************************/ + +void +AcpiCmInitStaticObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + FUNCTION_TRACE_PTR ("CmInitStaticObject", ObjDesc); + + + if (!ObjDesc) + { + return_VOID; + } + + + /* + * Clear the entire descriptor + */ + MEMSET ((void *) ObjDesc, 0, sizeof (ACPI_OPERAND_OBJECT)); + + + /* + * Initialize the header fields + * 1) This is an ACPI_OPERAND_OBJECT descriptor + * 2) The size is the full object (worst case) + * 3) The flags field indicates static allocation + * 4) Reference count starts at one (not really necessary since the + * object can't be deleted, but keeps everything sane) + */ + + ObjDesc->Common.DataType = ACPI_DESC_TYPE_INTERNAL; + ObjDesc->Common.Flags = AOPOBJ_STATIC_ALLOCATION; + ObjDesc->Common.ReferenceCount = 1; + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmGetSimpleObjectSize + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *RetLength - Where the length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to determine the space required to + * contain a simple object for return to an API user. + * + * The length includes the object structure plus any additional + * needed space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT32 *ObjLength) +{ + UINT32 Length; + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObj); + + + /* Handle a null object (Could be a uninitialized package element -- which is legal) */ + + if (!InternalObj) + { + *ObjLength = 0; + return_ACPI_STATUS (AE_OK); + } + + + /* Start with the length of the Acpi object */ + + Length = sizeof (ACPI_OBJECT); + + if (VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_NAMED)) + { + /* Object is a named object (reference), just return the length */ + + *ObjLength = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (Status); + } + + + /* + * The final length depends on the object type + * Strings and Buffers are packed right up against the parent object and + * must be accessed bytewise or there may be alignment problems. + * + * TBD:[Investigate] do strings and buffers require alignment also? + */ + + switch (InternalObj->Common.Type) + { + + case ACPI_TYPE_STRING: + + Length += InternalObj->String.Length; + break; + + + case ACPI_TYPE_BUFFER: + + Length += InternalObj->Buffer.Length; + break; + + + case ACPI_TYPE_NUMBER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + + /* + * No extra data for these types + */ + break; + + + case INTERNAL_TYPE_REFERENCE: + + /* + * The only type that should be here is opcode AML_NAMEPATH_OP -- since + * this means an object reference + */ + if (InternalObj->Reference.OpCode != AML_NAMEPATH_OP) + { + DEBUG_PRINT (ACPI_ERROR, + ("CmGetSimpleObjectSize: Unsupported Reference opcode=0x%X in object %p\n", + InternalObj->Reference.OpCode, InternalObj)); + Status = AE_TYPE; + } + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, + ("CmGetSimpleObjectSize: Unsupported type=0x%X in object %p\n", + InternalObj->Common.Type, InternalObj)); + 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 = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmGetPackageObjectSize + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *RetLength - Where the length is returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to determine the space required to contain + * a package object for return to an API user. + * + * This is moderately complex since a package contains other objects + * including packages. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *InternalObj, + UINT32 *ObjLength) +{ + + ACPI_OPERAND_OBJECT *ThisInternalObj; + ACPI_OPERAND_OBJECT *ParentObj[MAX_PACKAGE_DEPTH] = { 0,0,0,0,0 }; + ACPI_OPERAND_OBJECT *ThisParent; + UINT32 ThisIndex; + UINT32 Index[MAX_PACKAGE_DEPTH] = { 0,0,0,0,0 }; + UINT32 Length = 0; + UINT32 ObjectSpace; + UINT32 CurrentDepth = 0; + UINT32 PackageCount = 1; + ACPI_STATUS Status; + + + FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObj); + + + ParentObj[0] = InternalObj; + + while (1) + { + ThisParent = ParentObj[CurrentDepth]; + ThisIndex = Index[CurrentDepth]; + ThisInternalObj = ThisParent->Package.Elements[ThisIndex]; + + + /* + * Check for 1) An uninitialized package element. It is completely + * legal to declare a package and leave it uninitialized + * 2) Any type other than a package. Packages are handled + * below. + */ + + if ((!ThisInternalObj) || + (!IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE))) + { + /* + * Simple object - just get the size (Null object/entry handled + * also) + */ + + Status = + AcpiCmGetSimpleObjectSize (ThisInternalObj, &ObjectSpace); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length += ObjectSpace; + + Index[CurrentDepth]++; + while (Index[CurrentDepth] >= + ParentObj[CurrentDepth]->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. + */ + if (CurrentDepth == 0) + { + /* + * We have handled all of the objects + * in the top level package just add the + * length of the package objects and + * get out. Round up to the next machine + * word. + */ + Length += + ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)) * + PackageCount; + + *ObjLength = Length; + + return_ACPI_STATUS (AE_OK); + } + + /* + * Go back up a level and move the index + * past the just completed package object. + */ + CurrentDepth--; + Index[CurrentDepth]++; + } + } + + else + { + /* + * This object is a package + * -- go one level deeper + */ + PackageCount++; + if (CurrentDepth < MAX_PACKAGE_DEPTH-1) + { + CurrentDepth++; + ParentObj[CurrentDepth] = ThisInternalObj; + Index[CurrentDepth] = 0; + } + + else + { + /* + * Too many nested levels of packages for us + * to handle + */ + + DEBUG_PRINT (ACPI_ERROR, + ("CmGetPackageObjectSize: Pkg nested too deep (max %d)\n", + MAX_PACKAGE_DEPTH)); + return_ACPI_STATUS (AE_LIMIT); + } + } + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiCmGetObjectSize + * + * PARAMETERS: *InternalObj - Pointer to the object we are examining + * *RetLength - Where the length will be returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to determine the space required to + * contain an object for return to an API user. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiCmGetObjectSize( + ACPI_OPERAND_OBJECT *InternalObj, + UINT32 *ObjLength) +{ + ACPI_STATUS Status; + + + if ((VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_INTERNAL)) && + (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE))) + { + Status = + AcpiCmGetPackageObjectSize (InternalObj, ObjLength); + } + + else + { + Status = + AcpiCmGetSimpleObjectSize (InternalObj, ObjLength); + } + + return (Status); +} + + diff --git a/sys/contrib/dev/acpica/utxface.c b/sys/contrib/dev/acpica/utxface.c new file mode 100644 index 0000000..3e8e8d7 --- /dev/null +++ b/sys/contrib/dev/acpica/utxface.c @@ -0,0 +1,529 @@ +/****************************************************************************** + * + * Module Name: cmxface - External interfaces for "global" ACPI functions + * $Revision: 51 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMXFACE_C__ + +#include "acpi.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acdebug.h" + + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmxface") + + +/******************************************************************************* + * + * 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; + + + FUNCTION_TRACE ("AcpiInitializeSubsystem"); + + DEBUG_PRINT_RAW (ACPI_OK, + ("ACPI Subsystem version [%s]\n", ACPI_CA_VERSION)); + DEBUG_PRINT (ACPI_INFO, ("Initializing ACPI Subsystem...\n")); + + + /* Initialize all globals used by the subsystem */ + + AcpiCmInitGlobals (); + + /* Initialize the OS-Dependent layer */ + + Status = AcpiOsInitialize (); + if (ACPI_FAILURE (Status)) + { + REPORT_ERROR (("OSD failed to initialize, %s\n", + AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); + } + + /* Create the default mutex objects */ + + Status = AcpiCmMutexInitialize (); + if (ACPI_FAILURE (Status)) + { + REPORT_ERROR (("Global mutex creation failure, %s\n", + AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); + } + + /* + * Initialize the namespace manager and + * the root of the namespace tree + */ + + Status = AcpiNsRootInitialize (); + if (ACPI_FAILURE (Status)) + { + REPORT_ERROR (("Namespace initialization failure, %s\n", + AcpiCmFormatException (Status))); + return_ACPI_STATUS (Status); + } + + + /* If configured, initialize the AML debugger */ + + DEBUGGER_EXEC (AcpiDbInitialize ()); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableSubsystem + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes the subsystem initialization including hardware. + * Puts system into ACPI mode if it isn't already. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + FUNCTION_TRACE ("AcpiEnableSubsystem"); + + + /* Sanity check the FACP for valid values */ + + Status = AcpiCmValidateFacp (); + if (ACPI_FAILURE (Status)) + { + 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)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Installing default address space handlers\n")); + + Status = AcpiEvInstallDefaultAddressSpaceHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * We must initialize the hardware before we can enable ACPI. + */ + + if (!(Flags & ACPI_NO_HARDWARE_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI hardware\n")); + + Status = AcpiHwInitialize (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Enable ACPI on this platform + */ + + if (!(Flags & ACPI_NO_ACPI_ENABLE)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Going into ACPI mode\n")); + + AcpiEnable (); + } + + /* + * Note: + * We must have the hardware AND events initialized before we can execute + * ANY control methods SAFELY. Any control method can require ACPI hardware + * support, so the hardware MUST be initialized before execution! + */ + + if (!(Flags & ACPI_NO_EVENT_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI events\n")); + + Status = AcpiEvInitialize (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + /* + * Initialize all device objects in the namespace + * This runs the _STA, _INI, and _HID methods, and detects + * the PCI root bus(es) + */ + + if (!(Flags & ACPI_NO_DEVICE_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI Devices\n")); + + Status = AcpiNsInitializeDevices (Flags & ACPI_NO_PCI_INIT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + /* + * Initialize the objects that remain unitialized. This + * runs the executable AML that is part of the declaration of OpRegions + * and Fields. + */ + + if (!(Flags & ACPI_NO_OBJECT_INIT)) + { + DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI Objects\n")); + + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTerminate + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTerminate (void) +{ + + FUNCTION_TRACE ("AcpiTerminate"); + + /* Terminate the AML Debuger if present */ + + AcpiGbl_DbTerminateThreads = TRUE; + + /* TBD: [Investigate] This is no longer needed?*/ +/* AcpiCmReleaseMutex (ACPI_MTX_DEBUG_CMD_READY); */ + + + /* Shutdown and free all resources */ + + AcpiCmSubsystemShutdown (); + + + /* Free the mutex objects */ + + AcpiCmMutexTerminate (); + + + /* Now we can shutdown the OS-dependent layer */ + + AcpiOsTerminate (); + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetSystemInfo + * + * PARAMETERS: OutBuffer - a pointer to a buffer to receive the + * resources for the device + * BufferLength - the number of bytes available in the buffer + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get information about the current + * state of the ACPI subsystem. It will return system information + * in the OutBuffer. + * + * If the function fails an appropriate status will be returned + * and the value of OutBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *OutBuffer) +{ + ACPI_SYSTEM_INFO *InfoPtr; + UINT32 i; + + + FUNCTION_TRACE ("AcpiGetSystemInfo"); + + + /* + * Must have a valid buffer + */ + if ((!OutBuffer) || + (!OutBuffer->Pointer)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (OutBuffer->Length < sizeof (ACPI_SYSTEM_INFO)) + { + /* + * Caller's buffer is too small + */ + OutBuffer->Length = sizeof (ACPI_SYSTEM_INFO); + + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + + /* + * Set return length and get data + */ + OutBuffer->Length = sizeof (ACPI_SYSTEM_INFO); + InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; + + /* TBD [Future]: need a version number, or use the version string */ + InfoPtr->AcpiCaVersion = 0x1234; + + /* System flags (ACPI capabilities) */ + + InfoPtr->Flags = AcpiGbl_SystemFlags; + + /* Timer resolution - 24 or 32 bits */ + + InfoPtr->TimerResolution = AcpiHwPmtResolution (); + + /* Clear the reserved fields */ + + InfoPtr->Reserved1 = 0; + InfoPtr->Reserved2 = 0; + + /* Current debug levels */ + + InfoPtr->DebugLayer = AcpiDbgLayer; + InfoPtr->DebugLevel = AcpiDbgLevel; + + /* Current status of the ACPI tables, per table type */ + + InfoPtr->NumTableTypes = NUM_ACPI_TABLES; + for (i = 0; i < NUM_ACPI_TABLES; i++) + { + InfoPtr->TableInfo[i].Count = AcpiGbl_AcpiTables[i].Count; + } + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiFormatException + * + * PARAMETERS: OutBuffer - a pointer to a buffer to receive the + * exception name + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function translates an ACPI exception into an ASCII string. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiFormatException ( + ACPI_STATUS Exception, + ACPI_BUFFER *OutBuffer) +{ + UINT32 Length; + NATIVE_CHAR *FormattedException; + + + FUNCTION_TRACE ("AcpiFormatException"); + + + /* + * Must have a valid buffer + */ + if ((!OutBuffer) || + (!OutBuffer->Pointer)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + + /* Convert the exception code (Handles bad exception codes) */ + + FormattedException = AcpiCmFormatException (Exception); + + /* + * Get length of string and check if it will fit in caller's buffer + */ + + Length = STRLEN (FormattedException); + if (OutBuffer->Length < Length) + { + OutBuffer->Length = Length; + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + + + /* Copy the string, all done */ + + STRCPY (OutBuffer->Pointer, FormattedException); + + return_ACPI_STATUS (AE_OK); +} + -- cgit v1.1